import{s as Ce,o as ke,n as he}from"../chunks/scheduler.8c3d61f6.js";import{S as Ie,i as Re,g as f,s as p,r as g,A as ve,h as u,f as l,c as o,j as We,u as T,x as h,k as K,y as Be,a,v as Z,d as U,t as j,w as G}from"../chunks/index.da70eac4.js";import{T as xe}from"../chunks/Tip.1d9b8c37.js";import{C as X}from"../chunks/CodeBlock.00a903b3.js";import{H as ye,E as Xe}from"../chunks/EditOnGithub.1e64e623.js";import{H as Ve,a as $e}from"../chunks/HfOption.c1483eb1.js";function _e(v){let n,w=`There are several T2I-Adapters available for different conditions, such as color palette, depth, sketch, pose, and
segmentation. Check out the <a href="https://hf.co/TencentARC" rel="nofollow">TencentARC</a> repository to try them out!`;return{c(){n=f("p"),n.innerHTML=w},l(d){n=u(d,"P",{"data-svelte-h":!0}),h(n)!=="svelte-92wv1m"&&(n.innerHTML=w)},m(d,c){a(d,n,c)},p:he,d(d){d&&l(n)}}}function Fe(v){let n,w='Create a canny image with the <a href="https://github.com/opencv/opencv-python" rel="nofollow">opencv-library</a>.',d,c,i,m,k=`Now load a T2I-Adapter conditioned on <a href="https://hf.co/TencentARC/t2iadapter_canny_sd15v2" rel="nofollow">canny images</a> and pass it to
the <a href="/docs/diffusers/pr_10011/en/api/pipelines/stable_diffusion/adapter#diffusers.StableDiffusionAdapterPipeline">StableDiffusionAdapterPipeline</a>.`,I,y,W,J,B="Finally, pass your prompt and control image to the pipeline.",$,b,R,M,x='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/t2i-sd1.5.png"/>',C;return c=new X({props:{code:"aW1wb3J0JTIwY3YyJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEFpbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnNkX2NvbnRyb2xuZXQlMkZoZi1sb2dvLnBuZyUyMiklMEFpbWFnZSUyMCUzRCUyMG5wLmFycmF5KGltYWdlKSUwQSUwQWxvd190aHJlc2hvbGQlMjAlM0QlMjAxMDAlMEFoaWdoX3RocmVzaG9sZCUyMCUzRCUyMDIwMCUwQSUwQWltYWdlJTIwJTNEJTIwY3YyLkNhbm55KGltYWdlJTJDJTIwbG93X3RocmVzaG9sZCUyQyUyMGhpZ2hfdGhyZXNob2xkKSUwQWltYWdlJTIwJTNEJTIwSW1hZ2UuZnJvbWFycmF5KGltYWdlKQ==",highlighted:`<span class="hljs-keyword">import</span> cv2
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png&quot;</span>)
image = np.array(image)

low_threshold = <span class="hljs-number">100</span>
high_threshold = <span class="hljs-number">200</span>

image = cv2.Canny(image, low_threshold, high_threshold)
image = Image.fromarray(image)`,wrap:!1}}),y=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uQWRhcHRlclBpcGVsaW5lJTJDJTIwVDJJQWRhcHRlciUwQSUwQWFkYXB0ZXIlMjAlM0QlMjBUMklBZGFwdGVyLmZyb21fcHJldHJhaW5lZCglMjJUZW5jZW50QVJDJTJGdDJpYWRhcHRlcl9jYW5ueV9zZDE1djIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25BZGFwdGVyUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUwQSUyMCUyMCUyMCUyMGFkYXB0ZXIlM0RhZGFwdGVyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKSUwQXBpcGVsaW5lLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionAdapterPipeline, T2IAdapter

adapter = T2IAdapter.from_pretrained(<span class="hljs-string">&quot;TencentARC/t2iadapter_canny_sd15v2&quot;</span>, torch_dtype=torch.float16)
pipeline = StableDiffusionAdapterPipeline.from_pretrained(
    <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>,
    adapter=adapter,
    torch_dtype=torch.float16,
)
pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),b=new X({props:{code:"Z2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKCUyMmN1ZGElMjIpLm1hbnVhbF9zZWVkKDApJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZSglMEElMjAlMjAlMjAlMjBwcm9tcHQlM0QlMjJjaW5lbWF0aWMlMjBwaG90byUyMG9mJTIwYSUyMHBsdXNoJTIwYW5kJTIwc29mdCUyMG1pZGNlbnR1cnklMjBzdHlsZSUyMHJ1ZyUyMG9uJTIwYSUyMHdvb2RlbiUyMGZsb29yJTJDJTIwMzVtbSUyMHBob3RvZ3JhcGglMkMlMjBmaWxtJTJDJTIwcHJvZmVzc2lvbmFsJTJDJTIwNGslMkMlMjBoaWdobHklMjBkZXRhaWxlZCUyMiUyQyUwQSUyMCUyMCUyMCUyMGltYWdlJTNEaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEEpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)

image = pipeline(
    prompt=<span class="hljs-string">&quot;cinematic photo of a plush and soft midcentury style rug on a wooden floor, 35mm photograph, film, professional, 4k, highly detailed&quot;</span>,
    image=image,
    generator=generator,
).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){n=f("p"),n.innerHTML=w,d=p(),g(c.$$.fragment),i=p(),m=f("p"),m.innerHTML=k,I=p(),g(y.$$.fragment),W=p(),J=f("p"),J.textContent=B,$=p(),g(b.$$.fragment),R=p(),M=f("div"),M.innerHTML=x,this.h()},l(t){n=u(t,"P",{"data-svelte-h":!0}),h(n)!=="svelte-7kire0"&&(n.innerHTML=w),d=o(t),T(c.$$.fragment,t),i=o(t),m=u(t,"P",{"data-svelte-h":!0}),h(m)!=="svelte-1ixjjpl"&&(m.innerHTML=k),I=o(t),T(y.$$.fragment,t),W=o(t),J=u(t,"P",{"data-svelte-h":!0}),h(J)!=="svelte-1q7w192"&&(J.textContent=B),$=o(t),T(b.$$.fragment,t),R=o(t),M=u(t,"DIV",{class:!0,"data-svelte-h":!0}),h(M)!=="svelte-167mmab"&&(M.innerHTML=x),this.h()},h(){K(M,"class","flex justify-center")},m(t,r){a(t,n,r),a(t,d,r),Z(c,t,r),a(t,i,r),a(t,m,r),a(t,I,r),Z(y,t,r),a(t,W,r),a(t,J,r),a(t,$,r),Z(b,t,r),a(t,R,r),a(t,M,r),C=!0},p:he,i(t){C||(U(c.$$.fragment,t),U(y.$$.fragment,t),U(b.$$.fragment,t),C=!0)},o(t){j(c.$$.fragment,t),j(y.$$.fragment,t),j(b.$$.fragment,t),C=!1},d(t){t&&(l(n),l(d),l(i),l(m),l(I),l(W),l(J),l($),l(R),l(M)),G(c,t),G(y,t),G(b,t)}}}function Ye(v){let n,w='Create a canny image with the <a href="https://github.com/huggingface/controlnet_aux" rel="nofollow">controlnet-aux</a> library.',d,c,i,m,k=`Now load a T2I-Adapter conditioned on <a href="https://hf.co/TencentARC/t2i-adapter-canny-sdxl-1.0" rel="nofollow">canny images</a> and pass it
to the <a href="/docs/diffusers/pr_10011/en/api/pipelines/stable_diffusion/adapter#diffusers.StableDiffusionXLAdapterPipeline">StableDiffusionXLAdapterPipeline</a>.`,I,y,W,J,B="Finally, pass your prompt and control image to the pipeline.",$,b,R,M,x='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/t2i-sdxl.png"/>',C;return c=new X({props:{code:"ZnJvbSUyMGNvbnRyb2xuZXRfYXV4LmNhbm55JTIwaW1wb3J0JTIwQ2FubnlEZXRlY3RvciUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBY2FubnlfZGV0ZWN0b3IlMjAlM0QlMjBDYW5ueURldGVjdG9yKCklMEElMEFpbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnNkX2NvbnRyb2xuZXQlMkZoZi1sb2dvLnBuZyUyMiklMEFpbWFnZSUyMCUzRCUyMGNhbm55X2RldGVjdG9yKGltYWdlJTJDJTIwZGV0ZWN0X3Jlc29sdXRpb24lM0QzODQlMkMlMjBpbWFnZV9yZXNvbHV0aW9uJTNEMTAyNCk=",highlighted:`<span class="hljs-keyword">from</span> controlnet_aux.canny <span class="hljs-keyword">import</span> CannyDetector
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

canny_detector = CannyDetector()

image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png&quot;</span>)
image = canny_detector(image, detect_resolution=<span class="hljs-number">384</span>, image_resolution=<span class="hljs-number">1024</span>)`,wrap:!1}}),y=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExBZGFwdGVyUGlwZWxpbmUlMkMlMjBUMklBZGFwdGVyJTJDJTIwRXVsZXJBbmNlc3RyYWxEaXNjcmV0ZVNjaGVkdWxlciUyQyUyMEF1dG9lbmNvZGVyS0wlMEElMEFzY2hlZHVsZXIlMjAlM0QlMjBFdWxlckFuY2VzdHJhbERpc2NyZXRlU2NoZWR1bGVyLmZyb21fcHJldHJhaW5lZCglMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJzY2hlZHVsZXIlMjIpJTBBdmFlJTIwJTNEJTIwQXV0b2VuY29kZXJLTC5mcm9tX3ByZXRyYWluZWQoJTIybWFkZWJ5b2xsaW4lMkZzZHhsLXZhZS1mcDE2LWZpeCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFhZGFwdGVyJTIwJTNEJTIwVDJJQWRhcHRlci5mcm9tX3ByZXRyYWluZWQoJTIyVGVuY2VudEFSQyUyRnQyaS1hZGFwdGVyLWNhbm55LXNkeGwtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExBZGFwdGVyUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUwQSUyMCUyMCUyMCUyMGFkYXB0ZXIlM0RhZGFwdGVyJTJDJTBBJTIwJTIwJTIwJTIwdmFlJTNEdmFlJTJDJTBBJTIwJTIwJTIwJTIwc2NoZWR1bGVyJTNEc2NoZWR1bGVyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBJTIwJTIwJTIwJTIwdmFyaWFudCUzRCUyMmZwMTYlMjIlMkMlMEEpJTBBcGlwZWxpbmUudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLAdapterPipeline, T2IAdapter, EulerAncestralDiscreteScheduler, AutoencoderKL

scheduler = EulerAncestralDiscreteScheduler.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
vae = AutoencoderKL.from_pretrained(<span class="hljs-string">&quot;madebyollin/sdxl-vae-fp16-fix&quot;</span>, torch_dtype=torch.float16)
adapter = T2IAdapter.from_pretrained(<span class="hljs-string">&quot;TencentARC/t2i-adapter-canny-sdxl-1.0&quot;</span>, torch_dtype=torch.float16)
pipeline = StableDiffusionXLAdapterPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    adapter=adapter,
    vae=vae,
    scheduler=scheduler,
    torch_dtype=torch.float16,
    variant=<span class="hljs-string">&quot;fp16&quot;</span>,
)
pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),b=new X({props:{code:"Z2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKCUyMmN1ZGElMjIpLm1hbnVhbF9zZWVkKDApJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZSglMEElMjAlMjBwcm9tcHQlM0QlMjJjaW5lbWF0aWMlMjBwaG90byUyMG9mJTIwYSUyMHBsdXNoJTIwYW5kJTIwc29mdCUyMG1pZGNlbnR1cnklMjBzdHlsZSUyMHJ1ZyUyMG9uJTIwYSUyMHdvb2RlbiUyMGZsb29yJTJDJTIwMzVtbSUyMHBob3RvZ3JhcGglMkMlMjBmaWxtJTJDJTIwcHJvZmVzc2lvbmFsJTJDJTIwNGslMkMlMjBoaWdobHklMjBkZXRhaWxlZCUyMiUyQyUwQSUyMCUyMGltYWdlJTNEaW1hZ2UlMkMlMEElMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEEpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)

image = pipeline(
  prompt=<span class="hljs-string">&quot;cinematic photo of a plush and soft midcentury style rug on a wooden floor, 35mm photograph, film, professional, 4k, highly detailed&quot;</span>,
  image=image,
  generator=generator,
).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),{c(){n=f("p"),n.innerHTML=w,d=p(),g(c.$$.fragment),i=p(),m=f("p"),m.innerHTML=k,I=p(),g(y.$$.fragment),W=p(),J=f("p"),J.textContent=B,$=p(),g(b.$$.fragment),R=p(),M=f("div"),M.innerHTML=x,this.h()},l(t){n=u(t,"P",{"data-svelte-h":!0}),h(n)!=="svelte-afcj4j"&&(n.innerHTML=w),d=o(t),T(c.$$.fragment,t),i=o(t),m=u(t,"P",{"data-svelte-h":!0}),h(m)!=="svelte-7kic8a"&&(m.innerHTML=k),I=o(t),T(y.$$.fragment,t),W=o(t),J=u(t,"P",{"data-svelte-h":!0}),h(J)!=="svelte-1q7w192"&&(J.textContent=B),$=o(t),T(b.$$.fragment,t),R=o(t),M=u(t,"DIV",{class:!0,"data-svelte-h":!0}),h(M)!=="svelte-zs821h"&&(M.innerHTML=x),this.h()},h(){K(M,"class","flex justify-center")},m(t,r){a(t,n,r),a(t,d,r),Z(c,t,r),a(t,i,r),a(t,m,r),a(t,I,r),Z(y,t,r),a(t,W,r),a(t,J,r),a(t,$,r),Z(b,t,r),a(t,R,r),a(t,M,r),C=!0},p:he,i(t){C||(U(c.$$.fragment,t),U(y.$$.fragment,t),U(b.$$.fragment,t),C=!0)},o(t){j(c.$$.fragment,t),j(y.$$.fragment,t),j(b.$$.fragment,t),C=!1},d(t){t&&(l(n),l(d),l(i),l(m),l(I),l(W),l(J),l($),l(R),l(M)),G(c,t),G(y,t),G(b,t)}}}function Ne(v){let n,w,d,c;return n=new $e({props:{id:"stablediffusion",option:"Stable Diffusion 1.5",$$slots:{default:[Fe]},$$scope:{ctx:v}}}),d=new $e({props:{id:"stablediffusion",option:"Stable Diffusion XL",$$slots:{default:[Ye]},$$scope:{ctx:v}}}),{c(){g(n.$$.fragment),w=p(),g(d.$$.fragment)},l(i){T(n.$$.fragment,i),w=o(i),T(d.$$.fragment,i)},m(i,m){Z(n,i,m),a(i,w,m),Z(d,i,m),c=!0},p(i,m){const k={};m&2&&(k.$$scope={dirty:m,ctx:i}),n.$set(k);const I={};m&2&&(I.$$scope={dirty:m,ctx:i}),d.$set(I)},i(i){c||(U(n.$$.fragment,i),U(d.$$.fragment,i),c=!0)},o(i){j(n.$$.fragment,i),j(d.$$.fragment,i),c=!1},d(i){i&&l(w),G(n,i),G(d,i)}}}function Ee(v){let n,w,d,c,i,m,k,I=`<a href="https://hf.co/papers/2302.08453" rel="nofollow">T2I-Adapter</a> is a lightweight adapter for controlling and providing more accurate
structure guidance for text-to-image models. It works by learning an alignment between the internal knowledge of the
text-to-image model and an external control signal, such as edge detection or depth estimation.`,y,W,J=`The T2I-Adapter design is simple, the condition is passed to four feature extraction blocks and three downsample
blocks. This makes it fast and easy to train different adapters for different conditions which can be plugged into the
text-to-image model. T2I-Adapter is similar to <a href="controlnet">ControlNet</a> except it is smaller (~77M parameters) and
faster because it only runs once during the diffusion process. The downside is that performance may be slightly worse
than ControlNet.`,B,$,b=`This guide will show you how to use T2I-Adapter with different Stable Diffusion models and how you can compose multiple
T2I-Adapters to impose more than one condition.`,R,M,x,C,t="Before you begin, make sure you have the following libraries installed.",r,Y,ee,N,te,E,we=`Text-to-image models rely on a prompt to generate an image, but sometimes, text alone may not be enough to provide more
accurate structural guidance. T2I-Adapter allows you to provide an additional control image to guide the generation
process. For example, you can provide a canny image (a white outline of an image on a black background) to guide the
model to generate an image with a similar structure.`,le,V,ae,H,se,A,Je=`T2I-Adapters are also composable, allowing you to use more than one adapter to impose multiple control conditions on an
image. For example, you can use a pose map to provide structural control and a depth map for depth control. This is
enabled by the <code>MultiAdapter</code> class.`,ne,Q,be="Let’s condition a text-to-image model with a pose and depth adapter. Create and place your depth and pose image and in a list.",ie,S,pe,_,ge='<div><img class="rounded-xl" src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/t2i-adapter/depth_sample_input.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">depth image</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/t2i-adapter/keypose_sample_input.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">pose image</figcaption></div>',oe,L,Te="Load the corresponding pose and depth adapters as a list in the <code>MultiAdapter</code> class.",re,D,de,z,Ze=`Finally, load a <a href="/docs/diffusers/pr_10011/en/api/pipelines/stable_diffusion/adapter#diffusers.StableDiffusionAdapterPipeline">StableDiffusionAdapterPipeline</a> with the adapters, and pass your prompt and conditioned images to
it. Use the <code>adapter_conditioning_scale</code> to adjust the weight of each adapter on the image.`,me,q,ce,F,Ue='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/t2i-multi.png"/>',Me,P,fe,O,ue;return i=new ye({props:{title:"T2I-Adapter",local:"t2i-adapter",headingTag:"h1"}}),M=new xe({props:{warning:!1,$$slots:{default:[_e]},$$scope:{ctx:v}}}),Y=new X({props:{code:"JTIzJTIwdW5jb21tZW50JTIwdG8lMjBpbnN0YWxsJTIwdGhlJTIwbmVjZXNzYXJ5JTIwbGlicmFyaWVzJTIwaW4lMjBDb2xhYiUwQSUyMyFwaXAlMjBpbnN0YWxsJTIwLXElMjBkaWZmdXNlcnMlMjBhY2NlbGVyYXRlJTIwY29udHJvbG5ldC1hdXglM0QlM0QwLjAuNw==",highlighted:`<span class="hljs-comment"># uncomment to install the necessary libraries in Colab</span>
<span class="hljs-comment">#!pip install -q diffusers accelerate controlnet-aux==0.0.7</span>`,wrap:!1}}),N=new ye({props:{title:"Text-to-image",local:"text-to-image",headingTag:"h2"}}),V=new Ve({props:{id:"stablediffusion",options:["Stable Diffusion 1.5","Stable Diffusion XL"],$$slots:{default:[Ne]},$$scope:{ctx:v}}}),H=new ye({props:{title:"MultiAdapter",local:"multiadapter",headingTag:"h2"}}),S=new X({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEFwb3NlX2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMEElMjAlMjAlMjAlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZkaWZmdXNlcnMlMkZkb2NzLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGdDJpLWFkYXB0ZXIlMkZrZXlwb3NlX3NhbXBsZV9pbnB1dC5wbmclMjIlMEEpJTBBZGVwdGhfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUwQSUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmRpZmZ1c2VycyUyRmRvY3MtaW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZ0MmktYWRhcHRlciUyRmRlcHRoX3NhbXBsZV9pbnB1dC5wbmclMjIlMEEpJTBBY29uZCUyMCUzRCUyMCU1QnBvc2VfaW1hZ2UlMkMlMjBkZXB0aF9pbWFnZSU1RCUwQXByb21wdCUyMCUzRCUyMCU1QiUyMlNhbnRhJTIwQ2xhdXMlMjB3YWxraW5nJTIwaW50byUyMGFuJTIwb2ZmaWNlJTIwcm9vbSUyMHdpdGglMjBhJTIwYmVhdXRpZnVsJTIwY2l0eSUyMHZpZXclMjIlNUQ=",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pose_image = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/diffusers/docs-images/resolve/main/t2i-adapter/keypose_sample_input.png&quot;</span>
)
depth_image = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/diffusers/docs-images/resolve/main/t2i-adapter/depth_sample_input.png&quot;</span>
)
cond = [pose_image, depth_image]
prompt = [<span class="hljs-string">&quot;Santa Claus walking into an office room with a beautiful city view&quot;</span>]`,wrap:!1}}),D=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uQWRhcHRlclBpcGVsaW5lJTJDJTIwTXVsdGlBZGFwdGVyJTJDJTIwVDJJQWRhcHRlciUwQSUwQWFkYXB0ZXJzJTIwJTNEJTIwTXVsdGlBZGFwdGVyKCUwQSUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFQySUFkYXB0ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMlRlbmNlbnRBUkMlMkZ0MmlhZGFwdGVyX2tleXBvc2Vfc2QxNHYxJTIyKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFQySUFkYXB0ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMlRlbmNlbnRBUkMlMkZ0MmlhZGFwdGVyX2RlcHRoX3NkMTR2MSUyMiklMkMlMEElMjAlMjAlMjAlMjAlNUQlMEEpJTBBYWRhcHRlcnMlMjAlM0QlMjBhZGFwdGVycy50byh0b3JjaC5mbG9hdDE2KQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionAdapterPipeline, MultiAdapter, T2IAdapter

adapters = MultiAdapter(
    [
        T2IAdapter.from_pretrained(<span class="hljs-string">&quot;TencentARC/t2iadapter_keypose_sd14v1&quot;</span>),
        T2IAdapter.from_pretrained(<span class="hljs-string">&quot;TencentARC/t2iadapter_depth_sd14v1&quot;</span>),
    ]
)
adapters = adapters.to(torch.float16)`,wrap:!1}}),q=new X({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25BZGFwdGVyUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMEElMjAlMjAlMjAlMjBhZGFwdGVyJTNEYWRhcHRlcnMlMkMlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBjb25kJTJDJTIwYWRhcHRlcl9jb25kaXRpb25pbmdfc2NhbGUlM0QlNUIwLjclMkMlMjAwLjclNUQpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`pipeline = StableDiffusionAdapterPipeline.from_pretrained(
    <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>,
    torch_dtype=torch.float16,
    adapter=adapters,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipeline(prompt, cond, adapter_conditioning_scale=[<span class="hljs-number">0.7</span>, <span class="hljs-number">0.7</span>]).images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),P=new Xe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/t2i_adapter.md"}}),{c(){n=f("meta"),w=p(),d=f("p"),c=p(),g(i.$$.fragment),m=p(),k=f("p"),k.innerHTML=I,y=p(),W=f("p"),W.innerHTML=J,B=p(),$=f("p"),$.textContent=b,R=p(),g(M.$$.fragment),x=p(),C=f("p"),C.textContent=t,r=p(),g(Y.$$.fragment),ee=p(),g(N.$$.fragment),te=p(),E=f("p"),E.textContent=we,le=p(),g(V.$$.fragment),ae=p(),g(H.$$.fragment),se=p(),A=f("p"),A.innerHTML=Je,ne=p(),Q=f("p"),Q.textContent=be,ie=p(),g(S.$$.fragment),pe=p(),_=f("div"),_.innerHTML=ge,oe=p(),L=f("p"),L.innerHTML=Te,re=p(),g(D.$$.fragment),de=p(),z=f("p"),z.innerHTML=Ze,me=p(),g(q.$$.fragment),ce=p(),F=f("div"),F.innerHTML=Ue,Me=p(),g(P.$$.fragment),fe=p(),O=f("p"),this.h()},l(e){const s=ve("svelte-u9bgzb",document.head);n=u(s,"META",{name:!0,content:!0}),s.forEach(l),w=o(e),d=u(e,"P",{}),We(d).forEach(l),c=o(e),T(i.$$.fragment,e),m=o(e),k=u(e,"P",{"data-svelte-h":!0}),h(k)!=="svelte-1io8we0"&&(k.innerHTML=I),y=o(e),W=u(e,"P",{"data-svelte-h":!0}),h(W)!=="svelte-108wdn7"&&(W.innerHTML=J),B=o(e),$=u(e,"P",{"data-svelte-h":!0}),h($)!=="svelte-zp0yjh"&&($.textContent=b),R=o(e),T(M.$$.fragment,e),x=o(e),C=u(e,"P",{"data-svelte-h":!0}),h(C)!=="svelte-1l6eask"&&(C.textContent=t),r=o(e),T(Y.$$.fragment,e),ee=o(e),T(N.$$.fragment,e),te=o(e),E=u(e,"P",{"data-svelte-h":!0}),h(E)!=="svelte-eeblg5"&&(E.textContent=we),le=o(e),T(V.$$.fragment,e),ae=o(e),T(H.$$.fragment,e),se=o(e),A=u(e,"P",{"data-svelte-h":!0}),h(A)!=="svelte-1plb61a"&&(A.innerHTML=Je),ne=o(e),Q=u(e,"P",{"data-svelte-h":!0}),h(Q)!=="svelte-1vc3q28"&&(Q.textContent=be),ie=o(e),T(S.$$.fragment,e),pe=o(e),_=u(e,"DIV",{class:!0,"data-svelte-h":!0}),h(_)!=="svelte-15pp6ky"&&(_.innerHTML=ge),oe=o(e),L=u(e,"P",{"data-svelte-h":!0}),h(L)!=="svelte-1djmhwl"&&(L.innerHTML=Te),re=o(e),T(D.$$.fragment,e),de=o(e),z=u(e,"P",{"data-svelte-h":!0}),h(z)!=="svelte-1frvqs0"&&(z.innerHTML=Ze),me=o(e),T(q.$$.fragment,e),ce=o(e),F=u(e,"DIV",{class:!0,"data-svelte-h":!0}),h(F)!=="svelte-dw6ekt"&&(F.innerHTML=Ue),Me=o(e),T(P.$$.fragment,e),fe=o(e),O=u(e,"P",{}),We(O).forEach(l),this.h()},h(){K(n,"name","hf:doc:metadata"),K(n,"content",He),K(_,"class","flex gap-4"),K(F,"class","flex justify-center")},m(e,s){Be(document.head,n),a(e,w,s),a(e,d,s),a(e,c,s),Z(i,e,s),a(e,m,s),a(e,k,s),a(e,y,s),a(e,W,s),a(e,B,s),a(e,$,s),a(e,R,s),Z(M,e,s),a(e,x,s),a(e,C,s),a(e,r,s),Z(Y,e,s),a(e,ee,s),Z(N,e,s),a(e,te,s),a(e,E,s),a(e,le,s),Z(V,e,s),a(e,ae,s),Z(H,e,s),a(e,se,s),a(e,A,s),a(e,ne,s),a(e,Q,s),a(e,ie,s),Z(S,e,s),a(e,pe,s),a(e,_,s),a(e,oe,s),a(e,L,s),a(e,re,s),Z(D,e,s),a(e,de,s),a(e,z,s),a(e,me,s),Z(q,e,s),a(e,ce,s),a(e,F,s),a(e,Me,s),Z(P,e,s),a(e,fe,s),a(e,O,s),ue=!0},p(e,[s]){const je={};s&2&&(je.$$scope={dirty:s,ctx:e}),M.$set(je);const Ge={};s&2&&(Ge.$$scope={dirty:s,ctx:e}),V.$set(Ge)},i(e){ue||(U(i.$$.fragment,e),U(M.$$.fragment,e),U(Y.$$.fragment,e),U(N.$$.fragment,e),U(V.$$.fragment,e),U(H.$$.fragment,e),U(S.$$.fragment,e),U(D.$$.fragment,e),U(q.$$.fragment,e),U(P.$$.fragment,e),ue=!0)},o(e){j(i.$$.fragment,e),j(M.$$.fragment,e),j(Y.$$.fragment,e),j(N.$$.fragment,e),j(V.$$.fragment,e),j(H.$$.fragment,e),j(S.$$.fragment,e),j(D.$$.fragment,e),j(q.$$.fragment,e),j(P.$$.fragment,e),ue=!1},d(e){e&&(l(w),l(d),l(c),l(m),l(k),l(y),l(W),l(B),l($),l(R),l(x),l(C),l(r),l(ee),l(te),l(E),l(le),l(ae),l(se),l(A),l(ne),l(Q),l(ie),l(pe),l(_),l(oe),l(L),l(re),l(de),l(z),l(me),l(ce),l(F),l(Me),l(fe),l(O)),l(n),G(i,e),G(M,e),G(Y,e),G(N,e),G(V,e),G(H,e),G(S,e),G(D,e),G(q,e),G(P,e)}}}const He='{"title":"T2I-Adapter","local":"t2i-adapter","sections":[{"title":"Text-to-image","local":"text-to-image","sections":[],"depth":2},{"title":"MultiAdapter","local":"multiadapter","sections":[],"depth":2}],"depth":1}';function Ae(v){return ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pe extends Ie{constructor(n){super(),Re(this,n,Ae,Ee,Ce,{})}}export{Pe as component};
