import{s as pa,o as oa,n as ze}from"../chunks/scheduler.53228c21.js";import{S as ma,i as ra,e as c,s as p,c as f,h as da,a as M,d as t,b as o,f as na,g as h,j as y,k as Pe,w as T,l as ca,m as a,n as J,t as w,o as Z,p as b}from"../chunks/index.100fac89.js";import{C as Ma}from"../chunks/CopyLLMTxtMenu.9360b11d.js";import{C as W}from"../chunks/CodeBlock.d30a6509.js";import{H as C,E as ua}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.c9001d7a.js";import{H as yt,a as Ae}from"../chunks/HfOption.fad27e59.js";function ya(I){let n,u,i,g='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_bear_1.png" width="300" alt="input image"/> <figcaption style="text-align: center;">input image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_gummy.png" width="300" alt="IP-Adapter image"/> <figcaption style="text-align: center;">IP-Adapter image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_bear_3.png" width="300" alt="generated image"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',m;return n=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW1hZ2UySW1hZ2UlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9ySW1hZ2UySW1hZ2UuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUwQSUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEFwaXBlbGluZS5sb2FkX2lwX2FkYXB0ZXIoJTBBJTIwJTIwJTIyaDk0JTJGSVAtQWRhcHRlciUyMiUyQyUwQSUyMCUyMHN1YmZvbGRlciUzRCUyMnNkeGxfbW9kZWxzJTIyJTJDJTBBJTIwJTIwd2VpZ2h0X25hbWUlM0QlMjJpcC1hZGFwdGVyX3NkeGwuYmluJTIyJTBBKSUwQXBpcGVsaW5lLnNldF9pcF9hZGFwdGVyX3NjYWxlKDAuOCklMEElMEFpbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGaXBfYWRhcHRlcl9iZWFyXzEucG5nJTIyKSUwQWlwX2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpcF9hZGFwdGVyX2d1bW15LnBuZyUyMiklMEFwaXBlbGluZSglMEElMjAlMjAlMjAlMjBwcm9tcHQlM0QlMjJiZXN0JTIwcXVhbGl0eSUyQyUyMGhpZ2glMjBxdWFsaXR5JTIyJTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0RpbWFnZSUyQyUwQSUyMCUyMCUyMCUyMGlwX2FkYXB0ZXJfaW1hZ2UlM0RpcF9pbWFnZSUyQyUwQSUyMCUyMCUyMCUyMHN0cmVuZ3RoJTNEMC41JTJDJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForImage2Image
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pipeline = AutoPipelineForImage2Image.from_pretrained(
  <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
  torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;sdxl_models&quot;</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter_sdxl.bin&quot;</span>
)
pipeline.set_ip_adapter_scale(<span class="hljs-number">0.8</span>)

