import{S as st,i as nt,s as lt,e as s,k as p,w as v,t as h,M as it,c as n,d as a,m,a as i,x as j,h as c,b as r,N as Qe,G as t,g as o,y as G,q as B,o as E,B as X,v as rt}from"../../chunks/vendor-hf-doc-builder.js";import{T as ot}from"../../chunks/Tip-hf-doc-builder.js";import{I as tt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as De}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as pt}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function mt(Me){let u,M;return{c(){u=s("p"),M=h("A previous experimental implementation of inpainting used a different, lower-quality process. To ensure backwards compatibility, loading a pretrained pipeline that doesn\u2019t contain the new model will still apply the old inpainting method.")},l(d){u=n(d,"P",{});var f=i(u);M=c(f,"A previous experimental implementation of inpainting used a different, lower-quality process. To ensure backwards compatibility, loading a pretrained pipeline that doesn\u2019t contain the new model will still apply the old inpainting method."),f.forEach(a)},m(d,f){o(d,u,f),t(u,M)},d(d){d&&a(u)}}}function ht(Me){let u,M,d,f,pe,F,xe,me,ze,Ue,S,Te,g,He,H,Ae,qe,V,he,Pe,Ke,_e,U,Le,A,Oe,ea,We,Y,ke,q,aa,Ze,C,Ie,P,ta,ve,R,je,T,ce,y,K,ue,sa,na,L,de,la,ia,O,fe,ra,oa,ee,pa,ma,ye,b,ae,N,Ua,ha,te,$,Ta,ca,se,be,ge,ua,da,ne,Q,_a,Ge,_,Be,le,fa,Ee,w,Wa,Xe,J,W,we,D,ya,Je,ba,Fe,k,ga,ie,wa,Ja,Se,x,Ve,re,Ma,Ye;return F=new tt({}),S=new pt({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"}]}}),Y=new De({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uSW5wYWludFBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbnBhaW50UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi1pbnBhaW50aW5nJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBJTIwJTIwJTIwJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHZhcmlhbnQlM0QlMjJmcDE2JTIyJTJDJTBBKSUwQXBpcGVsaW5lJTIwJTNEJTIwcGlwZWxpbmUudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">import</span> PIL
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionInpaintPipeline

pipeline = StableDiffusionInpaintPipeline.from_pretrained(
    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>,
    torch_dtype=torch.float16,
    use_safetensors=<span class="hljs-literal">True</span>,
    variant=<span class="hljs-string">&quot;fp16&quot;</span>,
)
pipeline = pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)`}}),C=new De({props:{code:"ZGVmJTIwZG93bmxvYWRfaW1hZ2UodXJsKSUzQSUwQSUyMCUyMCUyMCUyMHJlc3BvbnNlJTIwJTNEJTIwcmVxdWVzdHMuZ2V0KHVybCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBQSUwuSW1hZ2Uub3BlbihCeXRlc0lPKHJlc3BvbnNlLmNvbnRlbnQpKS5jb252ZXJ0KCUyMlJHQiUyMiklMEElMEElMEFpbWdfdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGQ29tcFZpcyUyRmxhdGVudC1kaWZmdXNpb24lMkZtYWluJTJGZGF0YSUyRmlucGFpbnRpbmdfZXhhbXBsZXMlMkZvdmVydHVyZS1jcmVhdGlvbnMtNXNJNmZRZ1lJdW8ucG5nJTIyJTBBbWFza191cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZDb21wVmlzJTJGbGF0ZW50LWRpZmZ1c2lvbiUyRm1haW4lMkZkYXRhJTJGaW5wYWludGluZ19leGFtcGxlcyUyRm92ZXJ0dXJlLWNyZWF0aW9ucy01c0k2ZlFnWUl1b19tYXNrLnBuZyUyMiUwQSUwQWluaXRfaW1hZ2UlMjAlM0QlMjBkb3dubG9hZF9pbWFnZShpbWdfdXJsKS5yZXNpemUoKDUxMiUyQyUyMDUxMikpJTBBbWFza19pbWFnZSUyMCUzRCUyMGRvd25sb2FkX2ltYWdlKG1hc2tfdXJsKS5yZXNpemUoKDUxMiUyQyUyMDUxMikp",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
    response = requests.get(url)
    <span class="hljs-keyword">return</span> PIL.Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)


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 = download_image(img_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
mask_image = download_image(mask_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))`}}),R=new De({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyRmFjZSUyMG9mJTIwYSUyMHllbGxvdyUyMGNhdCUyQyUyMGhpZ2glMjByZXNvbHV0aW9uJTJDJTIwc2l0dGluZyUyMG9uJTIwYSUyMHBhcmslMjBiZW5jaCUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UpLmltYWdlcyU1QjAlNUQ=",highlighted:`prompt = <span class="hljs-string">&quot;Face of a yellow cat, high resolution, sitting on a park bench&quot;</span>
image = pipeline(prompt=prompt, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]`}}),_=new ot({props:{warning:!0,$$slots:{default:[mt]},$$scope:{ctx:Me}}}),D=new tt({}),x=new De({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uSW5wYWludFBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1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TIwMC41JTVEJTIwJTNEJTIwMSUwQSUwQSUyMyUyMFRha2UlMjB0aGUlMjBtYXNrZWQlMjBwaXhlbHMlMjBmcm9tJTIwdGhlJTIwcmVwYWludGVkJTIwaW1hZ2UlMjBhbmQlMjB0aGUlMjB1bm1hc2tlZCUyMHBpeGVscyUyMGZyb20lMjB0aGUlMjBpbml0aWFsJTIwaW1hZ2UlMEF1bm1hc2tlZF91bmNoYW5nZWRfaW1hZ2VfYXJyJTIwJTNEJTIwKDElMjAtJTIwbWFza19pbWFnZV9hcnIpJTIwKiUyMGluaXRfaW1hZ2UlMjAlMkIlMjBtYXNrX2ltYWdlX2FyciUyMColMjByZXBhaW50ZWRfaW1hZ2UlMEF1bm1hc2tlZF91bmNoYW5nZWRfaW1hZ2UlMjAlM0QlMjBQSUwuSW1hZ2UuZnJvbWFycmF5KHVubWFza2VkX3VuY2hhbmdlZF9pbWFnZV9hcnIucm91bmQoKS5hc3R5cGUoJTIydWludDglMjIpKSUwQXVubWFza2VkX3VuY2hhbmdlZF9pbWFnZS5zYXZlKCUyMmZvcmNlX3VubWFza2VkX3VuY2hhbmdlZC5wbmclMjIp",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> StableDiffusionInpaintPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

device = <span class="hljs-string">&quot;cuda&quot;</span>
pipeline = StableDiffusionInpaintPipeline.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>)`}}),{c(){u=s("meta"),M=p(),d=s("h1"),f=s("a"),pe=s("span"),v(F.$$.fragment),xe=p(),me=s("span"),ze=h("Text-guided image-inpainting"),Ue=p(),v(S.$$.fragment),Te=p(),g=s("p"),He=h("The "),H=s("a"),Ae=h("StableDiffusionInpaintPipeline"),qe=h(" allows you to edit specific parts of an image by providing a mask and a text prompt. It uses a version of Stable Diffusion, like "),V=s("a"),he=s("code"),Pe=h("runwayml/stable-diffusion-inpainting"),Ke=h(" specifically trained for inpainting tasks."),_e=p(),U=s("p"),Le=h("Get started by loading an instance of the "),A=s("a"),Oe=h("StableDiffusionInpaintPipeline"),ea=h(":"),We=p(),v(Y.$$.fragment),ke=p(),q=s("p"),aa=h("Download an image and a mask of a dog which you\u2019ll eventually replace:"),Ze=p(),v(C.$$.fragment),Ie=p(),P=s("p"),ta=h("Now you can create a prompt to replace the mask with something else:"),ve=p(),v(R.$$.fragment),je=p(),T=s("table"),ce=s("thead"),y=s("tr"),K=s("th"),ue=s("code"),sa=h("image"),na=p(),L=s("th"),de=s("code"),la=h("mask_image"),ia=p(),O=s("th"),fe=s("code"),ra=h("prompt"),oa=p(),ee=s("th"),pa=h("output"),ma=p(),ye=s("tbody"),b=s("tr"),ae=s("td"),N=s("img"),ha=p(),te=s("td"),$=s("img"),ca=p(),se=s("td"),be=s("strong"),ge=s("em"),ua=h("Face of a yellow cat, high resolution, sitting on a park bench"),da=p(),ne=s("td"),Q=s("img"),Ge=p(),v(_.$$.fragment),Be=p(),le=s("p"),fa=h("Check out the Spaces below to try out image inpainting yourself!"),Ee=p(),w=s("iframe"),Xe=p(),J=s("h2"),W=s("a"),we=s("span"),v(D.$$.fragment),ya=p(),Je=s("span"),ba=h("Preserving the Unmasked Area of the Image"),Fe=p(),k=s("p"),ga=h("Generally speaking, "),ie=s("a"),wa=h("StableDiffusionInpaintPipeline"),Ja=h(" (and other inpainting pipelines) will change the unmasked part of the image as well. If this behavior is undesirable, you can force the unmasked area to remain the same as follows:"),Se=p(),v(x.$$.fragment),Ve=p(),re=s("p"),Ma=h("Forcing the unmasked portion of the image to remain the same might result in some weird transitions between the unmasked and masked areas, since the model will typically change the masked and unmasked areas to make the transition more natural."),this.h()},l(e){const l=it('[data-svelte="svelte-1phssyn"]',document.head);u=n(l,"META",{name:!0,content:!0}),l.forEach(a),M=m(e),d=n(e,"H1",{class:!0});var z=i(d);f=n(z,"A",{id:!0,class:!0,href:!0});var ka=i(f);pe=n(ka,"SPAN",{});var Za=i(pe);j(F.$$.fragment,Za),Za.forEach(a),ka.forEach(a),xe=m(z),me=n(z,"SPAN",{});var Ia=i(me);ze=c(Ia,"Text-guided image-inpainting"),Ia.forEach(a),z.forEach(a),Ue=m(e),j(S.$$.fragment,e),Te=m(e),g=n(e,"P",{});var oe=i(g);He=c(oe,"The "),H=n(oe,"A",{href:!0});var va=i(H);Ae=c(va,"StableDiffusionInpaintPipeline"),va.forEach(a),qe=c(oe," allows you to edit specific parts of an image by providing a mask and a text prompt. It uses a version of Stable Diffusion, like "),V=n(oe,"A",{href:!0,rel:!0});var ja=i(V);he=n(ja,"CODE",{});var Ga=i(he);Pe=c(Ga,"runwayml/stable-diffusion-inpainting"),Ga.forEach(a),ja.forEach(a),Ke=c(oe," specifically trained for inpainting tasks."),oe.forEach(a),_e=m(e),U=n(e,"P",{});var Ce=i(U);Le=c(Ce,"Get started by loading an instance of the "),A=n(Ce,"A",{href:!0});var Ba=i(A);Oe=c(Ba,"StableDiffusionInpaintPipeline"),Ba.forEach(a),ea=c(Ce,":"),Ce.forEach(a),We=m(e),j(Y.$$.fragment,e),ke=m(e),q=n(e,"P",{});var Ea=i(q);aa=c(Ea,"Download an image and a mask of a dog which you\u2019ll eventually replace:"),Ea.forEach(a),Ze=m(e),j(C.$$.fragment,e),Ie=m(e),P=n(e,"P",{});var Xa=i(P);ta=c(Xa,"Now you can create a prompt to replace the mask with something else:"),Xa.forEach(a),ve=m(e),j(R.$$.fragment,e),je=m(e),T=n(e,"TABLE",{});var Re=i(T);ce=n(Re,"THEAD",{});var Fa=i(ce);y=n(Fa,"TR",{});var Z=i(y);K=n(Z,"TH",{align:!0});var Sa=i(K);ue=n(Sa,"CODE",{});var Va=i(ue);sa=c(Va,"image"),Va.forEach(a),Sa.forEach(a),na=m(Z),L=n(Z,"TH",{align:!0});var Ya=i(L);de=n(Ya,"CODE",{});var Ca=i(de);la=c(Ca,"mask_image"),Ca.forEach(a),Ya.forEach(a),ia=m(Z),O=n(Z,"TH",{align:!0});var Ra=i(O);fe=n(Ra,"CODE",{});var Na=i(fe);ra=c(Na,"prompt"),Na.forEach(a),Ra.forEach(a),oa=m(Z),ee=n(Z,"TH",{align:!0});var $a=i(ee);pa=c($a,"output"),$a.forEach(a),Z.forEach(a),Fa.forEach(a),ma=m(Re),ye=n(Re,"TBODY",{});var Qa=i(ye);b=n(Qa,"TR",{});var I=i(b);ae=n(I,"TD",{align:!0});var Da=i(ae);N=n(Da,"IMG",{src:!0,alt:!0,width:!0}),Da.forEach(a),ha=m(I),te=n(I,"TD",{align:!0});var xa=i(te);$=n(xa,"IMG",{src:!0,alt:!0,width:!0}),xa.forEach(a),ca=m(I),se=n(I,"TD",{align:!0});var za=i(se);be=n(za,"STRONG",{});var Ha=i(be);ge=n(Ha,"EM",{});var Aa=i(ge);ua=c(Aa,"Face of a yellow cat, high resolution, sitting on a park bench"),Aa.forEach(a),Ha.forEach(a),za.forEach(a),da=m(I),ne=n(I,"TD",{align:!0});var qa=i(ne);Q=n(qa,"IMG",{src:!0,alt:!0,width:!0}),qa.forEach(a),I.forEach(a),Qa.forEach(a),Re.forEach(a),Ge=m(e),j(_.$$.fragment,e),Be=m(e),le=n(e,"P",{});var Pa=i(le);fa=c(Pa,"Check out the Spaces below to try out image inpainting yourself!"),Pa.forEach(a),Ee=m(e),w=n(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),i(w).forEach(a),Xe=m(e),J=n(e,"H2",{class:!0});var Ne=i(J);W=n(Ne,"A",{id:!0,class:!0,href:!0});var Ka=i(W);we=n(Ka,"SPAN",{});var La=i(we);j(D.$$.fragment,La),La.forEach(a),Ka.forEach(a),ya=m(Ne),Je=n(Ne,"SPAN",{});var Oa=i(Je);ba=c(Oa,"Preserving the Unmasked Area of the Image"),Oa.forEach(a),Ne.forEach(a),Fe=m(e),k=n(e,"P",{});var $e=i(k);ga=c($e,"Generally speaking, "),ie=n($e,"A",{href:!0});var et=i(ie);wa=c(et,"StableDiffusionInpaintPipeline"),et.forEach(a),Ja=c($e," (and other inpainting pipelines) will change the unmasked part of the image as well. If this behavior is undesirable, you can force the unmasked area to remain the same as follows:"),$e.forEach(a),Se=m(e),j(x.$$.fragment,e),Ve=m(e),re=n(e,"P",{});var at=i(re);Ma=c(at,"Forcing the unmasked portion of the image to remain the same might result in some weird transitions between the unmasked and masked areas, since the model will typically change the masked and unmasked areas to make the transition more natural."),at.forEach(a),this.h()},h(){r(u,"name","hf:doc:metadata"),r(u,"content",JSON.stringify(ct)),r(f,"id","textguided-imageinpainting"),r(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),r(f,"href","#textguided-imageinpainting"),r(d,"class","relative group"),r(H,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline"),r(V,"href","https://huggingface.co/runwayml/stable-diffusion-inpainting"),r(V,"rel","nofollow"),r(A,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline"),r(K,"align","center"),r(L,"align","center"),r(O,"align","center"),r(ee,"align","right"),Qe(N.src,Ua="https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png")||r(N,"src",Ua),r(N,"alt","drawing"),r(N,"width","250"),r(ae,"align","center"),Qe($.src,Ta="https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png")||r($,"src",Ta),r($,"alt","drawing"),r($,"width","250"),r(te,"align","center"),r(se,"align","center"),Qe(Q.src,_a="https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/in_paint/yellow_cat_sitting_on_a_park_bench.png")||r(Q,"src",_a),r(Q,"alt","drawing"),r(Q,"width","250"),r(ne,"align","right"),Qe(w.src,Wa="https://runwayml-stable-diffusion-inpainting.hf.space")||r(w,"src",Wa),r(w,"frameborder","0"),r(w,"width","850"),r(w,"height","500"),r(W,"id","preserving-the-unmasked-area-of-the-image"),r(W,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),r(W,"href","#preserving-the-unmasked-area-of-the-image"),r(J,"class","relative group"),r(ie,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline")},m(e,l){t(document.head,u),o(e,M,l),o(e,d,l),t(d,f),t(f,pe),G(F,pe,null),t(d,xe),t(d,me),t(me,ze),o(e,Ue,l),G(S,e,l),o(e,Te,l),o(e,g,l),t(g,He),t(g,H),t(H,Ae),t(g,qe),t(g,V),t(V,he),t(he,Pe),t(g,Ke),o(e,_e,l),o(e,U,l),t(U,Le),t(U,A),t(A,Oe),t(U,ea),o(e,We,l),G(Y,e,l),o(e,ke,l),o(e,q,l),t(q,aa),o(e,Ze,l),G(C,e,l),o(e,Ie,l),o(e,P,l),t(P,ta),o(e,ve,l),G(R,e,l),o(e,je,l),o(e,T,l),t(T,ce),t(ce,y),t(y,K),t(K,ue),t(ue,sa),t(y,na),t(y,L),t(L,de),t(de,la),t(y,ia),t(y,O),t(O,fe),t(fe,ra),t(y,oa),t(y,ee),t(ee,pa),t(T,ma),t(T,ye),t(ye,b),t(b,ae),t(ae,N),t(b,ha),t(b,te),t(te,$),t(b,ca),t(b,se),t(se,be),t(be,ge),t(ge,ua),t(b,da),t(b,ne),t(ne,Q),o(e,Ge,l),G(_,e,l),o(e,Be,l),o(e,le,l),t(le,fa),o(e,Ee,l),o(e,w,l),o(e,Xe,l),o(e,J,l),t(J,W),t(W,we),G(D,we,null),t(J,ya),t(J,Je),t(Je,ba),o(e,Fe,l),o(e,k,l),t(k,ga),t(k,ie),t(ie,wa),t(k,Ja),o(e,Se,l),G(x,e,l),o(e,Ve,l),o(e,re,l),t(re,Ma),Ye=!0},p(e,[l]){const z={};l&2&&(z.$$scope={dirty:l,ctx:e}),_.$set(z)},i(e){Ye||(B(F.$$.fragment,e),B(S.$$.fragment,e),B(Y.$$.fragment,e),B(C.$$.fragment,e),B(R.$$.fragment,e),B(_.$$.fragment,e),B(D.$$.fragment,e),B(x.$$.fragment,e),Ye=!0)},o(e){E(F.$$.fragment,e),E(S.$$.fragment,e),E(Y.$$.fragment,e),E(C.$$.fragment,e),E(R.$$.fragment,e),E(_.$$.fragment,e),E(D.$$.fragment,e),E(x.$$.fragment,e),Ye=!1},d(e){a(u),e&&a(M),e&&a(d),X(F),e&&a(Ue),X(S,e),e&&a(Te),e&&a(g),e&&a(_e),e&&a(U),e&&a(We),X(Y,e),e&&a(ke),e&&a(q),e&&a(Ze),X(C,e),e&&a(Ie),e&&a(P),e&&a(ve),X(R,e),e&&a(je),e&&a(T),e&&a(Ge),X(_,e),e&&a(Be),e&&a(le),e&&a(Ee),e&&a(w),e&&a(Xe),e&&a(J),X(D),e&&a(Fe),e&&a(k),e&&a(Se),X(x,e),e&&a(Ve),e&&a(re)}}}const ct={local:"textguided-imageinpainting",sections:[{local:"preserving-the-unmasked-area-of-the-image",title:"Preserving the Unmasked Area of the Image"}],title:"Text-guided image-inpainting"};function ut(Me){return rt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class wt extends st{constructor(u){super();nt(this,u,ut,ht,lt,{})}}export{wt as default,ct as metadata};
