import{s as bn,z as Zn,o as Wn,n as ya}from"../chunks/scheduler.182ea377.js";import{S as wn,i as Tn,g as m,s as n,r as c,A as Un,h as o,f as l,c as s,j as ct,u as d,x as r,k as w,y as jn,a as t,v as g,d as u,t as M,w as h}from"../chunks/index.abf12888.js";import{T as fn}from"../chunks/Tip.230e2334.js";import{C as b}from"../chunks/CodeBlock.57fe6e13.js";import{D as Gn}from"../chunks/DocNotebookDropdown.d9060979.js";import{H as T}from"../chunks/Heading.16916d63.js";import{H as Jn,a as rt}from"../chunks/HfOption.fc88c804.js";function kn(W){let i,f='You’ll notice throughout the guide, we use <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/gligen#diffusers.StableDiffusionGLIGENTextImagePipeline.enable_model_cpu_offload">enable_model_cpu_offload()</a> and <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/image_variation#diffusers.StableDiffusionImageVariationPipeline.enable_xformers_memory_efficient_attention">enable_xformers_memory_efficient_attention()</a>, to save memory and increase inference speed. If you’re using PyTorch 2.0, it’s not necessary to call <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/image_variation#diffusers.StableDiffusionImageVariationPipeline.enable_xformers_memory_efficient_attention">enable_xformers_memory_efficient_attention()</a> on your pipeline because it’ll already be using PyTorch 2.0’s native <a href="../optimization/torch2.0#scaled-dot-product-attention">scaled-dot product attention</a>.';return{c(){i=m("p"),i.innerHTML=f},l(p){i=o(p,"P",{"data-svelte-h":!0}),r(i)!=="svelte-1a3m199"&&(i.innerHTML=f)},m(p,J){t(p,i,J)},p:ya,d(p){p&&l(i)}}}function Bn(W){let i,f;return i=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBc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vciUyMCUzRCUyMHRvcmNoLkdlbmVyYXRvciglMjJjdWRhJTIyKS5tYW51YWxfc2VlZCg5MiklMEFwcm9tcHQlMjAlM0QlMjAlMjJjb25jZXB0JTIwYXJ0JTIwZGlnaXRhbCUyMHBhaW50aW5nJTIwb2YlMjBhbiUyMGVsdmVuJTIwY2FzdGxlJTJDJTIwaW5zcGlyZWQlMjBieSUyMGxvcmQlMjBvZiUyMHRoZSUyMHJpbmdzJTJDJTIwaGlnaGx5JTIwZGV0YWlsZWQlMkMlMjA4ayUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW5pdF9pbWFnZSUyQyUyMGltYWdlJTVEJTJDJTIwcm93cyUzRDElMkMlMjBjb2xzJTNEMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">92</span>)
prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, generator=generator).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){c(i.$$.fragment)},l(p){d(i.$$.fragment,p)},m(p,J){g(i,p,J),f=!0},p:ya,i(p){f||(u(i.$$.fragment,p),f=!0)},o(p){M(i.$$.fragment,p),f=!1},d(p){h(i,p)}}}function In(W){let i,f;return i=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24taW5wYWludGluZyUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTIzJTIwcmVtb3ZlJTIwZm9sbG93aW5nJTIwbGluZSUyMGlmJTIweEZvcm1lcnMlMjBpcyUyMG5vdCUyMGluc3RhbGxlZCUyMG9yJTIweW91JTIwaGF2ZSU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BnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW5pdF9pbWFnZSUyQyUyMGltYWdlJTVEJTJDJTIwcm93cyUzRDElMkMlMjBjb2xzJTNEMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">92</span>)
prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, generator=generator).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){c(i.$$.fragment)},l(p){d(i.$$.fragment,p)},m(p,J){g(i,p,J),f=!0},p:ya,i(p){f||(u(i.$$.fragment,p),f=!0)},o(p){M(i.$$.fragment,p),f=!1},d(p){h(i,p)}}}function vn(W){let i,f,p,J;return i=new rt({props:{id:"regular-specific",option:"runwayml/stable-diffusion-v1-5",$$slots:{default:[Bn]},$$scope:{ctx:W}}}),p=new rt({props:{id:"regular-specific",option:"runwayml/stable-diffusion-inpainting",$$slots:{default:[In]},$$scope:{ctx:W}}}),{c(){c(i.$$.fragment),f=n(),c(p.$$.fragment)},l(y){d(i.$$.fragment,y),f=s(y),d(p.$$.fragment,y)},m(y,Z){g(i,y,Z),t(y,f,Z),g(p,y,Z),J=!0},p(y,Z){const U={};Z&2&&(U.$$scope={dirty:Z,ctx:y}),i.$set(U);const j={};Z&2&&(j.$$scope={dirty:Z,ctx:y}),p.$set(j)},i(y){J||(u(i.$$.fragment,y),u(p.$$.fragment,y),J=!0)},o(y){M(i.$$.fragment,y),M(p.$$.fragment,y),J=!1},d(y){y&&l(f),h(i,y),h(p,y)}}}function Xn(W){let i,f;return i=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTIzJTIwcmVtb3ZlJTIwZm9sbG93aW5nJTIwbGluZSUyMGlmJTIweEZvcm1lcnMlMjBpcyUyMG5vdCUyMGluc3RhbGxlZCUyMG9yJTIweW91JTIwaGF2ZSUyMFB5VG9yY2glMjAyLjAlMjBvciUyMGhpZ2hlciUyMGluc3RhbGxlZCUwQXBpcGVsaW5lLmVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbigpJTBBJTBBJTIzJTIwbG9hZCUyMGJhc2UlMjBhbmQlMjBtYXNrJTIwaW1hZ2UlMEFpbml0X2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpbnBhaW50LnBuZyUyMiklMEFtYXNrX2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZyb2FkLW1hc2sucG5nJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEJTIycm9hZCUyMiUyQyUyMGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlKS5pbWFnZXMlNUIwJTVEJTBBbWFrZV9pbWFnZV9ncmlkKCU1QmluaXRfaW1hZ2UlMkMlMjBpbWFnZSU1RCUyQyUyMHJvd3MlM0QxJTJDJTIwY29scyUzRDIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/road-mask.png&quot;</span>)

image = pipeline(prompt=<span class="hljs-string">&quot;road&quot;</span>, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){c(i.$$.fragment)},l(p){d(i.$$.fragment,p)},m(p,J){g(i,p,J),f=!0},p:ya,i(p){f||(u(i.$$.fragment,p),f=!0)},o(p){M(i.$$.fragment,p),f=!1},d(p){h(i,p)}}}function _n(W){let i,f;return i=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24taW5wYWludGluZyUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHZhcm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yQyUyMHJvd3MlM0QxJTJDJTIwY29scyUzRDIp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/road-mask.png&quot;</span>)