image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_bear_1.png&quot;</span>)
ip_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_gummy.png&quot;</span>)
pipeline(
    prompt=<span class="hljs-string">&quot;best quality, high quality&quot;</span>,
    image=image,
    ip_adapter_image=ip_image,
    strength=<span class="hljs-number">0.5</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){f(n.$$.fragment),u=p(),i=c("div"),i.innerHTML=g,this.h()},l(s){h(n.$$.fragment,s),u=o(s),i=M(s,"DIV",{style:!0,"data-svelte-h":!0}),y(i)!=="svelte-143vd3e"&&(i.innerHTML=g),this.h()},h(){T(i,"display","flex"),T(i,"gap","10px"),T(i,"justify-content","space-around"),T(i,"align-items","flex-end")},m(s,r){J(n,s,r),a(s,u,r),a(s,i,r),m=!0},p:ze,i(s){m||(w(n.$$.fragment,s),m=!0)},o(s){Z(n.$$.fragment,s),m=!1},d(s){s&&(t(u),t(i)),b(n,s)}}}function ga(I){let n,u,i,g='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_bear_1.png" width="300" alt="input image"/> <figcaption style="text-align: center;">input image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_gummy.png" width="300" alt="IP-Adapter image"/> <figcaption style="text-align: center;">IP-Adapter image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_inpaint.png" width="300" alt="generated image"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',m;return n=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW1hZ2UySW1hZ2UlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9ySW1hZ2UySW1hZ2UuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUwQSUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEFwaXBlbGluZS5sb2FkX2lwX2FkYXB0ZXIoJTBBJTIwJTIwJTIyaDk0JTJGSVAtQWRhcHRlciUyMiUyQyUwQSUyMCUyMHN1YmZvbGRlciUzRCUyMnNkeGxfbW9kZWxzJTIyJTJDJTBBJTIwJTIwd2VpZ2h0X25hbWUlM0QlMjJpcC1hZGFwdGVyX3NkeGwuYmluJTIyJTBBKSUwQXBpcGVsaW5lLnNldF9pcF9hZGFwdGVyX3NjYWxlKDAuNiklMEElMEFtYXNrX2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpcF9hZGFwdGVyX21hc2sucG5nJTIyKSUwQWltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpcF9hZGFwdGVyX2JlYXJfMS5wbmclMjIpJTBBaXBfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmlwX2FkYXB0ZXJfZ3VtbXkucG5nJTIyKSUwQXBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCUyMmElMjBjdXRlJTIwZ3VtbXklMjBiZWFyJTIwd2F2aW5nJTIyJTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0RpbWFnZSUyQyUwQSUyMCUyMCUyMCUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlJTJDJTBBJTIwJTIwJTIwJTIwaXBfYWRhcHRlcl9pbWFnZSUzRGlwX2ltYWdlJTJDJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForImage2Image
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pipeline = AutoPipelineForImage2Image.from_pretrained(
  <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
  torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;sdxl_models&quot;</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter_sdxl.bin&quot;</span>
)
pipeline.set_ip_adapter_scale(<span class="hljs-number">0.6</span>)

mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_mask.png&quot;</span>)
image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_bear_1.png&quot;</span>)
ip_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_gummy.png&quot;</span>)
pipeline(
    prompt=<span class="hljs-string">&quot;a cute gummy bear waving&quot;</span>,
    image=image,
    mask_image=mask_image,
    ip_adapter_image=ip_image,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){f(n.$$.fragment),u=p(),i=c("div"),i.innerHTML=g,this.h()},l(s){h(n.$$.fragment,s),u=o(s),i=M(s,"DIV",{style:!0,"data-svelte-h":!0}),y(i)!=="svelte-1hqj44d"&&(i.innerHTML=g),this.h()},h(){T(i,"display","flex"),T(i,"gap","10px"),T(i,"justify-content","space-around"),T(i,"align-items","flex-end")},m(s,r){J(n,s,r),a(s,u,r),a(s,i,r),m=!0},p:ze,i(s){m||(w(n.$$.fragment,s),m=!0)},o(s){Z(n.$$.fragment,s),m=!1},d(s){s&&(t(u),t(i)),b(n,s)}}}function fa(I){let n,u='The <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline.enable_model_cpu_offload">enable_model_cpu_offload()</a> method is useful for reducing memory and it should be enabled <strong>after</strong> the IP-Adapter is loaded. Otherwise, the IP-Adapter’s image encoder is also offloaded to the CPU and returns an error.',i,g,m,s,r='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_inpaint.png" width="400" alt="IP-Adapter image"/> <figcaption style="text-align: center;">IP-Adapter image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/gummy_bear.gif" width="400" alt="generated video"/> <figcaption style="text-align: center;">generated video</figcaption></figure>',d;return g=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQW5pbWF0ZURpZmZQaXBlbGluZSUyQyUyMERESU1TY2hlZHVsZXIlMkMlMjBNb3Rpb25BZGFwdGVyJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b19naWYlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQWFkYXB0ZXIlMjAlM0QlMjBNb3Rpb25BZGFwdGVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJndW95d3clMkZhbmltYXRlZGlmZi1tb3Rpb24tYWRhcHRlci12MS01LTIlMjIlMkMlMEElMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpJTBBcGlwZWxpbmUlMjAlM0QlMjBBbmltYXRlRGlmZlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJlbWlsaWFuSlIlMkZlcGlDUmVhbGlzbSUyMiUyQyUwQSUyMCUyMG1vdGlvbl9hZGFwdGVyJTNEYWRhcHRlciUyQyUwQSUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFzY2hlZHVsZXIlMjAlM0QlMjBERElNU2NoZWR1bGVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJlbWlsaWFuSlIlMkZlcGlDUmVhbGlzbSUyMiUyQyUwQSUyMCUyMCUyMCUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMiUyQyUwQSUyMCUyMCUyMCUyMGNsaXBfc2FtcGxlJTNERmFsc2UlMkMlMEElMjAl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udW1fZnJhbWVzJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDcuNSUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q1MCUyQyUwQSkuZnJhbWVzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AnimateDiffPipeline, DDIMScheduler, MotionAdapter
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_gif
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

adapter = MotionAdapter.from_pretrained(
  <span class="hljs-string">&quot;guoyww/animatediff-motion-adapter-v1-5-2&quot;</span>,
  torch_dtype=torch.float16
)
pipeline = AnimateDiffPipeline.from_pretrained(
  <span class="hljs-string">&quot;emilianJR/epiCRealism&quot;</span>,
  motion_adapter=adapter,
  torch_dtype=torch.float16
)
scheduler = DDIMScheduler.from_pretrained(
    <span class="hljs-string">&quot;emilianJR/epiCRealism&quot;</span>,
    subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>,
    clip_sample=<span class="hljs-literal">False</span>,
    timestep_spacing=<span class="hljs-string">&quot;linspace&quot;</span>,
    beta_schedule=<span class="hljs-string">&quot;linear&quot;</span>,
    steps_offset=<span class="hljs-number">1</span>,
)
pipeline.scheduler = scheduler
pipeline.enable_vae_slicing()
pipeline.load_ip_adapter(<span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>, subfolder=<span class="hljs-string">&quot;models&quot;</span>, weight_name=<span class="hljs-string">&quot;ip-adapter_sd15.bin&quot;</span>)
pipeline.enable_model_cpu_offload()

ip_adapter_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_inpaint.png&quot;</span>)
pipeline(
    prompt=<span class="hljs-string">&quot;A cute gummy bear waving&quot;</span>,
    negative_prompt=<span class="hljs-string">&quot;bad quality, worse quality, low resolution&quot;</span>,
    ip_adapter_image=ip_adapter_image,
    num_frames=<span class="hljs-number">16</span>,
    guidance_scale=<span class="hljs-number">7.5</span>,
    num_inference_steps=<span class="hljs-number">50</span>,
).frames[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){n=c("p"),n.innerHTML=u,i=p(),f(g.$$.fragment),m=p(),s=c("div"),s.innerHTML=r,this.h()},l(U){n=M(U,"P",{"data-svelte-h":!0}),y(n)!=="svelte-1wmzkcn"&&(n.innerHTML=u),i=o(U),h(g.$$.fragment,U),m=o(U),s=M(U,"DIV",{style:!0,"data-svelte-h":!0}),y(s)!=="svelte-nx5uxl"&&(s.innerHTML=r),this.h()},h(){T(s,"display","flex"),T(s,"gap","10px"),T(s,"justify-content","space-around"),T(s,"align-items","flex-end")},m(U,G){a(U,n,G),a(U,i,G),J(g,U,G),a(U,m,G),a(U,s,G),d=!0},p:ze,i(U){d||(w(g.$$.fragment,U),d=!0)},o(U){Z(g.$$.fragment,U),d=!1},d(U){U&&(t(n),t(i),t(m),t(s)),b(g,U)}}}function ha(I){let n,u,i,g,m,s;return n=new Ae({props:{id:"usage",option:"image-to-image",$$slots:{default:[ya]},$$scope:{ctx:I}}}),i=new Ae({props:{id:"usage",option:"inpainting",$$slots:{default:[ga]},$$scope:{ctx:I}}}),m=new Ae({props:{id:"usage",option:"video",$$slots:{default:[fa]},$$scope:{ctx:I}}}),{c(){f(n.$$.fragment),u=p(),f(i.$$.fragment),g=p(),f(m.$$.fragment)},l(r){h(n.$$.fragment,r),u=o(r),h(i.$$.fragment,r),g=o(r),h(m.$$.fragment,r)},m(r,d){J(n,r,d),a(r,u,d),J(i,r,d),a(r,g,d),J(m,r,d),s=!0},p(r,d){const U={};d&2&&(U.$$scope={dirty:d,ctx:r}),n.$set(U);const G={};d&2&&(G.$$scope={dirty:d,ctx:r}),i.$set(G);const j={};d&2&&(j.$$scope={dirty:d,ctx:r}),m.$set(j)},i(r){s||(w(n.$$.fragment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jAlMjB3ZWlnaHRfbmFtZSUzRCUyMmlwLWFkYXB0ZXItcGx1c19zZHhsX3ZpdC1oLnNhZmV0ZW5zb3JzJTIyJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPVisionModelWithProjection, AutoPipelineForText2Image

image_encoder = CLIPVisionModelWithProjection.from_pretrained(
    <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
    subfolder=<span class="hljs-string">&quot;models/image_encoder&quot;</span>,
    torch_dtype=torch.float16
)

pipeline = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    image_encoder=image_encoder,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;sdxl_models&quot;</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter-plus_sdxl_vit-h.safetensors&quot;</span>
)`,wrap:!1}}),{c(){f(n.$$.fragment)},l(i){h(n.$$.fragment,i)},m(i,g){J(n,i,g),u=!0},p:ze,i(i){u||(w(n.$$.fragment,i),u=!0)},o(i){Z(n.$$.fragment,i),u=!1},d(i){b(n,i)}}}function wa(I){let n,u,i,g='To use a IP-Adapter FaceID Plus model, load the CLIP image encoder as well as <a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPVisionModelWithProjection" rel="nofollow">CLIPVisionModelWithProjection</a>.',m,s,r;return n=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQXBpcGVsaW5lLmxvYWRfaXBfYWRhcHRlciglMEElMjAlMjAlMjJoOTQlMkZJUC1BZGFwdGVyLUZhY2VJRCUyMiUyQyUwQSUyMCUyMHN1YmZvbGRlciUzRE5vbmUlMkMlMEElMjAlMjB3ZWlnaHRfbmFtZSUzRCUyMmlwLWFkYXB0ZXItZmFjZWlkX3NkeGwuYmluJTIyJTJDJTBBJTIwJTIwaW1hZ2VfZW5jb2Rlcl9mb2xkZXIlM0ROb25lJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoPipelineForText2Image

pipeline = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter-FaceID&quot;</span>,
  subfolder=<span class="hljs-literal">None</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter-faceid_sdxl.bin&quot;</span>,
  image_encoder_folder=<span class="hljs-literal">None</span>
)`,wrap:!1}}),s=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMkMlMjBDTElQVmlzaW9uTW9kZWxXaXRoUHJvamVjdGlvbiUwQSUwQWltYWdlX2VuY29kZXIlMjAlM0QlMjBDTElQVmlzaW9uTW9kZWxXaXRoUHJvamVjdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybGFpb24lMkZDTElQLVZpVC1ILTE0LWxhaW9uMkItczMyQi1iNzlLJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2VfZW5jb2RlciUzRGltYWdlX2VuY29kZXIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcGlwZWxpbmUubG9hZF9pcF9hZGFwdGVyKCUwQSUyMCUyMCUyMmg5NCUyRklQLUFkYXB0ZXItRmFjZUlEJTIyJTJDJTBBJTIwJTIwc3ViZm9sZGVyJTNETm9uZSUyQyUwQSUyMCUyMHdlaWdodF9uYW1lJTNEJTIyaXAtYWRhcHRlci1mYWNlaWQtcGx1c19zZDE1LmJpbiUyMiUwQSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoPipelineForText2Image, CLIPVisionModelWithProjection

image_encoder = CLIPVisionModelWithProjection.from_pretrained(
    <span class="hljs-string">&quot;laion/CLIP-ViT-H-14-laion2B-s32B-b79K&quot;</span>,
    torch_dtype=torch.float16,
)

pipeline = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>,
    image_encoder=image_encoder,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter-FaceID&quot;</span>,
  subfolder=<span class="hljs-literal">None</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter-faceid-plus_sd15.bin&quot;</span>
)`,wrap:!1}}),{c(){f(n.$$.fragment),u=p(),i=c("p"),i.innerHTML=g,m=p(),f(s.$$.fragment)},l(d){h(n.$$.fragment,d),u=o(d),i=M(d,"P",{"data-svelte-h":!0}),y(i)!=="svelte-g1sk9v"&&(i.innerHTML=g),m=o(d),h(s.$$.fragment,d)},m(d,U){J(n,d,U),a(d,u,U),a(d,i,U),a(d,m,U),J(s,d,U),r=!0},p:ze,i(d){r||(w(n.$$.fragment,d),w(s.$$.fragment,d),r=!0)},o(d){Z(n.$$.fragment,d),Z(s.$$.fragment,d),r=!1},d(d){d&&(t(u),t(i),t(m)),b(n,d),b(s,d)}}}function Za(I){let n,u,i,g;return n=new Ae({props:{id:"ipadapter-variants",option:"IP-Adapter Plus",$$slots:{default:[Ja]},$$scope:{ctx:I}}}),i=new Ae({props:{id:"ipadapter-variants",option:"IP-Adapter FaceID",$$slots:{default:[wa]},$$scope:{ctx:I}}}),{c(){f(n.$$.fragment),u=p(),f(i.$$.fragment)},l(m){h(n.$$.fragment,m),u=o(m),h(i.$$.fragment,m)},m(m,s){J(n,m,s),a(m,u,s),J(i,m,s),g=!0},p(m,s){const r={};s&2&&(r.$$scope={dirty:s,ctx:m}),n.$set(r);const d={};s&2&&(d.$$scope={dirty:s,ctx:m}),i.$set(d)},i(m){g||(w(n.$$.fragment,m),w(i.$$.fragment,m),g=!0)},o(m){Z(n.$$.fragment,m),Z(i.$$.fragment,m),g=!1},d(m){m&&t(u),b(n,m),b(i,m)}}}function ba(I){let n,u,i,g='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_einstein_base.png" width="400" alt="IP-Adapter image"/> <figcaption style="text-align: center;">IP-Adapter image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_einstein.png" width="400" alt="generated image"/> <figcaption style="text-align: center;">generated image</figcaption></figure>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pJTBBJTBBcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEJTIyQSUyMHBob3RvJTIwb2YlMjBFaW5zdGVpbiUyMGFzJTIwYSUyMGNoZWYlMkMlMjB3ZWFyaW5nJTIwYW4lMjBhcHJvbiUyQyUyMGNvb2tpbmclMjBpbiUyMGElMjBGcmVuY2glMjByZXN0YXVyYW50JTIyJTJDJTBBJTIwJTIwJTIwJTIwaXBfYWRhcHRlcl9pbWFnZSUzRGltYWdlJTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEJTIybG93cmVzJTJDJTIwYmFkJTIwYW5hdG9teSUyQyUyMHdvcnN0JTIwcXVhbGl0eSUyQyUyMGxvdyUyMHF1YWxpdHklMjIlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMTAwJTJDJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, DDIMScheduler
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pipeline = StableDiffusionPipeline.from_pretrained(
  <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>,
  torch_dtype=torch.float16,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;models&quot;</span>, 
  weight_name=<span class="hljs-string">&quot;ip-adapter-full-face_sd15.bin&quot;</span>
)

pipeline.set_ip_adapter_scale(<span class="hljs-number">0.5</span>)
image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_einstein_base.png&quot;</span>)

pipeline(
    prompt=<span class="hljs-string">&quot;A photo of Einstein as a chef, wearing an apron, cooking in a French restaurant&quot;</span>,
    ip_adapter_image=image,
    negative_prompt=<span class="hljs-string">&quot;lowres, bad anatomy, worst quality, low quality&quot;</span>,
    num_inference_steps=<span class="hljs-number">100</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){f(n.$$.fragment),u=p(),i=c("div"),i.innerHTML=g,this.h()},l(s){h(n.$$.fragment,s),u=o(s),i=M(s,"DIV",{style:!0,"data-svelte-h":!0}),y(i)!=="svelte-1sqhdfz"&&(i.innerHTML=g),this.h()},h(){T(i,"display","flex"),T(i,"gap","10px"),T(i,"justify-content","space-around"),T(i,"align-items","flex-end")},m(s,r){J(n,s,r),a(s,u,r),a(s,i,r),m=!0},p:ze,i(s){m||(w(n.$$.fragment,s),m=!0)},o(s){Z(n.$$.fragment,s),m=!1},d(s){s&&(t(u),t(i)),b(n,s)}}}function Ta(I){let n,u="For FaceID models, extract the face embeddings and pass them as a list of tensors to <code>ip_adapter_image_embeds</code>.",i,g,m,s,r="The IP-Adapter FaceID Plus and Plus v2 models require CLIP image embeddings. Prepare the face embeddings and then extract and pass the CLIP embeddings to the hidden image projection layers.",d,U,G;return g=new W({props:{code:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMGluc2lnaHRmYWNlJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBERElNU2NoZWR1bGVyJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEFmcm9tJTIwaW5zaWdodGZhY2UuYXBwJTIwaW1wb3J0JTIwRmFjZUFuYWx5c2lzJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmxlLWRpZm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CMCU1RA==",highlighted:`<span class="hljs-comment"># pip install insightface</span>
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, DDIMScheduler
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-keyword">from</span> insightface.app <span class="hljs-keyword">import</span> FaceAnalysis

