import{S as Xa,i as Va,s as za,e as n,k as h,w as x,t as p,M as Ra,c as s,d as a,m as g,a as i,x as P,h as c,b as r,G as t,g as f,y as E,q as T,o as I,B as k,v as Ya,L as Oa}from"../../../chunks/vendor-hf-doc-builder.js";import{T as Aa}from"../../../chunks/Tip-hf-doc-builder.js";import{D as wa}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as qa}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ge}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Qa}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Ha(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(a),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(a),W=c(v," section to learn how to efficiently load the same components into multiple pipelines."),v.forEach(a),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),t(o,_),t(o,m),t(m,u),t(o,b),t(o,d),t(d,w),t(o,W)},d(D){D&&a(o)}}}function Ka(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(a)},m(m,u){f(m,o,u),t(o,_)},d(m){m&&a(o)}}}function et(C){let o,_,m,u,b;return u=new qa({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(a),m=g(d),P(u.$$.fragment,d)},m(d,w){f(d,o,w),t(o,_),f(d,m,w),E(u,d,w),b=!0},p:Oa,i(d){b||(T(u.$$.fragment,d),b=!0)},o(d){I(u.$$.fragment,d),b=!1},d(d){d&&a(o),d&&a(m),k(u,d)}}}function at(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,ea,aa,$e,N,Be,L,A,ue,H,ta,he,na,Me,y,K,sa,X,ia,ge,oa,la,ee,ra,le,pa,ca,da,S,ae,ma,_e,fa,ua,V,Je,Z,z,ye,te,ha,be,ga,Se,G,ne,_a,we,ya,je;return d=new Ge({}),O=new Ge({}),N=new Aa({props:{$$slots:{default:[Ha]},$$scope:{ctx:C}}}),H=new Ge({}),K=new wa({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.20.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.20.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.20.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.20.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.20.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.20.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.20.0/src/diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py#L137"}}),X=new Aa({props:{warning:!0,$$slots:{default:[Ka]},$$scope:{ctx:C}}}),ae=new wa({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.20.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.20.0/en/api/pipelines/stable_diffusion/upscale#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.20.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.20.0/en/api/pipelines/stable_diffusion/upscale#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.20.0/en/api/pipelines/stable_diffusion/upscale#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),V=new Qa({props:{anchor:"diffusers.PaintByExamplePipeline.__call__.example",$$slots:{default:[et]},$$scope:{ctx:C}}}),te=new Ge({}),ne=new wa({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.20.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"),ea=p("CompVis/stable-diffusion-v1-4"),aa=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),ta=h(),he=n("span"),na=p("PaintByExamplePipeline"),Me=h(),y=n("div"),x(K.$$.fragment),sa=h(),x(X.$$.fragment),ia=h(),ge=n("p"),oa=p("Pipeline for image-guided image inpainting using Stable Diffusion."),la=h(),ee=n("p"),ra=p("This model inherits from "),le=n("a"),pa=p("DiffusionPipeline"),ca=p(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),da=h(),S=n("div"),x(ae.$$.fragment),ma=h(),_e=n("p"),fa=p("The call function to the pipeline for generation."),ua=h(),x(V.$$.fragment),Je=h(),Z=n("h2"),z=n("a"),ye=n("span"),x(te.$$.fragment),ha=h(),be=n("span"),ga=p("StableDiffusionPipelineOutput"),Se=h(),G=n("div"),x(ne.$$.fragment),_a=h(),we=n("p"),ya=p("Output class for Stable Diffusion pipelines."),this.h()},l(e){const l=Ra('[data-svelte="svelte-1phssyn"]',document.head);o=s(l,"META",{name:!0,content:!0}),l.forEach(a),_=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(a),ve.forEach(a),w=g(se),W=s(se,"SPAN",{});var va=i(W);D=c(va,"PaintByExample"),va.forEach(a),se.forEach(a),v=g(e),$=s(e,"P",{});var ba=i($);B=s(ba,"A",{href:!0,rel:!0});var xa=i(B);Ce=c(xa,"Paint by Example: Exemplar-based Image Editing with Diffusion Models"),xa.forEach(a),Fe=c(ba," is by Binxin Yang, Shuyang Gu, Bo Zhang, Ting Zhang, Xuejin Chen, Xiaoyan Sun, Dong Chen, Fang Wen."),ba.forEach(a),Pe=g(e),ie=s(e,"P",{});var Pa=i(ie);Ne=c(Pa,"The abstract from the paper is:"),Pa.forEach(a),Ee=g(e),oe=s(e,"P",{});var Ea=i(oe);de=s(Ea,"EM",{});var Ta=i(de);Ae=c(Ta,"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."),Ta.forEach(a),Ea.forEach(a),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 Ia=i(R);Ve=c(Ia,"Fantasy-Studio/Paint-by-Example"),Ia.forEach(a),ze=c(re,", and you can try it out in a "),Y=s(re,"A",{href:!0,rel:!0});var ka=i(Y);Re=c(ka,"demo"),ka.forEach(a),Ye=c(re,"."),re.forEach(a),Ie=g(e),U=s(e,"H2",{class:!0});var We=i(U);F=s(We,"A",{id:!0,class:!0,href:!0});var $a=i(F);me=s($a,"SPAN",{});var Ba=i(me);P(O.$$.fragment,Ba),Ba.forEach(a),$a.forEach(a),Oe=g(We),fe=s(We,"SPAN",{});var Ma=i(fe);qe=c(Ma,"Tips"),Ma.forEach(a),We.forEach(a),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 Ja=i(q);He=c(Ja,"Fantasy-Studio/Paint-by-Example"),Ja.forEach(a),Ke=c(pe," checkpoint. The checkpoint is warm-started from "),Q=s(pe,"A",{href:!0,rel:!0});var Sa=i(Q);ea=c(Sa,"CompVis/stable-diffusion-v1-4"),Sa.forEach(a),aa=c(pe," to inpaint partly masked images conditioned on example and reference images."),pe.forEach(a),$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 ja=i(A);ue=s(ja,"SPAN",{});var Wa=i(ue);P(H.$$.fragment,Wa),Wa.forEach(a),ja.forEach(a),ta=g(De),he=s(De,"SPAN",{});var Da=i(he);na=c(Da,"PaintByExamplePipeline"),Da.forEach(a),De.forEach(a),Me=g(e),y=s(e,"DIV",{class:!0});var j=i(y);P(K.$$.fragment,j),sa=g(j),P(X.$$.fragment,j),ia=g(j),ge=s(j,"P",{});var Ua=i(ge);oa=c(Ua,"Pipeline for image-guided image inpainting using Stable Diffusion."),Ua.forEach(a),la=g(j),ee=s(j,"P",{});var Ue=i(ee);ra=c(Ue,"This model inherits from "),le=s(Ue,"A",{href:!0});var La=i(le);pa=c(La,"DiffusionPipeline"),La.forEach(a),ca=c(Ue,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Ue.forEach(a),da=g(j),S=s(j,"DIV",{class:!0});var ce=i(S);P(ae.$$.fragment,ce),ma=g(ce),_e=s(ce,"P",{});var Za=i(_e);fa=c(Za,"The call function to the pipeline for generation."),Za.forEach(a),ua=g(ce),P(V.$$.fragment,ce),ce.forEach(a),j.forEach(a),Je=g(e),Z=s(e,"H2",{class:!0});var Le=i(Z);z=s(Le,"A",{id:!0,class:!0,href:!0});var Ga=i(z);ye=s(Ga,"SPAN",{});var Ca=i(ye);P(te.$$.fragment,Ca),Ca.forEach(a),Ga.forEach(a),ha=g(Le),be=s(Le,"SPAN",{});var Fa=i(be);ga=c(Fa,"StableDiffusionPipelineOutput"),Fa.forEach(a),Le.forEach(a),Se=g(e),G=s(e,"DIV",{class:!0});var Ze=i(G);P(ne.$$.fragment,Ze),_a=g(Ze),we=s(Ze,"P",{});var Na=i(we);ya=c(Na,"Output class for Stable Diffusion pipelines."),Na.forEach(a),Ze.forEach(a),this.h()},h(){r(o,"name","hf:doc:metadata"),r(o,"content",JSON.stringify(tt)),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.20.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){t(document.head,o),f(e,_,l),f(e,m,l),t(m,u),t(u,b),E(d,b,null),t(m,w),t(m,W),t(W,D),f(e,v,l),f(e,$,l),t($,B),t(B,Ce),t($,Fe),f(e,Pe,l),f(e,ie,l),t(ie,Ne),f(e,Ee,l),f(e,oe,l),t(oe,de),t(de,Ae),f(e,Te,l),f(e,M,l),t(M,Xe),t(M,R),t(R,Ve),t(M,ze),t(M,Y),t(Y,Re),t(M,Ye),f(e,Ie,l),f(e,U,l),t(U,F),t(F,me),E(O,me,null),t(U,Oe),t(U,fe),t(fe,qe),f(e,ke,l),f(e,J,l),t(J,Qe),t(J,q),t(q,He),t(J,Ke),t(J,Q),t(Q,ea),t(J,aa),f(e,$e,l),E(N,e,l),f(e,Be,l),f(e,L,l),t(L,A),t(A,ue),E(H,ue,null),t(L,ta),t(L,he),t(he,na),f(e,Me,l),f(e,y,l),E(K,y,null),t(y,sa),E(X,y,null),t(y,ia),t(y,ge),t(ge,oa),t(y,la),t(y,ee),t(ee,ra),t(ee,le),t(le,pa),t(ee,ca),t(y,da),t(y,S),E(ae,S,null),t(S,ma),t(S,_e),t(_e,fa),t(S,ua),E(V,S,null),f(e,Je,l),f(e,Z,l),t(Z,z),t(z,ye),E(te,ye,null),t(Z,ha),t(Z,be),t(be,ga),f(e,Se,l),f(e,G,l),E(ne,G,null),t(G,_a),t(G,we),t(we,ya),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(ae.$$.fragment,e),T(V.$$.fragment,e),T(te.$$.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(ae.$$.fragment,e),I(V.$$.fragment,e),I(te.$$.fragment,e),I(ne.$$.fragment,e),je=!1},d(e){a(o),e&&a(_),e&&a(m),k(d),e&&a(v),e&&a($),e&&a(Pe),e&&a(ie),e&&a(Ee),e&&a(oe),e&&a(Te),e&&a(M),e&&a(Ie),e&&a(U),k(O),e&&a(ke),e&&a(J),e&&a($e),k(N,e),e&&a(Be),e&&a(L),k(H),e&&a(Me),e&&a(y),k(K),k(X),k(ae),k(V),e&&a(Je),e&&a(Z),k(te),e&&a(Se),e&&a(G),k(ne)}}}const tt={local:"paintbyexample",sections:[{local:"tips",title:"Tips"},{local:"diffusers.PaintByExamplePipeline",title:"PaintByExamplePipeline"},{local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",title:"StableDiffusionPipelineOutput"}],title:"PaintByExample"};function nt(C){return Ya(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ct extends Xa{constructor(o){super();Va(this,o,nt,at,za,{})}}export{ct as default,tt as metadata};