image = pipeline(prompt=<span class="hljs-string">&quot;road&quot;</span>, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),{c(){c(i.$$.fragment)},l(p){d(i.$$.fragment,p)},m(p,J){g(i,p,J),f=!0},p:ya,i(p){f||(u(i.$$.fragment,p),f=!0)},o(p){M(i.$$.fragment,p),f=!1},d(p){h(i,p)}}}function Yn(W){let i,f,p,J;return i=new rt({props:{id:"inpaint",option:"runwayml/stable-diffusion-v1-5",$$slots:{default:[Xn]},$$scope:{ctx:W}}}),p=new rt({props:{id:"inpaint",option:"runwayml/stable-diffusion-inpaint",$$slots:{default:[_n]},$$scope:{ctx:W}}}),{c(){c(i.$$.fragment),f=n(),c(p.$$.fragment)},l(y){d(i.$$.fragment,y),f=s(y),d(p.$$.fragment,y)},m(y,Z){g(i,y,Z),t(y,f,Z),g(p,y,Z),J=!0},p(y,Z){const U={};Z&2&&(U.$$scope={dirty:Z,ctx:y}),i.$set(U);const j={};Z&2&&(j.$$scope={dirty:Z,ctx:y}),p.$set(j)},i(y){J||(u(i.$$.fragment,y),u(p.$$.fragment,y),J=!0)},o(y){M(i.$$.fragment,y),M(p.$$.fragment,y),J=!1},d(y){y&&l(f),h(i,y),h(p,y)}}}function Fn(W){let i,f='It is important to specify <code>output_type=&quot;latent&quot;</code> in the pipeline to keep all the outputs in latent space to avoid an unnecessary decode-encode step. This only works if the chained pipelines are using the same VAE. For example, in the <a href="#text-to-image-to-inpaint">Text-to-image-to-inpaint</a> section, Kandinsky 2.2 uses a different VAE class than the Stable Diffusion model so it won’t work. But if you use Stable Diffusion v1.5 for both pipelines, then you can keep everything in latent space because they both use <a href="/docs/diffusers/main/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>.';return{c(){i=m("p"),i.innerHTML=f},l(p){i=o(p,"P",{"data-svelte-h":!0}),r(i)!=="svelte-15caib6"&&(i.innerHTML=f)},m(p,J){t(p,i,J)},p:ya,d(p){p&&l(i)}}}function Vn(W){let i,f,p,J,y,Z,U,j,H,dt="Inpainting replaces or edits specific areas of an image. This makes it a useful tool for image restoration like removing defects and artifacts, or even replacing an image area with something entirely new. Inpainting relies on a mask to determine which regions of an image to fill in; the area to inpaint is represented by white pixels and the area to keep is represented by black pixels. The white pixels are filled in by the prompt.",Ja,z,gt="With 🤗 Diffusers, here is how you can do inpainting:",ba,E,ut='<li>Load an inpainting checkpoint with the <a href="/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting">AutoPipelineForInpainting</a> class. This’ll automatically detect the appropriate pipeline class to load based on the checkpoint:</li>',Za,L,Wa,k,wa,B,Mt="<li>Load the base and mask images:</li>",Ta,q,Ua,I,ht="<li>Create a prompt to inpaint the image with and pass it to the pipeline with the base and mask images:</li>",ja,A,Ga,v,yt='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">base image</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">mask image</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-cat.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">generated image</figcaption></div>',ka,D,Ba,P,ft="Throughout this guide, the mask image is provided in all of the code examples for convenience. You can inpaint on your own images, but you’ll need to create a mask image for it. Use the Space below to easily create a mask image.",Ia,K,Jt="Upload a base image to inpaint on and use the sketch tool to draw a mask. Once you’re done, click <strong>Run</strong> to generate and download the mask image.",va,G,bt,Xa,O,_a,ee,Zt='<a href="https://huggingface.co/runwayml/stable-diffusion-inpainting" rel="nofollow">Stable Diffusion Inpainting</a>, <a href="https://huggingface.co/diffusers/stable-diffusion-xl-1.0-inpainting-0.1" rel="nofollow">Stable Diffusion XL (SDXL) Inpainting</a>, and <a href="https://huggingface.co/kandinsky-community/kandinsky-2-2-decoder-inpaint" rel="nofollow">Kandinsky 2.2 Inpainting</a> are among the most popular models for inpainting. SDXL typically produces higher resolution images than Stable Diffusion v1.5, and Kandinsky 2.2 is also capable of generating high-quality images.',Ya,ae,Fa,le,Wt="Stable Diffusion Inpainting is a latent diffusion model finetuned on 512x512 images on inpainting. It is a good starting point because it is relatively fast and generates good quality images. To use this model for inpainting, you’ll need to pass a prompt, base and mask image to the pipeline:",Va,te,Ra,ne,xa,se,wt='SDXL is a larger and more powerful version of Stable Diffusion v1.5. This model can follow a two-stage model process (though each model can also be used alone); the base model generates an image, and a refiner model takes that image and further enhances its details and quality. Take a look at the <a href="sdxl">SDXL</a> guide for a more comprehensive guide on how to use SDXL and configure it’s parameters.',$a,ie,Na,pe,Qa,me,Tt='The Kandinsky model family is similar to SDXL because it uses two models as well; the image prior model creates image embeddings, and the diffusion model generates images from them. You can load the image prior and diffusion model separately, but the easiest way to use Kandinsky 2.2 is to load it into the <a href="/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting">AutoPipelineForInpainting</a> class which uses the <a href="/docs/diffusers/main/en/api/pipelines/kandinsky_v22#diffusers.KandinskyV22InpaintCombinedPipeline">KandinskyV22InpaintCombinedPipeline</a> under the hood.',Ca,oe,Sa,X,Ut='<div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">base image</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-sdv1.5.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">Stable Diffusion Inpainting</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-sdxl.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">Stable Diffusion XL Inpainting</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-kandinsky.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">Kandinsky 2.2 Inpainting</figcaption></div>',Ha,re,za,ce,jt='So far, this guide has used inpaint specific checkpoints such as <a href="https://huggingface.co/runwayml/stable-diffusion-inpainting" rel="nofollow">runwayml/stable-diffusion-inpainting</a>. But you can also use regular checkpoints like <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">runwayml/stable-diffusion-v1-5</a>. Let’s compare the results of the two checkpoints.',Ea,de,Gt="The image on the left is generated from a regular checkpoint, and the image on the right is from an inpaint checkpoint. You’ll immediately notice the image on the left is not as clean, and you can still see the outline of the area the model is supposed to inpaint. The image on the right is much cleaner and the inpainted area appears more natural.",La,_,qa,Y,kt='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/non-inpaint-specific.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">runwayml/stable-diffusion-v1-5</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-specific.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">runwayml/stable-diffusion-inpainting</figcaption></div>',Aa,ge,Bt="However, for more basic tasks like erasing an object from an image (like the rocks in the road for example), a regular checkpoint yields pretty good results. There isn’t as noticeable of difference between the regular and inpaint checkpoint.",Da,F,Pa,V,It='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/regular-inpaint-basic.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">runwayml/stable-diffusion-v1-5</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/specific-inpaint-basic.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">runwayml/stable-diffusion-inpainting</figcaption></div>',Ka,ue,vt="The trade-off of using a non-inpaint specific checkpoint is the overall image quality may be lower, but it generally tends to preserve the mask area (that is why you can see the mask outline). The inpaint specific checkpoints are intentionally trained to generate higher quality inpainted images, and that includes creating a more natural transition between the masked and unmasked areas. As a result, these checkpoints are more likely to change your unmasked area.",Oa,Me,Xt="If preserving the unmasked area is important for your task, you can use the code below to force the unmasked area of an image to remain the same at the expense of some more unnatural transitions between the masked and unmasked areas.",el,he,al,ye,ll,fe,_t="Image features - like quality and “creativity” - are dependent on pipeline parameters. Knowing what these parameters do is important for getting the results you want. Let’s take a look at the most important parameters and see how changing them affects the output.",tl,Je,nl,be,Yt="<code>strength</code> is a measure of how much noise is added to the base image, which influences how similar the output is to the base image.",sl,Ze,Ft="<li>📈 a high <code>strength</code> value means more noise is added to an image and the denoising process takes longer, but you’ll get higher quality images that are more different from the base image</li> <li>📉 a low <code>strength</code> value means less noise is added to an image and the denoising process is faster, but the image quality may not be as great and the generated image resembles the base image more</li>",il,We,pl,R,Vt='<div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-strength-0.6.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">strength = 0.6</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-strength-0.8.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">strength = 0.8</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-strength-1.0.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">strength = 1.0</figcaption></div>',ml,we,ol,Te,Rt="<code>guidance_scale</code> affects how aligned the text prompt and generated image are.",rl,Ue,xt="<li>📈 a high <code>guidance_scale</code> value means the prompt and generated image are closely aligned, so the output is a stricter interpretation of the prompt</li> <li>📉 a low <code>guidance_scale</code> value means the prompt and generated image are more loosely aligned, so the output may be more varied from the prompt</li>",cl,je,$t="You can use <code>strength</code> and <code>guidance_scale</code> together for more control over how expressive the model is. For example, a combination high <code>strength</code> and <code>guidance_scale</code> values gives the model the most creative freedom.",dl,Ge,gl,x,Nt='<div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-guidance-2.5.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">guidance_scale = 2.5</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-guidance-7.5.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">guidance_scale = 7.5</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-guidance-12.5.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">guidance_scale = 12.5</figcaption></div>',ul,ke,Ml,Be,Qt="A negative prompt assumes the opposite role of a prompt; it guides the model away from generating certain things in an image. This is useful for quickly improving image quality and preventing the model from generating things you don’t want.",hl,Ie,yl,$,Ct='<figure><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-negative.png"/> <figcaption class="text-center">negative_prompt = &quot;bad architecture, unstable, poor details, blurry&quot;</figcaption></figure>',fl,ve,Jl,Xe,St='<a href="/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting">AutoPipelineForInpainting</a> can be chained with other 🤗 Diffusers pipelines to edit their outputs. This is often useful for improving the output quality from your other diffusion pipelines, and if you’re using multiple pipelines, it can be more memory-efficient to chain them together to keep the outputs in latent space and reuse the same pipeline components.',bl,_e,Zl,Ye,Ht="Chaining a text-to-image and inpainting pipeline allows you to inpaint the generated image, and you don’t have to provide a base image to begin with. This makes it convenient to edit your favorite text-to-image outputs without having to generate an entirely new image.",Wl,Fe,zt="Start with the text-to-image pipeline to create a castle:",wl,Ve,Tl,Re,Et="Load the mask image of the output from above:",Ul,xe,jl,$e,Lt="And let’s inpaint the masked area with a waterfall:",Gl,Ne,kl,N,qt='<div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-text-chain.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">text-to-image</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-text-chain-out.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">inpaint</figcaption></div>',Bl,Qe,Il,Ce,At="You can also chain an inpainting pipeline before another pipeline like image-to-image or an upscaler to improve the quality.",vl,Se,Dt="Begin by inpainting an image:",Xl,He,_l,ze,Pt="Now let’s pass the image to another inpainting pipeline with SDXL’s refiner model to enhance the image details and quality:",Yl,Ee,Fl,Q,Vl,Le,Kt='Finally, you can pass this image to an image-to-image pipeline to put the finishing touches on it. It is more efficient to use the <a href="/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForImage2Image.from_pipe">from_pipe()</a> method to reuse the existing pipeline components, and avoid unnecessarily loading all the pipeline components into memory again.',Rl,qe,xl,C,Ot='<div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">initial image</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-to-image-chain.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">inpaint</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-to-image-final.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">image-to-image</figcaption></div>',$l,Ae,en="Image-to-image and inpainting are actually very similar tasks. Image-to-image generates a new image that resembles the existing provided image. Inpainting does the same thing, but it only transforms the image area defined by the mask and the rest of the image is unchanged. You can think of inpainting as a more precise tool for making specific changes and image-to-image has a broader scope for making more sweeping changes.",Nl,De,Ql,Pe,an="Getting an image to look exactly the way you want is challenging because the denoising process is random. While you can control certain aspects of generation by configuring parameters like <code>negative_prompt</code>, there are better and more efficient methods for controlling image generation.",Cl,Ke,Sl,Oe,ln='Prompt weighting provides a quantifiable way to scale the representation of concepts in a prompt. You can use it to increase or decrease the magnitude of the text embedding vector for each concept in the prompt, which subsequently determines how much of each concept is generated. The <a href="https://github.com/damian0815/compel" rel="nofollow">Compel</a> library offers an intuitive syntax for scaling the prompt weights and generating the embeddings. Learn how to create the embeddings in the <a href="../using-diffusers/weighted_prompts">Prompt weighting</a> guide.',Hl,ea,tn='Once you’ve generated the embeddings, pass them to the <code>prompt_embeds</code> (and <code>negative_prompt_embeds</code> if you’re using a negative prompt) parameter in the <a href="/docs/diffusers/main/en/api/pipelines/auto_pipeline#diffusers.AutoPipelineForInpainting">AutoPipelineForInpainting</a>. The embeddings replace the <code>prompt</code> parameter:',zl,aa,El,la,Ll,ta,nn="ControlNet models are used with other diffusion models like Stable Diffusion, and they provide an even more flexible and accurate way to control how an image is generated. A ControlNet accepts an additional conditioning image input that guides the diffusion model to preserve the features in it.",ql,na,sn="For example, let’s condition an image with a ControlNet pretrained on inpaint images:",Al,sa,Dl,ia,pn="Now generate an image from the base, mask and control images. You’ll notice features of the base image are strongly preserved in the generated image.",Pl,pa,Kl,ma,mn='You can take this a step further and chain it with an image-to-image pipeline to apply a new <a href="https://huggingface.co/nitrosocke/elden-ring-diffusion" rel="nofollow">style</a>:',Ol,oa,et,S,on='<div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">initial image</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-controlnet.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">ControlNet inpaint</figcaption></div> <div class="flex-1"><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint-img2img.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">image-to-image</figcaption></div>',at,ra,lt,ca,rn='It can be difficult and slow to run diffusion models if you’re resource constrained, but it doesn’t have to be with a few optimization tricks. One of the biggest (and easiest) optimizations you can enable is switching to memory-efficient attention. If you’re using PyTorch 2.0, <a href="../optimization/torch2.0#scaled-dot-product-attention">scaled-dot product attention</a> is automatically enabled and you don’t need to do anything else. For non-PyTorch 2.0 users, you can install and use <a href="../optimization/xformers">xFormers</a>’s implementation of memory-efficient attention. Both options reduce memory usage and accelerate inference.',tt,da,cn="You can also offload the model to the CPU to save even more memory:",nt,ga,st,ua,dn='To speed-up your inference code even more, use <a href="../optimization/torch2.0#torchcompile"><code>torch_compile</code></a>. You should wrap <code>torch.compile</code> around the most intensive component in the pipeline which is typically the UNet:',it,Ma,pt,ha,gn='Learn more in the <a href="../optimization/memory">Reduce memory usage</a> and <a href="../optimization/torch2.0">Torch 2.0</a> guides.',mt,fa,ot;return y=new T({props:{title:"Inpainting",local:"inpainting",headingTag:"h1"}}),U=new Gn({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/inpaint.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/inpaint.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/inpaint.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/inpaint.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/inpaint.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/inpaint.ipynb"}]}}),L=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMi1kZWNvZGVyLWlucGFpbnQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMjMlMjByZW1vdmUlMjBmb2xsb3dpbmclMjBsaW5lJTIwaWYlMjB4Rm9ybWVycyUyMGlzJTIwbm90JTIwaW5zdGFsbGVkJTIwb3IlMjB5b3UlMjBoYXZlJTIwUHlUb3JjaCUyMDIuMCUyMG9yJTIwaGlnaGVyJTIwaW5zdGFsbGVkJTBBcGlwZWxpbmUuZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uKCk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder-inpaint&quot;</span>, torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()`,wrap:!1}}),k=new fn({props:{$$slots:{default:[kn]},$$scope:{ctx:W}}}),q=new b({props:{code:"aW5pdF9pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGaW5wYWludC5wbmclMjIpJTBBbWFza19pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGaW5wYWludF9tYXNrLnBuZyUyMik=",highlighted:`init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)`,wrap:!1}}),A=new b({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyYSUyMGJsYWNrJTIwY2F0JTIwd2l0aCUyMGdsb3dpbmclMjBleWVzJTJDJTIwY3V0ZSUyQyUyMGFkb3JhYmxlJTJDJTIwZGlzbmV5JTJDJTIwcGl4YXIlMkMlMjBoaWdobHklMjBkZXRhaWxlZCUyQyUyMDhrJTIyJTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwJTIyYmFkJTIwYW5hdG9teSUyQyUyMGRlZm9ybWVkJTJDJTIwdWdseSUyQyUyMGRpc2ZpZ3VyZWQlMjIlMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCUzRHByb21wdCUyQyUyMG5lZ2F0aXZlX3Byb21wdCUzRG5lZ2F0aXZlX3Byb21wdCUyQyUyMGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlKS5pbWFnZXMlNUIwJTVEJTBBbWFrZV9pbWFnZV9ncmlkKCU1QmluaXRfaW1hZ2UlMkMlMjBtYXNrX2ltYWdlJTJDJTIwaW1hZ2UlNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QzKQ==",highlighted:`prompt = <span class="hljs-string">&quot;a black cat with glowing eyes, cute, adorable, disney, pixar, highly detailed, 8k&quot;</span>
negative_prompt = <span class="hljs-string">&quot;bad anatomy, deformed, ugly, disfigured&quot;</span>
image = pipeline(prompt=prompt, negative_prompt=negative_prompt, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),D=new T({props:{title:"Create a mask image",local:"create-a-mask-image",headingTag:"h2"}}),O=new T({props:{title:"Popular models",local:"popular-models",headingTag:"h2"}}),ae=new T({props:{title:"Stable Diffusion Inpainting",local:"stable-diffusion-inpainting",headingTag:"h3"}}),te=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24taW5wYWludGluZyUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTBBKSUwQXBpcGVsaW5lLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTIzJTIwcmVtb3ZlJTIwZm9sbG93aW5nJTIwbGluZSUyMGlmJTIweEZvcm1lcnMlMjBpcyUyMG5vdCUyMGluc3RhbGxlZCUyMG9yJTIweW91JTIwaGF2ZSUyMFB5VG9yY2glMjAyLjAlMjBvciUyMGhpZ2hlciUyMGluc3RhbGxlZCUwQXBpcGVsaW5lLmVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbigpJTBBJTBBJTIzJTIwbG9hZCUyMGJhc2UlMjBhbmQlMjBtYXNrJTIwaW1hZ2UlMEFpbml0X2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpbnBhaW50LnBuZyUyMiklMEFtYXNrX2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpbnBhaW50X21hc2sucG5nJTIyKSUwQSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLkdlbmVyYXRvciglMjJjdWRhJTIyKS5tYW51YWxfc2VlZCg5MiklMEFwcm9tcHQlMjAlM0QlMjAlMjJjb25jZXB0JTIwYXJ0JTIwZGlnaXRhbCUyMHBhaW50aW5nJTIwb2YlMjBhbiUyMGVsdmVuJTIwY2FzdGxlJTJDJTIwaW5zcGlyZWQlMjBieSUyMGxvcmQlMjBvZiUyMHRoZSUyMHJpbmdzJTJDJTIwaGlnaGx5JTIwZGV0YWlsZWQlMkMlMjA4ayUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlMkMlMjBpbWFnZSU1RCUyQyUyMHJvd3MlM0QxJTJDJTIwY29scyUzRDMp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">92</span>)
prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, generator=generator).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),ne=new T({props:{title:"Stable Diffusion XL (SDXL) Inpainting",local:"stable-diffusion-xl-sdxl-inpainting",headingTag:"h3"}}),ie=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJka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AlMjJjb25jZXB0JTIwYXJ0JTIwZGlnaXRhbCUyMHBhaW50aW5nJTIwb2YlMjBhbiUyMGVsdmVuJTIwY2FzdGxlJTJDJTIwaW5zcGlyZWQlMjBieSUyMGxvcmQlMjBvZiUyMHRoZSUyMHJpbmdzJTJDJTIwaGlnaGx5JTIwZGV0YWlsZWQlMkMlMjA4ayUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlMkMlMjBpbWFnZSU1RCUyQyUyMHJvd3MlM0QxJTJDJTIwY29scyUzRDMp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;diffusers/stable-diffusion-xl-1.0-inpainting-0.1&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">92</span>)
prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, generator=generator).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),pe=new T({props:{title:"Kandinsky 2.2 Inpainting",local:"kandinsky-22-inpainting",headingTag:"h3"}}),oe=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMi1kZWNvZGVyLWlucGFpbnQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMjMlMjByZW1vdmUlMjBmb2xsb3dpbmclMjBsaW5lJTIwaWYlMjB4Rm9ybWVycyUyMGlzJTIwbm90JTIwaW5zdGFsbGVkJTIwb3IlMjB5b3UlMjBoYXZlJTIwUHlUb3JjaCUyMDIuMCUyMG9yJTIwaGlnaGVyJTIwaW5zdGFsbGVkJTBBcGlwZWxpbmUuZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uKCklMEElMEElMjMlMjBsb2FkJTIwYmFzZSUyMGFuZCUyMG1hc2slMjBpbWFnZSU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k=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder-inpaint&quot;</span>, torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">92</span>)
prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, generator=generator).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),re=new T({props:{title:"Non-inpaint specific checkpoints",local:"non-inpaint-specific-checkpoints",headingTag:"h2"}}),_=new Jn({props:{id:"regular-specific",options:["runwayml/stable-diffusion-v1-5","runwayml/stable-diffusion-inpainting"],$$slots:{default:[vn]},$$scope:{ctx:W}}}),F=new Jn({props:{id:"inpaint",options:["runwayml/stable-diffusion-v1-5","runwayml/stable-diffusion-inpaint"],$$slots:{default:[Yn]},$$scope:{ctx:W}}}),he=new b({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdG9y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FyciU1Qm1hc2tfaW1hZ2VfYXJyJTIwJTNDJTIwMC41JTVEJTIwJTNEJTIwMCUwQW1hc2tfaW1hZ2VfYXJyJTVCbWFza19pbWFnZV9hcnIlMjAlM0UlM0QlMjAwLjUlNUQlMjAlM0QlMjAxJTBBJTBBJTIzJTIwVGFrZSUyMHRoZSUyMG1hc2tlZCUyMHBpeGVscyUyMGZyb20lMjB0aGUlMjByZXBhaW50ZWQlMjBpbWFnZSUyMGFuZCUyMHRoZSUyMHVubWFza2VkJTIwcGl4ZWxzJTIwZnJvbSUyMHRoZSUyMGluaXRpYWwlMjBpbWFnZSUwQXVubWFza2VkX3VuY2hhbmdlZF9pbWFnZV9hcnIlMjAlM0QlMjAoMSUyMC0lMjBtYXNrX2ltYWdlX2FyciklMjAqJTIwaW5pdF9pbWFnZSUyMCUyQiUyMG1hc2tfaW1hZ2VfYXJyJTIwKiUyMHJlcGFpbnRlZF9pbWFnZSUwQXVubWFza2VkX3VuY2hhbmdlZF9pbWFnZSUyMCUzRCUyMFBJTC5JbWFnZS5mcm9tYXJyYXkodW5tYXNrZWRfdW5jaGFuZ2VkX2ltYWdlX2Fyci5yb3VuZCgpLmFzdHlwZSglMjJ1aW50OCUyMikpJTBBdW5tYXNrZWRfdW5jaGFuZ2VkX2ltYWdlLnNhdmUoJTIyZm9yY2VfdW5tYXNrZWRfdW5jaGFuZ2VkLnBuZyUyMiklMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlMkMlMjByZXBhaW50ZWRfaW1hZ2UlMkMlMjB1bm1hc2tlZF91bmNoYW5nZWRfaW1hZ2UlNUQlMkMlMjByb3dzJTNEMiUyQyUyMGNvbHMlM0QyKQ==",highlighted:`<span class="hljs-keyword">import</span> PIL
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

device = <span class="hljs-string">&quot;cuda&quot;</span>
pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>,
    torch_dtype=torch.float16,
)
pipeline = pipeline.to(device)

img_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png&quot;</span>
mask_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png&quot;</span>

init_image = load_image(img_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
mask_image = load_image(mask_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))

prompt = <span class="hljs-string">&quot;Face of a yellow cat, high resolution, sitting on a park bench&quot;</span>
repainted_image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]
repainted_image.save(<span class="hljs-string">&quot;repainted_image.png&quot;</span>)

<span class="hljs-comment"># Convert mask to grayscale NumPy array</span>
mask_image_arr = np.array(mask_image.convert(<span class="hljs-string">&quot;L&quot;</span>))
<span class="hljs-comment"># Add a channel dimension to the end of the grayscale mask</span>
mask_image_arr = mask_image_arr[:, :, <span class="hljs-literal">None</span>]
<span class="hljs-comment"># Binarize the mask: 1s correspond to the pixels which are repainted</span>
mask_image_arr = mask_image_arr.astype(np.float32) / <span class="hljs-number">255.0</span>
mask_image_arr[mask_image_arr &lt; <span class="hljs-number">0.5</span>] = <span class="hljs-number">0</span>
mask_image_arr[mask_image_arr &gt;= <span class="hljs-number">0.5</span>] = <span class="hljs-number">1</span>

<span class="hljs-comment"># Take the masked pixels from the repainted image and the unmasked pixels from the initial image</span>
unmasked_unchanged_image_arr = (<span class="hljs-number">1</span> - mask_image_arr) * init_image + mask_image_arr * repainted_image
unmasked_unchanged_image = PIL.Image.fromarray(unmasked_unchanged_image_arr.<span class="hljs-built_in">round</span>().astype(<span class="hljs-string">&quot;uint8&quot;</span>))
unmasked_unchanged_image.save(<span class="hljs-string">&quot;force_unmasked_unchanged.png&quot;</span>)
make_image_grid([init_image, mask_image, repainted_image, unmasked_unchanged_image], rows=<span class="hljs-number">2</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),ye=new T({props:{title:"Configure pipeline parameters",local:"configure-pipeline-parameters",headingTag:"h2"}}),Je=new T({props:{title:"Strength",local:"strength",headingTag:"h3"}}),We=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24taW5wYWludGluZyUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTBBKSUwQXBpcGVsaW5lLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTIzJTIwcmVtb3ZlJTIwZm9sbG93aW5nJTIwbGluZSUyMGlmJTIweEZvcm1lcnMlMjBpcyUyMG5vdCUyMGluc3RhbGxlZCUyMG9yJTIweW91JTIwaGF2ZSUyMFB5VG9yY2glMjAyLjAlMjBvciUyMGhpZ2hlciUyMGluc3RhbGxlZCUwQXBpcGVsaW5lLmVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbigpJTBBJTB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span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, strength=<span class="hljs-number">0.6</span>).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),we=new T({props:{title:"Guidance scale",local:"guidance-scale",headingTag:"h3"}}),Ge=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24taW5wYWludGluZyUyMiU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MlMjBoaWdobHklMjBkZXRhaWxlZCUyQyUyMDhrJTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBpbWFnZSUzRGluaXRfaW1hZ2UlMkMlMjBtYXNrX2ltYWdlJTNEbWFza19pbWFnZSUyQyUyMGd1aWRhbmNlX3NjYWxlJTNEMi41KS5pbWFnZXMlNUIwJTVEJTBBbWFrZV9pbWFnZV9ncmlkKCU1QmluaXRfaW1hZ2UlMkMlMjBtYXNrX2ltYWdlJTJDJTIwaW1hZ2UlNUQlMkMlMjByb3dzJTNEMSUyQyUyMGNvbHMlM0QzKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, guidance_scale=<span class="hljs-number">2.5</span>).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wr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uZyUyMiklMEFtYXNrX2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZpbnBhaW50X21hc2sucG5nJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMmNvbmNlcHQlMjBhcnQlMjBkaWdpdGFsJTIwcGFpbnRpbmclMjBvZiUyMGFuJTIwZWx2ZW4lMjBjYXN0bGUlMkMlMjBpbnNwaXJlZCUyMGJ5JTIwbG9yZCUyMG9mJTIwdGhlJTIwcmluZ3MlMkMlMjBoaWdobHklMjBkZXRhaWxlZCUyQyUyMDhrJTIyJTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwJTIyYmFkJTIwYXJjaGl0ZWN0dXJlJTJDJTIwdW5zdGFibGUlMkMlMjBwb29yJTIwZGV0YWlscyUyQyUyMGJsdXJyeSUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlMkMlMjBpbWFnZSU1RCUyQyUyMHJvd3MlM0QxJTJDJTIwY29scyUzRDMp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
negative_prompt = <span class="hljs-string">&quot;bad architecture, unstable, poor details, blurry&quot;</span>
image = pipeline(prompt=prompt, negative_prompt=negative_prompt, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),ve=new T({props:{title:"Chained inpainting pipelines",local:"chained-inpainting-pipelines",headingTag:"h2"}}),_e=new T({props:{title:"Text-to-image-to-inpaint",local:"text-to-image-to-inpaint",headingTag:"h3"}}),Ve=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUyQyUyMEF1dG9QaXBlbGluZUZvcklucGFpbnRpbmclMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUyQyUyMG1ha2VfaW1hZ2VfZ3JpZCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMjMlMjByZW1vdmUlMjBmb2xsb3dpbmclMjBsaW5lJTIwaWYlMjB4Rm9ybWVycyUyMGlzJTIwbm90JTIwaW5zdGFsbGVkJTIwb3IlMjB5b3UlMjBoYXZlJTIwUHlUb3JjaCUyMDIuMCUyMG9yJTIwaGlnaGVyJTIwaW5zdGFsbGVkJTBBcGlwZWxpbmUuZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uKCklMEElMEF0ZXh0MmltYWdlJTIwJTNEJTIwcGlwZWxpbmUoJTIyY29uY2VwdCUyMGFydCUyMGRpZ2l0YWwlMjBwYWludGluZyUyMG9mJTIwYW4lMjBlbHZlbiUyMGNhc3RsZSUyQyUyMGluc3BpcmVkJTIwYnklMjBsb3JkJTIwb2YlMjB0aGUlMjByaW5ncyUyQyUyMGhpZ2hseSUyMGRldGFpbGVkJTJDJTIwOGslMjIpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image, AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

