import{s as Te,o as we,n as re}from"../chunks/scheduler.8c3d61f6.js";import{S as fe,i as Ue,g as b,s as c,r as j,A as je,h as T,f as t,c as M,j as be,u as Z,x as f,k as oe,l as w,y as Ze,a,v as C,d as W,t as I,w as G}from"../chunks/index.da70eac4.js";import{C as N}from"../chunks/CodeBlock.a9c4becf.js";import{H as pe,E as Ce}from"../chunks/getInferenceSnippets.cb466318.js";import{H as We,a as me}from"../chunks/HfOption.6c3b4e77.js";function Ie(v){let i,U='Generate a canny image with <a href="https://github.com/opencv/opencv-python" rel="nofollow">opencv-python</a>.',J,m,d,r,n="Pass the canny image to the pipeline. Use the <code>controlnet_conditioning_scale</code> parameter to determine how much weight to assign to the control.",u,y,h,o,B='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/non-enhanced-prompt.png" width="300" alt="Generated image (prompt only)"/> <figcaption style="text-align: center;">original image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/canny-cat.png" width="300" alt="Control image (Canny edges)"/> <figcaption style="text-align: center;">canny image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/canny-cat-generated.png" width="300" alt="Generated image (ControlNet + prompt)"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',g;return m=new N({props:{code:"aW1wb3J0JTIwY3YyJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEFvcmlnaW5hbF9pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTBBJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGbm9uLWVuaGFuY2VkLXByb21wdC5wbmclMjIlMEEpJTBBJTBBaW1hZ2UlMjAlM0QlMjBucC5hcnJheShvcmlnaW5hbF9pbWFnZSklMEElMEFsb3dfdGhyZXNob2xkJTIwJTNEJTIwMTAwJTBBaGlnaF90aHJlc2hvbGQlMjAlM0QlMjAyMDAlMEElMEFpbWFnZSUyMCUzRCUyMGN2Mi5DYW5ueShpbWFnZSUyQyUyMGxvd190aHJlc2hvbGQlMkMlMjBoaWdoX3RocmVzaG9sZCklMEFpbWFnZSUyMCUzRCUyMGltYWdlJTVCJTNBJTJDJTIwJTNBJTJDJTIwTm9uZSU1RCUwQWltYWdlJTIwJTNEJTIwbnAuY29uY2F0ZW5hdGUoJTVCaW1hZ2UlMkMlMjBpbWFnZSUyQyUyMGltYWdlJTVEJTJDJTIwYXhpcyUzRDIpJTBBY2FubnlfaW1hZ2UlMjAlM0QlMjBJbWFnZS5mcm9tYXJyYXkoaW1hZ2Up",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

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

image = np.array(original_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[:, :, <span class="hljs-literal">None</span>]
image = np.concatenate([image, image, image], axis=<span class="hljs-number">2</span>)
canny_image = Image.fromarray(image)`,wrap:!1}}),y=new N({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQWZyb20lMjBkaWZ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UwQSUyMCUyMCUyMCUyMGNvbnRyb2xuZXRfY29uZGl0aW9uaW5nX3NjYWxlJTNEMC41JTJDJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwJTJDJTIwJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0QzLjUlMkMlMEEpLmltYWdlcyU1QjAlNUQ=",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> FluxControlNetPipeline, FluxControlNetModel

controlnet = FluxControlNetModel.from_pretrained(
    <span class="hljs-string">&quot;InstantX/FLUX.1-dev-Controlnet-Canny&quot;</span>, torch_dtype=torch.bfloat16
)
pipeline = FluxControlNetPipeline.from_pretrained(
    <span class="hljs-string">&quot;black-forest-labs/FLUX.1-dev&quot;</span>, controlnet=controlnet, torch_dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;&quot;&quot;
A photorealistic overhead image of a cat reclining sideways in a flamingo pool floatie holding a margarita. 
The cat is floating leisurely in the pool and completely relaxed and happy.
&quot;&quot;&quot;</span>

pipeline(
    prompt, 
    control_image=canny_image,
    controlnet_conditioning_scale=<span class="hljs-number">0.5</span>,
    num_inference_steps=<span class="hljs-number">50</span>, 
    guidance_scale=<span class="hljs-number">3.5</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){i=b("p"),i.innerHTML=U,J=c(),j(m.$$.fragment),d=c(),r=b("p"),r.innerHTML=n,u=c(),j(y.$$.fragment),h=c(),o=b("div"),o.innerHTML=B,this.h()},l(l){i=T(l,"P",{"data-svelte-h":!0}),f(i)!=="svelte-odtmr5"&&(i.innerHTML=U),J=M(l),Z(m.$$.fragment,l),d=M(l),r=T(l,"P",{"data-svelte-h":!0}),f(r)!=="svelte-zjofbt"&&(r.innerHTML=n),u=M(l),Z(y.$$.fragment,l),h=M(l),o=T(l,"DIV",{style:!0,"data-svelte-h":!0}),f(o)!=="svelte-y2w2wd"&&(o.innerHTML=B),this.h()},h(){w(o,"display","flex"),w(o,"gap","10px"),w(o,"justify-content","space-around"),w(o,"align-items","flex-end")},m(l,p){a(l,i,p),a(l,J,p),C(m,l,p),a(l,d,p),a(l,r,p),a(l,u,p),C(y,l,p),a(l,h,p),a(l,o,p),g=!0},p:re,i(l){g||(W(m.$$.fragment,l),W(y.$$.fragment,l),g=!0)},o(l){I(m.$$.fragment,l),I(y.$$.fragment,l),g=!1},d(l){l&&(t(i),t(J),t(d),t(r),t(u),t(h),t(o)),G(m,l),G(y,l)}}}function Ge(v){let i,U="Generate a depth map with a depth estimation pipeline from Transformers.",J,m,d,r,n="Pass the depth map to the pipeline. Use the <code>controlnet_conditioning_scale</code> parameter to determine how much weight to assign to the control.",u,y,h,o,B='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/non-enhanced-prompt.png" width="300" alt="Generated image (prompt only)"/> <figcaption style="text-align: center;">original image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl_depth_image.png" width="300" alt="Control image (Canny edges)"/> <figcaption style="text-align: center;">depth map</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl_depth_cat.png" width="300" alt="Generated image (ControlNet + prompt)"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',g;return m=new N({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwRFBUSW1hZ2VQcm9jZXNzb3IlMkMlMjBEUFRGb3JEZXB0aEVzdGltYXRpb24lMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0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FwKGltYWdlKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<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> transformers <span class="hljs-keyword">import</span> DPTImageProcessor, DPTForDepthEstimation
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ControlNetModel, StableDiffusionXLControlNetImg2ImgPipeline, AutoencoderKL
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image


depth_estimator = DPTForDepthEstimation.from_pretrained(<span class="hljs-string">&quot;Intel/dpt-hybrid-midas&quot;</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
feature_extractor = DPTImageProcessor.from_pretrained(<span class="hljs-string">&quot;Intel/dpt-hybrid-midas&quot;</span>)

<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_depth_map</span>(<span class="hljs-params">image</span>):
    image = feature_extractor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values.to(<span class="hljs-string">&quot;cuda&quot;</span>)
    <span class="hljs-keyword">with</span> torch.no_grad(), torch.autocast(<span class="hljs-string">&quot;cuda&quot;</span>):
        depth_map = depth_estimator(image).predicted_depth

    depth_map = torch.nn.functional.interpolate(
        depth_map.unsqueeze(<span class="hljs-number">1</span>),
        size=(<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>),
        mode=<span class="hljs-string">&quot;bicubic&quot;</span>,
        align_corners=<span class="hljs-literal">False</span>,
    )
    depth_min = torch.amin(depth_map, dim=[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], keepdim=<span class="hljs-literal">True</span>)
    depth_max = torch.amax(depth_map, dim=[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], keepdim=<span class="hljs-literal">True</span>)
    depth_map = (depth_map - depth_min) / (depth_max - depth_min)
    image = torch.cat([depth_map] * <span class="hljs-number">3</span>, dim=<span class="hljs-number">1</span>)
    image = image.permute(<span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>).cpu().numpy()[<span class="hljs-number">0</span>]
    image = Image.fromarray((image * <span class="hljs-number">255.0</span>).clip(<span class="hljs-number">0</span>, <span class="hljs-number">255</span>).astype(np.uint8))
    <span class="hljs-keyword">return</span> image

depth_image = get_depth_map(image)`,wrap:!1}}),y=new N({props:{code:"Y29udHJvbG5ldCUyMCUzRCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZGlmZnVzZXJzJTJGY29udHJvbG5ldC1kZXB0aC1zZHhsLTEuMC1zbWFsbCUyMiUyQyUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUwQSklMEF2YWUlMjAlM0QlMjBBdXRvZW5jb2RlcktMLmZyb21fcHJldHJhaW5lZCglMjJtYWRlYnlvbGxpbiUyRnNkeGwtdmFlLWZwMTYtZml4JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExDb250cm9sTmV0SW1nMkltZ1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMEElMjAlMjAlMjAlMjBjb250cm9sbmV0JTNEY29udHJvbG5ldCUyQyUwQSUyMCUyMCUyMCUyMHZhZSUzRHZhZSUyQyUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjIlMjIlMjIlMEFBJTIwcGhvd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1RA==",highlighted:`controlnet = ControlNetModel.from_pretrained(
    <span class="hljs-string">&quot;diffusers/controlnet-depth-sdxl-1.0-small&quot;</span>,
    torch_dtype=torch.float16,
)
vae = AutoencoderKL.from_pretrained(<span class="hljs-string">&quot;madebyollin/sdxl-vae-fp16-fix&quot;</span>, torch_dtype=torch.float16)
pipeline = StableDiffusionXLControlNetImg2ImgPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    controlnet=controlnet,
    vae=vae,
    torch_dtype=torch.float16,
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;&quot;&quot;
A photorealistic overhead image of a cat reclining sideways in a flamingo pool floatie holding a margarita. 
The cat is floating leisurely in the pool and completely relaxed and happy.
&quot;&quot;&quot;</span>
image = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/non-enhanced-prompt.png&quot;</span>
).resize((<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>))
controlnet_conditioning_scale = <span class="hljs-number">0.5</span> 
pipeline(
    prompt,
    image=image,
    control_image=depth_image,
    controlnet_conditioning_scale=controlnet_conditioning_scale,
    strength=<span class="hljs-number">0.99</span>,
    num_inference_steps=<span class="hljs-number">100</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){i=b("p"),i.textContent=U,J=c(),j(m.$$.fragment),d=c(),r=b("p"),r.innerHTML=n,u=c(),j(y.$$.fragment),h=c(),o=b("div"),o.innerHTML=B,this.h()},l(l){i=T(l,"P",{"data-svelte-h":!0}),f(i)!=="svelte-1gx6o1u"&&(i.textContent=U),J=M(l),Z(m.$$.fragment,l),d=M(l),r=T(l,"P",{"data-svelte-h":!0}),f(r)!=="svelte-19jdy5i"&&(r.innerHTML=n),u=M(l),Z(y.$$.fragment,l),h=M(l),o=T(l,"DIV",{style:!0,"data-svelte-h":!0}),f(o)!=="svelte-1ac87db"&&(o.innerHTML=B),this.h()},h(){w(o,"display","flex"),w(o,"gap","10px"),w(o,"justify-content","space-around"),w(o,"align-items","flex-end")},m(l,p){a(l,i,p),a(l,J,p),C(m,l,p),a(l,d,p),a(l,r,p),a(l,u,p),C(y,l,p),a(l,h,p),a(l,o,p),g=!0},p:re,i(l){g||(W(m.$$.fragment,l),W(y.$$.fragment,l),g=!0)},o(l){I(m.$$.fragment,l),I(y.$$.fragment,l),g=!1},d(l){l&&(t(i),t(J),t(d),t(r),t(u),t(h),t(o)),G(m,l),G(y,l)}}}function Be(v){let i,U="Generate a mask image and convert it to a tensor to mark the pixels in the original image as masked if the corresponding pixel in the mask image is over a certain threshold.",J,m,d,r,n="Pass the mask and control image to the pipeline. Use the <code>controlnet_conditioning_scale</code> parameter to determine how much weight to assign to the control.",u,y,h,o,B='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/non-enhanced-prompt.png" width="300" alt="Generated image (prompt only)"/> <figcaption style="text-align: center;">original image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat_mask.png" width="300" alt="Control image (Canny edges)"/> <figcaption style="text-align: center;">mask image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl_rabbit_inpaint.png" width="300" alt="Generated image (ControlNet + prompt)"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',g;return m=new N({props:{code:"aW1wb3J0JTIwY3YyJTBBaW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBTdGFibGVEaWZmdXNpb25YTENvbnRyb2xOZXRJbnBhaW50UGlwZWxpbmUlMkMlMjBDb250cm9sTmV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vbF9pbWFnZSUyMCUzRCUyMG1ha2VfY2FubnlfY29uZGl0aW9uKGluaXRfaW1hZ2Up",highlighted:`<span class="hljs-keyword">import</span> cv2
<span class="hljs-keyword">import</span> torch
<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
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLControlNetInpaintPipeline, ControlNetModel

init_image = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/non-enhanced-prompt.png&quot;</span>
)
init_image = init_image.resize((<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>))
mask_image = load_image(
    <span class="hljs-string">&quot;/content/cat_mask.png&quot;</span>
)
mask_image = mask_image.resize((<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>))

<span class="hljs-keyword">def</span> <span class="hljs-title function_">make_canny_condition</span>(<span class="hljs-params">image</span>):
    image = np.array(image)
    image = cv2.Canny(image, <span class="hljs-number">100</span>, <span class="hljs-number">200</span>)
    image = image[:, :, <span class="hljs-literal">None</span>]
    image = np.concatenate([image, image, image], axis=<span class="hljs-number">2</span>)
    image = Image.fromarray(image)
    <span class="hljs-keyword">return</span> image

control_image = make_canny_condition(init_image)`,wrap:!1}}),y=new N({props:{code:"Y29udHJvbG5ldCUyMCUzRCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZGlmZnVzZXJzJTJGY29udHJvbG5ldC1jYW5ueS1zZHhsLTEuMCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblhMQ29udHJvbE5ldElucGFpbnRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwY29udHJvbG5ldCUzRGNvbnRyb2xuZXQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpJTBBcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwJTIyYSUyMGN1dGUlMjBhbmQlMjBmbHVmZnklMjBidW5ueSUyMHJhYmJpdCUyMiUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QxMDAlMkMlMEElMjAlMjAlMjAlMjBzdHJlbmd0aCUzRDAuOTklMkMlMEElMjAlMjAlMjAlMjBjb250cm9sbmV0X2NvbmRpdGlvbmluZ19zY2FsZSUzRDAuNSUyQyUwQSUyMCUyMCUyMCUyMGltYWdlJTNEaW5pdF9pbWFnZSUyQyUwQSUyMCUyMCUyMCUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlJTJDJTBBJTIwJTIwJTIwJTIwY29udHJvbF9pbWFnZSUzRGNvbnRyb2xfaW1hZ2UlMkMlMEEpLmltYWdlcyU1QjAlNUQ=",highlighted:`controlnet = ControlNetModel.from_pretrained(
    <span class="hljs-string">&quot;diffusers/controlnet-canny-sdxl-1.0&quot;</span>, torch_dtype=torch.float16
)
pipeline = StableDiffusionXLControlNetInpaintPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, controlnet=controlnet, torch_dtype=torch.float16
)
pipeline(
    <span class="hljs-string">&quot;a cute and fluffy bunny rabbit&quot;</span>,
    num_inference_steps=<span class="hljs-number">100</span>,
    strength=<span class="hljs-number">0.99</span>,
    controlnet_conditioning_scale=<span class="hljs-number">0.5</span>,
    image=init_image,
    mask_image=mask_image,
    control_image=control_image,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){i=b("p"),i.textContent=U,J=c(),j(m.$$.fragment),d=c(),r=b("p"),r.innerHTML=n,u=c(),j(y.$$.fragment),h=c(),o=b("div"),o.innerHTML=B,this.h()},l(l){i=T(l,"P",{"data-svelte-h":!0}),f(i)!=="svelte-1y2qw8o"&&(i.textContent=U),J=M(l),Z(m.$$.fragment,l),d=M(l),r=T(l,"P",{"data-svelte-h":!0}),f(r)!=="svelte-24u084"&&(r.innerHTML=n),u=M(l),Z(y.$$.fragment,l),h=M(l),o=T(l,"DIV",{style:!0,"data-svelte-h":!0}),f(o)!=="svelte-ggobk5"&&(o.innerHTML=B),this.h()},h(){w(o,"display","flex"),w(o,"gap","10px"),w(o,"justify-content","space-around"),w(o,"align-items","flex-end")},m(l,p){a(l,i,p),a(l,J,p),C(m,l,p),a(l,d,p),a(l,r,p),a(l,u,p),C(y,l,p),a(l,h,p),a(l,o,p),g=!0},p:re,i(l){g||(W(m.$$.fragment,l),W(y.$$.fragment,l),g=!0)},o(l){I(m.$$.fragment,l),I(y.$$.fragment,l),g=!1},d(l){l&&(t(i),t(J),t(d),t(r),t(u),t(h),t(o)),G(m,l),G(y,l)}}}function Re(v){let i,U,J,m,d,r;return i=new me({props:{id:"usage",option:"text-to-image",$$slots:{default:[Ie]},$$scope:{ctx:v}}}),J=new me({props:{id:"usage",option:"image-to-image",$$slots:{default:[Ge]},$$scope:{ctx:v}}}),d=new me({props:{id:"usage",option:"inpainting",$$slots:{default:[Be]},$$scope:{ctx:v}}}),{c(){j(i.$$.fragment),U=c(),j(J.$$.fragment),m=c(),j(d.$$.fragment)},l(n){Z(i.$$.fragment,n),U=M(n),Z(J.$$.fragment,n),m=M(n),Z(d.$$.fragment,n)},m(n,u){C(i,n,u),a(n,U,u),C(J,n,u),a(n,m,u),C(d,n,u),r=!0},p(n,u){const y={};u&2&&(y.$$scope={dirty:u,ctx:n}),i.$set(y);const h={};u&2&&(h.$$scope={dirty:u,ctx:n}),J.$set(h);const o={};u&2&&(o.$$scope={dirty:u,ctx:n}),d.$set(o)},i(n){r||(W(i.$$.fragment,n),W(J.$$.fragment,n),W(d.$$.fragment,n),r=!0)},o(n){I(i.$$.fragment,n),I(J.$$.fragment,n),I(d.$$.fragment,n),r=!1},d(n){n&&(t(U),t(m)),G(i,n),G(J,n),G(d,n)}}}function ke(v){let i,U,J,m,d,r,n,u='<a href="https://huggingface.co/papers/2302.05543" rel="nofollow">ControlNet</a> is an adapter that enables controllable generation such as generating an image of a cat in a <em>specific pose</em> or following the lines in a sketch of a <em>specific</em> cat. It works by adding a smaller network of “zero convolution” layers and progressively training these to avoid disrupting with the original model. The original model parameters are frozen to avoid retraining it.',y,h,o="A ControlNet is conditioned on extra visual information or “structural controls” (canny edge, depth maps, human pose, etc.) that can be combined with text prompts to generate images that are guided by the visual input.",B,g,l='<p>ControlNets are available to many models such as <a href="../api/pipelines/controlnet_flux">Flux</a>, <a href="../api/pipelines/controlnet_hunyuandit">Hunyuan-DiT</a>, <a href="../api/pipelines/controlnet_sd3">Stable Diffusion 3</a>, and more. The examples in this guide use Flux and Stable Diffusion XL.</p>',p,Y,ce='Load a ControlNet conditioned on a specific control, such as canny edge, and pass it to the pipeline in <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained">from_pretrained()</a>.',z,X,D,_,L,Q,Me="You can compose multiple ControlNet conditionings, such as canny image and a depth map, to create a <em>MultiControlNet</em>. For the best rersults, you should mask conditionings so they don’t overlap and experiment with different <code>controlnet_conditioning_scale</code> parameters to adjust how much weight is assigned to each control input.",q,x,de="The example below composes a canny image and depth map.",K,E,ye="Pass the ControlNets as a list to the pipeline and resize the images to the expected input size.",P,F,O,R,ue='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/canny-cat.png" width="300" alt="Generated image (prompt only)"/> <figcaption style="text-align: center;">canny image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/multicontrolnet_depth.png" width="300" alt="Control image (Canny edges)"/> <figcaption style="text-align: center;">depth map</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl_multi_controlnet.png" width="300" alt="Generated image (ControlNet + prompt)"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',ee,V,le,S,Je='<a href="https://github.com/lllyasviel/ControlNet/discussions/188" rel="nofollow">Guess mode</a> generates an image from <strong>only</strong> the control input (canny edge, depth map, pose, etc.) and without guidance from a prompt. It adjusts the scale of the ControlNet’s output residuals by a fixed ratio depending on block depth. The earlier <code>DownBlock</code> is only scaled by <code>0.1</code> and the <code>MidBlock</code> is fully scaled by <code>1.0</code>.',te,H,ae,k,he='<figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/canny-cat.png" width="300" alt="Control image (Canny edges)"/> <figcaption style="text-align: center;">canny image</figcaption></figure> <figure><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guess_mode.png" width="300" alt="Generated image (Guess mode)"/> <figcaption style="text-align: center;">generated image</figcaption></figure>',ne,$,se,A,ie;return d=new pe({props:{title:"ControlNet",local:"controlnet",headingTag:"h1"}}),X=new We({props:{id:"usage",options:["text-to-image","image-to-image","inpainting"],$$slots:{default:[Re]},$$scope:{ctx:v}}}),_=new pe({props:{title:"Multi-ControlNet",local:"multi-controlnet",headingTag:"h2"}}),F=new N({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uWExDb250cm9sTmV0UGlwZWxpbmUlMkMlMjBDb250cm9sTmV0TW9kZWwlMkMlMjBBdXRvZW5jb2RlcktMJTBBJTBBY29udHJvbG5ldHMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjBDb250cm9sTmV0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmRpZmZ1c2VycyUyRmNvbnRyb2xuZ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vbiUyMHNjZW5lJTJDJTIwMzVtbSUyMHBob3RvZ3JhcGglMkMlMjBmaWxtJTJDJTIwcHJvZmVzc2lvbmFsJTJDJTIwNGslMkMlMjBoaWdobHklMjBkZXRhaWxlZCUwQSUyMiUyMiUyMiUwQW5lZ2F0aXZlX3Byb21wdCUyMCUzRCUyMCUyMmxvd3JlcyUyQyUyMGJhZCUyMGFuYXRvbXklMkMlMjB3b3JzdCUyMHF1YWxpdHklMkMlMjBsb3clMjBxdWFsaXR5JTJDJTIwZGVmb3JtZWQlMkMlMjB1Z2x5JTIyJTBBJTBBaW1hZ2VzJTIwJTNEJTIwJTVCY2FubnlfaW1hZ2UucmVzaXplKCgxMDI0JTJDJTIwMTAyNCkpJTJDJTIwZGVwdGhfaW1hZ2UucmVzaXplKCgxMDI0JTJDJTIwMTAyNCkpJTVEJTBBJTBBcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0RpbWFnZXMlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwY29udHJvbG5ldF9jb25kaXRpb25pbmdfc2NhbGUlM0QlNUIwLjUlMkMlMjAwLjUlNUQlMkMlMEElMjAlMjAlMjAlMjBzdHJlbmd0aCUzRDAuNyUyQyUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLControlNetPipeline, ControlNetModel, AutoencoderKL

controlnets = [
    ControlNetModel.from_pretrained(
        <span class="hljs-string">&quot;diffusers/controlnet-depth-sdxl-1.0-small&quot;</span>, torch_dtype=torch.float16
    ),
    ControlNetModel.from_pretrained(
        <span class="hljs-string">&quot;diffusers/controlnet-canny-sdxl-1.0&quot;</span>, torch_dtype=torch.float16,
    ),
]

vae = AutoencoderKL.from_pretrained(<span class="hljs-string">&quot;madebyollin/sdxl-vae-fp16-fix&quot;</span>, torch_dtype=torch.float16)
pipeline = StableDiffusionXLControlNetPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, controlnet=controlnets, vae=vae, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;&quot;&quot;
a relaxed rabbit sitting on a striped towel next to a pool with a tropical drink nearby, 
bright sunny day, vacation scene, 35mm photograph, film, professional, 4k, highly detailed
&quot;&quot;&quot;</span>
negative_prompt = <span class="hljs-string">&quot;lowres, bad anatomy, worst quality, low quality, deformed, ugly&quot;</span>

images = [canny_image.resize((<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>)), depth_image.resize((<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>))]

pipeline(
    prompt,
    negative_prompt=negative_prompt,
    image=images,
    num_inference_steps=<span class="hljs-number">100</span>,
    controlnet_conditioning_scale=[<span class="hljs-number">0.5</span>, <span class="hljs-number">0.5</span>],
    strength=<span class="hljs-number">0.7</span>,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),V=new pe({props:{title:"guess_mode",local:"guessmode",headingTag:"h2"}}),H=new N({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pYW1nZSUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBTdGFibGVEaWZmdXNpb25YTENvbnRyb2xOZXRQaXBlbGluZSUyQyUyMENvbnRyb2xOZXRNb2RlbCUwQSUwQWNvbnRyb2xuZXQlMjAlM0QlMjBDb250cm9sTmV0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMmRpZmZ1c2VycyUyRmNvbnRyb2xuZXQtY2Fubnktc2R4bC0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25YTENvbnRyb2xOZXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTBBJTIwJTIwY29udHJvbG5ldCUzRGNvbnRyb2xuZXQlMkMlMEElMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBY2FubnlfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmNhbm55LWNhdC5wbmclMjIpJTBBcGlwZWxpbmUoJTBBJTIwJTIwJTIyJTIyJTJDJTBBJTIwJTIwaW1hZ2UlM0RjYW5ueV9pbWFnZSUyQyUwQSUyMCUyMGd1ZXNzX21vZGUlM0RUcnVlJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_iamge
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLControlNetPipeline, ControlNetModel

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

canny_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/canny-cat.png&quot;</span>)
pipeline(
  <span class="hljs-string">&quot;&quot;</span>,
  image=canny_image,
  guess_mode=<span class="hljs-literal">True</span>
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),$=new Ce({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/controlnet.md"}}),{c(){i=b("meta"),U=c(),J=b("p"),m=c(),j(d.$$.fragment),r=c(),n=b("p"),n.innerHTML=u,y=c(),h=b("p"),h.textContent=o,B=c(),g=b("blockquote"),g.innerHTML=l,p=c(),Y=b("p"),Y.innerHTML=ce,z=c(),j(X.$$.fragment),D=c(),j(_.$$.fragment),L=c(),Q=b("p"),Q.innerHTML=Me,q=c(),x=b("p"),x.textContent=de,K=c(),E=b("p"),E.textContent=ye,P=c(),j(F.$$.fragment),O=c(),R=b("div"),R.innerHTML=ue,ee=c(),j(V.$$.fragment),le=c(),S=b("p"),S.innerHTML=Je,te=c(),j(H.$$.fragment),ae=c(),k=b("div"),k.innerHTML=he,ne=c(),j($.$$.fragment),se=c(),A=b("p"),this.h()},l(e){const s=je("svelte-u9bgzb",document.head);i=T(s,"META",{name:!0,content:!0}),s.forEach(t),U=M(e),J=T(e,"P",{}),be(J).forEach(t),m=M(e),Z(d.$$.fragment,e),r=M(e),n=T(e,"P",{"data-svelte-h":!0}),f(n)!=="svelte-1n3ntx6"&&(n.innerHTML=u),y=M(e),h=T(e,"P",{"data-svelte-h":!0}),f(h)!=="svelte-1qp3bo6"&&(h.textContent=o),B=M(e),g=T(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(g)!=="svelte-17w1v3e"&&(g.innerHTML=l),p=M(e),Y=T(e,"P",{"data-svelte-h":!0}),f(Y)!=="svelte-88bwwp"&&(Y.innerHTML=ce),z=M(e),Z(X.$$.fragment,e),D=M(e),Z(_.$$.fragment,e),L=M(e),Q=T(e,"P",{"data-svelte-h":!0}),f(Q)!=="svelte-11jp78z"&&(Q.innerHTML=Me),q=M(e),x=T(e,"P",{"data-svelte-h":!0}),f(x)!=="svelte-ueyms4"&&(x.textContent=de),K=M(e),E=T(e,"P",{"data-svelte-h":!0}),f(E)!=="svelte-1yb2pw9"&&(E.textContent=ye),P=M(e),Z(F.$$.fragment,e),O=M(e),R=T(e,"DIV",{style:!0,"data-svelte-h":!0}),f(R)!=="svelte-1ols1y"&&(R.innerHTML=ue),ee=M(e),Z(V.$$.fragment,e),le=M(e),S=T(e,"P",{"data-svelte-h":!0}),f(S)!=="svelte-1cijut3"&&(S.innerHTML=Je),te=M(e),Z(H.$$.fragment,e),ae=M(e),k=T(e,"DIV",{style:!0,"data-svelte-h":!0}),f(k)!=="svelte-193ffwv"&&(k.innerHTML=he),ne=M(e),Z($.$$.fragment,e),se=M(e),A=T(e,"P",{}),be(A).forEach(t),this.h()},h(){oe(i,"name","hf:doc:metadata"),oe(i,"content",ve),oe(g,"class","tip"),w(R,"display","flex"),w(R,"gap","10px"),w(R,"justify-content","space-around"),w(R,"align-items","flex-end"),w(k,"display","flex"),w(k,"gap","10px"),w(k,"justify-content","space-around"),w(k,"align-items","flex-end")},m(e,s){Ze(document.head,i),a(e,U,s),a(e,J,s),a(e,m,s),C(d,e,s),a(e,r,s),a(e,n,s),a(e,y,s),a(e,h,s),a(e,B,s),a(e,g,s),a(e,p,s),a(e,Y,s),a(e,z,s),C(X,e,s),a(e,D,s),C(_,e,s),a(e,L,s),a(e,Q,s),a(e,q,s),a(e,x,s),a(e,K,s),a(e,E,s),a(e,P,s),C(F,e,s),a(e,O,s),a(e,R,s),a(e,ee,s),C(V,e,s),a(e,le,s),a(e,S,s),a(e,te,s),C(H,e,s),a(e,ae,s),a(e,k,s),a(e,ne,s),C($,e,s),a(e,se,s),a(e,A,s),ie=!0},p(e,[s]){const ge={};s&2&&(ge.$$scope={dirty:s,ctx:e}),X.$set(ge)},i(e){ie||(W(d.$$.fragment,e),W(X.$$.fragment,e),W(_.$$.fragment,e),W(F.$$.fragment,e),W(V.$$.fragment,e),W(H.$$.fragment,e),W($.$$.fragment,e),ie=!0)},o(e){I(d.$$.fragment,e),I(X.$$.fragment,e),I(_.$$.fragment,e),I(F.$$.fragment,e),I(V.$$.fragment,e),I(H.$$.fragment,e),I($.$$.fragment,e),ie=!1},d(e){e&&(t(U),t(J),t(m),t(r),t(n),t(y),t(h),t(B),t(g),t(p),t(Y),t(z),t(D),t(L),t(Q),t(q),t(x),t(K),t(E),t(P),t(O),t(R),t(ee),t(le),t(S),t(te),t(ae),t(k),t(ne),t(se),t(A)),t(i),G(d,e),G(X,e),G(_,e),G(F,e),G(V,e),G(H,e),G($,e)}}}const ve='{"title":"ControlNet","local":"controlnet","sections":[{"title":"Multi-ControlNet","local":"multi-controlnet","sections":[],"depth":2},{"title":"guess_mode","local":"guessmode","sections":[],"depth":2}],"depth":1}';function Xe(v){return we(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ee extends fe{constructor(i){super(),Ue(this,i,Xe,ke,Te,{})}}export{Ee as component};