pipeline = StableDiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>,
    torch_dtype=torch.float16,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter-FaceID&quot;</span>,
  subfolder=<span class="hljs-literal">None</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter-faceid_sd15.bin&quot;</span>,
  image_encoder_folder=<span class="hljs-literal">None</span>
)
pipeline.set_ip_adapter_scale(<span class="hljs-number">0.6</span>)

image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_mask_girl1.png&quot;</span>)

ref_images_embeds = []
app = FaceAnalysis(name=<span class="hljs-string">&quot;buffalo_l&quot;</span>, providers=[<span class="hljs-string">&#x27;CUDAExecutionProvider&#x27;</span>, <span class="hljs-string">&#x27;CPUExecutionProvider&#x27;</span>])
app.prepare(ctx_id=<span class="hljs-number">0</span>, det_size=(<span class="hljs-number">640</span>, <span class="hljs-number">640</span>))
image = cv2.cvtColor(np.asarray(image), cv2.COLOR_BGR2RGB)
faces = app.get(image)
image = torch.from_numpy(faces[<span class="hljs-number">0</span>].normed_embedding)
ref_images_embeds.append(image.unsqueeze(<span class="hljs-number">0</span>))
ref_images_embeds = torch.stack(ref_images_embeds, dim=<span class="hljs-number">0</span>).unsqueeze(<span class="hljs-number">0</span>)
neg_ref_images_embeds = torch.zeros_like(ref_images_embeds)
id_embeds = torch.cat([neg_ref_images_embeds, ref_images_embeds]).to(dtype=torch.float16, device=<span class="hljs-string">&quot;cuda&quot;</span>)

pipeline(
    prompt=<span class="hljs-string">&quot;A photo of a girl&quot;</span>,
    ip_adapter_image_embeds=[id_embeds],
    negative_prompt=<span class="hljs-string">&quot;monochrome, lowres, bad anatomy, worst quality, low quality&quot;</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),U=new W({props:{code:"Y2xpcF9lbWJlZHMlMjAlM0QlMjBwaXBlbGluZS5wcmVwYXJlX2lwX2FkYXB0ZXJfaW1hZ2VfZW1iZWRzKCUwQSUyMCUyMCU1QmlwX2FkYXB0ZXJfaW1hZ2VzJTVEJTJDJTIwTm9uZSUyQyUyMHRvcmNoLmRldmljZSglMjJjdWRhJTIyKSUyQyUyMG51bV9pbWFnZXMlMkMlMjBUcnVlKSU1QjAlNUQlMEElMEFwaXBlbGluZS51bmV0LmVuY29kZXJfaGlkX3Byb2ouaW1hZ2VfcHJvamVjdGlvbl9sYXllcnMlNUIwJTVELmNsaXBfZW1iZWRzJTIwJTNEJTIwY2xpcF9lbWJlZHMudG8oZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQSUyMyUyMHNldCUyMHRvJTIwVHJ1ZSUyMGlmJTIwdXNpbmclMjBJUC1BZGFwdGVyJTIwRmFjZUlEJTIwUGx1cyUyMHYyJTBBcGlwZWxpbmUudW5ldC5lbmNvZGVyX2hpZF9wcm9qLmltYWdlX3Byb2plY3Rpb25fbGF5ZXJzJTVCMCU1RC5zaG9ydGN1dCUyMCUzRCUyMEZhbHNl",highlighted:`clip_embeds = pipeline.prepare_ip_adapter_image_embeds(
  [ip_adapter_images], <span class="hljs-literal">None</span>, torch.device(<span class="hljs-string">&quot;cuda&quot;</span>), num_images, <span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]

pipeline.unet.encoder_hid_proj.image_projection_layers[<span class="hljs-number">0</span>].clip_embeds = clip_embeds.to(dtype=torch.float16)
<span class="hljs-comment"># set to True if using IP-Adapter FaceID Plus v2</span>
pipeline.unet.encoder_hid_proj.image_projection_layers[<span class="hljs-number">0</span>].shortcut = <span class="hljs-literal">False</span>`,wrap:!1}}),{c(){n=c("p"),n.innerHTML=u,i=p(),f(g.$$.fragment),m=p(),s=c("p"),s.textContent=r,d=p(),f(U.$$.fragment)},l(j){n=M(j,"P",{"data-svelte-h":!0}),y(n)!=="svelte-136q08"&&(n.innerHTML=u),i=o(j),h(g.$$.fragment,j),m=o(j),s=M(j,"P",{"data-svelte-h":!0}),y(s)!=="svelte-iaigew"&&(s.textContent=r),d=o(j),h(U.$$.fragment,j)},m(j,_){a(j,n,_),a(j,i,_),J(g,j,_),a(j,m,_),a(j,s,_),a(j,d,_),J(U,j,_),G=!0},p:ze,i(j){G||(w(g.$$.fragment,j),w(U.$$.fragment,j),G=!0)},o(j){Z(g.$$.fragment,j),Z(U.$$.fragment,j),G=!1},d(j){j&&(t(n),t(i),t(m),t(s),t(d)),b(g,j),b(U,j)}}}function Ua(I){let n,u,i,g;return n=new Ae({props:{id:"usage",option:"h94/IP-Adapter",$$slots:{default:[ba]},$$scope:{ctx:I}}}),i=new Ae({props:{id:"usage",option:"h94/IP-Adapter-FaceID",$$slots:{default:[Ta]},$$scope:{ctx:I}}}),{c(){f(n.$$.fragment),u=p(),f(i.$$.fragment)},l(m){h(n.$$.fragment,m),u=o(m),h(i.$$.fragment,m)},m(m,s){J(n,m,s),a(m,u,s),J(i,m,s),g=!0},p(m,s){const r={};s&2&&(r.$$scope={dirty:s,ctx:m}),n.$set(r);const d={};s&2&&(d.$$scope={dirty:s,ctx:m}),i.$set(d)},i(m){g||(w(n.$$.fragment,m),w(i.$$.fragment,m),g=!0)},o(m){Z(n.$$.fragment,m),Z(i.$$.fragment,m),g=!1},d(m){m&&t(u),b(n,m),b(i,m)}}}function ja(I){let n,u,i,g,m,s,r,d,U,G='<a href="https://huggingface.co/papers/2308.06721" rel="nofollow">IP-Adapter</a> is a lightweight adapter designed to integrate image-based guidance with text-to-image diffusion models. The adapter uses an image encoder to extract image features that are passed to the newly added cross-attention layers in the UNet and fine-tuned. The original UNet model and the existing cross-attention layers corresponding to text features is frozen. Decoupling the cross-attention for image and text features enables more fine-grained and controllable generation.',j,_,gt='IP-Adapter files are typically ~100MBs because they only contain the image embeddings. This means you need to load a model first, and then load the IP-Adapter with <a href="/docs/diffusers/main/en/api/loaders/ip_adapter#diffusers.loaders.IPAdapterMixin.load_ip_adapter">load_ip_adapter()</a>.',De,Q,ft='<p>IP-Adapters are available to many models such as <a href="../api/pipelines/flux#ip-adapter">Flux</a> and <a href="../api/pipelines/stable_diffusion/stable_diffusion_3">Stable Diffusion 3</a>, and more. The examples in this guide use Stable Diffusion and Stable Diffusion XL.</p>',Ke,q,ht='Use the <a href="/docs/diffusers/main/en/api/loaders/ip_adapter#diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale">set_ip_adapter_scale()</a> parameter to scale the influence of the IP-Adapter during generation. A value of <code>1.0</code> means the model is only conditioned on the image prompt, and <code>0.5</code> typically produces balanced results between the text and image prompt.',Oe,A,el,z,Jt="Pass an image to <code>ip_adapter_image</code> along with a text prompt to generate an image.",ll,L,tl,B,wt='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_diner.png" width="400" alt="IP-Adapter image"/> <figcaption style="text-align: center;">IP-Adapter image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_diner_2.png" width="400" alt="generated image"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',al,P,Zt="Take a look at the examples below to learn how to use IP-Adapter for other tasks.",sl,x,il,D,nl,K,bt="There are two variants of IP-Adapter, Plus and FaceID. The Plus variant uses patch embeddings and the ViT-H image encoder. FaceID variant uses face embeddings generated from InsightFace.",pl,S,ol,O,ml,ee,Tt="The <code>prepare_ip_adapter_image_embeds</code> generates image embeddings you can reuse if you’re running the pipeline multiple times because you have more than one image. Loading and encoding multiple images each time you use the pipeline can be inefficient. Precomputing the image embeddings ahead of time, saving them to disk, and loading them when you need them is more efficient.",rl,le,dl,te,Ut="Reload the image embeddings by passing them to the <code>ip_adapter_image_embeds</code> parameter. Set <code>image_encoder_folder</code> to <code>None</code> because you don’t need the image encoder anymore to generate the image embeddings.",cl,E,jt="<p>You can also load image embeddings from other sources such as ComfyUI.</p>",Ml,ae,ul,se,yl,ie,Wt="Binary masking enables assigning an IP-Adapter image to a specific area of the output image, making it useful for composing multiple IP-Adapter images. Each IP-Adapter image requires a binary mask.",gl,ne,It='Load the <a href="/docs/diffusers/main/en/api/loaders/ip_adapter#diffusers.image_processor.IPAdapterMaskProcessor">IPAdapterMaskProcessor</a> to preprocess the image masks. For the best results, provide the output <code>height</code> and <code>width</code> to ensure masks with different aspect ratios are appropriately sized. If the input masks already match the aspect ratio of the generated image, you don’t need to set the <code>height</code> and <code>width</code>.',fl,pe,hl,X,Gt='<figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/ip_mask_mask1.png" width="200" alt="mask 1"/> <figcaption style="text-align: center;">mask 1</figcaption></figure> <figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/ip_mask_mask2.png" width="200" alt="mask 2"/> <figcaption style="text-align: center;">mask 2</figcaption></figure>',Jl,oe,_t="Provide both the IP-Adapter images and their scales as a list. Pass the preprocessed masks to <code>cross_attention_kwargs</code> in the pipeline.",wl,me,Zl,Y,Bt='<div style="display: flex; gap: 10px; justify-content: space-around; align-items: flex-end;"><figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/ip_mask_girl1.png" width="400" alt="IP-Adapter image 1"/> <figcaption style="text-align: center;">IP-Adapter image 1</figcaption></figure> <figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/ip_mask_girl2.png" width="400" alt="IP-Adapter image 2"/> <figcaption style="text-align: center;">IP-Adapter image 2</figcaption></figure></div> <div style="display: flex; gap: 10px; justify-content: space-around; align-items: flex-end;"><figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_attention_mask_result_seed_0.png" width="400" alt="Generated image with mask"/> <figcaption style="text-align: center;">generated with mask</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_no_attention_mask_result_seed_0.png" width="400" alt="Generated image without mask"/> <figcaption style="text-align: center;">generated without mask</figcaption></figure></div>',bl,re,Tl,de,Xt="The section below covers some popular applications of IP-Adapter.",Ul,ce,jl,Me,kt='Face generation and preserving its details can be challenging. To help generate more accurate faces, there are checkpoints specifically conditioned on images of cropped faces. You can find the face models in the <a href="https://huggingface.co/h94/IP-Adapter" rel="nofollow">h94/IP-Adapter</a> repository or the <a href="https://huggingface.co/h94/IP-Adapter-FaceID" rel="nofollow">h94/IP-Adapter-FaceID</a> repository. The FaceID checkpoints use the FaceID embeddings from <a href="https://github.com/deepinsight/insightface" rel="nofollow">InsightFace</a> instead of CLIP image embeddings.',Wl,ue,Vt='We recommend using the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a> or <a href="/docs/diffusers/main/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a> for face models.',Il,N,Gl,ye,_l,ge,Rt="Combine multiple IP-Adapters to generate images in more diverse styles. For example, you can use IP-Adapter Face to generate consistent faces and characters and IP-Adapter Plus to generate those faces in specific styles.",Bl,fe,Ft='Load an image encoder with <a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPVisionModelWithProjection" rel="nofollow">CLIPVisionModelWithProjection</a>.',Xl,he,kl,Je,Yt="Load a base model, scheduler and the following IP-Adapters.",Vl,we,Ct='<li><a href="https://huggingface.co/h94/IP-Adapter#ip-adapter-for-sdxl-10" rel="nofollow">ip-adapter-plus_sdxl_vit-h</a> uses patch embeddings and a ViT-H image encoder</li> <li><a href="https://huggingface.co/h94/IP-Adapter#ip-adapter-for-sdxl-10" rel="nofollow">ip-adapter-plus-face_sdxl_vit-h</a> uses patch embeddings and a ViT-H image encoder but it is conditioned on images of cropped faces</li>',Rl,Ze,Fl,be,vt="Load an image and a folder containing images of a certain style to apply.",Yl,Te,Cl,k,$t='<figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/women_input.png" width="400" alt="Face image"/> <figcaption style="text-align: center;">face image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/ip_style_grid.png" width="400" alt="Style images"/> <figcaption style="text-align: center;">style images</figcaption></figure>',vl,Ue,Qt="Pass style and face images as a list to <code>ip_adapter_image</code>.",$l,je,Ql,v,xt='<figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/ip_multi_out.png" width="400" alt="Generated image"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',xl,We,Sl,Ie,St='<a href="../api/pipelines/latent_consistency_models">Latent Consistency Models (LCM)</a> can generate images 4 steps or less, unlike other diffusion models which require a lot more steps, making it feel “instantaneous”. IP-Adapters are compatible with LCM models to instantly generate images.',El,Ge,Et='Load the IP-Adapter weights and load the LoRA weights with <a href="/docs/diffusers/main/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights">load_lora_weights()</a>.',Nl,_e,Hl,Be,Nt="Try using a lower IP-Adapter scale to condition generation more on the style you want to apply and remember to use the special token in your prompt to trigger its generation.",ql,Xe,Al,$,Ht='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_herge.png" width="400" alt="Generated image"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',zl,ke,Ll,Ve,qt='For structural control, combine IP-Adapter with <a href="../api/pipelines/controlnet">ControlNet</a> conditioned on depth maps, edge maps, pose estimations, and more.',Pl,Re,At='The example below loads a <a href="/docs/diffusers/main/en/api/models/controlnet#diffusers.ControlNetModel">ControlNetModel</a> checkpoint conditioned on depth maps and combines it with a IP-Adapter.',Dl,Fe,Kl,Ye,zt="Pass the depth map and IP-Adapter image to the pipeline.",Ol,Ce,et,V,Lt='<figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/statue.png" width="300" alt="IP-Adapter image"/> <figcaption style="text-align: center;">IP-Adapter image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/depth.png" width="300" alt="Depth map"/> <figcaption style="text-align: center;">depth map</figcaption></figure> <figure><img src="https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/ipa-controlnet-out.png" width="300" alt="Generated image"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',lt,ve,tt,$e,Pt='For style and layout control, combine IP-Adapter with <a href="https://huggingface.co/papers/2404.02733" rel="nofollow">InstantStyle</a>. InstantStyle separates <em>style</em> (color, texture, overall feel) and <em>content</em> from each other. It only applies the style in style-specific blocks of the model to prevent it from distorting other areas of an image. This generates images with stronger and more consistent styles and better control over the layout.',at,Qe,Dt='The IP-Adapter is only activated for specific parts of the model. Use the <a href="/docs/diffusers/main/en/api/loaders/ip_adapter#diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale">set_ip_adapter_scale()</a> method to scale the influence of the IP-Adapter in different layers. The example below activates the IP-Adapter in the second layer of the models down <code>block_2</code> and up <code>block_0</code>. Down <code>block_2</code> is where the IP-Adapter injects layout information and up <code>block_0</code> is where style is injected.',st,xe,it,Se,Kt="Load the style image and generate an image.",nt,Ee,pt,R,Ot='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg" width="400" alt="Style image"/> <figcaption style="text-align: center;">style image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/cat_style_layout.png" width="400" alt="Generated image"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',ot,Ne,ea="You can also insert the IP-Adapter in all the model layers. This tends to generate images that focus more on the image prompt and may reduce the diversity of generated images. Only activate the IP-Adapter in up <code>block_0</code> or the style layer.",mt,H,la="<p>You don’t need to specify all the layers in the <code>scale</code> dictionary. Layers not included are set to 0, which means the IP-Adapter is disabled.</p>",rt,He,dt,F,ta='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/cat_style_only.png" width="400" alt="Generated image (style only)"/> <figcaption style="text-align: center;">style-layer generated image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/cat_ip_adapter.png" width="400" alt="Generated image (IP-Adapter only)"/> <figcaption style="text-align: center;">all layers generated image</figcaption></figure>',ct,qe,Mt,Le,ut;return m=new Ma({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),r=new C({props:{title:"IP-Adapter",local:"ip-adapter",headingTag:"h1"}}),A=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JUZXh0MkltYWdlLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMEElMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUubG9hZF9pcF9hZGFwdGVyKCUwQSUyMCUyMCUyMmg5NCUyRklQLUFkYXB0ZXIlMjIlMkMlMEElMjAlMjBzdWJmb2xkZXIlM0QlMjJzZHhsX21vZGVscyUyMiUyQyUwQSUyMCUyMHdlaWdodF9uYW1lJTNEJTIyaXAtYWRhcHRlcl9zZHhsLmJpbiUyMiUwQSklMEFwaXBlbGluZS5zZXRfaXBfYWRhcHRlcl9zY2FsZSgwLjgp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pipeline = AutoPipelineForText2Image.from_pretrained(
  <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
  torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;sdxl_models&quot;</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter_sdxl.bin&quot;</span>
)
pipeline.set_ip_adapter_scale(<span class="hljs-number">0.8</span>)`,wrap:!1}}),L=new W({props:{code:"aW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmlwX2FkYXB0ZXJfZGluZXIucG5nJTIyKSUwQXBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCUyMmElMjBwb2xhciUyMGJlYXIlMjBzaXR0aW5nJTIwaW4lMjBhJTIwY2hhaXIlMjBkcmlua2luZyUyMGElMjBtaWxrc2hha2UlMjIlMkMlMEElMjAlMjAlMjAlMjBpcF9hZGFwdGVyX2ltYWdlJTNEaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjBuZWdhdGl2ZV9wcm9tcHQlM0QlMjJkZWZvcm1lZCUyQyUyMHVnbHklMkMlMjB3cm9uZyUyMHByb3BvcnRpb24lMkMlMjBsb3clMjByZXMlMkMlMjBiYWQlMjBhbmF0b215JTJDJTIwd29yc3QlMjBxdWFsaXR5JTJDJTIwbG93JTIwcXVhbGl0eSUyMiUyQyUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_adapter_diner.png&quot;</span>)
pipeline(
    prompt=<span class="hljs-string">&quot;a polar bear sitting in a chair drinking a milkshake&quot;</span>,
    ip_adapter_image=image,
    negative_prompt=<span class="hljs-string">&quot;deformed, ugly, wrong proportion, low res, bad anatomy, worst quality, low quality&quot;</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),x=new yt({props:{id:"usage",options:["image-to-image","inpainting","video"],$$slots:{default:[ha]},$$scope:{ctx:I}}}),D=new C({props:{title:"Model variants",local:"model-variants",headingTag:"h2"}}),S=new yt({props:{id:"ipadapter-variants",options:["IP-Adapter Plus","IP-Adapter FaceID"],$$slots:{default:[Za]},$$scope:{ctx:I}}}),O=new C({props:{title:"Image embeddings",local:"image-embeddings",headingTag:"h2"}}),le=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9ySW1hZ2UySW1hZ2UuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUwQSUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZV9lbWJlZHMlMjAlM0QlMjBwaXBlbGluZS5wcmVwYXJlX2lwX2FkYXB0ZXJfaW1hZ2VfZW1iZWRzKCUwQSUyMCUyMCUyMCUyMGlwX2FkYXB0ZXJfaW1hZ2UlM0RpbWFnZSUyQyUwQSUyMCUyMCUyMCUyMGlwX2FkYXB0ZXJfaW1hZ2VfZW1iZWRzJTNETm9uZSUyQyUwQSUyMCUyMCUyMCUyMGRldmljZSUzRCUyMmN1ZGElMjIlMkMlMEElMjAlMjAlMjAlMjBudW1faW1hZ2VzX3Blcl9wcm9tcHQlM0QxJTJDJTBBJTIwJTIwJTIwJTIwZG9fY2xhc3NpZmllcl9mcmVlX2d1aWRhbmNlJTNEVHJ1ZSUyQyUwQSklMEElMEF0b3JjaC5zYXZlKGltYWdlX2VtYmVkcyUyQyUyMCUyMmltYWdlX2VtYmVkcy5pcGFkcHQlMjIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image

pipeline = AutoPipelineForImage2Image.from_pretrained(
  <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
  torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image_embeds = pipeline.prepare_ip_adapter_image_embeds(
    ip_adapter_image=image,
    ip_adapter_image_embeds=<span class="hljs-literal">None</span>,
    device=<span class="hljs-string">&quot;cuda&quot;</span>,
    num_images_per_prompt=<span class="hljs-number">1</span>,
    do_classifier_free_guidance=<span class="hljs-literal">True</span>,
)

torch.save(image_embeds, <span class="hljs-string">&quot;image_embeds.ipadpt&quot;</span>)`,wrap:!1}}),ae=new W({props:{code:"cGlwZWxpbmUubG9hZF9pcF9hZGFwdGVyKCUwQSUyMCUyMCUyMmg5NCUyRklQLUFkYXB0ZXIlMjIlMkMlMEElMjAlMjBzdWJmb2xkZXIlM0QlMjJzZHhsX21vZGVscyUyMiUyQyUwQSUyMCUyMGltYWdlX2VuY29kZXJfZm9sZGVyJTNETm9uZSUyQyUwQSUyMCUyMHdlaWdodF9uYW1lJTNEJTIyaXAtYWRhcHRlcl9zZHhsLmJpbiUyMiUwQSklMEFwaXBlbGluZS5zZXRfaXBfYWRhcHRlcl9zY2FsZSgwLjgpJTBBaW1hZ2VfZW1iZWRzJTIwJTNEJTIwdG9yY2gubG9hZCglMjJpbWFnZV9lbWJlZHMuaXBhZHB0JTIyKSUwQXBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCUyMmElMjBwb2xhciUyMGJlYXIlMjBzaXR0aW5nJTIwaW4lMjBhJTIwY2hhaXIlMjBkcmlua2luZyUyMGElMjBtaWxrc2hha2UlMjIlMkMlMEElMjAlMjAlMjAlMjBpcF9hZGFwdGVyX2ltYWdlX2VtYmVkcyUzRGltYWdlX2VtYmVkcyUyQyUwQSUyMCUyMCUyMCUyMG5lZ2F0aXZlX3Byb21wdCUzRCUyMmRlZm9ybWVkJTJDJTIwdWdseSUyQyUyMHdyb25nJTIwcHJvcG9ydGlvbiUyQyUyMGxvdyUyMHJlcyUyQyUyMGJhZCUyMGFuYXRvbXklMkMlMjB3b3JzdCUyMHF1YWxpdHklMkMlMjBsb3clMjBxdWFsaXR5JTIyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRvciUzRGdlbmVyYXRvciUyQyUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;sdxl_models&quot;</span>,
  image_encoder_folder=<span class="hljs-literal">None</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter_sdxl.bin&quot;</span>
)
pipeline.set_ip_adapter_scale(<span class="hljs-number">0.8</span>)
image_embeds = torch.load(<span class="hljs-string">&quot;image_embeds.ipadpt&quot;</span>)
pipeline(
    prompt=<span class="hljs-string">&quot;a polar bear sitting in a chair drinking a milkshake&quot;</span>,
    ip_adapter_image_embeds=image_embeds,
    negative_prompt=<span class="hljs-string">&quot;deformed, ugly, wrong proportion, low res, bad anatomy, worst quality, low quality&quot;</span>,
    num_inference_steps=<span class="hljs-number">100</span>,
    generator=generator,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),se=new C({props:{title:"Masking",local:"masking",headingTag:"h2"}}),pe=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUwQWZyb20lMjBkaWZmdXNlcnMuaW1hZ2VfcHJvY2Vzc29yJTIwaW1wb3J0JTIwSVBBZGFwdGVyTWFza1Byb2Nlc3NvciUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbWFnZTJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTBBJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQW1hc2sxJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpcF9tYXNrX21hc2sxLnBuZyUyMiklMEFtYXNrMiUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGaXBfbWFza19tYXNrMi5wbmclMjIpJTBBJTBBcHJvY2Vzc29yJTIwJTNEJTIwSVBBZGFwdGVyTWFza1Byb2Nlc3NvcigpJTBBbWFza3MlMjAlM0QlMjBwcm9jZXNzb3IucHJlcHJvY2VzcyglNUJtYXNrMSUyQyUyMG1hc2syJTVEJTJDJTIwaGVpZ2h0JTNEMTAyNCUyQyUyMHdpZHRoJTNEMTAyNCk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image
<span class="hljs-keyword">from</span> diffusers.image_processor <span class="hljs-keyword">import</span> IPAdapterMaskProcessor
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pipeline = AutoPipelineForImage2Image.from_pretrained(
  <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
  torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

mask1 = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_mask_mask1.png&quot;</span>)
mask2 = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_mask_mask2.png&quot;</span>)

processor = IPAdapterMaskProcessor()
masks = processor.preprocess([mask1, mask2], height=<span class="hljs-number">1024</span>, width=<span class="hljs-number">1024</span>)`,wrap:!1}}),me=new W({props:{code:"ZmFjZV9pbWFnZTElMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmlwX21hc2tfZ2lybDEucG5nJTIyKSUwQWZhY2VfaW1hZ2UyJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJ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yX21hc2tzJTIyJTNBJTIwbWFza3MlN0QlMEEpLmltYWdlcyU1QjAlNUQ=",highlighted:`face_image1 = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_mask_girl1.png&quot;</span>)
face_image2 = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/ip_mask_girl2.png&quot;</span>)

pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;sdxl_models&quot;</span>,
  weight_name=[<span class="hljs-string">&quot;ip-adapter-plus-face_sdxl_vit-h.safetensors&quot;</span>]
)
pipeline.set_ip_adapter_scale([[<span class="hljs-number">0.7</span>, <span class="hljs-number">0.7</span>]])

ip_images = [[face_image1, face_image2]]
masks = [masks.reshape(<span class="hljs-number">1</span>, masks.shape[<span class="hljs-number">0</span>], masks.shape[<span class="hljs-number">2</span>], masks.shape[<span class="hljs-number">3</span>])]

pipeline(
  prompt=<span class="hljs-string">&quot;2 girls&quot;</span>,
  ip_adapter_image=ip_images,
  negative_prompt=<span class="hljs-string">&quot;monochrome, lowres, bad anatomy, worst quality, low quality&quot;</span>,
  cross_attention_kwargs={<span class="hljs-string">&quot;ip_adapter_masks&quot;</span>: masks}
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),re=new C({props:{title:"Applications",local:"applications",headingTag:"h2"}}),ce=new C({props:{title:"Face models",local:"face-models",headingTag:"h3"}}),N=new yt({props:{id:"usage",options:["h94/IP-Adapter","h94/IP-Adapter-FaceID"],$$slots:{default:[Ua]},$$scope:{ctx:I}}}),ye=new C({props:{title:"Multiple IP-Adapters",local:"multiple-ip-adapters",headingTag:"h3"}}),he=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUyQyUyMERESU1TY2hlZHVsZXIlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQ0xJUFZpc2lvbk1vZGVsV2l0aFByb2plY3Rpb24lMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQWltYWdlX2VuY29kZXIlMjAlM0QlMjBDTElQVmlzaW9uTW9kZWxXaXRoUHJvamVjdGlvbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyaDk0JTJGSVAtQWRhcHRlciUyMiUyQyUwQSUyMCUyMCUyMCUyMHN1YmZvbGRlciUzRCUyMm1vZGVscyUyRmltYWdlX2VuY29kZXIlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image, DDIMScheduler
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPVisionModelWithProjection
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

