import{s as ia,o as na,n as ze}from"../chunks/scheduler.8c3d61f6.js";import{S as pa,i as oa,g as c,s as p,r as f,A as ma,h as M,f as t,c as o,j as sa,u as h,x as y,k as Pe,l as J,y as ra,a,v as w,d as Z,t as b,w as T}from"../chunks/index.da70eac4.js";import{C as W}from"../chunks/CodeBlock.a9c4becf.js";import{H as C,E as da}from"../chunks/getInferenceSnippets.cb466318.js";import{H as ut,a as Ae}from"../chunks/HfOption.6c3b4e77.js";function ca(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(){J(i,"display","flex"),J(i,"gap","10px"),J(i,"justify-content","space-around"),J(i,"align-items","flex-end")},m(s,r){w(n,s,r),a(s,u,r),a(s,i,r),m=!0},p:ze,i(s){m||(Z(n.$$.fragment,s),m=!0)},o(s){b(n.$$.fragment,s),m=!1},d(s){s&&(t(u),t(i)),T(n,s)}}}function Ma(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(){J(i,"display","flex"),J(i,"gap","10px"),J(i,"justify-content","space-around"),J(i,"align-items","flex-end")},m(s,r){w(n,s,r),a(s,u,r),a(s,i,r),m=!0},p:ze,i(s){m||(Z(n.$$.fragment,s),m=!0)},o(s){b(n.$$.fragment,s),m=!1},d(s){s&&(t(u),t(i)),T(n,s)}}}function ua(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:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQW5pbWF0ZURpZmZQaXBlbGluZSUyQyUyMERESU1TY2hlZHVsZXIlMkMlMjBNb3Rpb25BZGFwdGVyJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGV4cG9ydF90b19naWYlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQWFkYXB0ZXIlMjAlM0QlMjBNb3Rpb25BZGFwdGVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJndW95d3clMkZhbmltYXRlZGlmZi1tb3Rpb24tYWRhcHRlci12MS01LTIlMjIlMkMlMEElMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpJTBBcGlwZWxpbmUlMjAlM0QlMjBBbmltYXRlRGlmZlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJlbWlsaWFuSlIlMkZlcGlDUmVhbGlzbSUyMiUyQyUwQSUyMCUyMG1vdGlvbl9hZGFwdGVyJTNEYWRhcHRlciUyQyUwQSUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFzY2hlZHVsZXIlMjAlM0QlMjBERElNU2NoZWR1bGVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJlbWlsaWFuSlIlMkZlcGlDUmVhbGlzbSUyMiUyQyUwQSUyMCUyMCUyMCUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMiUyQyUwQSUyMCUyMCUyMCUyMGNsaXBfc2FtcGxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjB0aW1lc3RlcF9zcGFjaW5nJTNEJTIybGluc3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lkYW5jZV9zY2FsZSUzRDcuNSUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q1MCUyQyUwQSkuZnJhbWVzJTVCMCU1RA==",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(){J(s,"display","flex"),J(s,"gap","10px"),J(s,"justify-content","space-around"),J(s,"align-items","flex-end")},m(U,G){a(U,n,G),a(U,i,G),w(g,U,G),a(U,m,G),a(U,s,G),d=!0},p:ze,i(U){d||(Z(g.$$.fragment,U),d=!0)},o(U){b(g.$$.fragment,U),d=!1},d(U){U&&(t(n),t(i),t(m),t(s)),T(g,U)}}}function ya(I){let n,u,i,g,m,s;return n=new Ae({props:{id:"usage",option:"image-to-image",$$slots:{default:[ca]},$$scope:{ctx:I}}}),i=new Ae({props:{id:"usage",option:"inpainting",$$slots:{default:[Ma]},$$scope:{ctx:I}}}),m=new Ae({props:{id:"usage",option:"video",$$slots:{default:[ua]},$$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){w(n,r,d),a(r,u,d),w(i,r,d),a(r,g,d),w(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||(Z(n.$$.fragment,r),Z(i.$$.fragment,r),Z(m.$$.fragment,r),s=!0)},o(r){b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cGx1c19zZHhsX3ZpdC1oLnNhZmV0ZW5zb3JzJTIyJTBBKQ==",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){w(n,i,g),u=!0},p:ze,i(i){u||(Z(n.$$.fragment,i),u=!0)},o(i){b(n.$$.fragment,i),u=!1},d(i){T(n,i)}}}function fa(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){w(n,d,U),a(d,u,U),a(d,i,U),a(d,m,U),w(s,d,U),r=!0},p:ze,i(d){r||(Z(n.$$.fragment,d),Z(s.$$.fragment,d),r=!0)},o(d){b(n.$$.fragment,d),b(s.$$.fragment,d),r=!1},d(d){d&&(t(u),t(i),t(m)),T(n,d),T(s,d)}}}function ha(I){let n,u,i,g;return n=new Ae({props:{id:"ipadapter-variants",option:"IP-Adapter Plus",$$slots:{default:[ga]},$$scope:{ctx:I}}}),i=new Ae({props:{id:"ipadapter-variants",option:"IP-Adapter FaceID",$$slots:{default:[fa]},$$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){w(n,m,s),a(m,u,s),w(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||(Z(n.$$.fragment,m),Z(i.$$.fragment,m),g=!0)},o(m){b(n.$$.fragment,m),b(i.$$.fragment,m),g=!1},d(m){m&&t(u),T(n,m),T(i,m)}}}function Ja(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>',m;return n=new W({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJT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vbXB0JTNEJTIyQSUyMHBob3RvJTIwb2YlMjBFaW5zdGVpbiUyMGFzJTIwYSUyMGNoZWYlMkMlMjB3ZWFyaW5nJTIwYW4lMjBhcHJvbiUyQyUyMGNvb2tpbmclMjBpbiUyMGElMjBGcmVuY2glMjByZXN0YXVyYW50JTIyJTJDJTBBJTIwJTIwJTIwJTIwaXBfYWRhcHRlcl9pbWFnZSUzRGltYWdlJTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEJTIybG93cmVzJTJDJTIwYmFkJTIwYW5hdG9teSUyQyUyMHdvcnN0JTIwcXVhbGl0eSUyQyUyMGxvdyUyMHF1YWxpdHklMjIlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMTAwJTJDJTBBKS5pbWFnZXMlNUIwJTVE",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(){J(i,"display","flex"),J(i,"gap","10px"),J(i,"justify-content","space-around"),J(i,"align-items","flex-end")},m(s,r){w(n,s,r),a(s,u,r),a(s,i,r),m=!0},p:ze,i(s){m||(Z(n.$$.fragment,s),m=!0)},o(s){b(n.$$.fragment,s),m=!1},d(s){s&&(t(u),t(i)),T(n,s)}}}function wa(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:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMGluc2lnaHRmYWNlJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBERElNU2NoZWR1bGVyJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEFmcm9tJTIwaW5zaWdodGZhY2UuYXBwJTIwaW1wb3J0JTIwRmFjZUFuYWx5c2lzJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01J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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,_),w(g,j,_),a(j,m,_),a(j,s,_),a(j,d,_),w(U,j,_),G=!0},p:ze,i(j){G||(Z(g.$$.fragment,j),Z(U.$$.fragment,j),G=!0)},o(j){b(g.$$.fragment,j),b(U.$$.fragment,j),G=!1},d(j){j&&(t(n),t(i),t(m),t(s),t(d)),T(g,j),T(U,j)}}}function Za(I){let n,u,i,g;return n=new Ae({props:{id:"usage",option:"h94/IP-Adapter",$$slots:{default:[Ja]},$$scope:{ctx:I}}}),i=new Ae({props:{id:"usage",option:"h94/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){w(n,m,s),a(m,u,s),w(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||(Z(n.$$.fragment,m),Z(i.$$.fragment,m),g=!0)},o(m){b(n.$$.fragment,m),b(i.$$.fragment,m),g=!1},d(m){m&&t(u),T(n,m),T(i,m)}}}function ba(I){let n,u,i,g,m,s,r,d='<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.',U,G,j='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>.',_,Q,yt='<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>',De,q,gt='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.',Ke,A,Oe,z,ft="Pass an image to <code>ip_adapter_image</code> along with a text prompt to generate an image.",el,L,ll,B,ht='<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>',tl,P,Jt="Take a look at the examples below to learn how to use IP-Adapter for other tasks.",al,x,sl,D,il,K,wt="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.",nl,E,pl,O,ol,ee,Zt="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.",ml,le,rl,te,bt="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.",dl,S,Tt="<p>You can also load image embeddings from other sources such as ComfyUI.</p>",cl,ae,Ml,se,ul,ie,Ut="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.",yl,ne,jt='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>.',gl,pe,fl,X,Wt='<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>',hl,oe,It="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.",Jl,me,wl,Y,Gt='<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>',Zl,re,bl,de,_t="The section below covers some popular applications of IP-Adapter.",Tl,ce,Ul,Me,Bt='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.',jl,ue,Xt='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.',Wl,N,Il,ye,Gl,ge,kt="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.",_l,fe,Vt='Load an image encoder with <a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPVisionModelWithProjection" rel="nofollow">CLIPVisionModelWithProjection</a>.',Bl,he,Xl,Je,Rt="Load a base model, scheduler and the following IP-Adapters.",kl,we,Ft='<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>',Vl,Ze,Rl,be,Yt="Load an image and a folder containing images of a certain style to apply.",Fl,Te,Yl,k,Ct='<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>',Cl,Ue,vt="Pass style and face images as a list to <code>ip_adapter_image</code>.",vl,je,$l,v,$t='<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>',Ql,We,xl,Ie,Qt='<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,xt='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>.',Sl,_e,Nl,Be,Et="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.",Hl,Xe,ql,$,St='<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>',Al,ke,zl,Ve,Nt='For structural control, combine IP-Adapter with <a href="../api/pipelines/controlnet">ControlNet</a> conditioned on depth maps, edge maps, pose estimations, and more.',Ll,Re,Ht='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.',Pl,Fe,Dl,Ye,qt="Pass the depth map and IP-Adapter image to the pipeline.",Kl,Ce,Ol,V,At='<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>',et,ve,lt,$e,zt='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.',tt,Qe,Lt='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.',at,xe,st,Ee,Pt="Load the style image and generate an image.",it,Se,nt,R,Dt='<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>',pt,Ne,Kt="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.",ot,H,Ot="<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>",mt,He,rt,F,ea='<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>',dt,qe,ct,Le,Mt;return m=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 ut({props:{id:"usage",options:["image-to-image","inpainting","video"],$$slots:{default:[ya]},$$scope:{ctx:I}}}),D=new C({props:{title:"Model variants",local:"model-variants",headingTag:"h2"}}),E=new ut({props:{id:"ipadapter-variants",options:["IP-Adapter Plus","IP-Adapter FaceID"],$$slots:{default:[ha]},$$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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NrMSUyQyUyMG1hc2syJTVEJTJDJTIwaGVpZ2h0JTNEMTAyNCUyQyUyMHdpZHRoJTNEMTAyNCk=",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:"ZmFjZV9pbWFnZTElMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmlwX21hc2tfZ2lybDEucG5nJTIyKSUwQWZhY2VfaW1hZ2UyJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpcF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entation-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 ut({props:{id:"usage",options:["h94/IP-Adapter","h94/IP-Adapter-FaceID"],$$slots:{default:[Za]},$$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}}),Se=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 da({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(),r=c("p"),r.innerHTML=d,U=p(),G=c("p"),G.innerHTML=j,_=p(),Q=c("blockquote"),Q.innerHTML=yt,De=p(),q=c("p"),q.innerHTML=gt,Ke=p(),f(A.$$.fragment),Oe=p(),z=c("p"),z.innerHTML=ft,el=p(),f(L.$$.fragment),ll=p(),B=c("div"),B.innerHTML=ht,tl=p(),P=c("p"),P.textContent=Jt,al=p(),f(x.$$.fragment),sl=p(),f(D.$$.fragment),il=p(),K=c("p"),K.textContent=wt,nl=p(),f(E.$$.fragment),pl=p(),f(O.$$.fragment),ol=p(),ee=c("p"),ee.innerHTML=Zt,ml=p(),f(le.$$.fragment),rl=p(),te=c("p"),te.innerHTML=bt,dl=p(),S=c("blockquote"),S.innerHTML=Tt,cl=p(),f(ae.$$.fragment),Ml=p(),f(se.$$.fragment),ul=p(),ie=c("p"),ie.textContent=Ut,yl=p(),ne=c("p"),ne.innerHTML=jt,gl=p(),f(pe.$$.fragment),fl=p(),X=c("div"),X.innerHTML=Wt,hl=p(),oe=c("p"),oe.innerHTML=It,Jl=p(),f(me.$$.fragment),wl=p(),Y=c("div"),Y.innerHTML=Gt,Zl=p(),f(re.$$.fragment),bl=p(),de=c("p"),de.textContent=_t,Tl=p(),f(ce.$$.fragment),Ul=p(),Me=c("p"),Me.innerHTML=Bt,jl=p(),ue=c("p"),ue.innerHTML=Xt,Wl=p(),f(N.$$.fragment),Il=p(),f(ye.$$.fragment),Gl=p(),ge=c("p"),ge.textContent=kt,_l=p(),fe=c("p"),fe.innerHTML=Vt,Bl=p(),f(he.$$.fragment),Xl=p(),Je=c("p"),Je.textContent=Rt,kl=p(),we=c("ul"),we.innerHTML=Ft,Vl=p(),f(Ze.$$.fragment),Rl=p(),be=c("p"),be.textContent=Yt,Fl=p(),f(Te.$$.fragment),Yl=p(),k=c("div"),k.innerHTML=Ct,Cl=p(),Ue=c("p"),Ue.innerHTML=vt,vl=p(),f(je.$$.fragment),$l=p(),v=c("div"),v.innerHTML=$t,Ql=p(),f(We.$$.fragment),xl=p(),Ie=c("p"),Ie.innerHTML=Qt,El=p(),Ge=c("p"),Ge.innerHTML=xt,Sl=p(),f(_e.$$.fragment),Nl=p(),Be=c("p"),Be.textContent=Et,Hl=p(),f(Xe.$$.fragment),ql=p(),$=c("div"),$.innerHTML=St,Al=p(),f(ke.$$.fragment),zl=p(),Ve=c("p"),Ve.innerHTML=Nt,Ll=p(),Re=c("p"),Re.innerHTML=Ht,Pl=p(),f(Fe.$$.fragment),Dl=p(),Ye=c("p"),Ye.textContent=qt,Kl=p(),f(Ce.$$.fragment),Ol=p(),V=c("div"),V.innerHTML=At,et=p(),f(ve.$$.fragment),lt=p(),$e=c("p"),$e.innerHTML=zt,tt=p(),Qe=c("p"),Qe.innerHTML=Lt,at=p(),f(xe.$$.fragment),st=p(),Ee=c("p"),Ee.textContent=Pt,it=p(),f(Se.$$.fragment),nt=p(),R=c("div"),R.innerHTML=Dt,pt=p(),Ne=c("p"),Ne.innerHTML=Kt,ot=p(),H=c("blockquote"),H.innerHTML=Ot,mt=p(),f(He.$$.fragment),rt=p(),F=c("div"),F.innerHTML=ea,dt=p(),f(qe.$$.fragment),ct=p(),Le=c("p"),this.h()},l(e){const l=ma("svelte-u9bgzb",document.head);n=M(l,"META",{name:!0,content:!0}),l.forEach(t),u=o(e),i=M(e,"P",{}),sa(i).forEach(t),g=o(e),h(m.$$.fragment,e),s=o(e),r=M(e,"P",{"data-svelte-h":!0}),y(r)!=="svelte-lv4dxu"&&(r.innerHTML=d),U=o(e),G=M(e,"P",{"data-svelte-h":!0}),y(G)!=="svelte-145huch"&&(G.innerHTML=j),_=o(e),Q=M(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),y(Q)!=="svelte-12fjs1p"&&(Q.innerHTML=yt),De=o(e),q=M(e,"P",{"data-svelte-h":!0}),y(q)!=="svelte-iwas5e"&&(q.innerHTML=gt),Ke=o(e),h(A.$$.fragment,e),Oe=o(e),z=M(e,"P",{"data-svelte-h":!0}),y(z)!=="svelte-1wker05"&&(z.innerHTML=ft),el=o(e),h(L.$$.fragment,e),ll=o(e),B=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(B)!=="svelte-295lls"&&(B.innerHTML=ht),tl=o(e),P=M(e,"P",{"data-svelte-h":!0}),y(P)!=="svelte-12n8oag"&&(P.textContent=Jt),al=o(e),h(x.$$.fragment,e),sl=o(e),h(D.$$.fragment,e),il=o(e),K=M(e,"P",{"data-svelte-h":!0}),y(K)!=="svelte-9uieuk"&&(K.textContent=wt),nl=o(e),h(E.$$.fragment,e),pl=o(e),h(O.$$.fragment,e),ol=o(e),ee=M(e,"P",{"data-svelte-h":!0}),y(ee)!=="svelte-hpizde"&&(ee.innerHTML=Zt),ml=o(e),h(le.$$.fragment,e),rl=o(e),te=M(e,"P",{"data-svelte-h":!0}),y(te)!=="svelte-17yemw9"&&(te.innerHTML=bt),dl=o(e),S=M(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),y(S)!=="svelte-vk2j0b"&&(S.innerHTML=Tt),cl=o(e),h(ae.$$.fragment,e),Ml=o(e),h(se.$$.fragment,e),ul=o(e),ie=M(e,"P",{"data-svelte-h":!0}),y(ie)!=="svelte-1btur7m"&&(ie.textContent=Ut),yl=o(e),ne=M(e,"P",{"data-svelte-h":!0}),y(ne)!=="svelte-1rivkhw"&&(ne.innerHTML=jt),gl=o(e),h(pe.$$.fragment,e),fl=o(e),X=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(X)!=="svelte-8iu0me"&&(X.innerHTML=Wt),hl=o(e),oe=M(e,"P",{"data-svelte-h":!0}),y(oe)!=="svelte-bmwit0"&&(oe.innerHTML=It),Jl=o(e),h(me.$$.fragment,e),wl=o(e),Y=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(Y)!=="svelte-1cx2gkd"&&(Y.innerHTML=Gt),Zl=o(e),h(re.$$.fragment,e),bl=o(e),de=M(e,"P",{"data-svelte-h":!0}),y(de)!=="svelte-1j6fwoj"&&(de.textContent=_t),Tl=o(e),h(ce.$$.fragment,e),Ul=o(e),Me=M(e,"P",{"data-svelte-h":!0}),y(Me)!=="svelte-jdscb4"&&(Me.innerHTML=Bt),jl=o(e),ue=M(e,"P",{"data-svelte-h":!0}),y(ue)!=="svelte-nblulr"&&(ue.innerHTML=Xt),Wl=o(e),h(N.$$.fragment,e),Il=o(e),h(ye.$$.fragment,e),Gl=o(e),ge=M(e,"P",{"data-svelte-h":!0}),y(ge)!=="svelte-8t9z4d"&&(ge.textContent=kt),_l=o(e),fe=M(e,"P",{"data-svelte-h":!0}),y(fe)!=="svelte-1rlgp6a"&&(fe.innerHTML=Vt),Bl=o(e),h(he.$$.fragment,e),Xl=o(e),Je=M(e,"P",{"data-svelte-h":!0}),y(Je)!=="svelte-12sbcxj"&&(Je.textContent=Rt),kl=o(e),we=M(e,"UL",{"data-svelte-h":!0}),y(we)!=="svelte-14lybvh"&&(we.innerHTML=Ft),Vl=o(e),h(Ze.$$.fragment,e),Rl=o(e),be=M(e,"P",{"data-svelte-h":!0}),y(be)!=="svelte-1lm8xpa"&&(be.textContent=Yt),Fl=o(e),h(Te.$$.fragment,e),Yl=o(e),k=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(k)!=="svelte-1fqw2fw"&&(k.innerHTML=Ct),Cl=o(e),Ue=M(e,"P",{"data-svelte-h":!0}),y(Ue)!=="svelte-1f9ayt4"&&(Ue.innerHTML=vt),vl=o(e),h(je.$$.fragment,e),$l=o(e),v=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(v)!=="svelte-1vyi3xu"&&(v.innerHTML=$t),Ql=o(e),h(We.$$.fragment,e),xl=o(e),Ie=M(e,"P",{"data-svelte-h":!0}),y(Ie)!=="svelte-gtun4"&&(Ie.innerHTML=Qt),El=o(e),Ge=M(e,"P",{"data-svelte-h":!0}),y(Ge)!=="svelte-1329zmn"&&(Ge.innerHTML=xt),Sl=o(e),h(_e.$$.fragment,e),Nl=o(e),Be=M(e,"P",{"data-svelte-h":!0}),y(Be)!=="svelte-9f9j6q"&&(Be.textContent=Et),Hl=o(e),h(Xe.$$.fragment,e),ql=o(e),$=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y($)!=="svelte-uhx8ym"&&($.innerHTML=St),Al=o(e),h(ke.$$.fragment,e),zl=o(e),Ve=M(e,"P",{"data-svelte-h":!0}),y(Ve)!=="svelte-f8td34"&&(Ve.innerHTML=Nt),Ll=o(e),Re=M(e,"P",{"data-svelte-h":!0}),y(Re)!=="svelte-1c3mmhb"&&(Re.innerHTML=Ht),Pl=o(e),h(Fe.$$.fragment,e),Dl=o(e),Ye=M(e,"P",{"data-svelte-h":!0}),y(Ye)!=="svelte-1grcvlc"&&(Ye.textContent=qt),Kl=o(e),h(Ce.$$.fragment,e),Ol=o(e),V=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(V)!=="svelte-11joxfd"&&(V.innerHTML=At),et=o(e),h(ve.$$.fragment,e),lt=o(e),$e=M(e,"P",{"data-svelte-h":!0}),y($e)!=="svelte-znjjtu"&&($e.innerHTML=zt),tt=o(e),Qe=M(e,"P",{"data-svelte-h":!0}),y(Qe)!=="svelte-1n7mj5h"&&(Qe.innerHTML=Lt),at=o(e),h(xe.$$.fragment,e),st=o(e),Ee=M(e,"P",{"data-svelte-h":!0}),y(Ee)!=="svelte-a2xkl9"&&(Ee.textContent=Pt),it=o(e),h(Se.$$.fragment,e),nt=o(e),R=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(R)!=="svelte-1i6rw5e"&&(R.innerHTML=Dt),pt=o(e),Ne=M(e,"P",{"data-svelte-h":!0}),y(Ne)!=="svelte-1z0qe12"&&(Ne.innerHTML=Kt),ot=o(e),H=M(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),y(H)!=="svelte-1wn55xk"&&(H.innerHTML=Ot),mt=o(e),h(He.$$.fragment,e),rt=o(e),F=M(e,"DIV",{style:!0,"data-svelte-h":!0}),y(F)!=="svelte-sniway"&&(F.innerHTML=ea),dt=o(e),h(qe.$$.fragment,e),ct=o(e),Le=M(e,"P",{}),sa(Le).forEach(t),this.h()},h(){Pe(n,"name","hf:doc:metadata"),Pe(n,"content",Ta),Pe(Q,"class","tip"),J(B,"display","flex"),J(B,"gap","10px"),J(B,"justify-content","space-around"),J(B,"align-items","flex-end"),Pe(S,"class","tip"),J(X,"display","flex"),J(X,"gap","10px"),J(X,"justify-content","space-around"),J(X,"align-items","flex-end"),J(Y,"display","flex"),J(Y,"flex-direction","column"),J(Y,"gap","10px"),J(k,"display","flex"),J(k,"gap","10px"),J(k,"justify-content","space-around"),J(k,"align-items","flex-end"),J(v,"display","flex"),J(v,"justify-content","center"),J($,"display","flex"),J($,"justify-content","center"),J(V,"display","flex"),J(V,"gap","10px"),J(V,"justify-content","space-around"),J(V,"align-items","flex-end"),J(R,"display","flex"),J(R,"gap","10px"),J(R,"justify-content","space-around"),J(R,"align-items","flex-end"),Pe(H,"class","tip"),J(F,"display","flex"),J(F,"gap","10px"),J(F,"justify-content","space-around"),J(F,"align-items","flex-end")},m(e,l){ra(document.head,n),a(e,u,l),a(e,i,l),a(e,g,l),w(m,e,l),a(e,s,l),a(e,r,l),a(e,U,l),a(e,G,l),a(e,_,l),a(e,Q,l),a(e,De,l),a(e,q,l),a(e,Ke,l),w(A,e,l),a(e,Oe,l),a(e,z,l),a(e,el,l),w(L,e,l),a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e,l),a(e,st,l),a(e,Ee,l),a(e,it,l),w(Se,e,l),a(e,nt,l),a(e,R,l),a(e,pt,l),a(e,Ne,l),a(e,ot,l),a(e,H,l),a(e,mt,l),w(He,e,l),a(e,rt,l),a(e,F,l),a(e,dt,l),w(qe,e,l),a(e,ct,l),a(e,Le,l),Mt=!0},p(e,[l]){const la={};l&2&&(la.$$scope={dirty:l,ctx:e}),x.$set(la);const ta={};l&2&&(ta.$$scope={dirty:l,ctx:e}),E.$set(ta);const aa={};l&2&&(aa.$$scope={dirty:l,ctx:e}),N.$set(aa)},i(e){Mt||(Z(m.$$.fragment,e),Z(A.$$.fragment,e),Z(L.$$.fragment,e),Z(x.$$.fragment,e),Z(D.$$.fragment,e),Z(E.$$.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(Se.$$.fragment,e),Z(He.$$.fragment,e),Z(qe.$$.fragment,e),Mt=!0)},o(e){b(m.$$.fragment,e),b(A.$$.fragment,e),b(L.$$.fragment,e),b(x.$$.fragment,e),b(D.$$.fragment,e),b(E.$$.fragment,e),b(O.$$.fragment,e),b(le.$$.fragment,e),b(ae.$$.fragment,e),b(se.$$.fragment,e),b(pe.$$.fragment,e),b(me.$$.fragment,e),b(re.$$.fragment,e),b(ce.$$.fragment,e),b(N.$$.fragment,e),b(ye.$$.fragment,e),b(he.$$.fragment,e),b(Ze.$$.fragment,e),b(Te.$$.fragment,e),b(je.$$.fragment,e),b(We.$$.fragment,e),b(_e.$$.fragment,e),b(Xe.$$.fragment,e),b(ke.$$.fragment,e),b(Fe.$$.fragment,e),b(Ce.$$.fragment,e),b(ve.$$.fragment,e),b(xe.$$.fragment,e),b(Se.$$.fragment,e),b(He.$$.fragment,e),b(qe.$$.fragment,e),Mt=!1},d(e){e&&(t(u),t(i),t(g),t(s),t(r),t(U),t(G),t(_),t(Q),t(De),t(q),t(Ke),t(Oe),t(z),t(el),t(ll),t(B),t(tl),t(P),t(al),t(sl),t(il),t(K),t(nl),t(pl),t(ol),t(ee),t(ml),t(rl),t(te),t(dl),t(S),t(cl),t(Ml),t(ul),t(ie),t(yl),t(ne),t(gl),t(fl),t(X),t(hl),t(oe),t(Jl),t(wl),t(Y),t(Zl),t(bl),t(de),t(Tl),t(Ul),t(Me),t(jl),t(ue),t(Wl),t(Il),t(Gl),t(ge),t(_l),t(fe),t(Bl),t(Xl),t(Je),t(kl),t(we),t(Vl),t(Rl),t(be),t(Fl),t(Yl),t(k),t(Cl),t(Ue),t(vl),t($l),t(v),t(Ql),t(xl),t(Ie),t(El),t(Ge),t(Sl),t(Nl),t(Be),t(Hl),t(ql),t($),t(Al),t(zl),t(Ve),t(Ll),t(Re),t(Pl),t(Dl),t(Ye),t(Kl),t(Ol),t(V),t(et),t(lt),t($e),t(tt),t(Qe),t(at),t(st),t(Ee),t(it),t(nt),t(R),t(pt),t(Ne),t(ot),t(H),t(mt),t(rt),t(F),t(dt),t(ct),t(Le)),t(n),T(m,e),T(A,e),T(L,e),T(x,e),T(D,e),T(E,e),T(O,e),T(le,e),T(ae,e),T(se,e),T(pe,e),T(me,e),T(re,e),T(ce,e),T(N,e),T(ye,e),T(he,e),T(Ze,e),T(Te,e),T(je,e),T(We,e),T(_e,e),T(Xe,e),T(ke,e),T(Fe,e),T(Ce,e),T(ve,e),T(xe,e),T(Se,e),T(He,e),T(qe,e)}}}const Ta='{"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 Ua(I){return na(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ba extends pa{constructor(n){super(),oa(this,n,Ua,ba,ia,{})}}export{Ba as component};
