import{S as Zn,i as ei,s as ti,e as i,k as p,w as I,t as o,M as ni,c as a,d as n,m as f,a as s,x as P,h as r,b as l,G as e,g as h,y as x,q as D,o as S,B as $,v as ii,L as ai}from"../../../../chunks/vendor-hf-doc-builder.js";import{D as ue}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as si}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Xn}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as oi}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function ri(Oe){let g,j,v,_,k;return _=new si({props:{code:`import PIL
import requests
import torch
from io import BytesIO

from diffusers import StableDiffusionInpaintPipeline


def download_image(url):
    response = requests.get(url)
    return PIL.Image.open(BytesIO(response.content)).convert("RGB")


img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"

init_image = download_image(img_url).resize((512, 512))
mask_image = download_image(mask_url).resize((512, 512))

pipe = StableDiffusionInpaintPipeline.from_pretrained(
    "runwayml/stable-diffusion-inpainting", torch_dtype=torch.float16
)
pipe = pipe.to("cuda")

prompt = "Face of a yellow cat, high resolution, sitting on a park bench"
image = pipe(prompt=prompt, image=init_image, mask_image=mask_image).images[0]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> PIL
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionInpaintPipeline


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
<span class="hljs-meta">... </span>    response = requests.get(url)
<span class="hljs-meta">... </span>    <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>)


<span class="hljs-meta">&gt;&gt;&gt; </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>
<span class="hljs-meta">&gt;&gt;&gt; </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>

<span class="hljs-meta">&gt;&gt;&gt; </span>init_image = download_image(img_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_image = download_image(mask_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionInpaintPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;runwayml/stable-diffusion-inpainting&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Face of a yellow cat, high resolution, sitting on a park bench&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt=prompt, image=init_image, mask_image=mask_image).images[<span class="hljs-number">0</span>]`}}),{c(){g=i("p"),j=o("Examples:"),v=p(),I(_.$$.fragment)},l(d){g=a(d,"P",{});var E=s(g);j=r(E,"Examples:"),E.forEach(n),v=f(d),P(_.$$.fragment,d)},m(d,E){h(d,g,E),e(g,j),h(d,v,E),x(_,d,E),k=!0},p:ai,i(d){k||(D(_.$$.fragment,d),k=!0)},o(d){S(_.$$.fragment,d),k=!1},d(d){d&&n(g),d&&n(v),$(_,d)}}}function li(Oe){let g,j,v,_,k,d,E,ye,ot,Ne,C,A,we,G,rt,Ie,lt,ze,b,pt,W,ft,dt,F,ct,ut,B,mt,ht,H,gt,_t,me,bt,vt,Ue,he,yt,Ve,q,K,Pe,wt,It,Q,Pt,xt,Y,xe,Dt,St,R,$t,Ge,ge,kt,We,M,J,De,Et,Lt,X,Tt,Ct,Z,Se,jt,At,ee,qt,Fe,c,te,Mt,ne,Ot,$e,Nt,zt,Ut,ie,Vt,_e,Gt,Wt,Ft,L,ae,Bt,ke,Ht,Kt,O,Qt,T,se,Yt,Ee,Rt,Jt,Le,Xt,Zt,N,oe,en,re,tn,Te,nn,an,sn,y,le,on,Ce,rn,ln,je,pn,fn,Ae,dn,cn,z,pe,un,qe,mn,hn,U,fe,gn,de,_n,Me,bn,vn,Be;return d=new Xn({}),G=new Xn({}),te=new ue({props:{name:"class diffusers.StableDiffusionInpaintPipeline",anchor:"diffusers.StableDiffusionInpaintPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"safety_checker",val:": StableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPFeatureExtractor"},{name:"requires_safety_checker",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.StableDiffusionInpaintPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionInpaintPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder. Stable Diffusion uses the text portion of
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIP</a>, specifically
the <a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a> variant.`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionInpaintPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionInpaintPipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.StableDiffusionInpaintPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/main/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionInpaintPipeline.safety_checker",description:`<strong>safety_checker</strong> (<code>StableDiffusionSafetyChecker</code>) &#x2014;
Classification module that estimates whether generated images could be considered offensive or harmful.
Please, refer to the <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">model card</a> for details.`,name:"safety_checker"},{anchor:"diffusers.StableDiffusionInpaintPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<code>CLIPFeatureExtractor</code>) &#x2014;
Model that extracts features from generated images to be used as inputs for the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py#L141"}}),ae=new ue({props:{name:"__call__",anchor:"diffusers.StableDiffusionInpaintPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image]"},{name:"mask_image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image]"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"num_inference_steps",val:": int = 50"},{name:"guidance_scale",val:": float = 7.5"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": typing.Optional[int] = 1"}],parametersDescription:[{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>) &#x2014;
The prompt or prompts to guide the image generation.`,name:"prompt"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.image",description:`<strong>image</strong> (<code>PIL.Image.Image</code>) &#x2014;
<code>Image</code>, or tensor representing an image batch which will be inpainted, <em>i.e.</em> parts of the image will
be masked out with <code>mask_image</code> and repainted according to <code>prompt</code>.`,name:"image"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.mask_image",description:`<strong>mask_image</strong> (<code>PIL.Image.Image</code>) &#x2014;
<code>Image</code>, or tensor representing an image batch, to mask <code>image</code>. White pixels in the mask will be
repainted, while black pixels will be preserved. If <code>mask_image</code> is a PIL image, it will be converted
to a single channel (luminance) before use. If it&#x2019;s a tensor, it should contain one color channel (L)
instead of 3, so the expected shape would be <code>(B, H, W, 1)</code>.`,name:"mask_image"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion Guidance</a>.
<code>guidance_scale</code> is defined as <code>w</code> of equation 2. of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen
Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to the text <code>prompt</code>,
usually at the expense of lower image quality.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. Ignored when not using guidance (i.e., ignored
if <code>guidance_scale</code> is less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) in the DDIM paper: <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">https://arxiv.org/abs/2010.02502</a>. Only applies to
<a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,name:"eta"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor will ge generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that will be called every <code>callback_steps</code> steps during inference. The function will be
called with the following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function will be called. If not specified, the callback will be
called at every step.`,name:"callback_steps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py#L528",returnDescription:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> if <code>return_dict</code> is True, otherwise a <code>tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of </code>bool<code>s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the </code>safety_checker\`.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),O=new oi({props:{anchor:"diffusers.StableDiffusionInpaintPipeline.__call__.example",$$slots:{default:[ri]},$$scope:{ctx:Oe}}}),se=new ue({props:{name:"enable_attention_slicing",anchor:"diffusers.StableDiffusionInpaintPipeline.enable_attention_slicing",parameters:[{name:"slice_size",val:": typing.Union[str, int, NoneType] = 'auto'"}],parametersDescription:[{anchor:"diffusers.StableDiffusionInpaintPipeline.enable_attention_slicing.slice_size",description:`<strong>slice_size</strong> (<code>str</code> or <code>int</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
When <code>&quot;auto&quot;</code>, halves the input to the attention heads, so attention will be computed in two steps. If
<code>&quot;max&quot;</code>, maxium amount of memory will be saved by running only one slice at a time. If a number is
provided, uses as many slices as <code>attention_head_dim // slice_size</code>. In this case, <code>attention_head_dim</code>
must be a multiple of <code>slice_size</code>.`,name:"slice_size"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L876"}}),oe=new ue({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionInpaintPipeline.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L892"}}),le=new ue({props:{name:"enable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionInpaintPipeline.enable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L841"}}),pe=new ue({props:{name:"disable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionInpaintPipeline.disable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L853"}}),fe=new ue({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionInpaintPipeline.enable_sequential_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py#L261"}}),{c(){g=i("meta"),j=p(),v=i("h1"),_=i("a"),k=i("span"),I(d.$$.fragment),E=p(),ye=i("span"),ot=o("Text-Guided Image Inpainting"),Ne=p(),C=i("h2"),A=i("a"),we=i("span"),I(G.$$.fragment),rt=p(),Ie=i("span"),lt=o("StableDiffusionInpaintPipeline"),ze=p(),b=i("p"),pt=o("The Stable Diffusion model was created by the researchers and engineers from "),W=i("a"),ft=o("CompVis"),dt=o(", "),F=i("a"),ct=o("Stability AI"),ut=o(", "),B=i("a"),mt=o("runway"),ht=o(", and "),H=i("a"),gt=o("LAION"),_t=o(". The "),me=i("a"),bt=o("StableDiffusionInpaintPipeline"),vt=o(" lets you edit specific parts of an image by providing a mask and a text prompt using Stable Diffusion."),Ue=p(),he=i("p"),yt=o("The original codebase can be found here:"),Ve=p(),q=i("ul"),K=i("li"),Pe=i("em"),wt=o("Stable Diffusion V1"),It=o(": "),Q=i("a"),Pt=o("CampVis/stable-diffusion"),xt=p(),Y=i("li"),xe=i("em"),Dt=o("Stable Diffusion V2"),St=o(": "),R=i("a"),$t=o("Stability-AI/stablediffusion"),Ge=p(),ge=i("p"),kt=o("Available checkpoints are:"),We=p(),M=i("ul"),J=i("li"),De=i("em"),Et=o("stable-diffusion-inpainting (512x512 resolution)"),Lt=o(": "),X=i("a"),Tt=o("runwayml/stable-diffusion-inpainting"),Ct=p(),Z=i("li"),Se=i("em"),jt=o("stable-diffusion-2-inpainting (512x512 resolution)"),At=o(": "),ee=i("a"),qt=o("stabilityai/stable-diffusion-2-inpainting"),Fe=p(),c=i("div"),I(te.$$.fragment),Mt=p(),ne=i("p"),Ot=o("Pipeline for text-guided image inpainting using Stable Diffusion. "),$e=i("em"),Nt=o("This is an experimental feature"),zt=o("."),Ut=p(),ie=i("p"),Vt=o("This model inherits from "),_e=i("a"),Gt=o("DiffusionPipeline"),Wt=o(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),Ft=p(),L=i("div"),I(ae.$$.fragment),Bt=p(),ke=i("p"),Ht=o("Function invoked when calling the pipeline for generation."),Kt=p(),I(O.$$.fragment),Qt=p(),T=i("div"),I(se.$$.fragment),Yt=p(),Ee=i("p"),Rt=o("Enable sliced attention computation."),Jt=p(),Le=i("p"),Xt=o(`When this option is enabled, the attention module will split the input tensor in slices, to compute attention
in several steps. This is useful to save some memory in exchange for a small speed decrease.`),Zt=p(),N=i("div"),I(oe.$$.fragment),en=p(),re=i("p"),tn=o("Disable sliced attention computation. If "),Te=i("code"),nn=o("enable_attention_slicing"),an=o(` was previously invoked, this method will go
back to computing attention in one step.`),sn=p(),y=i("div"),I(le.$$.fragment),on=p(),Ce=i("p"),rn=o("Enable memory efficient attention as implemented in xformers."),ln=p(),je=i("p"),pn=o(`When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.`),fn=p(),Ae=i("p"),dn=o(`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),cn=p(),z=i("div"),I(pe.$$.fragment),un=p(),qe=i("p"),mn=o("Disable memory efficient attention as implemented in xformers."),hn=p(),U=i("div"),I(fe.$$.fragment),gn=p(),de=i("p"),_n=o(`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Me=i("code"),bn=o("torch.device('meta') and loaded to GPU only when their specific submodule has its "),vn=o("forward` method called."),this.h()},l(t){const u=ni('[data-svelte="svelte-1phssyn"]',document.head);g=a(u,"META",{name:!0,content:!0}),u.forEach(n),j=f(t),v=a(t,"H1",{class:!0});var ce=s(v);_=a(ce,"A",{id:!0,class:!0,href:!0});var yn=s(_);k=a(yn,"SPAN",{});var wn=s(k);P(d.$$.fragment,wn),wn.forEach(n),yn.forEach(n),E=f(ce),ye=a(ce,"SPAN",{});var In=s(ye);ot=r(In,"Text-Guided Image Inpainting"),In.forEach(n),ce.forEach(n),Ne=f(t),C=a(t,"H2",{class:!0});var He=s(C);A=a(He,"A",{id:!0,class:!0,href:!0});var Pn=s(A);we=a(Pn,"SPAN",{});var xn=s(we);P(G.$$.fragment,xn),xn.forEach(n),Pn.forEach(n),rt=f(He),Ie=a(He,"SPAN",{});var Dn=s(Ie);lt=r(Dn,"StableDiffusionInpaintPipeline"),Dn.forEach(n),He.forEach(n),ze=f(t),b=a(t,"P",{});var w=s(b);pt=r(w,"The Stable Diffusion model was created by the researchers and engineers from "),W=a(w,"A",{href:!0,rel:!0});var Sn=s(W);ft=r(Sn,"CompVis"),Sn.forEach(n),dt=r(w,", "),F=a(w,"A",{href:!0,rel:!0});var $n=s(F);ct=r($n,"Stability AI"),$n.forEach(n),ut=r(w,", "),B=a(w,"A",{href:!0,rel:!0});var kn=s(B);mt=r(kn,"runway"),kn.forEach(n),ht=r(w,", and "),H=a(w,"A",{href:!0,rel:!0});var En=s(H);gt=r(En,"LAION"),En.forEach(n),_t=r(w,". The "),me=a(w,"A",{href:!0});var Ln=s(me);bt=r(Ln,"StableDiffusionInpaintPipeline"),Ln.forEach(n),vt=r(w," lets you edit specific parts of an image by providing a mask and a text prompt using Stable Diffusion."),w.forEach(n),Ue=f(t),he=a(t,"P",{});var Tn=s(he);yt=r(Tn,"The original codebase can be found here:"),Tn.forEach(n),Ve=f(t),q=a(t,"UL",{});var Ke=s(q);K=a(Ke,"LI",{});var Qe=s(K);Pe=a(Qe,"EM",{});var Cn=s(Pe);wt=r(Cn,"Stable Diffusion V1"),Cn.forEach(n),It=r(Qe,": "),Q=a(Qe,"A",{href:!0,rel:!0});var jn=s(Q);Pt=r(jn,"CampVis/stable-diffusion"),jn.forEach(n),Qe.forEach(n),xt=f(Ke),Y=a(Ke,"LI",{});var Ye=s(Y);xe=a(Ye,"EM",{});var An=s(xe);Dt=r(An,"Stable Diffusion V2"),An.forEach(n),St=r(Ye,": "),R=a(Ye,"A",{href:!0,rel:!0});var qn=s(R);$t=r(qn,"Stability-AI/stablediffusion"),qn.forEach(n),Ye.forEach(n),Ke.forEach(n),Ge=f(t),ge=a(t,"P",{});var Mn=s(ge);kt=r(Mn,"Available checkpoints are:"),Mn.forEach(n),We=f(t),M=a(t,"UL",{});var Re=s(M);J=a(Re,"LI",{});var Je=s(J);De=a(Je,"EM",{});var On=s(De);Et=r(On,"stable-diffusion-inpainting (512x512 resolution)"),On.forEach(n),Lt=r(Je,": "),X=a(Je,"A",{href:!0,rel:!0});var Nn=s(X);Tt=r(Nn,"runwayml/stable-diffusion-inpainting"),Nn.forEach(n),Je.forEach(n),Ct=f(Re),Z=a(Re,"LI",{});var Xe=s(Z);Se=a(Xe,"EM",{});var zn=s(Se);jt=r(zn,"stable-diffusion-2-inpainting (512x512 resolution)"),zn.forEach(n),At=r(Xe,": "),ee=a(Xe,"A",{href:!0,rel:!0});var Un=s(ee);qt=r(Un,"stabilityai/stable-diffusion-2-inpainting"),Un.forEach(n),Xe.forEach(n),Re.forEach(n),Fe=f(t),c=a(t,"DIV",{class:!0});var m=s(c);P(te.$$.fragment,m),Mt=f(m),ne=a(m,"P",{});var Ze=s(ne);Ot=r(Ze,"Pipeline for text-guided image inpainting using Stable Diffusion. "),$e=a(Ze,"EM",{});var Vn=s($e);Nt=r(Vn,"This is an experimental feature"),Vn.forEach(n),zt=r(Ze,"."),Ze.forEach(n),Ut=f(m),ie=a(m,"P",{});var et=s(ie);Vt=r(et,"This model inherits from "),_e=a(et,"A",{href:!0});var Gn=s(_e);Gt=r(Gn,"DiffusionPipeline"),Gn.forEach(n),Wt=r(et,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),et.forEach(n),Ft=f(m),L=a(m,"DIV",{class:!0});var be=s(L);P(ae.$$.fragment,be),Bt=f(be),ke=a(be,"P",{});var Wn=s(ke);Ht=r(Wn,"Function invoked when calling the pipeline for generation."),Wn.forEach(n),Kt=f(be),P(O.$$.fragment,be),be.forEach(n),Qt=f(m),T=a(m,"DIV",{class:!0});var ve=s(T);P(se.$$.fragment,ve),Yt=f(ve),Ee=a(ve,"P",{});var Fn=s(Ee);Rt=r(Fn,"Enable sliced attention computation."),Fn.forEach(n),Jt=f(ve),Le=a(ve,"P",{});var Bn=s(Le);Xt=r(Bn,`When this option is enabled, the attention module will split the input tensor in slices, to compute attention
in several steps. This is useful to save some memory in exchange for a small speed decrease.`),Bn.forEach(n),ve.forEach(n),Zt=f(m),N=a(m,"DIV",{class:!0});var tt=s(N);P(oe.$$.fragment,tt),en=f(tt),re=a(tt,"P",{});var nt=s(re);tn=r(nt,"Disable sliced attention computation. If "),Te=a(nt,"CODE",{});var Hn=s(Te);nn=r(Hn,"enable_attention_slicing"),Hn.forEach(n),an=r(nt,` was previously invoked, this method will go
back to computing attention in one step.`),nt.forEach(n),tt.forEach(n),sn=f(m),y=a(m,"DIV",{class:!0});var V=s(y);P(le.$$.fragment,V),on=f(V),Ce=a(V,"P",{});var Kn=s(Ce);rn=r(Kn,"Enable memory efficient attention as implemented in xformers."),Kn.forEach(n),ln=f(V),je=a(V,"P",{});var Qn=s(je);pn=r(Qn,`When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.`),Qn.forEach(n),fn=f(V),Ae=a(V,"P",{});var Yn=s(Ae);dn=r(Yn,`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Yn.forEach(n),V.forEach(n),cn=f(m),z=a(m,"DIV",{class:!0});var it=s(z);P(pe.$$.fragment,it),un=f(it),qe=a(it,"P",{});var Rn=s(qe);mn=r(Rn,"Disable memory efficient attention as implemented in xformers."),Rn.forEach(n),it.forEach(n),hn=f(m),U=a(m,"DIV",{class:!0});var at=s(U);P(fe.$$.fragment,at),gn=f(at),de=a(at,"P",{});var st=s(de);_n=r(st,`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Me=a(st,"CODE",{});var Jn=s(Me);bn=r(Jn,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),Jn.forEach(n),vn=r(st,"forward` method called."),st.forEach(n),at.forEach(n),m.forEach(n),this.h()},h(){l(g,"name","hf:doc:metadata"),l(g,"content",JSON.stringify(pi)),l(_,"id","textguided-image-inpainting"),l(_,"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"),l(_,"href","#textguided-image-inpainting"),l(v,"class","relative group"),l(A,"id","diffusers.StableDiffusionInpaintPipeline"),l(A,"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"),l(A,"href","#diffusers.StableDiffusionInpaintPipeline"),l(C,"class","relative group"),l(W,"href","https://github.com/CompVis"),l(W,"rel","nofollow"),l(F,"href","https://stability.ai/"),l(F,"rel","nofollow"),l(B,"href","https://github.com/runwayml"),l(B,"rel","nofollow"),l(H,"href","https://laion.ai/"),l(H,"rel","nofollow"),l(me,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline"),l(Q,"href","https://github.com/runwayml/stable-diffusion#inpainting-with-stable-diffusion"),l(Q,"rel","nofollow"),l(R,"href","https://github.com/Stability-AI/stablediffusion#image-inpainting-with-stable-diffusion"),l(R,"rel","nofollow"),l(X,"href","https://huggingface.co/runwayml/stable-diffusion-inpainting"),l(X,"rel","nofollow"),l(ee,"href","https://huggingface.co/stabilityai/stable-diffusion-2-inpainting"),l(ee,"rel","nofollow"),l(_e,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),l(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,u){e(document.head,g),h(t,j,u),h(t,v,u),e(v,_),e(_,k),x(d,k,null),e(v,E),e(v,ye),e(ye,ot),h(t,Ne,u),h(t,C,u),e(C,A),e(A,we),x(G,we,null),e(C,rt),e(C,Ie),e(Ie,lt),h(t,ze,u),h(t,b,u),e(b,pt),e(b,W),e(W,ft),e(b,dt),e(b,F),e(F,ct),e(b,ut),e(b,B),e(B,mt),e(b,ht),e(b,H),e(H,gt),e(b,_t),e(b,me),e(me,bt),e(b,vt),h(t,Ue,u),h(t,he,u),e(he,yt),h(t,Ve,u),h(t,q,u),e(q,K),e(K,Pe),e(Pe,wt),e(K,It),e(K,Q),e(Q,Pt),e(q,xt),e(q,Y),e(Y,xe),e(xe,Dt),e(Y,St),e(Y,R),e(R,$t),h(t,Ge,u),h(t,ge,u),e(ge,kt),h(t,We,u),h(t,M,u),e(M,J),e(J,De),e(De,Et),e(J,Lt),e(J,X),e(X,Tt),e(M,Ct),e(M,Z),e(Z,Se),e(Se,jt),e(Z,At),e(Z,ee),e(ee,qt),h(t,Fe,u),h(t,c,u),x(te,c,null),e(c,Mt),e(c,ne),e(ne,Ot),e(ne,$e),e($e,Nt),e(ne,zt),e(c,Ut),e(c,ie),e(ie,Vt),e(ie,_e),e(_e,Gt),e(ie,Wt),e(c,Ft),e(c,L),x(ae,L,null),e(L,Bt),e(L,ke),e(ke,Ht),e(L,Kt),x(O,L,null),e(c,Qt),e(c,T),x(se,T,null),e(T,Yt),e(T,Ee),e(Ee,Rt),e(T,Jt),e(T,Le),e(Le,Xt),e(c,Zt),e(c,N),x(oe,N,null),e(N,en),e(N,re),e(re,tn),e(re,Te),e(Te,nn),e(re,an),e(c,sn),e(c,y),x(le,y,null),e(y,on),e(y,Ce),e(Ce,rn),e(y,ln),e(y,je),e(je,pn),e(y,fn),e(y,Ae),e(Ae,dn),e(c,cn),e(c,z),x(pe,z,null),e(z,un),e(z,qe),e(qe,mn),e(c,hn),e(c,U),x(fe,U,null),e(U,gn),e(U,de),e(de,_n),e(de,Me),e(Me,bn),e(de,vn),Be=!0},p(t,[u]){const ce={};u&2&&(ce.$$scope={dirty:u,ctx:t}),O.$set(ce)},i(t){Be||(D(d.$$.fragment,t),D(G.$$.fragment,t),D(te.$$.fragment,t),D(ae.$$.fragment,t),D(O.$$.fragment,t),D(se.$$.fragment,t),D(oe.$$.fragment,t),D(le.$$.fragment,t),D(pe.$$.fragment,t),D(fe.$$.fragment,t),Be=!0)},o(t){S(d.$$.fragment,t),S(G.$$.fragment,t),S(te.$$.fragment,t),S(ae.$$.fragment,t),S(O.$$.fragment,t),S(se.$$.fragment,t),S(oe.$$.fragment,t),S(le.$$.fragment,t),S(pe.$$.fragment,t),S(fe.$$.fragment,t),Be=!1},d(t){n(g),t&&n(j),t&&n(v),$(d),t&&n(Ne),t&&n(C),$(G),t&&n(ze),t&&n(b),t&&n(Ue),t&&n(he),t&&n(Ve),t&&n(q),t&&n(Ge),t&&n(ge),t&&n(We),t&&n(M),t&&n(Fe),t&&n(c),$(te),$(ae),$(O),$(se),$(oe),$(le),$(pe),$(fe)}}}const pi={local:"textguided-image-inpainting",sections:[{local:"diffusers.StableDiffusionInpaintPipeline",title:"StableDiffusionInpaintPipeline"}],title:"Text-Guided Image Inpainting"};function fi(Oe){return ii(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class gi extends Zn{constructor(g){super();ei(this,g,fi,li,ti,{})}}export{gi as default,pi as metadata};