image_encoder = CLIPVisionModelWithProjection.from_pretrained(
    <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
    subfolder=<span class="hljs-string">&quot;models/image_encoder&quot;</span>,
    torch_dtype=torch.float16,
)`,wrap:!1}}),Ze=new W({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JUZXh0MkltYWdlLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMEElMjAlMjAlMjAlMjBpbWFnZV9lbmNvZGVyJTNEaW1hZ2VfZW5jb2RlciUyQyUwQSklMEFwaXBlbGluZS5zY2hlZHVsZXIlMjAlM0QlMjBERElNU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBcGlwZWxpbmUubG9hZF9pcF9hZGFwdGVyKCUwQSUyMCUyMCUyMmg5NCUyRklQLUFkYXB0ZXIlMjIlMkMlMEElMjAlMjBzdWJmb2xkZXIlM0QlMjJzZHhsX21vZGVscyUyMiUyQyUwQSUyMCUyMHdlaWdodF9uYW1lJTNEJTVCJTIyaXAtYWRhcHRlci1wbHVzX3NkeGxfdml0LWguc2FmZXRlbnNvcnMlMjIlMkMlMjAlMjJpcC1hZGFwdGVyLXBsdXMtZmFjZV9zZHhsX3ZpdC1oLnNhZmV0ZW5zb3JzJTIyJTVEJTBBKSUwQXBpcGVsaW5lLnNldF9pcF9hZGFwdGVyX3NjYWxlKCU1QjAuNyUyQyUyMDAuMyU1RCklMEElMjMlMjBlbmFibGVfbW9kZWxfY3B1X29mZmxvYWQlMjB0byUyMHJlZHVjZSUyMG1lbW9yeSUyMHVzYWdlJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCk=",highlighted:`pipeline = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    torch_dtype=torch.float16,
    image_encoder=image_encoder,
)
pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;sdxl_models&quot;</span>,
  weight_name=[<span class="hljs-string">&quot;ip-adapter-plus_sdxl_vit-h.safetensors&quot;</span>, <span class="hljs-string">&quot;ip-adapter-plus-face_sdxl_vit-h.safetensors&quot;</span>]
)
pipeline.set_ip_adapter_scale([<span class="hljs-number">0.7</span>, <span class="hljs-number">0.3</span>])
<span class="hljs-comment"># enable_model_cpu_offload to reduce memory usage</span>
pipeline.enable_model_cpu_offload()`,wrap:!1}}),Te=new W({props:{code:"ZmFjZV9pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGWWlZaVh1JTJGdGVzdGluZy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRndvbWVuX2lucHV0LnBuZyUyMiklMEFzdHlsZV9mb2xkZXIlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZZaVlpWHUlMkZ0ZXN0aW5nLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGc3R5bGVfemlnZ3klMjIlMEFzdHlsZV9pbWFnZXMlMjAlM0QlMjAlNUJsb2FkX2ltYWdlKGYlMjIlN0JzdHlsZV9mb2xkZXIlN0QlMkZpbWclN0JpJTdELnBuZyUyMiklMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgxMCklNUQ=",highlighted:`face_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/women_input.png&quot;</span>)
style_folder = <span class="hljs-string">&quot;https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/style_ziggy&quot;</span>
style_images = [load_image(<span class="hljs-string">f&quot;<span class="hljs-subst">{style_folder}</span>/img<span class="hljs-subst">{i}</span>.png&quot;</span>) <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">10</span>)]`,wrap:!1}}),je=new W({props:{code:"Z2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKGRldmljZSUzRCUyMmNwdSUyMikubWFudWFsX3NlZWQoMCklMEElMEFwaXBlbGluZSglMEElMjAlMjAlMjAlMjBwcm9tcHQlM0QlMjJ3b25kZXJ3b21hbiUyMiUyQyUwQSUyMCUyMCUyMCUyMGlwX2FkYXB0ZXJfaW1hZ2UlM0QlNUJzdHlsZV9pbWFnZXMlMkMlMjBmYWNlX2ltYWdlJTVEJTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEJTIybW9ub2Nocm9tZSUyQyUyMGxvd3JlcyUyQyUyMGJhZCUyMGFuYXRvbXklMkMlMjB3b3JzdCUyMHF1YWxpdHklMkMlMjBsb3clMjBxdWFsaXR5JTIyJTJDJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`generator = torch.Generator(device=<span class="hljs-string">&quot;cpu&quot;</span>).manual_seed(<span class="hljs-number">0</span>)

pipeline(
    prompt=<span class="hljs-string">&quot;wonderwoman&quot;</span>,
    ip_adapter_image=[style_images, face_image],
    negative_prompt=<span class="hljs-string">&quot;monochrome, lowres, bad anatomy, worst quality, low quality&quot;</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),We=new C({props:{title:"Instant generation",local:"instant-generation",headingTag:"h3"}}),_e=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBMQ01TY2hlZHVsZXIlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMnNkLWRyZWFtYm9vdGgtbGlicmFyeSUyRmhlcmdlLXN0eWxlJTIyJTJDJTBBJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKSUwQSUwQXBpcGVsaW5lLmxvYWRfaXBfYWRhcHRlciglMEElMjAlMjAlMjJoOTQlMkZJUC1BZGFwdGVyJTIyJTJDJTBBJTIwJTIwc3ViZm9sZGVyJTNEJTIybW9kZWxzJTIyJTJDJTBBJTIwJTIwd2VpZ2h0X25hbWUlM0QlMjJpcC1hZGFwdGVyX3NkMTUuYmluJTIyJTBBKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUyMmxhdGVudC1jb25zaXN0ZW5jeSUyRmxjbS1sb3JhLXNkdjEtNSUyMiklMEFwaXBlbGluZS5zY2hlZHVsZXIlMjAlM0QlMjBMQ01TY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEElMjMlMjBlbmFibGVfbW9kZWxfY3B1X29mZmxvYWQlMjB0byUyMHJlZHVjZSUyMG1lbW9yeSUyMHVzYWdlJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, LCMScheduler
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pipeline = DiffusionPipeline.from_pretrained(
  <span class="hljs-string">&quot;sd-dreambooth-library/herge-style&quot;</span>,
  torch_dtype=torch.float16
)

pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;models&quot;</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter_sd15.bin&quot;</span>
)
pipeline.load_lora_weights(<span class="hljs-string">&quot;latent-consistency/lcm-lora-sdv1-5&quot;</span>)
pipeline.scheduler = LCMScheduler.from_config(pipeline.scheduler.config)
<span class="hljs-comment"># enable_model_cpu_offload to reduce memory usage</span>
pipeline.enable_model_cpu_offload()`,wrap:!1}}),Xe=new W({props:{code:"cGlwZWxpbmUuc2V0X2lwX2FkYXB0ZXJfc2NhbGUoMC40KSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMmhlcmdlX3N0eWxlJTIwd29tYW4lMjBpbiUyMGFybW9yJTJDJTIwYmVzdCUyMHF1YWxpdHklMkMlMjBoaWdoJTIwcXVhbGl0eSUyMiUwQSUwQWlwX2FkYXB0ZXJfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGdXNlci1pbWFnZXMuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGMjQ3MzQxNDIlMkYyNjY0OTI4NzUtMmQ1MGQyMjMtODQ3NS00NGYwLWE3YzYtMDhiNTFjYjUzNTcyLnBuZyUyMiklMEFwaXBlbGluZSglMEElMjAlMjAlMjAlMjBwcm9tcHQlM0Rwcm9tcHQlMkMlMEElMjAlMjAlMjAlMjBpcF9hZGFwdGVyX2ltYWdlJTNEaXBfYWRhcHRlcl9pbWFnZSUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q0JTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0QxJTJDJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`pipeline.set_ip_adapter_scale(<span class="hljs-number">0.4</span>)

prompt = <span class="hljs-string">&quot;herge_style woman in armor, best quality, high quality&quot;</span>

ip_adapter_image = load_image(<span class="hljs-string">&quot;https://user-images.githubusercontent.com/24734142/266492875-2d50d223-8475-44f0-a7c6-08b51cb53572.png&quot;</span>)
pipeline(
    prompt=prompt,
    ip_adapter_image=ip_adapter_image,
    num_inference_steps=<span class="hljs-number">4</span>,
    guidance_scale=<span class="hljs-number">1</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),ke=new C({props:{title:"Structural control",local:"structural-control",headingTag:"h3"}}),Fe=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBTdGFibGVEaWZmdXNpb25Db250cm9sTmV0UGlwZWxpbmUlMkMlMjBDb250cm9sTmV0TW9kZWwlMEElMEFjb250cm9sbmV0JTIwJTNEJTIwQ29udHJvbE5ldE1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJsbGx5YXN2aWVsJTJGY29udHJvbF92MTFmMXBfc2QxNV9kZXB0aCUyMiUyQyUwQSUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTBBJTIwJTIwJTIwJTIwY29udHJvbG5ldCUzRGNvbnRyb2xuZXQlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUubG9hZF9pcF9hZGFwdGVyKCUwQSUyMCUyMCUyMmg5NCUyRklQLUFkYXB0ZXIlMjIlMkMlMEElMjAlMjBzdWJmb2xkZXIlM0QlMjJtb2RlbHMlMjIlMkMlMEElMjAlMjB3ZWlnaHRfbmFtZSUzRCUyMmlwLWFkYXB0ZXJfc2QxNS5iaW4lMjIlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetPipeline, ControlNetModel

controlnet = ControlNetModel.from_pretrained(
  <span class="hljs-string">&quot;lllyasviel/control_v11f1p_sd15_depth&quot;</span>,
  torch_dtype=torch.float16
)

pipeline = StableDiffusionControlNetPipeline.from_pretrained(
    <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>,
    controlnet=controlnet,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;models&quot;</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter_sd15.bin&quot;</span>
)`,wrap:!1}}),Ce=new W({props:{code:"cGlwZWxpbmUoJTBBJTIwJTIwcHJvbXB0JTNEJTIyYmVzdCUyMHF1YWxpdHklMkMlMjBoaWdoJTIwcXVhbGl0eSUyMiUyQyUwQSUyMCUyMGltYWdlJTNEZGVwdGhfbWFwJTJDJTBBJTIwJTIwaXBfYWRhcHRlcl9pbWFnZSUzRGlwX2FkYXB0ZXJfaW1hZ2UlMkMlMEElMjAlMjBuZWdhdGl2ZV9wcm9tcHQlM0QlMjJtb25vY2hyb21lJTJDJTIwbG93cmVzJTJDJTIwYmFkJTIwYW5hdG9teSUyQyUyMHdvcnN0JTIwcXVhbGl0eSUyQyUyMGxvdyUyMHF1YWxpdHklMjIlMkMlMEEpLmltYWdlcyU1QjAlNUQ=",highlighted:`pipeline(
  prompt=<span class="hljs-string">&quot;best quality, high quality&quot;</span>,
  image=depth_map,
  ip_adapter_image=ip_adapter_image,
  negative_prompt=<span class="hljs-string">&quot;monochrome, lowres, bad anatomy, worst quality, low quality&quot;</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),ve=new C({props:{title:"Style and layout control",local:"style-and-layout-control",headingTag:"h3"}}),xe=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JUZXh0MkltYWdlLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMEElMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUubG9hZF9pcF9hZGFwdGVyKCUwQSUyMCUyMCUyMmg5NCUyRklQLUFkYXB0ZXIlMjIlMkMlMEElMjAlMjBzdWJmb2xkZXIlM0QlMjJzZHhsX21vZGVscyUyMiUyQyUwQSUyMCUyMHdlaWdodF9uYW1lJTNEJTIyaXAtYWRhcHRlcl9zZHhsLmJpbiUyMiUwQSklMEElMEFzY2FsZSUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMmRvd24lMjIlM0ElMjAlN0IlMjJibG9ja18yJTIyJTNBJTIwJTVCMC4wJTJDJTIwMS4wJTVEJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIydXAlMjIlM0ElMjAlN0IlMjJibG9ja18wJTIyJTNBJTIwJTVCMC4wJTJDJTIwMS4wJTJDJTIwMC4wJTVEJTdEJTJDJTBBJTdEJTBBcGlwZWxpbmUuc2V0X2lwX2FkYXB0ZXJfc2NhbGUoc2NhbGUp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pipeline = AutoPipelineForText2Image.from_pretrained(
  <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
  torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_ip_adapter(
  <span class="hljs-string">&quot;h94/IP-Adapter&quot;</span>,
  subfolder=<span class="hljs-string">&quot;sdxl_models&quot;</span>,
  weight_name=<span class="hljs-string">&quot;ip-adapter_sdxl.bin&quot;</span>
)

scale = {
    <span class="hljs-string">&quot;down&quot;</span>: {<span class="hljs-string">&quot;block_2&quot;</span>: [<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>]},
    <span class="hljs-string">&quot;up&quot;</span>: {<span class="hljs-string">&quot;block_0&quot;</span>: [<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>, <span class="hljs-number">0.0</span>]},
}
pipeline.set_ip_adapter_scale(scale)`,wrap:!1}}),Ee=new W({props:{code:"c3R5bGVfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGMDA1MmE3MGJlZWQ1YmY3MWI5MjYxMGE0M2E1MmRmNmQyODZjZDVmMyUyRmRpZmZ1c2VycyUyRnJhYmJpdC5qcGclMjIpJTBBJTBBcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEJTIyYSUyMGNhdCUyQyUyMG1hc3RlcnBpZWNlJTJDJTIwYmVzdCUyMHF1YWxpdHklMkMlMjBoaWdoJTIwcXVhbGl0eSUyMiUyQyUwQSUyMCUyMCUyMCUyMGlwX2FkYXB0ZXJfaW1hZ2UlM0RzdHlsZV9pbWFnZSUyQyUwQSUyMCUyMCUyMCUyMG5lZ2F0aXZlX3Byb21wdCUzRCUyMnRleHQlMkMlMjB3YXRlcm1hcmslMkMlMjBsb3dyZXMlMkMlMjBsb3clMjBxdWFsaXR5JTJDJTIwd29yc3QlMjBxdWFsaXR5JTJDJTIwZGVmb3JtZWQlMkMlMjBnbGl0Y2glMkMlMjBsb3clMjBjb250cmFzdCUyQyUyMG5vaXN5JTJDJTIwc2F0dXJhdGlvbiUyQyUyMGJsdXJyeSUyMiUyQyUwQSUyMCUyMCUyMCUyMGd1aWRhbmNlX3NjYWxlJTNENSUyQyUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`style_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg&quot;</span>)

pipeline(
    prompt=<span class="hljs-string">&quot;a cat, masterpiece, best quality, high quality&quot;</span>,
    ip_adapter_image=style_image,
    negative_prompt=<span class="hljs-string">&quot;text, watermark, lowres, low quality, worst quality, deformed, glitch, low contrast, noisy, saturation, blurry&quot;</span>,
    guidance_scale=<span class="hljs-number">5</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),He=new W({props:{code:"c2NhbGUlMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJ1cCUyMiUzQSUyMCU3QiUyMmJsb2NrXzAlMjIlM0ElMjAlNUIwLjAlMkMlMjAxLjAlMkMlMjAwLjAlNUQlN0QlMkMlMEElN0QlMEFwaXBlbGluZS5zZXRfaXBfYWRhcHRlcl9zY2FsZShzY2FsZSklMEElMEFwaXBlbGluZSglMEElMjAlMjAlMjAlMjBwcm9tcHQlM0QlMjJhJTIwY2F0JTJDJTIwbWFzdGVycGllY2UlMkMlMjBiZXN0JTIwcXVhbGl0eSUyQyUyMGhpZ2glMjBxdWFsaXR5JTIyJTJDJTBBJTIwJTIwJTIwJTIwaXBfYWRhcHRlcl9pbWFnZSUzRHN0eWxlX2ltYWdlJTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEJTIydGV4dCUyQyUyMHdhdGVybWFyayUyQyUyMGxvd3JlcyUyQyUyMGxvdyUyMHF1YWxpdHklMkMlMjB3b3JzdCUyMHF1YWxpdHklMkMlMjBkZWZvcm1lZCUyQyUyMGdsaXRjaCUyQyUyMGxvdyUyMGNvbnRyYXN0JTJDJTIwbm9pc3klMkMlMjBzYXR1cmF0aW9uJTJDJTIwYmx1cnJ5JTIyJTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q1JTJDJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`scale = {
    <span class="hljs-string">&quot;up&quot;</span>: {<span class="hljs-string">&quot;block_0&quot;</span>: [<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>, <span class="hljs-number">0.0</span>]},
}
pipeline.set_ip_adapter_scale(scale)

pipeline(
    prompt=<span class="hljs-string">&quot;a cat, masterpiece, best quality, high quality&quot;</span>,
    ip_adapter_image=style_image,
    negative_prompt=<span class="hljs-string">&quot;text, watermark, lowres, low quality, worst quality, deformed, glitch, low contrast, noisy, saturation, blurry&quot;</span>,
    guidance_scale=<span class="hljs-number">5</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),qe=new ua({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/ip_adapter.md"}}),{c(){n=c("meta"),u=p(),i=c("p"),g=p(),f(m.$$.fragment),s=p(),f(r.$$.fragment),d=p(),U=c("p"),U.innerHTML=G,j=p(),_=c("p"),_.innerHTML=gt,De=p(),Q=c("blockquote"),Q.innerHTML=ft,Ke=p(),q=c("p"),q.innerHTML=ht,Oe=p(),f(A.$$.fragment),el=p(),z=c("p"),z.innerHTML=Jt,ll=p(),f(L.$$.fragment),tl=p(),B=c("div"),B.innerHTML=wt,al=p(),P=c("p"),P.textContent=Zt,sl=p(),f(x.$$.fragment),il=p(),f(D.$$.fragment),nl=p(),K=c("p"),K.textContent=bt,pl=p(),f(S.$$.fragment),ol=p(),f(O.$$.fragment),ml=p(),ee=c("p"),ee.innerHTML=Tt,rl=p(),f(le.$$.fragment),dl=p(),te=c("p"),te.innerHTML=Ut,cl=p(),E=c("blockquote"),E.innerHTML=jt,Ml=p(),f(ae.$$.fragment),ul=p(),f(se.$$.fragment),yl=p(),ie=c("p"),ie.textContent=Wt,gl=p(),ne=c("p"),ne.innerHTML=It,fl=p(),f(pe.$$.fragment),hl=p(),X=c("div"),X.innerHTML=Gt,Jl=p(),oe=c("p"),oe.innerHTML=_t,wl=p(),f(me.$$.fragment),Zl=p(),Y=c("div"),Y.innerHTML=Bt,bl=p(),f(re.$$.fragment),Tl=p(),de=c("p"),de.textContent=Xt,Ul=p(),f(ce.$$.fragment),jl=p(),Me=c("p"),Me.innerHTML=kt,Wl=p(),ue=c("p"),ue.innerHTML=Vt,Il=p(),f(N.$$.fragment),Gl=p(),f(ye.$$.fragment),_l=p(),ge=c("p"),ge.textContent=Rt,Bl=p(),fe=c("p"),fe.innerHTML=Ft,Xl=p(),f(he.$$.fragment),kl=p(),Je=c("p"),Je.textContent=Yt,Vl=p(),we=c("ul"),we.innerHTML=Ct,Rl=p(),f(Ze.$$.fragment),Fl=p(),be=c("p"),be.textContent=vt,Yl=p(),f(Te.$$.fragment),Cl=p(),k=c("div"),k.innerHTML=$t,vl=p(),Ue=c("p"),Ue.innerHTML=Qt,$l=p(),f(je.$$.fragment),Ql=p(),v=c("div"),v.innerHTML=xt,xl=p(),f(We.$$.fragment),Sl=p(),Ie=c("p"),Ie.innerHTML=St,El=p(),Ge=c("p"),Ge.innerHTML=Et,Nl=p(),f(_e.$$.fragment),Hl=p(),Be=c("p"),Be.textContent=Nt,ql=p(),f(Xe.$$.fragment),Al=p(),$=c("div"),$.innerHTML=Ht,zl=p(),f(ke.$$.fragment),Ll=p(),Ve=c("p"),Ve.innerHTML=qt,Pl=p(),Re=c("p"),Re.innerHTML=At,Dl=p(),f(Fe.$$.fragment),Kl=p(),Ye=c("p"),Ye.textContent=zt,Ol=p(),f(Ce.$$.fragment),et=p(),V=c("div"),V.innerHTML=Lt,lt=p(),f(ve.$$.fragment),tt=p(),$e=c("p"),$e.innerHTML=Pt,at=p(),Qe=c("p"),Qe.innerHTML=Dt,st=p(),f(xe.$$.fragment),it=p(),Se=c("p"),Se.textContent=Kt,nt=p(),f(Ee.$$.fragment),pt=p(),R=c("div"),R.innerHTML=Ot,ot=p(),Ne=c("p"),Ne.innerHTML=ea,mt=p(),H=c("blockquote"),H.innerHTML=la,rt=p(),f(He.$$.fragment),dt=p(),F=c("div"),F.innerHTML=ta,ct=p(),f(qe.$$.fragment),Mt=p(),Le=c("p"),this.h()},l(e){const l=da("svelte-u9bgzb",document.head);n=M(l,"META",{name:!0,content:!0}),l.forEach(t),u=o(e),i=M(e,"P",{}),na(i).forEach(t),g=o(e),h(m.$$.fragment,e),s=o(e),h(r.$$.fragment,e),d=o(e),U=M(e,"P",{"data-svelte-h":!0}),y(U)!=="svelte-lv4dxu"&&(U.innerHTML=G),j=o(e),_=M(e,"P",{"data-svelte-h":!0}),y(_)!=="svelte-145huch"&&(_.innerHTML=gt),De=o(e),Q=M(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),y(Q)!=="svelte-12fjs1p"&&(Q.innerHTML=ft),Ke=o(e),q=M(e,"P",{"data-svelte-h":!0}),y(q)!=="svelte-iwas5e"&&(q.innerHTML=ht),Oe=o(e),h(A.$$.fragment,e),el=o(e),z=M(e,"P",{"data-svelte-h":!0}),y(z)!=="svelte-1wker05"&&(z.innerHTML=Jt),ll=o(e),h(L.$$.fragment,e),tl=o(e),B=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(B)!=="svelte-295lls"&&(B.innerHTML=wt),al=o(e),P=M(e,"P",{"data-svelte-h":!0}),y(P)!=="svelte-12n8oag"&&(P.textContent=Zt),sl=o(e),h(x.$$.fragment,e),il=o(e),h(D.$$.fragment,e),nl=o(e),K=M(e,"P",{"data-svelte-h":!0}),y(K)!=="svelte-9uieuk"&&(K.textContent=bt),pl=o(e),h(S.$$.fragment,e),ol=o(e),h(O.$$.fragment,e),ml=o(e),ee=M(e,"P",{"data-svelte-h":!0}),y(ee)!=="svelte-hpizde"&&(ee.innerHTML=Tt),rl=o(e),h(le.$$.fragment,e),dl=o(e),te=M(e,"P",{"data-svelte-h":!0}),y(te)!=="svelte-17yemw9"&&(te.innerHTML=Ut),cl=o(e),E=M(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),y(E)!=="svelte-vk2j0b"&&(E.innerHTML=jt),Ml=o(e),h(ae.$$.fragment,e),ul=o(e),h(se.$$.fragment,e),yl=o(e),ie=M(e,"P",{"data-svelte-h":!0}),y(ie)!=="svelte-1btur7m"&&(ie.textContent=Wt),gl=o(e),ne=M(e,"P",{"data-svelte-h":!0}),y(ne)!=="svelte-1rivkhw"&&(ne.innerHTML=It),fl=o(e),h(pe.$$.fragment,e),hl=o(e),X=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(X)!=="svelte-8iu0me"&&(X.innerHTML=Gt),Jl=o(e),oe=M(e,"P",{"data-svelte-h":!0}),y(oe)!=="svelte-bmwit0"&&(oe.innerHTML=_t),wl=o(e),h(me.$$.fragment,e),Zl=o(e),Y=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(Y)!=="svelte-1cx2gkd"&&(Y.innerHTML=Bt),bl=o(e),h(re.$$.fragment,e),Tl=o(e),de=M(e,"P",{"data-svelte-h":!0}),y(de)!=="svelte-1j6fwoj"&&(de.textContent=Xt),Ul=o(e),h(ce.$$.fragment,e),jl=o(e),Me=M(e,"P",{"data-svelte-h":!0}),y(Me)!=="svelte-jdscb4"&&(Me.innerHTML=kt),Wl=o(e),ue=M(e,"P",{"data-svelte-h":!0}),y(ue)!=="svelte-nblulr"&&(ue.innerHTML=Vt),Il=o(e),h(N.$$.fragment,e),Gl=o(e),h(ye.$$.fragment,e),_l=o(e),ge=M(e,"P",{"data-svelte-h":!0}),y(ge)!=="svelte-8t9z4d"&&(ge.textContent=Rt),Bl=o(e),fe=M(e,"P",{"data-svelte-h":!0}),y(fe)!=="svelte-1rlgp6a"&&(fe.innerHTML=Ft),Xl=o(e),h(he.$$.fragment,e),kl=o(e),Je=M(e,"P",{"data-svelte-h":!0}),y(Je)!=="svelte-12sbcxj"&&(Je.textContent=Yt),Vl=o(e),we=M(e,"UL",{"data-svelte-h":!0}),y(we)!=="svelte-14lybvh"&&(we.innerHTML=Ct),Rl=o(e),h(Ze.$$.fragment,e),Fl=o(e),be=M(e,"P",{"data-svelte-h":!0}),y(be)!=="svelte-1lm8xpa"&&(be.textContent=vt),Yl=o(e),h(Te.$$.fragment,e),Cl=o(e),k=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(k)!=="svelte-1fqw2fw"&&(k.innerHTML=$t),vl=o(e),Ue=M(e,"P",{"data-svelte-h":!0}),y(Ue)!=="svelte-1f9ayt4"&&(Ue.innerHTML=Qt),$l=o(e),h(je.$$.fragment,e),Ql=o(e),v=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(v)!=="svelte-1vyi3xu"&&(v.innerHTML=xt),xl=o(e),h(We.$$.fragment,e),Sl=o(e),Ie=M(e,"P",{"data-svelte-h":!0}),y(Ie)!=="svelte-gtun4"&&(Ie.innerHTML=St),El=o(e),Ge=M(e,"P",{"data-svelte-h":!0}),y(Ge)!=="svelte-1329zmn"&&(Ge.innerHTML=Et),Nl=o(e),h(_e.$$.fragment,e),Hl=o(e),Be=M(e,"P",{"data-svelte-h":!0}),y(Be)!=="svelte-9f9j6q"&&(Be.textContent=Nt),ql=o(e),h(Xe.$$.fragment,e),Al=o(e),$=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y($)!=="svelte-uhx8ym"&&($.innerHTML=Ht),zl=o(e),h(ke.$$.fragment,e),Ll=o(e),Ve=M(e,"P",{"data-svelte-h":!0}),y(Ve)!=="svelte-f8td34"&&(Ve.innerHTML=qt),Pl=o(e),Re=M(e,"P",{"data-svelte-h":!0}),y(Re)!=="svelte-1c3mmhb"&&(Re.innerHTML=At),Dl=o(e),h(Fe.$$.fragment,e),Kl=o(e),Ye=M(e,"P",{"data-svelte-h":!0}),y(Ye)!=="svelte-1grcvlc"&&(Ye.textContent=zt),Ol=o(e),h(Ce.$$.fragment,e),et=o(e),V=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(V)!=="svelte-11joxfd"&&(V.innerHTML=Lt),lt=o(e),h(ve.$$.fragment,e),tt=o(e),$e=M(e,"P",{"data-svelte-h":!0}),y($e)!=="svelte-znjjtu"&&($e.innerHTML=Pt),at=o(e),Qe=M(e,"P",{"data-svelte-h":!0}),y(Qe)!=="svelte-1n7mj5h"&&(Qe.innerHTML=Dt),st=o(e),h(xe.$$.fragment,e),it=o(e),Se=M(e,"P",{"data-svelte-h":!0}),y(Se)!=="svelte-a2xkl9"&&(Se.textContent=Kt),nt=o(e),h(Ee.$$.fragment,e),pt=o(e),R=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(R)!=="svelte-1i6rw5e"&&(R.innerHTML=Ot),ot=o(e),Ne=M(e,"P",{"data-svelte-h":!0}),y(Ne)!=="svelte-1z0qe12"&&(Ne.innerHTML=ea),mt=o(e),H=M(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),y(H)!=="svelte-1wn55xk"&&(H.innerHTML=la),rt=o(e),h(He.$$.fragment,e),dt=o(e),F=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(F)!=="svelte-sniway"&&(F.innerHTML=ta),ct=o(e),h(qe.$$.fragment,e),Mt=o(e),Le=M(e,"P",{}),na(Le).forEach(t),this.h()},h(){Pe(n,"name","hf:doc:metadata"),Pe(n,"content",Wa),Pe(Q,"class","tip"),T(B,"display","flex"),T(B,"gap","10px"),T(B,"justify-content","space-around"),T(B,"align-items","flex-end"),Pe(E,"class","tip"),T(X,"display","flex"),T(X,"gap","10px"),T(X,"justify-content","space-around"),T(X,"align-items","flex-end"),T(Y,"display","flex"),T(Y,"flex-direction","column"),T(Y,"gap","10px"),T(k,"display","flex"),T(k,"gap","10px"),T(k,"justify-content","space-around"),T(k,"align-items","flex-end"),T(v,"display","flex"),T(v,"justify-content","center"),T($,"display","flex"),T($,"justify-content","center"),T(V,"display","flex"),T(V,"gap","10px"),T(V,"justify-content","space-around"),T(V,"align-items","flex-end"),T(R,"display","flex"),T(R,"gap","10px"),T(R,"justify-content","space-around"),T(R,"align-items","flex-end"),Pe(H,"class","tip"),T(F,"display","flex"),T(F,"gap","10px"),T(F,"justify-content","space-around"),T(F,"align-items","flex-end")},m(e,l){ca(document.head,n),a(e,u,l),a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pl,l),a(e,Re,l),a(e,Dl,l),J(Fe,e,l),a(e,Kl,l),a(e,Ye,l),a(e,Ol,l),J(Ce,e,l),a(e,et,l),a(e,V,l),a(e,lt,l),J(ve,e,l),a(e,tt,l),a(e,$e,l),a(e,at,l),a(e,Qe,l),a(e,st,l),J(xe,e,l),a(e,it,l),a(e,Se,l),a(e,nt,l),J(Ee,e,l),a(e,pt,l),a(e,R,l),a(e,ot,l),a(e,Ne,l),a(e,mt,l),a(e,H,l),a(e,rt,l),J(He,e,l),a(e,dt,l),a(e,F,l),a(e,ct,l),J(qe,e,l),a(e,Mt,l),a(e,Le,l),ut=!0},p(e,[l]){const aa={};l&2&&(aa.$$scope={dirty:l,ctx:e}),x.$set(aa);const sa={};l&2&&(sa.$$scope={dirty:l,ctx:e}),S.$set(sa);const ia={};l&2&&(ia.$$scope={dirty:l,ctx:e}),N.$set(ia)},i(e){ut||(w(m.$$.fragment,e),w(r.$$.fragment,e),w(A.$$.fragment,e),w(L.$$.fragment,e),w(x.$$.fragment,e),w(D.$$.fragment,e),w(S.$$.fragment,e),w(O.$$.fragment,e),w(le.$$.fragment,e),w(ae.$$.fragment,e),w(se.$$.fragment,e),w(pe.$$.fragment,e),w(me.$$.fragment,e),w(re.$$.fragment,e),w(ce.$$.fragment,e),w(N.$$.fragment,e),w(ye.$$.fragment,e),w(he.$$.fragment,e),w(Ze.$$.fragment,e),w(Te.$$.fragment,e),w(je.$$.fragment,e),w(We.$$.fragment,e),w(_e.$$.fragment,e),w(Xe.$$.fragment,e),w(ke.$$.fragment,e),w(Fe.$$.fragment,e),w(Ce.$$.fragment,e),w(ve.$$.fragment,e),w(xe.$$.fragment,e),w(Ee.$$.fragment,e),w(He.$$.fragment,e),w(qe.$$.fragment,e),ut=!0)},o(e){Z(m.$$.fragment,e),Z(r.$$.fragment,e),Z(A.$$.fragment,e),Z(L.$$.fragment,e),Z(x.$$.fragment,e),Z(D.$$.fragment,e),Z(S.$$.fragment,e),Z(O.$$.fragment,e),Z(le.$$.fragment,e),Z(ae.$$.fragment,e),Z(se.$$.fragment,e),Z(pe.$$.fragment,e),Z(me.$$.fragment,e),Z(re.$$.fragment,e),Z(ce.$$.fragment,e),Z(N.$$.fragment,e),Z(ye.$$.fragment,e),Z(he.$$.fragment,e),Z(Ze.$$.fragment,e),Z(Te.$$.fragment,e),Z(je.$$.fragment,e),Z(We.$$.fragment,e),Z(_e.$$.fragment,e),Z(Xe.$$.fragment,e),Z(ke.$$.fragment,e),Z(Fe.$$.fragment,e),Z(Ce.$$.fragment,e),Z(ve.$$.fragment,e),Z(xe.$$.fragment,e),Z(Ee.$$.fragment,e),Z(He.$$.fragment,e),Z(qe.$$.fragment,e),ut=!1},d(e){e&&(t(u),t(i),t(g),t(s),t(d),t(U),t(j),t(_),t(De),t(Q),t(Ke),t(q),t(Oe),t(el),t(z),t(ll),t(tl),t(B),t(al),t(P),t(sl),t(il),t(nl),t(K),t(pl),t(ol),t(ml),t(ee),t(rl),t(dl),t(te),t(cl),t(E),t(Ml),t(ul),t(yl),t(ie),t(gl),t(ne),t(fl),t(hl),t(X),t(Jl),t(oe),t(wl),t(Zl),t(Y),t(bl),t(Tl),t(de),t(Ul),t(jl),t(Me),t(Wl),t(ue),t(Il),t(Gl),t(_l),t(ge),t(Bl),t(fe),t(Xl),t(kl),t(Je),t(Vl),t(we),t(Rl),t(Fl),t(be),t(Yl),t(Cl),t(k),t(vl),t(Ue),t($l),t(Ql),t(v),t(xl),t(Sl),t(Ie),t(El),t(Ge),t(Nl),t(Hl),t(Be),t(ql),t(Al),t($),t(zl),t(Ll),t(Ve),t(Pl),t(Re),t(Dl),t(Kl),t(Ye),t(Ol),t(et),t(V),t(lt),t(tt),t($e),t(at),t(Qe),t(st),t(it),t(Se),t(nt),t(pt),t(R),t(ot),t(Ne),t(mt),t(H),t(rt),t(dt),t(F),t(ct),t(Mt),t(Le)),t(n),b(m,e),b(r,e),b(A,e),b(L,e),b(x,e),b(D,e),b(S,e),b(O,e),b(le,e),b(ae,e),b(se,e),b(pe,e),b(me,e),b(re,e),b(ce,e),b(N,e),b(ye,e),b(he,e),b(Ze,e),b(Te,e),b(je,e),b(We,e),b(_e,e),b(Xe,e),b(ke,e),b(Fe,e),b(Ce,e),b(ve,e),b(xe,e),b(Ee,e),b(He,e),b(qe,e)}}}const Wa='{"title":"IP-Adapter","local":"ip-adapter","sections":[{"title":"Model variants","local":"model-variants","sections":[],"depth":2},{"title":"Image embeddings","local":"image-embeddings","sections":[],"depth":2},{"title":"Masking","local":"masking","sections":[],"depth":2},{"title":"Applications","local":"applications","sections":[{"title":"Face models","local":"face-models","sections":[],"depth":3},{"title":"Multiple IP-Adapters","local":"multiple-ip-adapters","sections":[],"depth":3},{"title":"Instant generation","local":"instant-generation","sections":[],"depth":3},{"title":"Structural control","local":"structural-control","sections":[],"depth":3},{"title":"Style and layout control","local":"style-and-layout-control","sections":[],"depth":3}],"depth":2}],"depth":1}';function Ia(I){return oa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ra extends ma{constructor(n){super(),ra(this,n,Ia,ja,pa,{})}}export{Ra as component};