text2image = pipeline(<span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),xe=new b({props:{code:"bWFza19pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGaW5wYWludF90ZXh0LWNoYWluLW1hc2sucG5nJTIyKQ==",highlighted:'mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_text-chain-mask.png&quot;</span>)',wrap:!1}}),Ne=new b({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJrYW5kaW5za3ktY29tbXVuaXR5JTJGa2FuZGluc2t5LTItMi1kZWNvZGVyLWlucGFpbnQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMjMlMjByZW1vdmUlMjBmb2xsb3dpbmclMjBsaW5lJTIwaWYlMjB4Rm9ybWVycyUyMGlzJTIwbm90JTIwaW5zdGFsbGVkJTIwb3IlMjB5b3UlMjBoYXZlJTIwUHlUb3JjaCUyMDIuMCUyMG9yJTIwaGlnaGVyJTIwaW5zdGFsbGVkJTBBcGlwZWxpbmUuZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uKCklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJkaWdpdGFsJTIwcGFpbnRpbmclMjBvZiUyMGElMjBmYW50YXN5JTIwd2F0ZXJmYWxsJTJDJTIwY2xvdWR5JTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBpbWFnZSUzRHRleHQyaW1hZ2UlMkMlMjBtYXNrX2ltYWdlJTNEbWFza19pbWFnZSkuaW1hZ2VzJTVCMCU1RCUwQW1ha2VfaW1hZ2VfZ3JpZCglNUJ0ZXh0MmltYWdlJTJDJTIwbWFza19pbWFnZSUyQyUyMGltYWdlJTVEJTJDJTIwcm93cyUzRDElMkMlMjBjb2xzJTNEMyk=",highlighted:`pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;kandinsky-community/kandinsky-2-2-decoder-inpaint&quot;</span>, torch_dtype=torch.float16
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

prompt = <span class="hljs-string">&quot;digital painting of a fantasy waterfall, cloudy&quot;</span>
image = pipeline(prompt=prompt, image=text2image, mask_image=mask_image).images[<span class="hljs-number">0</span>]
make_image_grid([text2image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),Qe=new T({props:{title:"Inpaint-to-image-to-image",local:"inpaint-to-image-to-image",headingTag:"h3"}}),He=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUyQyUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlJTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMkMlMjBtYWtlX2ltYWdlX2dyaWQlMEElMEFwaXBlbGluZSUyMCUzRCUyMEF1dG9QaXBlbGluZUZvcklucGFpbnR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l0YWwlMjBwYWludGluZyUyMG9mJTIwYW4lMjBlbHZlbiUyMGNhc3RsZSUyQyUyMGluc3BpcmVkJTIwYnklMjBsb3JkJTIwb2YlMjB0aGUlMjByaW5ncyUyQyUyMGhpZ2hseSUyMGRldGFpbGVkJTJDJTIwOGslMjIlMEFpbWFnZV9pbnBhaW50aW5nJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UpLmltYWdlcyU1QjAlNUQlMEElMEElMjMlMjByZXNpemUlMjBpbWFnZSUyMHRvJTIwMTAyNHgxMDI0JTIwZm9yJTIwU0RYTCUwQWltYWdlX2lucGFpbnRpbmclMjAlM0QlMjBpbWFnZV9pbnBhaW50aW5nLnJlc2l6ZSgoMTAyNCUyQyUyMDEwMjQpKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting, AutoPipelineForImage2Image
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image_inpainting = pipeline(prompt=prompt, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]

<span class="hljs-comment"># resize image to 1024x1024 for SDXL</span>
image_inpainting = image_inpainting.resize((<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>))`,wrap:!1}}),Ee=new b({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbnBhaW50aW5nLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtcmVmaW5lci0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUwQSklMEFwaXBlbGluZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKSUwQSUyMyUyMHJlbW92ZSUyMGZvbGxvd2luZyUyMGxpbmUlMjBpZiUyMHhGb3JtZXJzJTIwaXMlMjBub3QlMjBpbnN0YWxsZWQlMjBvciUyMHlvdSUyMGhhdmUlMjBQeVRvcmNoJTIwMi4wJTIwb3IlMjBoaWdoZXIlMjBpbnN0YWxsZWQlMEFwaXBlbGluZS5lbmFibGVfeGZvcm1lcnNfbWVtb3J5X2VmZmljaWVudF9hdHRlbnRpb24oKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0RpbWFnZV9pbnBhaW50aW5nJTJDJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UlMkMlMjBvdXRwdXRfdHlwZSUzRCUyMmxhdGVudCUyMikuaW1hZ2VzJTVCMCU1RA==",highlighted:`pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-refiner-1.0&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

image = pipeline(prompt=prompt, image=image_inpainting, mask_image=mask_image, output_type=<span class="hljs-string">&quot;latent&quot;</span>).images[<span class="hljs-number">0</span>]`,wrap:!1}}),Q=new fn({props:{$$slots:{default:[Fn]},$$scope:{ctx:W}}}),qe=new b({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbWFnZTJJbWFnZS5mcm9tX3BpcGUocGlwZWxpbmUpJTBBJTIzJTIwcmVtb3ZlJTIwZm9sbG93aW5nJTIwbGluZSUyMGlmJTIweEZvcm1lcnMlMjBpcyUyMG5vdCUyMGluc3RhbGxlZCUyMG9yJTIweW91JTIwaGF2ZSUyMFB5VG9yY2glMjAyLjAlMjBvciUyMGhpZ2hlciUyMGluc3RhbGxlZCUwQXBpcGVsaW5lLmVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbigpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBpbWFnZSUzRGltYWdlKS5pbWFnZXMlNUIwJTVEJTBBbWFrZV9pbWFnZV9ncmlkKCU1QmluaXRfaW1hZ2UlMkMlMjBtYXNrX2ltYWdlJTJDJTIwaW1hZ2VfaW5wYWludGluZyUyQyUyMGltYWdlJTVEJTJDJTIwcm93cyUzRDIlMkMlMjBjb2xzJTNEMik=",highlighted:`pipeline = AutoPipelineForImage2Image.from_pipe(pipeline)
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

image = pipeline(prompt=prompt, image=image).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image_inpainting, image], rows=<span class="hljs-number">2</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),De=new T({props:{title:"Control image generation",local:"control-image-generation",headingTag:"h2"}}),Ke=new T({props:{title:"Prompt weighting",local:"prompt-weighting",headingTag:"h3"}}),aa=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9ySW5wYWludGluZyUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBtYWtlX2ltYWdlX2dyaWQlMEElMEFwaXBlbGluZSUyMCUzRCUyMEF1dG9QaXBlbGluZUZvcklucGFpbnRpbmcuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi1pbnBhaW50aW5nJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKSUwQXBpcGVsaW5lLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTIzJTIwcmVtb3ZlJTIwZm9sbG93aW5nJTIwbGluZSUyMGlmJTIweEZvcm1lcnMlMjBpcyUyMG5vdCUyMGluc3RhbGxlZCUyMG9yJTIweW91JTIwaGF2ZSUyMFB5VG9yY2glMjAyLjAlMjBvciUyMGhpZ2hlciUyMGluc3RhbGxlZCUwQXBpcGVsaW5lLmVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbigpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHRfZW1iZWRzJTNEcHJvbXB0X2VtYmVkcyUyQyUyMCUyMyUyMGdlbmVyYXRlZCUyMGZyb20lMjBDb21wZWwlMEElMjAlMjAlMjAlMjBuZWdhdGl2ZV9wcm9tcHRfZW1iZWRzJTNEbmVnYXRpdmVfcHJvbXB0X2VtYmVkcyUyQyUyMCUyMyUyMGdlbmVyYXRlZCUyMGZyb20lMjBDb21wZWwlMEElMjAlMjAlMjAlMjBpbWFnZSUzRGluaXRfaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjBtYXNrX2ltYWdlJTNEbWFza19pbWFnZSUwQSkuaW1hZ2VzJTVCMCU1RCUwQW1ha2VfaW1hZ2VfZ3JpZCglNUJpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUyQyUyMGltYWdlJTVEJTJDJTIwcm93cyUzRDElMkMlMjBjb2xzJTNEMyk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForInpainting
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> make_image_grid

pipeline = AutoPipelineForInpainting.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16,
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

image = pipeline(prompt_embeds=prompt_embeds, <span class="hljs-comment"># generated from Compel</span>
    negative_prompt_embeds=negative_prompt_embeds, <span class="hljs-comment"># generated from Compel</span>
    image=init_image,
    mask_image=mask_image
).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image], rows=<span class="hljs-number">1</span>, cols=<span class="hljs-number">3</span>)`,wrap:!1}}),la=new T({props:{title:"ControlNet",local:"controlnet",headingTag:"h3"}}),sa=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29udHJvbE5ldE1vZGVsJTJDJTIwU3RhYmxlRGlmZnVzaW9uQ29udHJvbE5ldElucGFpbnRQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTJDJTIwbWFrZV9pbWFnZV9ncmlkJTBBJTBBJTI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NEJTIwLTEuMCUyMCUyMCUyMyUyMHNldCUyMGFzJTIwbWFza2VkJTIwcGl4ZWwlMEElMjAlMjAlMjAlMjBpbml0X2ltYWdlJTIwJTNEJTIwbnAuZXhwYW5kX2RpbXMoaW5pdF9pbWFnZSUyQyUyMDApLnRyYW5zcG9zZSgwJTJDJTIwMyUyQyUyMDElMkMlMjAyKSUwQSUyMCUyMCUyMCUyMGluaXRfaW1hZ2UlMjAlM0QlMjB0b3JjaC5mcm9tX251bXB5KGluaXRfaW1hZ2UpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW5pdF9pbWFnZSUwQSUwQWNvbnRyb2xfaW1hZ2UlMjAlM0QlMjBtYWtlX2lucGFpbnRfY29uZGl0aW9uKGluaXRfaW1hZ2UlMkMlMjBtYXNrX2ltYWdlKQ==",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> diffusers <span class="hljs-keyword">import</span> ControlNetModel, StableDiffusionControlNetInpaintPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image, make_image_grid

<span class="hljs-comment"># load ControlNet</span>
controlnet = ControlNetModel.from_pretrained(<span class="hljs-string">&quot;lllyasviel/control_v11p_sd15_inpaint&quot;</span>, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>)

<span class="hljs-comment"># pass ControlNet to the pipeline</span>
pipeline = StableDiffusionControlNetInpaintPipeline.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, controlnet=controlnet, torch_dtype=torch.float16, variant=<span class="hljs-string">&quot;fp16&quot;</span>
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

<span class="hljs-comment"># load base and mask image</span>
init_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>)
mask_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint_mask.png&quot;</span>)

<span class="hljs-comment"># prepare control image</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">make_inpaint_condition</span>(<span class="hljs-params">init_image, mask_image</span>):
    init_image = np.array(init_image.convert(<span class="hljs-string">&quot;RGB&quot;</span>)).astype(np.float32) / <span class="hljs-number">255.0</span>
    mask_image = np.array(mask_image.convert(<span class="hljs-string">&quot;L&quot;</span>)).astype(np.float32) / <span class="hljs-number">255.0</span>

    <span class="hljs-keyword">assert</span> init_image.shape[<span class="hljs-number">0</span>:<span class="hljs-number">1</span>] == mask_image.shape[<span class="hljs-number">0</span>:<span class="hljs-number">1</span>], <span class="hljs-string">&quot;image and image_mask must have the same image size&quot;</span>
    init_image[mask_image &gt; <span class="hljs-number">0.5</span>] = -<span class="hljs-number">1.0</span>  <span class="hljs-comment"># set as masked pixel</span>
    init_image = np.expand_dims(init_image, <span class="hljs-number">0</span>).transpose(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>)
    init_image = torch.from_numpy(init_image)
    <span class="hljs-keyword">return</span> init_image

control_image = make_inpaint_condition(init_image, mask_image)`,wrap:!1}}),pa=new b({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyY29uY2VwdCUyMGFydCUyMGRpZ2l0YWwlMjBwYWludGluZyUyMG9mJTIwYW4lMjBlbHZlbiUyMGNhc3RsZSUyQyUyMGluc3BpcmVkJTIwYnklMjBsb3JkJTIwb2YlMjB0aGUlMjByaW5ncyUyQyUyMGhpZ2hseSUyMGRldGFpbGVkJTJDJTIwOGslMjIlMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCUzRHByb21wdCUyQyUyMGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlJTJDJTIwY29udHJvbF9pbWFnZSUzRGNvbnRyb2xfaW1hZ2UpLmltYWdlcyU1QjAlNUQlMEFtYWtlX2ltYWdlX2dyaWQoJTVCaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlMkMlMjBQSUwuSW1hZ2UuZnJvbWFycmF5KG5wLnVpbnQ4KGNvbnRyb2xfaW1hZ2UlNUIwJTVEJTVCMCU1RCkpLmNvbnZlcnQoJ1JHQicpJTJDJTIwaW1hZ2UlNUQlMkMlMjByb3dzJTNEMiUyQyUyMGNvbHMlM0QyKQ==",highlighted:`prompt = <span class="hljs-string">&quot;concept art digital painting of an elven castle, inspired by lord of the rings, highly detailed, 8k&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image, control_image=control_image).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, PIL.Image.fromarray(np.uint8(control_image[<span class="hljs-number">0</span>][<span class="hljs-number">0</span>])).convert(<span class="hljs-string">&#x27;RGB&#x27;</span>), image], rows=<span class="hljs-number">2</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),oa=new b({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvckltYWdlMkltYWdlJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBBdXRvUGlwZWxpbmVGb3JJbWFnZTJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIybml0cm9zb2NrZSUyRmVsZGVuLXJpbmctZGlmZnVzaW9uJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKSUwQXBpcGVsaW5lLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTIzJTIwcmVtb3ZlJTIwZm9sbG93aW5nJTIwbGluZSUyMGlmJTIweEZvcm1lcnMlMjBpcyUyMG5vdCUyMGluc3RhbGxlZCUyMG9yJTIweW91JTIwaGF2ZSUyMFB5VG9yY2glMjAyLjAlMjBvciUyMGhpZ2hlciUyMGluc3RhbGxlZCUwQXBpcGVsaW5lLmVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbigpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyZWxkZW4lMjByaW5nJTIwc3R5bGUlMjBjYXN0bGUlMjIlMjAlMjMlMjBpbmNsdWRlJTIwdGhlJTIwdG9rZW4lMjAlMjJlbGRlbiUyMHJpbmclMjBzdHlsZSUyMiUyMGluJTIwdGhlJTIwcHJvbXB0JTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwJTIyYmFkJTIwYXJjaGl0ZWN0dXJlJTJDJTIwZGVmb3JtZWQlMkMlMjBkaXNmaWd1cmVkJTJDJTIwcG9vciUyMGRldGFpbHMlMjIlMEElMEFpbWFnZV9lbGRlbl9yaW5nJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTIwaW1hZ2UlM0RpbWFnZSkuaW1hZ2VzJTVCMCU1RCUwQW1ha2VfaW1hZ2VfZ3JpZCglNUJpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUyQyUyMGltYWdlJTJDJTIwaW1hZ2VfZWxkZW5fcmluZyU1RCUyQyUyMHJvd3MlM0QyJTJDJTIwY29scyUzRDIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForImage2Image

pipeline = AutoPipelineForImage2Image.from_pretrained(
    <span class="hljs-string">&quot;nitrosocke/elden-ring-diffusion&quot;</span>, torch_dtype=torch.float16,
)
pipeline.enable_model_cpu_offload()
<span class="hljs-comment"># remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed</span>
pipeline.enable_xformers_memory_efficient_attention()

prompt = <span class="hljs-string">&quot;elden ring style castle&quot;</span> <span class="hljs-comment"># include the token &quot;elden ring style&quot; in the prompt</span>
negative_prompt = <span class="hljs-string">&quot;bad architecture, deformed, disfigured, poor details&quot;</span>

image_elden_ring = pipeline(prompt, negative_prompt=negative_prompt, image=image).images[<span class="hljs-number">0</span>]
make_image_grid([init_image, mask_image, image, image_elden_ring], rows=<span class="hljs-number">2</span>, cols=<span class="hljs-number">2</span>)`,wrap:!1}}),ra=new T({props:{title:"Optimize",local:"optimize",headingTag:"h2"}}),ga=new b({props:{code:"JTJCJTIwcGlwZWxpbmUuZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uKCklMEElMkIlMjBwaXBlbGluZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKQ==",highlighted:`<span class="hljs-addition">+ pipeline.enable_xformers_memory_efficient_attention()</span>
<span class="hljs-addition">+ pipeline.enable_model_cpu_offload()</span>`,wrap:!1}}),Ma=new b({props:{code:"cGlwZWxpbmUudW5ldCUyMCUzRCUyMHRvcmNoLmNvbXBpbGUocGlwZWxpbmUudW5ldCUyQyUyMG1vZGUlM0QlMjJyZWR1Y2Utb3ZlcmhlYWQlMjIlMkMlMjBmdWxsZ3JhcGglM0RUcnVlKQ==",highlighted:'pipeline.unet = torch.<span class="hljs-built_in">compile</span>(pipeline.unet, mode=<span class="hljs-string">&quot;reduce-overhead&quot;</span>, fullgraph=<span class="hljs-literal">True</span>)',wrap:!1}}),{c(){i=m("meta"),f=n(),p=m("p"),J=n(),c(y.$$.fragment),Z=n(),c(U.$$.fragment),j=n(),H=m("p"),H.textContent=dt,Ja=n(),z=m("p"),z.textContent=gt,ba=n(),E=m("ol"),E.innerHTML=ut,Za=n(),c(L.$$.fragment),Wa=n(),c(k.$$.fragment),wa=n(),B=m("ol"),B.innerHTML=Mt,Ta=n(),c(q.$$.fragment),Ua=n(),I=m("ol"),I.innerHTML=ht,ja=n(),c(A.$$.fragment),Ga=n(),v=m("div"),v.innerHTML=yt,ka=n(),c(D.$$.fragment),Ba=n(),P=m("p"),P.textContent=ft,Ia=n(),K=m("p"),K.innerHTML=Jt,va=n(),G=m("iframe"),Xa=n(),c(O.$$.fragment),_a=n(),ee=m("p"),ee.innerHTML=Zt,Ya=n(),c(ae.$$.fragment),Fa=n(),le=m("p"),le.textContent=Wt,Va=n(),c(te.$$.fragment),Ra=n(),c(ne.$$.fragment),xa=n(),se=m("p"),se.innerHTML=wt,$a=n(),c(ie.$$.fragment),Na=n(),c(pe.$$.fragment),Qa=n(),me=m("p"),me.innerHTML=Tt,Ca=n(),c(oe.$$.fragment),Sa=n(),X=m("div"),X.innerHTML=Ut,Ha=n(),c(re.$$.fragment),za=n(),ce=m("p"),ce.innerHTML=jt,Ea=n(),de=m("p"),de.textContent=Gt,La=n(),c(_.$$.fragment),qa=n(),Y=m("div"),Y.innerHTML=kt,Aa=n(),ge=m("p"),ge.textContent=Bt,Da=n(),c(F.$$.fragment),Pa=n(),V=m("div"),V.innerHTML=It,Ka=n(),ue=m("p"),ue.textContent=vt,Oa=n(),Me=m("p"),Me.textContent=Xt,el=n(),c(he.$$.fragment),al=n(),c(ye.$$.fragment),ll=n(),fe=m("p"),fe.textContent=_t,tl=n(),c(Je.$$.fragment),nl=n(),be=m("p"),be.innerHTML=Yt,sl=n(),Ze=m("ul"),Ze.innerHTML=Ft,il=n(),c(We.$$.fragment),pl=n(),R=m("div"),R.innerHTML=Vt,ml=n(),c(we.$$.fragment),ol=n(),Te=m("p"),Te.innerHTML=Rt,rl=n(),Ue=m("ul"),Ue.innerHTML=xt,cl=n(),je=m("p"),je.innerHTML=$t,dl=n(),c(Ge.$$.fragment),gl=n(),x=m("div"),x.innerHTML=Nt,ul=n(),c(ke.$$.fragment),Ml=n(),Be=m("p"),Be.textContent=Qt,hl=n(),c(Ie.$$.fragment),yl=n(),$=m("div"),$.innerHTML=Ct,fl=n(),c(ve.$$.fragment),Jl=n(),Xe=m("p"),Xe.innerHTML=St,bl=n(),c(_e.$$.fragment),Zl=n(),Ye=m("p"),Ye.textContent=Ht,Wl=n(),Fe=m("p"),Fe.textContent=zt,wl=n(),c(Ve.$$.fragment),Tl=n(),Re=m("p"),Re.textContent=Et,Ul=n(),c(xe.$$.fragment),jl=n(),$e=m("p"),$e.textContent=Lt,Gl=n(),c(Ne.$$.fragment),kl=n(),N=m("div"),N.innerHTML=qt,Bl=n(),c(Qe.$$.fragment),Il=n(),Ce=m("p"),Ce.textContent=At,vl=n(),Se=m("p"),Se.textContent=Dt,Xl=n(),c(He.$$.fragment),_l=n(),ze=m("p"),ze.textContent=Pt,Yl=n(),c(Ee.$$.fragment),Fl=n(),c(Q.$$.fragment),Vl=n(),Le=m("p"),Le.innerHTML=Kt,Rl=n(),c(qe.$$.fragment),xl=n(),C=m("div"),C.innerHTML=Ot,$l=n(),Ae=m("p"),Ae.textContent=en,Nl=n(),c(De.$$.fragment),Ql=n(),Pe=m("p"),Pe.innerHTML=an,Cl=n(),c(Ke.$$.fragment),Sl=n(),Oe=m("p"),Oe.innerHTML=ln,Hl=n(),ea=m("p"),ea.innerHTML=tn,zl=n(),c(aa.$$.fragment),El=n(),c(la.$$.fragment),Ll=n(),ta=m("p"),ta.textContent=nn,ql=n(),na=m("p"),na.textContent=sn,Al=n(),c(sa.$$.fragment),Dl=n(),ia=m("p"),ia.textContent=pn,Pl=n(),c(pa.$$.fragment),Kl=n(),ma=m("p"),ma.innerHTML=mn,Ol=n(),c(oa.$$.fragment),et=n(),S=m("div"),S.innerHTML=on,at=n(),c(ra.$$.fragment),lt=n(),ca=m("p"),ca.innerHTML=rn,tt=n(),da=m("p"),da.textContent=cn,nt=n(),c(ga.$$.fragment),st=n(),ua=m("p"),ua.innerHTML=dn,it=n(),c(Ma.$$.fragment),pt=n(),ha=m("p"),ha.innerHTML=gn,mt=n(),fa=m("p"),this.h()},l(e){const a=Un("svelte-u9bgzb",document.head);i=o(a,"META",{name:!0,content:!0}),a.forEach(l),f=s(e),p=o(e,"P",{}),ct(p).forEach(l),J=s(e),d(y.$$.fragment,e),Z=s(e),d(U.$$.fragment,e),j=s(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1vjeoqc"&&(H.textContent=dt),Ja=s(e),z=o(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-1t7j32f"&&(z.textContent=gt),ba=s(e),E=o(e,"OL",{"data-svelte-h":!0}),r(E)!=="svelte-1fn07c4"&&(E.innerHTML=ut),Za=s(e),d(L.$$.fragment,e),Wa=s(e),d(k.$$.fragment,e),wa=s(e),B=o(e,"OL",{start:!0,"data-svelte-h":!0}),r(B)!=="svelte-1jtpcib"&&(B.innerHTML=Mt),Ta=s(e),d(q.$$.fragment,e),Ua=s(e),I=o(e,"OL",{start:!0,"data-svelte-h":!0}),r(I)!=="svelte-1przvba"&&(I.innerHTML=ht),ja=s(e),d(A.$$.fragment,e),Ga=s(e),v=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(v)!=="svelte-72kdzo"&&(v.innerHTML=yt),ka=s(e),d(D.$$.fragment,e),Ba=s(e),P=o(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-ic55ez"&&(P.textContent=ft),Ia=s(e),K=o(e,"P",{"data-svelte-h":!0}),r(K)!=="svelte-87gmw5"&&(K.innerHTML=Jt),va=s(e),G=o(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),ct(G).forEach(l),Xa=s(e),d(O.$$.fragment,e),_a=s(e),ee=o(e,"P",{"data-svelte-h":!0}),r(ee)!=="svelte-5vkfn3"&&(ee.innerHTML=Zt),Ya=s(e),d(ae.$$.fragment,e),Fa=s(e),le=o(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-siyv04"&&(le.textContent=Wt),Va=s(e),d(te.$$.fragment,e),Ra=s(e),d(ne.$$.fragment,e),xa=s(e),se=o(e,"P",{"data-svelte-h":!0}),r(se)!=="svelte-1grw9dr"&&(se.innerHTML=wt),$a=s(e),d(ie.$$.fragment,e),Na=s(e),d(pe.$$.fragment,e),Qa=s(e),me=o(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-19inqtq"&&(me.innerHTML=Tt),Ca=s(e),d(oe.$$.fragment,e),Sa=s(e),X=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(X)!=="svelte-xc2o0t"&&(X.innerHTML=Ut),Ha=s(e),d(re.$$.fragment,e),za=s(e),ce=o(e,"P",{"data-svelte-h":!0}),r(ce)!=="svelte-3ddggj"&&(ce.innerHTML=jt),Ea=s(e),de=o(e,"P",{"data-svelte-h":!0}),r(de)!=="svelte-wgq5zt"&&(de.textContent=Gt),La=s(e),d(_.$$.fragment,e),qa=s(e),Y=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(Y)!=="svelte-8vd7az"&&(Y.innerHTML=kt),Aa=s(e),ge=o(e,"P",{"data-svelte-h":!0}),r(ge)!=="svelte-2plak"&&(ge.textContent=Bt),Da=s(e),d(F.$$.fragment,e),Pa=s(e),V=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(V)!=="svelte-ybt947"&&(V.innerHTML=It),Ka=s(e),ue=o(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-duydyd"&&(ue.textContent=vt),Oa=s(e),Me=o(e,"P",{"data-svelte-h":!0}),r(Me)!=="svelte-i9dpe4"&&(Me.textContent=Xt),el=s(e),d(he.$$.fragment,e),al=s(e),d(ye.$$.fragment,e),ll=s(e),fe=o(e,"P",{"data-svelte-h":!0}),r(fe)!=="svelte-13ocbdc"&&(fe.textContent=_t),tl=s(e),d(Je.$$.fragment,e),nl=s(e),be=o(e,"P",{"data-svelte-h":!0}),r(be)!=="svelte-qcb5md"&&(be.innerHTML=Yt),sl=s(e),Ze=o(e,"UL",{"data-svelte-h":!0}),r(Ze)!=="svelte-vvcg88"&&(Ze.innerHTML=Ft),il=s(e),d(We.$$.fragment,e),pl=s(e),R=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(R)!=="svelte-1vmqp5s"&&(R.innerHTML=Vt),ml=s(e),d(we.$$.fragment,e),ol=s(e),Te=o(e,"P",{"data-svelte-h":!0}),r(Te)!=="svelte-zcb81p"&&(Te.innerHTML=Rt),rl=s(e),Ue=o(e,"UL",{"data-svelte-h":!0}),r(Ue)!=="svelte-cnggx4"&&(Ue.innerHTML=xt),cl=s(e),je=o(e,"P",{"data-svelte-h":!0}),r(je)!=="svelte-196id8d"&&(je.innerHTML=$t),dl=s(e),d(Ge.$$.fragment,e),gl=s(e),x=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(x)!=="svelte-1cwhpu7"&&(x.innerHTML=Nt),ul=s(e),d(ke.$$.fragment,e),Ml=s(e),Be=o(e,"P",{"data-svelte-h":!0}),r(Be)!=="svelte-1ru9kar"&&(Be.textContent=Qt),hl=s(e),d(Ie.$$.fragment,e),yl=s(e),$=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r($)!=="svelte-15bd4ta"&&($.innerHTML=Ct),fl=s(e),d(ve.$$.fragment,e),Jl=s(e),Xe=o(e,"P",{"data-svelte-h":!0}),r(Xe)!=="svelte-r6qkkm"&&(Xe.innerHTML=St),bl=s(e),d(_e.$$.fragment,e),Zl=s(e),Ye=o(e,"P",{"data-svelte-h":!0}),r(Ye)!=="svelte-1uqw6jr"&&(Ye.textContent=Ht),Wl=s(e),Fe=o(e,"P",{"data-svelte-h":!0}),r(Fe)!=="svelte-1kzp8f0"&&(Fe.textContent=zt),wl=s(e),d(Ve.$$.fragment,e),Tl=s(e),Re=o(e,"P",{"data-svelte-h":!0}),r(Re)!=="svelte-yqefj6"&&(Re.textContent=Et),Ul=s(e),d(xe.$$.fragment,e),jl=s(e),$e=o(e,"P",{"data-svelte-h":!0}),r($e)!=="svelte-ua49j1"&&($e.textContent=Lt),Gl=s(e),d(Ne.$$.fragment,e),kl=s(e),N=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(N)!=="svelte-15ens2s"&&(N.innerHTML=qt),Bl=s(e),d(Qe.$$.fragment,e),Il=s(e),Ce=o(e,"P",{"data-svelte-h":!0}),r(Ce)!=="svelte-16qmg1v"&&(Ce.textContent=At),vl=s(e),Se=o(e,"P",{"data-svelte-h":!0}),r(Se)!=="svelte-1du3njh"&&(Se.textContent=Dt),Xl=s(e),d(He.$$.fragment,e),_l=s(e),ze=o(e,"P",{"data-svelte-h":!0}),r(ze)!=="svelte-j4alid"&&(ze.textContent=Pt),Yl=s(e),d(Ee.$$.fragment,e),Fl=s(e),d(Q.$$.fragment,e),Vl=s(e),Le=o(e,"P",{"data-svelte-h":!0}),r(Le)!=="svelte-2t52xe"&&(Le.innerHTML=Kt),Rl=s(e),d(qe.$$.fragment,e),xl=s(e),C=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(C)!=="svelte-1lbnv8n"&&(C.innerHTML=Ot),$l=s(e),Ae=o(e,"P",{"data-svelte-h":!0}),r(Ae)!=="svelte-1fd5b22"&&(Ae.textContent=en),Nl=s(e),d(De.$$.fragment,e),Ql=s(e),Pe=o(e,"P",{"data-svelte-h":!0}),r(Pe)!=="svelte-1gc804h"&&(Pe.innerHTML=an),Cl=s(e),d(Ke.$$.fragment,e),Sl=s(e),Oe=o(e,"P",{"data-svelte-h":!0}),r(Oe)!=="svelte-6zcpc0"&&(Oe.innerHTML=ln),Hl=s(e),ea=o(e,"P",{"data-svelte-h":!0}),r(ea)!=="svelte-1ar98vz"&&(ea.innerHTML=tn),zl=s(e),d(aa.$$.fragment,e),El=s(e),d(la.$$.fragment,e),Ll=s(e),ta=o(e,"P",{"data-svelte-h":!0}),r(ta)!=="svelte-3rypf9"&&(ta.textContent=nn),ql=s(e),na=o(e,"P",{"data-svelte-h":!0}),r(na)!=="svelte-1x7ee8u"&&(na.textContent=sn),Al=s(e),d(sa.$$.fragment,e),Dl=s(e),ia=o(e,"P",{"data-svelte-h":!0}),r(ia)!=="svelte-db3ja"&&(ia.textContent=pn),Pl=s(e),d(pa.$$.fragment,e),Kl=s(e),ma=o(e,"P",{"data-svelte-h":!0}),r(ma)!=="svelte-iaoixt"&&(ma.innerHTML=mn),Ol=s(e),d(oa.$$.fragment,e),et=s(e),S=o(e,"DIV",{class:!0,"data-svelte-h":!0}),r(S)!=="svelte-9rfwwm"&&(S.innerHTML=on),at=s(e),d(ra.$$.fragment,e),lt=s(e),ca=o(e,"P",{"data-svelte-h":!0}),r(ca)!=="svelte-1f04pnr"&&(ca.innerHTML=rn),tt=s(e),da=o(e,"P",{"data-svelte-h":!0}),r(da)!=="svelte-1eqbc05"&&(da.textContent=cn),nt=s(e),d(ga.$$.fragment,e),st=s(e),ua=o(e,"P",{"data-svelte-h":!0}),r(ua)!=="svelte-c3yozi"&&(ua.innerHTML=dn),it=s(e),d(Ma.$$.fragment,e),pt=s(e),ha=o(e,"P",{"data-svelte-h":!0}),r(ha)!=="svelte-ve8eie"&&(ha.innerHTML=gn),mt=s(e),fa=o(e,"P",{}),ct(fa).forEach(l),this.h()},h(){w(i,"name","hf:doc:metadata"),w(i,"content",Rn),w(B,"start","2"),w(I,"start","3"),w(v,"class","flex gap-4"),Zn(G.src,bt="https://stevhliu-inpaint-mask-maker.hf.space")||w(G,"src",bt),w(G,"frameborder","0"),w(G,"width","850"),w(G,"height","450"),w(X,"class","flex flex-row gap-4"),w(Y,"class","flex gap-4"),w(V,"class","flex gap-4"),w(R,"class","flex flex-row gap-4"),w(x,"class","flex flex-row gap-4"),w($,"class","flex justify-center"),w(N,"class","flex flex-row gap-4"),w(C,"class","flex flex-row gap-4"),w(S,"class","flex flex-row gap-4")},m(e,a){jn(document.head,i),t(e,f,a),t(e,p,a),t(e,J,a),g(y,e,a),t(e,Z,a),g(U,e,a),t(e,j,a),t(e,H,a),t(e,Ja,a),t(e,z,a),t(e,ba,a),t(e,E,a),t(e,Za,a),g(L,e,a),t(e,Wa,a),g(k,e,a),t(e,wa,a),t(e,B,a),t(e,Ta,a),g(q,e,a),t(e,Ua,a),t(e,I,a),t(e,ja,a),g(A,e,a),t(e,Ga,a),t(e,v,a),t(e,ka,a),g(D,e,a),t(e,Ba,a),t(e,P,a),t(e,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a),t(e,_l,a),t(e,ze,a),t(e,Yl,a),g(Ee,e,a),t(e,Fl,a),g(Q,e,a),t(e,Vl,a),t(e,Le,a),t(e,Rl,a),g(qe,e,a),t(e,xl,a),t(e,C,a),t(e,$l,a),t(e,Ae,a),t(e,Nl,a),g(De,e,a),t(e,Ql,a),t(e,Pe,a),t(e,Cl,a),g(Ke,e,a),t(e,Sl,a),t(e,Oe,a),t(e,Hl,a),t(e,ea,a),t(e,zl,a),g(aa,e,a),t(e,El,a),g(la,e,a),t(e,Ll,a),t(e,ta,a),t(e,ql,a),t(e,na,a),t(e,Al,a),g(sa,e,a),t(e,Dl,a),t(e,ia,a),t(e,Pl,a),g(pa,e,a),t(e,Kl,a),t(e,ma,a),t(e,Ol,a),g(oa,e,a),t(e,et,a),t(e,S,a),t(e,at,a),g(ra,e,a),t(e,lt,a),t(e,ca,a),t(e,tt,a),t(e,da,a),t(e,nt,a),g(ga,e,a),t(e,st,a),t(e,ua,a),t(e,it,a),g(Ma,e,a),t(e,pt,a),t(e,ha,a),t(e,mt,a),t(e,fa,a),ot=!0},p(e,[a]){const un={};a&2&&(un.$$scope={dirty:a,ctx:e}),k.$set(un);const Mn={};a&2&&(Mn.$$scope={dirty:a,ctx:e}),_.$set(Mn);const hn={};a&2&&(hn.$$scope={dirty:a,ctx:e}),F.$set(hn);const yn={};a&2&&(yn.$$scope={dirty:a,ctx:e}),Q.$set(yn)},i(e){ot||(u(y.$$.fragment,e),u(U.$$.fragment,e),u(L.$$.fragment,e),u(k.$$.fragment,e),u(q.$$.fragment,e),u(A.$$.fragment,e),u(D.$$.fragment,e),u(O.$$.fragment,e),u(ae.$$.fragment,e),u(te.$$.fragment,e),u(ne.$$.fragment,e),u(ie.$$.fragment,e),u(pe.$$.fragment,e),u(oe.$$.fragment,e),u(re.$$.fragment,e),u(_.$$.fragment,e),u(F.$$.fragment,e),u(he.$$.fragment,e),u(ye.$$.fragment,e),u(Je.$$.fragment,e),u(We.$$.fragment,e),u(we.$$.fragment,e),u(Ge.$$.fragment,e),u(ke.$$.fragment,e),u(Ie.$$.fragment,e),u(ve.$$.fragment,e),u(_e.$$.fragment,e),u(Ve.$$.fragment,e),u(xe.$$.fragment,e),u(Ne.$$.fragment,e),u(Qe.$$.fragment,e),u(He.$$.fragment,e),u(Ee.$$.fragment,e),u(Q.$$.fragment,e),u(qe.$$.fragment,e),u(De.$$.fragment,e),u(Ke.$$.fragment,e),u(aa.$$.fragment,e),u(la.$$.fragment,e),u(sa.$$.fragment,e),u(pa.$$.fragment,e),u(oa.$$.fragment,e),u(ra.$$.fragment,e),u(ga.$$.fragment,e),u(Ma.$$.fragment,e),ot=!0)},o(e){M(y.$$.fragment,e),M(U.$$.fragment,e),M(L.$$.fragment,e),M(k.$$.fragment,e),M(q.$$.fragment,e),M(A.$$.fragment,e),M(D.$$.fragment,e),M(O.$$.fragment,e),M(ae.$$.fragment,e),M(te.$$.fragment,e),M(ne.$$.fragment,e),M(ie.$$.fragment,e),M(pe.$$.fragment,e),M(oe.$$.fragment,e),M(re.$$.fragment,e),M(_.$$.fragment,e),M(F.$$.fragment,e),M(he.$$.fragment,e),M(ye.$$.fragment,e),M(Je.$$.fragment,e),M(We.$$.fragment,e),M(we.$$.fragment,e),M(Ge.$$.fragment,e),M(ke.$$.fragment,e),M(Ie.$$.fragment,e),M(ve.$$.fragment,e),M(_e.$$.fragment,e),M(Ve.$$.fragment,e),M(xe.$$.fragment,e),M(Ne.$$.fragment,e),M(Qe.$$.fragment,e),M(He.$$.fragment,e),M(Ee.$$.fragment,e),M(Q.$$.fragment,e),M(qe.$$.fragment,e),M(De.$$.fragment,e),M(Ke.$$.fragment,e),M(aa.$$.fragment,e),M(la.$$.fragment,e),M(sa.$$.fragment,e),M(pa.$$.fragment,e),M(oa.$$.fragment,e),M(ra.$$.fragment,e),M(ga.$$.fragment,e),M(Ma.$$.fragment,e),ot=!1},d(e){e&&(l(f),l(p),l(J),l(Z),l(j),l(H),l(Ja),l(z),l(ba),l(E),l(Za),l(Wa),l(wa),l(B),l(Ta),l(Ua),l(I),l(ja),l(Ga),l(v),l(ka),l(Ba),l(P),l(Ia),l(K),l(va),l(G),l(Xa),l(_a),l(ee),l(Ya),l(Fa),l(le),l(Va),l(Ra),l(xa),l(se),l($a),l(Na),l(Qa),l(me),l(Ca),l(Sa),l(X),l(Ha),l(za),l(ce),l(Ea),l(de),l(La),l(qa),l(Y),l(Aa),l(ge),l(Da),l(Pa),l(V),l(Ka),l(ue),l(Oa),l(Me),l(el),l(al),l(ll),l(fe),l(tl),l(nl),l(be),l(sl),l(Ze),l(il),l(pl),l(R),l(ml),l(ol),l(Te),l(rl),l(Ue),l(cl),l(je),l(dl),l(gl),l(x),l(ul),l(Ml),l(Be),l(hl),l(yl),l($),l(fl),l(Jl),l(Xe),l(bl),l(Zl),l(Ye),l(Wl),l(Fe),l(wl),l(Tl),l(Re),l(Ul),l(jl),l($e),l(Gl),l(kl),l(N),l(Bl),l(Il),l(Ce),l(vl),l(Se),l(Xl),l(_l),l(ze),l(Yl),l(Fl),l(Vl),l(Le),l(Rl),l(xl),l(C),l($l),l(Ae),l(Nl),l(Ql),l(Pe),l(Cl),l(Sl),l(Oe),l(Hl),l(ea),l(zl),l(El),l(Ll),l(ta),l(ql),l(na),l(Al),l(Dl),l(ia),l(Pl),l(Kl),l(ma),l(Ol),l(et),l(S),l(at),l(lt),l(ca),l(tt),l(da),l(nt),l(st),l(ua),l(it),l(pt),l(ha),l(mt),l(fa)),l(i),h(y,e),h(U,e),h(L,e),h(k,e),h(q,e),h(A,e),h(D,e),h(O,e),h(ae,e),h(te,e),h(ne,e),h(ie,e),h(pe,e),h(oe,e),h(re,e),h(_,e),h(F,e),h(he,e),h(ye,e),h(Je,e),h(We,e),h(we,e),h(Ge,e),h(ke,e),h(Ie,e),h(ve,e),h(_e,e),h(Ve,e),h(xe,e),h(Ne,e),h(Qe,e),h(He,e),h(Ee,e),h(Q,e),h(qe,e),h(De,e),h(Ke,e),h(aa,e),h(la,e),h(sa,e),h(pa,e),h(oa,e),h(ra,e),h(ga,e),h(Ma,e)}}}const Rn='{"title":"Inpainting","local":"inpainting","sections":[{"title":"Create a mask image","local":"create-a-mask-image","sections":[],"depth":2},{"title":"Popular models","local":"popular-models","sections":[{"title":"Stable Diffusion Inpainting","local":"stable-diffusion-inpainting","sections":[],"depth":3},{"title":"Stable Diffusion XL (SDXL) Inpainting","local":"stable-diffusion-xl-sdxl-inpainting","sections":[],"depth":3},{"title":"Kandinsky 2.2 Inpainting","local":"kandinsky-22-inpainting","sections":[],"depth":3}],"depth":2},{"title":"Non-inpaint specific checkpoints","local":"non-inpaint-specific-checkpoints","sections":[],"depth":2},{"title":"Configure pipeline parameters","local":"configure-pipeline-parameters","sections":[{"title":"Strength","local":"strength","sections":[],"depth":3},{"title":"Guidance scale","local":"guidance-scale","sections":[],"depth":3},{"title":"Negative prompt","local":"negative-prompt","sections":[],"depth":3}],"depth":2},{"title":"Chained inpainting pipelines","local":"chained-inpainting-pipelines","sections":[{"title":"Text-to-image-to-inpaint","local":"text-to-image-to-inpaint","sections":[],"depth":3},{"title":"Inpaint-to-image-to-image","local":"inpaint-to-image-to-image","sections":[],"depth":3}],"depth":2},{"title":"Control image generation","local":"control-image-generation","sections":[{"title":"Prompt weighting","local":"prompt-weighting","sections":[],"depth":3},{"title":"ControlNet","local":"controlnet","sections":[],"depth":3}],"depth":2},{"title":"Optimize","local":"optimize","sections":[],"depth":2}],"depth":1}';function xn(W){return Wn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class En extends wn{constructor(i){super(),Tn(this,i,xn,Vn,bn,{})}}export{En as component};
