import{s as We,o as $e,n as ue}from"../chunks/scheduler.182ea377.js";import{S as ke,i as Ie,g as f,s as p,r as U,A as Ce,h as u,f as l,c as o,j as je,u as j,x as h,k as P,y as Re,a,v as G,d as W,t as $,w as k}from"../chunks/index.abf12888.js";import{T as ve}from"../chunks/Tip.230e2334.js";import{C as V}from"../chunks/CodeBlock.57fe6e13.js";import{H as fe}from"../chunks/Heading.16916d63.js";import{H as Be,a as Ge}from"../chunks/HfOption.fc88c804.js";function xe(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:ue,d(d){d&&l(n)}}}function Ve(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,I=`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/main/en/api/pipelines/stable_diffusion/adapter#diffusers.StableDiffusionAdapterPipeline">StableDiffusionAdapterPipeline</a>.`,C,y,T,J,B="Finally, pass your prompt and control image to the pipeline.",g,b,R,M,x='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/t2i-sd1.5.png"/>',Z;return c=new V({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 V({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uQWRhcHRlclBpcGVsaW5lJTJDJTIwVDJJQWRhcHRlciUwQSUwQWFkYXB0ZXIlMjAlM0QlMjBUMklBZGFwdGVyLmZyb21fcHJldHJhaW5lZCglMjJUZW5jZW50QVJDJTJGdDJpYWRhcHRlcl9jYW5ueV9zZDE1djIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25BZGFwdGVyUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTBBJTIwJTIwJTIwJTIwYWRhcHRlciUzRGFkYXB0ZXIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMEEpJTBBcGlwZWxpbmUudG8oJTIyY3VkYSUyMik=",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;runwayml/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 V({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(),U(c.$$.fragment),i=p(),m=f("p"),m.innerHTML=I,C=p(),U(y.$$.fragment),T=p(),J=f("p"),J.textContent=B,g=p(),U(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),j(c.$$.fragment,t),i=o(t),m=u(t,"P",{"data-svelte-h":!0}),h(m)!=="svelte-15z37by"&&(m.innerHTML=I),C=o(t),j(y.$$.fragment,t),T=o(t),J=u(t,"P",{"data-svelte-h":!0}),h(J)!=="svelte-1q7w192"&&(J.textContent=B),g=o(t),j(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(){P(M,"class","flex justify-center")},m(t,r){a(t,n,r),a(t,d,r),G(c,t,r),a(t,i,r),a(t,m,r),a(t,C,r),G(y,t,r),a(t,T,r),a(t,J,r),a(t,g,r),G(b,t,r),a(t,R,r),a(t,M,r),Z=!0},p:ue,i(t){Z||(W(c.$$.fragment,t),W(y.$$.fragment,t),W(b.$$.fragment,t),Z=!0)},o(t){$(c.$$.fragment,t),$(y.$$.fragment,t),$(b.$$.fragment,t),Z=!1},d(t){t&&(l(n),l(d),l(i),l(m),l(C),l(T),l(J),l(g),l(R),l(M)),k(c,t),k(y,t),k(b,t)}}}function Xe(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,I=`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/main/en/api/pipelines/stable_diffusion/adapter#diffusers.StableDiffusionXLAdapterPipeline">StableDiffusionXLAdapterPipeline</a>.`,C,y,T,J,B="Finally, pass your prompt and control image to the pipeline.",g,b,R,M,x='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/t2i-sdxl.png"/>',Z;return c=new V({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 V({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 V({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(),U(c.$$.fragment),i=p(),m=f("p"),m.innerHTML=I,C=p(),U(y.$$.fragment),T=p(),J=f("p"),J.textContent=B,g=p(),U(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),j(c.$$.fragment,t),i=o(t),m=u(t,"P",{"data-svelte-h":!0}),h(m)!=="svelte-33gv07"&&(m.innerHTML=I),C=o(t),j(y.$$.fragment,t),T=o(t),J=u(t,"P",{"data-svelte-h":!0}),h(J)!=="svelte-1q7w192"&&(J.textContent=B),g=o(t),j(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(){P(M,"class","flex justify-center")},m(t,r){a(t,n,r),a(t,d,r),G(c,t,r),a(t,i,r),a(t,m,r),a(t,C,r),G(y,t,r),a(t,T,r),a(t,J,r),a(t,g,r),G(b,t,r),a(t,R,r),a(t,M,r),Z=!0},p:ue,i(t){Z||(W(c.$$.fragment,t),W(y.$$.fragment,t),W(b.$$.fragment,t),Z=!0)},o(t){$(c.$$.fragment,t),$(y.$$.fragment,t),$(b.$$.fragment,t),Z=!1},d(t){t&&(l(n),l(d),l(i),l(m),l(C),l(T),l(J),l(g),l(R),l(M)),k(c,t),k(y,t),k(b,t)}}}function Fe(v){let n,w,d,c;return n=new Ge({props:{id:"stablediffusion",option:"Stable Diffusion 1.5",$$slots:{default:[Ve]},$$scope:{ctx:v}}}),d=new Ge({props:{id:"stablediffusion",option:"Stable Diffusion XL",$$slots:{default:[Xe]},$$scope:{ctx:v}}}),{c(){U(n.$$.fragment),w=p(),U(d.$$.fragment)},l(i){j(n.$$.fragment,i),w=o(i),j(d.$$.fragment,i)},m(i,m){G(n,i,m),a(i,w,m),G(d,i,m),c=!0},p(i,m){const I={};m&2&&(I.$$scope={dirty:m,ctx:i}),n.$set(I);const C={};m&2&&(C.$$scope={dirty:m,ctx:i}),d.$set(C)},i(i){c||(W(n.$$.fragment,i),W(d.$$.fragment,i),c=!0)},o(i){$(n.$$.fragment,i),$(d.$$.fragment,i),c=!1},d(i){i&&l(w),k(n,i),k(d,i)}}}function _e(v){let n,w,d,c,i,m,I,C=`<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,T,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,g,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,Z,t="Before you begin, make sure you have the following libraries installed.",r,Y,O,E,ee,A,ye=`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.`,te,X,le,H,ae,N,he=`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.`,se,Q,we="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.",ne,S,ie,F,Je='<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>',pe,L,be="Load the corresponding pose and depth adapters as a list in the <code>MultiAdapter</code> class.",oe,z,re,D,Te=`Finally, load a <a href="/docs/diffusers/main/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.`,de,q,me,_,ge='<img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/t2i-multi.png"/>',ce,K,Me;return i=new fe({props:{title:"T2I-Adapter",local:"t2i-adapter",headingTag:"h1"}}),M=new ve({props:{warning:!1,$$slots:{default:[xe]},$$scope:{ctx:v}}}),Y=new V({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}}),E=new fe({props:{title:"Text-to-image",local:"text-to-image",headingTag:"h2"}}),X=new Be({props:{id:"stablediffusion",options:["Stable Diffusion 1.5","Stable Diffusion XL"],$$slots:{default:[Fe]},$$scope:{ctx:v}}}),H=new fe({props:{title:"MultiAdapter",local:"multiadapter",headingTag:"h2"}}),S=new V({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}}),z=new V({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 V({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}}),{c(){n=f("meta"),w=p(),d=f("p"),c=p(),U(i.$$.fragment),m=p(),I=f("p"),I.innerHTML=C,y=p(),T=f("p"),T.innerHTML=J,B=p(),g=f("p"),g.textContent=b,R=p(),U(M.$$.fragment),x=p(),Z=f("p"),Z.textContent=t,r=p(),U(Y.$$.fragment),O=p(),U(E.$$.fragment),ee=p(),A=f("p"),A.textContent=ye,te=p(),U(X.$$.fragment),le=p(),U(H.$$.fragment),ae=p(),N=f("p"),N.innerHTML=he,se=p(),Q=f("p"),Q.textContent=we,ne=p(),U(S.$$.fragment),ie=p(),F=f("div"),F.innerHTML=Je,pe=p(),L=f("p"),L.innerHTML=be,oe=p(),U(z.$$.fragment),re=p(),D=f("p"),D.innerHTML=Te,de=p(),U(q.$$.fragment),me=p(),_=f("div"),_.innerHTML=ge,ce=p(),K=f("p"),this.h()},l(e){const s=Ce("svelte-u9bgzb",document.head);n=u(s,"META",{name:!0,content:!0}),s.forEach(l),w=o(e),d=u(e,"P",{}),je(d).forEach(l),c=o(e),j(i.$$.fragment,e),m=o(e),I=u(e,"P",{"data-svelte-h":!0}),h(I)!=="svelte-1io8we0"&&(I.innerHTML=C),y=o(e),T=u(e,"P",{"data-svelte-h":!0}),h(T)!=="svelte-108wdn7"&&(T.innerHTML=J),B=o(e),g=u(e,"P",{"data-svelte-h":!0}),h(g)!=="svelte-zp0yjh"&&(g.textContent=b),R=o(e),j(M.$$.fragment,e),x=o(e),Z=u(e,"P",{"data-svelte-h":!0}),h(Z)!=="svelte-1l6eask"&&(Z.textContent=t),r=o(e),j(Y.$$.fragment,e),O=o(e),j(E.$$.fragment,e),ee=o(e),A=u(e,"P",{"data-svelte-h":!0}),h(A)!=="svelte-eeblg5"&&(A.textContent=ye),te=o(e),j(X.$$.fragment,e),le=o(e),j(H.$$.fragment,e),ae=o(e),N=u(e,"P",{"data-svelte-h":!0}),h(N)!=="svelte-1plb61a"&&(N.innerHTML=he),se=o(e),Q=u(e,"P",{"data-svelte-h":!0}),h(Q)!=="svelte-1vc3q28"&&(Q.textContent=we),ne=o(e),j(S.$$.fragment,e),ie=o(e),F=u(e,"DIV",{class:!0,"data-svelte-h":!0}),h(F)!=="svelte-15pp6ky"&&(F.innerHTML=Je),pe=o(e),L=u(e,"P",{"data-svelte-h":!0}),h(L)!=="svelte-1djmhwl"&&(L.innerHTML=be),oe=o(e),j(z.$$.fragment,e),re=o(e),D=u(e,"P",{"data-svelte-h":!0}),h(D)!=="svelte-xn9hn1"&&(D.innerHTML=Te),de=o(e),j(q.$$.fragment,e),me=o(e),_=u(e,"DIV",{class:!0,"data-svelte-h":!0}),h(_)!=="svelte-dw6ekt"&&(_.innerHTML=ge),ce=o(e),K=u(e,"P",{}),je(K).forEach(l),this.h()},h(){P(n,"name","hf:doc:metadata"),P(n,"content",Ye),P(F,"class","flex gap-4"),P(_,"class","flex justify-center")},m(e,s){Re(document.head,n),a(e,w,s),a(e,d,s),a(e,c,s),G(i,e,s),a(e,m,s),a(e,I,s),a(e,y,s),a(e,T,s),a(e,B,s),a(e,g,s),a(e,R,s),G(M,e,s),a(e,x,s),a(e,Z,s),a(e,r,s),G(Y,e,s),a(e,O,s),G(E,e,s),a(e,ee,s),a(e,A,s),a(e,te,s),G(X,e,s),a(e,le,s),G(H,e,s),a(e,ae,s),a(e,N,s),a(e,se,s),a(e,Q,s),a(e,ne,s),G(S,e,s),a(e,ie,s),a(e,F,s),a(e,pe,s),a(e,L,s),a(e,oe,s),G(z,e,s),a(e,re,s),a(e,D,s),a(e,de,s),G(q,e,s),a(e,me,s),a(e,_,s),a(e,ce,s),a(e,K,s),Me=!0},p(e,[s]){const Ze={};s&2&&(Ze.$$scope={dirty:s,ctx:e}),M.$set(Ze);const Ue={};s&2&&(Ue.$$scope={dirty:s,ctx:e}),X.$set(Ue)},i(e){Me||(W(i.$$.fragment,e),W(M.$$.fragment,e),W(Y.$$.fragment,e),W(E.$$.fragment,e),W(X.$$.fragment,e),W(H.$$.fragment,e),W(S.$$.fragment,e),W(z.$$.fragment,e),W(q.$$.fragment,e),Me=!0)},o(e){$(i.$$.fragment,e),$(M.$$.fragment,e),$(Y.$$.fragment,e),$(E.$$.fragment,e),$(X.$$.fragment,e),$(H.$$.fragment,e),$(S.$$.fragment,e),$(z.$$.fragment,e),$(q.$$.fragment,e),Me=!1},d(e){e&&(l(w),l(d),l(c),l(m),l(I),l(y),l(T),l(B),l(g),l(R),l(x),l(Z),l(r),l(O),l(ee),l(A),l(te),l(le),l(ae),l(N),l(se),l(Q),l(ne),l(ie),l(F),l(pe),l(L),l(oe),l(re),l(D),l(de),l(me),l(_),l(ce),l(K)),l(n),k(i,e),k(M,e),k(Y,e),k(E,e),k(X,e),k(H,e),k(S,e),k(z,e),k(q,e)}}}const Ye='{"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 Ee(v){return $e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ze extends ke{constructor(n){super(),Ie(this,n,Ee,_e,We,{})}}export{ze as component};
