import{S as Xt,i as Vt,s as zt,e as n,k as h,w as x,t as p,M as Rt,c as s,d as t,m as g,a as i,x as P,h as c,b as r,G as a,g as f,y as E,q as T,o as I,B as k,v as Yt,L as Ot}from"../../../chunks/vendor-hf-doc-builder.js";import{T as At}from"../../../chunks/Tip-hf-doc-builder.js";import{D as wt}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as qt}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ge}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Qt}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Ht(C){let o,_,m,u,b,d,w,W;return{c(){o=n("p"),_=p("Make sure to check out the Schedulers "),m=n("a"),u=p("guide"),b=p(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),d=n("a"),w=p("reuse components across pipelines"),W=p(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(D){o=s(D,"P",{});var v=i(o);_=c(v,"Make sure to check out the Schedulers "),m=s(v,"A",{href:!0});var $=i(m);u=c($,"guide"),$.forEach(t),b=c(v," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),d=s(v,"A",{href:!0});var B=i(d);w=c(B,"reuse components across pipelines"),B.forEach(t),W=c(v," section to learn how to efficiently load the same components into multiple pipelines."),v.forEach(t),this.h()},h(){r(m,"href","/using-diffusers/schedulers"),r(d,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(D,v){f(D,o,v),a(o,_),a(o,m),a(m,u),a(o,b),a(o,d),a(d,w),a(o,W)},d(D){D&&t(o)}}}function Kt(C){let o,_;return{c(){o=n("p"),_=p("\u{1F9EA} This is an experimental feature!")},l(m){o=s(m,"P",{});var u=i(o);_=c(u,"\u{1F9EA} This is an experimental feature!"),u.forEach(t)},m(m,u){f(m,o,u),a(o,_)},d(m){m&&t(o)}}}function ea(C){let o,_,m,u,b;return u=new qt({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwUGFpbnRCeUV4YW1wbGVQaXBlbGluZSUwQSUwQSUwQWRlZiUyMGRvd25sb2FkX2ltYWdlKHVybCklM0ElMEElMjAlMjAlMjAlMjByZXNwb25zZSUyMCUzRCUyMHJlcXVlc3RzLmdldCh1cmwpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwUElMLkltYWdlLm9wZW4oQnl0ZXNJTyhyZXNwb25zZS5jb250ZW50KSkuY29udmVydCglMjJSR0IlMjIpJTBBJTBBJTBBaW1nX3VybCUyMCUzRCUyMCglMEElMjAlMjAlMjAlMjAlMjJodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZGYW50YXN5LVN0dWRpbyUyRlBhaW50LWJ5LUV4YW1wbGUlMkZtYWluJTJGZXhhbXBsZXMlMkZpbWFnZSUyRmV4YW1wbGVfMS5wbmclMjIlMEEpJTBBbWFza191cmwlMjAlM0QlMjAoJTBBJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZyYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tJTJGRmFudGFzeS1TdHVkaW8lMkZQYWludC1ieS1FeGFtcGxlJTJGbWFpbiUyRmV4YW1wbGVzJTJGbWFzayUyRmV4YW1wbGVfMS5wbmclMjIlMEEpJTBBZXhhbXBsZV91cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZGYW50YXN5LVN0dWRpbyUyRlBhaW50LWJ5LUV4YW1wbGUlMkZtYWluJTJGZXhhbXBsZXMlMkZyZWZlcmVuY2UlMkZleGFtcGxlXzEuanBnJTIyJTBBJTBBaW5pdF9pbWFnZSUyMCUzRCUyMGRvd25sb2FkX2ltYWdlKGltZ191cmwpLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklMEFtYXNrX2ltYWdlJTIwJTNEJTIwZG93bmxvYWRfaW1hZ2UobWFza191cmwpLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklMEFleGFtcGxlX2ltYWdlJTIwJTNEJTIwZG93bmxvYWRfaW1hZ2UoZXhhbXBsZV91cmwpLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklMEElMEFwaXBlJTIwJTNEJTIwUGFpbnRCeUV4YW1wbGVQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyRmFudGFzeS1TdHVkaW8lMkZQYWludC1ieS1FeGFtcGxlJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKSUwQXBpcGUlMjAlM0QlMjBwaXBlLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlJTJDJTIwZXhhbXBsZV9pbWFnZSUzRGV4YW1wbGVfaW1hZ2UpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",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> PaintByExamplePipeline


<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-meta">... </span>    <span class="hljs-string">&quot;https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/image/example_1.png&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_url = (
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/mask/example_1.png&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>example_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/reference/example_1.jpg&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>example_image = download_image(example_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = PaintByExamplePipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Fantasy-Studio/Paint-by-Example&quot;</span>,
<span class="hljs-meta">... </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>image = pipe(image=init_image, mask_image=mask_image, example_image=example_image).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image`}}),{c(){o=n("p"),_=p("Example:"),m=h(),x(u.$$.fragment)},l(d){o=s(d,"P",{});var w=i(o);_=c(w,"Example:"),w.forEach(t),m=g(d),P(u.$$.fragment,d)},m(d,w){f(d,o,w),a(o,_),f(d,m,w),E(u,d,w),b=!0},p:Ot,i(d){b||(T(u.$$.fragment,d),b=!0)},o(d){I(u.$$.fragment,d),b=!1},d(d){d&&t(o),d&&t(m),k(u,d)}}}function ta(C){let o,_,m,u,b,d,w,W,D,v,$,B,Ce,Fe,Pe,ie,Ne,Ee,oe,de,Ae,Te,M,Xe,R,Ve,ze,Y,Re,Ye,Ie,U,F,me,O,Oe,fe,qe,ke,J,Qe,q,He,Ke,Q,et,tt,$e,N,Be,L,A,ue,H,at,he,nt,Me,y,K,st,X,it,ge,ot,lt,ee,rt,le,pt,ct,dt,S,te,mt,_e,ft,ut,V,Je,Z,z,ye,ae,ht,be,gt,Se,G,ne,_t,we,yt,je;return d=new Ge({}),O=new Ge({}),N=new At({props:{$$slots:{default:[Ht]},$$scope:{ctx:C}}}),H=new Ge({}),K=new wt({props:{name:"class diffusers.PaintByExamplePipeline",anchor:"diffusers.PaintByExamplePipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"image_encoder",val:": PaintByExampleImageEncoder"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": typing.Union[diffusers.schedulers.scheduling_ddim.DDIMScheduler, diffusers.schedulers.scheduling_pndm.PNDMScheduler, diffusers.schedulers.scheduling_lms_discrete.LMSDiscreteScheduler]"},{name:"safety_checker",val:": StableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPImageProcessor"},{name:"requires_safety_checker",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.PaintByExamplePipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.19.0/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.PaintByExamplePipeline.image_encoder",description:`<strong>image_encoder</strong> (<code>PaintByExampleImageEncoder</code>) &#x2014;
Encodes the example input image. The <code>unet</code> is conditioned on the example image instead of a text prompt.`,name:"image_encoder"},{anchor:"diffusers.PaintByExamplePipeline.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/v4.31.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>) &#x2014;
A <code>CLIPTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.PaintByExamplePipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.19.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.PaintByExamplePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.19.0/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/v0.19.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.19.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.19.0/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.PaintByExamplePipeline.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 more details
about a model&#x2019;s potential harms.`,name:"safety_checker"},{anchor:"diffusers.PaintByExamplePipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<a href="https://huggingface.co/docs/transformers/v4.31.0/en/model_doc/clip#transformers.CLIPImageProcessor" rel="nofollow">CLIPImageProcessor</a>) &#x2014;
A <code>CLIPImageProcessor</code> to extract features from generated images; used as inputs to the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py#L137"}}),X=new At({props:{warning:!0,$$slots:{default:[Kt]},$$scope:{ctx:C}}}),te=new wt({props:{name:"__call__",anchor:"diffusers.PaintByExamplePipeline.__call__",parameters:[{name:"example_image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image]"},{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 = 5.0"},{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:": int = 1"}],parametersDescription:[{anchor:"diffusers.PaintByExamplePipeline.__call__.example_image",description:`<strong>example_image</strong> (<code>torch.FloatTensor</code> or <code>PIL.Image.Image</code> or <code>List[PIL.Image.Image]</code>) &#x2014;
An example image to guide image generation.`,name:"example_image"},{anchor:"diffusers.PaintByExamplePipeline.__call__.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> or <code>PIL.Image.Image</code> or <code>List[PIL.Image.Image]</code>) &#x2014;
<code>Image</code> or tensor representing an image batch to be inpainted (parts of the image are masked out with
<code>mask_image</code> and repainted according to <code>prompt</code>).`,name:"image"},{anchor:"diffusers.PaintByExamplePipeline.__call__.mask_image",description:`<strong>mask_image</strong> (<code>torch.FloatTensor</code> or <code>PIL.Image.Image</code> or <code>List[PIL.Image.Image]</code>) &#x2014;
<code>Image</code> or tensor representing an image batch to mask <code>image</code>. White pixels in the mask are repainted,
while black pixels are preserved. If <code>mask_image</code> is a PIL image, it is 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.PaintByExamplePipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.PaintByExamplePipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.PaintByExamplePipeline.__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.PaintByExamplePipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.PaintByExamplePipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide what to not include in image generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.PaintByExamplePipeline.__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.PaintByExamplePipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/v0.19.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.PaintByExamplePipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.PaintByExamplePipeline.__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 is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.PaintByExamplePipeline.__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 generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.PaintByExamplePipeline.__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/v0.19.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.PaintByExamplePipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.PaintByExamplePipeline.__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 is called. If not specified, the callback is called at
every step.`,name:"callback_steps"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py#L368",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.19.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images and the
second element is a list of <code>bool</code>s indicating whether the corresponding generated image contains
\u201Cnot-safe-for-work\u201D (nsfw) content.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.19.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),V=new Qt({props:{anchor:"diffusers.PaintByExamplePipeline.__call__.example",$$slots:{default:[ea]},$$scope:{ctx:C}}}),ae=new Ge({}),ne=new wt({props:{name:"class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"},{name:"nsfw_content_detected",val:": typing.Optional[typing.List[bool]]"}],parametersDescription:[{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List indicating whether the corresponding generated image contains &#x201C;not-safe-for-work&#x201D; (nsfw) content or
<code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/pipelines/stable_diffusion/__init__.py#L22"}}),{c(){o=n("meta"),_=h(),m=n("h1"),u=n("a"),b=n("span"),x(d.$$.fragment),w=h(),W=n("span"),D=p("PaintByExample"),v=h(),$=n("p"),B=n("a"),Ce=p("Paint by Example: Exemplar-based Image Editing with Diffusion Models"),Fe=p(" is by Binxin Yang, Shuyang Gu, Bo Zhang, Ting Zhang, Xuejin Chen, Xiaoyan Sun, Dong Chen, Fang Wen."),Pe=h(),ie=n("p"),Ne=p("The abstract from the paper is:"),Ee=h(),oe=n("p"),de=n("em"),Ae=p("Language-guided image editing has achieved great success recently. In this paper, for the first time, we investigate exemplar-guided image editing for more precise control. We achieve this goal by leveraging self-supervised training to disentangle and re-organize the source image and the exemplar. However, the naive approach will cause obvious fusing artifacts. We carefully analyze it and propose an information bottleneck and strong augmentations to avoid the trivial solution of directly copying and pasting the exemplar image. Meanwhile, to ensure the controllability of the editing process, we design an arbitrary shape mask for the exemplar image and leverage the classifier-free guidance to increase the similarity to the exemplar image. The whole framework involves a single forward of the diffusion model without any iterative optimization. We demonstrate that our method achieves an impressive performance and enables controllable editing on in-the-wild images with high fidelity."),Te=h(),M=n("p"),Xe=p("The original codebase can be found at "),R=n("a"),Ve=p("Fantasy-Studio/Paint-by-Example"),ze=p(", and you can try it out in a "),Y=n("a"),Re=p("demo"),Ye=p("."),Ie=h(),U=n("h2"),F=n("a"),me=n("span"),x(O.$$.fragment),Oe=h(),fe=n("span"),qe=p("Tips"),ke=h(),J=n("p"),Qe=p("PaintByExample is supported by the official "),q=n("a"),He=p("Fantasy-Studio/Paint-by-Example"),Ke=p(" checkpoint. The checkpoint is warm-started from "),Q=n("a"),et=p("CompVis/stable-diffusion-v1-4"),tt=p(" to inpaint partly masked images conditioned on example and reference images."),$e=h(),x(N.$$.fragment),Be=h(),L=n("h2"),A=n("a"),ue=n("span"),x(H.$$.fragment),at=h(),he=n("span"),nt=p("PaintByExamplePipeline"),Me=h(),y=n("div"),x(K.$$.fragment),st=h(),x(X.$$.fragment),it=h(),ge=n("p"),ot=p("Pipeline for image-guided image inpainting using Stable Diffusion."),lt=h(),ee=n("p"),rt=p("This model inherits from "),le=n("a"),pt=p("DiffusionPipeline"),ct=p(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),dt=h(),S=n("div"),x(te.$$.fragment),mt=h(),_e=n("p"),ft=p("The call function to the pipeline for generation."),ut=h(),x(V.$$.fragment),Je=h(),Z=n("h2"),z=n("a"),ye=n("span"),x(ae.$$.fragment),ht=h(),be=n("span"),gt=p("StableDiffusionPipelineOutput"),Se=h(),G=n("div"),x(ne.$$.fragment),_t=h(),we=n("p"),yt=p("Output class for Stable Diffusion pipelines."),this.h()},l(e){const l=Rt('[data-svelte="svelte-1phssyn"]',document.head);o=s(l,"META",{name:!0,content:!0}),l.forEach(t),_=g(e),m=s(e,"H1",{class:!0});var se=i(m);u=s(se,"A",{id:!0,class:!0,href:!0});var ve=i(u);b=s(ve,"SPAN",{});var xe=i(b);P(d.$$.fragment,xe),xe.forEach(t),ve.forEach(t),w=g(se),W=s(se,"SPAN",{});var vt=i(W);D=c(vt,"PaintByExample"),vt.forEach(t),se.forEach(t),v=g(e),$=s(e,"P",{});var bt=i($);B=s(bt,"A",{href:!0,rel:!0});var xt=i(B);Ce=c(xt,"Paint by Example: Exemplar-based Image Editing with Diffusion Models"),xt.forEach(t),Fe=c(bt," is by Binxin Yang, Shuyang Gu, Bo Zhang, Ting Zhang, Xuejin Chen, Xiaoyan Sun, Dong Chen, Fang Wen."),bt.forEach(t),Pe=g(e),ie=s(e,"P",{});var Pt=i(ie);Ne=c(Pt,"The abstract from the paper is:"),Pt.forEach(t),Ee=g(e),oe=s(e,"P",{});var Et=i(oe);de=s(Et,"EM",{});var Tt=i(de);Ae=c(Tt,"Language-guided image editing has achieved great success recently. In this paper, for the first time, we investigate exemplar-guided image editing for more precise control. We achieve this goal by leveraging self-supervised training to disentangle and re-organize the source image and the exemplar. However, the naive approach will cause obvious fusing artifacts. We carefully analyze it and propose an information bottleneck and strong augmentations to avoid the trivial solution of directly copying and pasting the exemplar image. Meanwhile, to ensure the controllability of the editing process, we design an arbitrary shape mask for the exemplar image and leverage the classifier-free guidance to increase the similarity to the exemplar image. The whole framework involves a single forward of the diffusion model without any iterative optimization. We demonstrate that our method achieves an impressive performance and enables controllable editing on in-the-wild images with high fidelity."),Tt.forEach(t),Et.forEach(t),Te=g(e),M=s(e,"P",{});var re=i(M);Xe=c(re,"The original codebase can be found at "),R=s(re,"A",{href:!0,rel:!0});var It=i(R);Ve=c(It,"Fantasy-Studio/Paint-by-Example"),It.forEach(t),ze=c(re,", and you can try it out in a "),Y=s(re,"A",{href:!0,rel:!0});var kt=i(Y);Re=c(kt,"demo"),kt.forEach(t),Ye=c(re,"."),re.forEach(t),Ie=g(e),U=s(e,"H2",{class:!0});var We=i(U);F=s(We,"A",{id:!0,class:!0,href:!0});var $t=i(F);me=s($t,"SPAN",{});var Bt=i(me);P(O.$$.fragment,Bt),Bt.forEach(t),$t.forEach(t),Oe=g(We),fe=s(We,"SPAN",{});var Mt=i(fe);qe=c(Mt,"Tips"),Mt.forEach(t),We.forEach(t),ke=g(e),J=s(e,"P",{});var pe=i(J);Qe=c(pe,"PaintByExample is supported by the official "),q=s(pe,"A",{href:!0,rel:!0});var Jt=i(q);He=c(Jt,"Fantasy-Studio/Paint-by-Example"),Jt.forEach(t),Ke=c(pe," checkpoint. The checkpoint is warm-started from "),Q=s(pe,"A",{href:!0,rel:!0});var St=i(Q);et=c(St,"CompVis/stable-diffusion-v1-4"),St.forEach(t),tt=c(pe," to inpaint partly masked images conditioned on example and reference images."),pe.forEach(t),$e=g(e),P(N.$$.fragment,e),Be=g(e),L=s(e,"H2",{class:!0});var De=i(L);A=s(De,"A",{id:!0,class:!0,href:!0});var jt=i(A);ue=s(jt,"SPAN",{});var Wt=i(ue);P(H.$$.fragment,Wt),Wt.forEach(t),jt.forEach(t),at=g(De),he=s(De,"SPAN",{});var Dt=i(he);nt=c(Dt,"PaintByExamplePipeline"),Dt.forEach(t),De.forEach(t),Me=g(e),y=s(e,"DIV",{class:!0});var j=i(y);P(K.$$.fragment,j),st=g(j),P(X.$$.fragment,j),it=g(j),ge=s(j,"P",{});var Ut=i(ge);ot=c(Ut,"Pipeline for image-guided image inpainting using Stable Diffusion."),Ut.forEach(t),lt=g(j),ee=s(j,"P",{});var Ue=i(ee);rt=c(Ue,"This model inherits from "),le=s(Ue,"A",{href:!0});var Lt=i(le);pt=c(Lt,"DiffusionPipeline"),Lt.forEach(t),ct=c(Ue,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Ue.forEach(t),dt=g(j),S=s(j,"DIV",{class:!0});var ce=i(S);P(te.$$.fragment,ce),mt=g(ce),_e=s(ce,"P",{});var Zt=i(_e);ft=c(Zt,"The call function to the pipeline for generation."),Zt.forEach(t),ut=g(ce),P(V.$$.fragment,ce),ce.forEach(t),j.forEach(t),Je=g(e),Z=s(e,"H2",{class:!0});var Le=i(Z);z=s(Le,"A",{id:!0,class:!0,href:!0});var Gt=i(z);ye=s(Gt,"SPAN",{});var Ct=i(ye);P(ae.$$.fragment,Ct),Ct.forEach(t),Gt.forEach(t),ht=g(Le),be=s(Le,"SPAN",{});var Ft=i(be);gt=c(Ft,"StableDiffusionPipelineOutput"),Ft.forEach(t),Le.forEach(t),Se=g(e),G=s(e,"DIV",{class:!0});var Ze=i(G);P(ne.$$.fragment,Ze),_t=g(Ze),we=s(Ze,"P",{});var Nt=i(we);yt=c(Nt,"Output class for Stable Diffusion pipelines."),Nt.forEach(t),Ze.forEach(t),this.h()},h(){r(o,"name","hf:doc:metadata"),r(o,"content",JSON.stringify(aa)),r(u,"id","paintbyexample"),r(u,"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(u,"href","#paintbyexample"),r(m,"class","relative group"),r(B,"href","https://huggingface.co/papers/2211.13227"),r(B,"rel","nofollow"),r(R,"href","https://github.com/Fantasy-Studio/Paint-by-Example"),r(R,"rel","nofollow"),r(Y,"href","https://huggingface.co/spaces/Fantasy-Studio/Paint-by-Example"),r(Y,"rel","nofollow"),r(F,"id","tips"),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","#tips"),r(U,"class","relative group"),r(q,"href","https://huggingface.co/Fantasy-Studio/Paint-by-Example"),r(q,"rel","nofollow"),r(Q,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4"),r(Q,"rel","nofollow"),r(A,"id","diffusers.PaintByExamplePipeline"),r(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"),r(A,"href","#diffusers.PaintByExamplePipeline"),r(L,"class","relative group"),r(le,"href","/docs/diffusers/v0.19.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),r(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(z,"id","diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),r(z,"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(z,"href","#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),r(Z,"class","relative group"),r(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,l){a(document.head,o),f(e,_,l),f(e,m,l),a(m,u),a(u,b),E(d,b,null),a(m,w),a(m,W),a(W,D),f(e,v,l),f(e,$,l),a($,B),a(B,Ce),a($,Fe),f(e,Pe,l),f(e,ie,l),a(ie,Ne),f(e,Ee,l),f(e,oe,l),a(oe,de),a(de,Ae),f(e,Te,l),f(e,M,l),a(M,Xe),a(M,R),a(R,Ve),a(M,ze),a(M,Y),a(Y,Re),a(M,Ye),f(e,Ie,l),f(e,U,l),a(U,F),a(F,me),E(O,me,null),a(U,Oe),a(U,fe),a(fe,qe),f(e,ke,l),f(e,J,l),a(J,Qe),a(J,q),a(q,He),a(J,Ke),a(J,Q),a(Q,et),a(J,tt),f(e,$e,l),E(N,e,l),f(e,Be,l),f(e,L,l),a(L,A),a(A,ue),E(H,ue,null),a(L,at),a(L,he),a(he,nt),f(e,Me,l),f(e,y,l),E(K,y,null),a(y,st),E(X,y,null),a(y,it),a(y,ge),a(ge,ot),a(y,lt),a(y,ee),a(ee,rt),a(ee,le),a(le,pt),a(ee,ct),a(y,dt),a(y,S),E(te,S,null),a(S,mt),a(S,_e),a(_e,ft),a(S,ut),E(V,S,null),f(e,Je,l),f(e,Z,l),a(Z,z),a(z,ye),E(ae,ye,null),a(Z,ht),a(Z,be),a(be,gt),f(e,Se,l),f(e,G,l),E(ne,G,null),a(G,_t),a(G,we),a(we,yt),je=!0},p(e,[l]){const se={};l&2&&(se.$$scope={dirty:l,ctx:e}),N.$set(se);const ve={};l&2&&(ve.$$scope={dirty:l,ctx:e}),X.$set(ve);const xe={};l&2&&(xe.$$scope={dirty:l,ctx:e}),V.$set(xe)},i(e){je||(T(d.$$.fragment,e),T(O.$$.fragment,e),T(N.$$.fragment,e),T(H.$$.fragment,e),T(K.$$.fragment,e),T(X.$$.fragment,e),T(te.$$.fragment,e),T(V.$$.fragment,e),T(ae.$$.fragment,e),T(ne.$$.fragment,e),je=!0)},o(e){I(d.$$.fragment,e),I(O.$$.fragment,e),I(N.$$.fragment,e),I(H.$$.fragment,e),I(K.$$.fragment,e),I(X.$$.fragment,e),I(te.$$.fragment,e),I(V.$$.fragment,e),I(ae.$$.fragment,e),I(ne.$$.fragment,e),je=!1},d(e){t(o),e&&t(_),e&&t(m),k(d),e&&t(v),e&&t($),e&&t(Pe),e&&t(ie),e&&t(Ee),e&&t(oe),e&&t(Te),e&&t(M),e&&t(Ie),e&&t(U),k(O),e&&t(ke),e&&t(J),e&&t($e),k(N,e),e&&t(Be),e&&t(L),k(H),e&&t(Me),e&&t(y),k(K),k(X),k(te),k(V),e&&t(Je),e&&t(Z),k(ae),e&&t(Se),e&&t(G),k(ne)}}}const aa={local:"paintbyexample",sections:[{local:"tips",title:"Tips"},{local:"diffusers.PaintByExamplePipeline",title:"PaintByExamplePipeline"},{local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",title:"StableDiffusionPipelineOutput"}],title:"PaintByExample"};function na(C){return Yt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ca extends Xt{constructor(o){super();Vt(this,o,na,ta,zt,{})}}export{ca as default,aa as metadata};
