import{S as Ut,i as Wt,s as Vt,e as i,k as c,w as A,t as r,M as Rt,c as n,d as t,m as d,a as o,x as M,h as l,b as s,G as a,g as m,y as j,L as Yt,q as F,o as q,B as N,v as Xt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as Ht}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Zt}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Me}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Kt(nt){let u,je,g,E,me,O,sa,fe,ra,Fe,_,k,he,z,la,ue,pa,qe,G,H,ca,da,Ne,ie,ma,Oe,ne,ge,fa,ze,I,ha,U,ua,ga,Ge,v,T,_e,W,_a,ve,va,He,$,ye,y,be,ya,ba,xe,xa,Pa,oe,wa,Ea,Pe,b,we,V,ka,Ia,Ee,ke,Ta,$a,se,Sa,Ue,x,S,Ie,R,Ba,Te,Da,We,h,P,La,Y,Ca,Aa,X,Ma,ja,Fa,B,qa,$e,Na,Oa,Z,za,Ga,Se,Ha,Ve,K,Re,w,D,Be,J,Ua,De,Wa,Ye,f,Q,Va,ee,Ra,Le,Ya,Xa,Za,ae,Ka,re,Ja,Qa,et,L,te,at,Ce,tt,Xe;return O=new Me({}),z=new Me({}),W=new Me({}),R=new Me({}),K=new Zt({props:{code:`# !pip install diffusers transformers

import PIL
import requests
import torch
from io import BytesIO
from diffusers import DiffusionPipeline


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


img_url = "https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/image/example_1.png"
mask_url = "https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/mask/example_1.png"
example_url = "https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/reference/example_1.jpg"

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

pipe = DiffusionPipeline.from_pretrained(
    "Fantasy-Studio/Paint-by-Example",
    torch_dtype=torch.float16,
)
pipe = pipe.to("cuda")

image = pipe(image=init_image, mask_image=mask_image, example_image=example_image).images[0]
image`,highlighted:`<span class="hljs-comment"># !pip install diffusers transformers</span>

<span class="hljs-keyword">import</span> PIL
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline


<span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
    response = requests.get(url)
    <span class="hljs-keyword">return</span> PIL.Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)


img_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/image/example_1.png&quot;</span>
mask_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/mask/example_1.png&quot;</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>

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

pipe = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;Fantasy-Studio/Paint-by-Example&quot;</span>,
    torch_dtype=torch.float16,
)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

image = pipe(image=init_image, mask_image=mask_image, example_image=example_image).images[<span class="hljs-number">0</span>]
image`}}),J=new Me({}),Q=new Ht({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:": CLIPFeatureExtractor"},{name:"requires_safety_checker",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.PaintByExamplePipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.11.0/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.PaintByExamplePipeline.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.PaintByExamplePipeline.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.PaintByExamplePipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/v0.11.0/en/api/models#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.PaintByExamplePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.11.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.11.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.11.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.11.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 details.`,name:"safety_checker"},{anchor:"diffusers.PaintByExamplePipeline.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/v0.11.0/src/diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py#L137"}}),te=new Ht({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:": typing.Optional[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;
The exemplar image to guide the 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 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.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 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.PaintByExamplePipeline.__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.PaintByExamplePipeline.__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.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;
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.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 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.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;) 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/v0.11.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,name:"eta"},{anchor:"diffusers.PaintByExamplePipeline.__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.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 will ge 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 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.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.11.0/en/api/pipelines/stable_diffusion#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 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.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 will be called. If not specified, the callback will be
called at every step.`,name:"callback_steps"}],source:"https://github.com/huggingface/diffusers/blob/v0.11.0/src/diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py#L399",returnDescription:`
<p><a
  href="/docs/diffusers/v0.11.0/en/api/pipelines/stable_diffusion#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/v0.11.0/en/api/pipelines/stable_diffusion#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),{c(){u=i("meta"),je=c(),g=i("h1"),E=i("a"),me=i("span"),A(O.$$.fragment),sa=c(),fe=i("span"),ra=r("PaintByExample"),Fe=c(),_=i("h2"),k=i("a"),he=i("span"),A(z.$$.fragment),la=c(),ue=i("span"),pa=r("Overview"),qe=c(),G=i("p"),H=i("a"),ca=r("Paint by Example: Exemplar-based Image Editing with Diffusion Models"),da=r(" by Binxin Yang, Shuyang Gu, Bo Zhang, Ting Zhang, Xuejin Chen, Xiaoyan Sun, Dong Chen, Fang Wen"),Ne=c(),ie=i("p"),ma=r("The abstract of the paper is the following:"),Oe=c(),ne=i("p"),ge=i("em"),fa=r("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."),ze=c(),I=i("p"),ha=r("The original codebase can be found "),U=i("a"),ua=r("here"),ga=r("."),Ge=c(),v=i("h2"),T=i("a"),_e=i("span"),A(W.$$.fragment),_a=c(),ve=i("span"),va=r("Available Pipelines:"),He=c(),$=i("table"),ye=i("thead"),y=i("tr"),be=i("th"),ya=r("Pipeline"),ba=c(),xe=i("th"),xa=r("Tasks"),Pa=c(),oe=i("th"),wa=r("Colab"),Ea=c(),Pe=i("tbody"),b=i("tr"),we=i("td"),V=i("a"),ka=r("pipeline_paint_by_example.py"),Ia=c(),Ee=i("td"),ke=i("em"),Ta=r("Image-Guided Image Painting"),$a=c(),se=i("td"),Sa=r("-"),Ue=c(),x=i("h2"),S=i("a"),Ie=i("span"),A(R.$$.fragment),Ba=c(),Te=i("span"),Da=r("Tips"),We=c(),h=i("ul"),P=i("li"),La=r("PaintByExample is supported by the official "),Y=i("a"),Ca=r("Fantasy-Studio/Paint-by-Example"),Aa=r(" checkpoint. The checkpoint has been warm-started from the "),X=i("a"),Ma=r("CompVis/stable-diffusion-v1-4"),ja=r(" and with the objective to inpaint partly masked images conditioned on example / reference images"),Fa=c(),B=i("li"),qa=r("To quickly demo "),$e=i("em"),Na=r("PaintByExample"),Oa=r(", please have a look at "),Z=i("a"),za=r("this demo"),Ga=c(),Se=i("li"),Ha=r("You can run the following code snippet as an example:"),Ve=c(),A(K.$$.fragment),Re=c(),w=i("h2"),D=i("a"),Be=i("span"),A(J.$$.fragment),Ua=c(),De=i("span"),Wa=r("PaintByExamplePipeline"),Ye=c(),f=i("div"),A(Q.$$.fragment),Va=c(),ee=i("p"),Ra=r("Pipeline for text-guided image inpainting using Stable Diffusion. "),Le=i("em"),Ya=r("This is an experimental feature"),Xa=r("."),Za=c(),ae=i("p"),Ka=r("This model inherits from "),re=i("a"),Ja=r("DiffusionPipeline"),Qa=r(`. 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=c(),L=i("div"),A(te.$$.fragment),at=c(),Ce=i("p"),tt=r("Function invoked when calling the pipeline for generation."),this.h()},l(e){const p=Rt('[data-svelte="svelte-1phssyn"]',document.head);u=n(p,"META",{name:!0,content:!0}),p.forEach(t),je=d(e),g=n(e,"H1",{class:!0});var Ze=o(g);E=n(Ze,"A",{id:!0,class:!0,href:!0});var ot=o(E);me=n(ot,"SPAN",{});var st=o(me);M(O.$$.fragment,st),st.forEach(t),ot.forEach(t),sa=d(Ze),fe=n(Ze,"SPAN",{});var rt=o(fe);ra=l(rt,"PaintByExample"),rt.forEach(t),Ze.forEach(t),Fe=d(e),_=n(e,"H2",{class:!0});var Ke=o(_);k=n(Ke,"A",{id:!0,class:!0,href:!0});var lt=o(k);he=n(lt,"SPAN",{});var pt=o(he);M(z.$$.fragment,pt),pt.forEach(t),lt.forEach(t),la=d(Ke),ue=n(Ke,"SPAN",{});var ct=o(ue);pa=l(ct,"Overview"),ct.forEach(t),Ke.forEach(t),qe=d(e),G=n(e,"P",{});var it=o(G);H=n(it,"A",{href:!0,rel:!0});var dt=o(H);ca=l(dt,"Paint by Example: Exemplar-based Image Editing with Diffusion Models"),dt.forEach(t),da=l(it," by Binxin Yang, Shuyang Gu, Bo Zhang, Ting Zhang, Xuejin Chen, Xiaoyan Sun, Dong Chen, Fang Wen"),it.forEach(t),Ne=d(e),ie=n(e,"P",{});var mt=o(ie);ma=l(mt,"The abstract of the paper is the following:"),mt.forEach(t),Oe=d(e),ne=n(e,"P",{});var ft=o(ne);ge=n(ft,"EM",{});var ht=o(ge);fa=l(ht,"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."),ht.forEach(t),ft.forEach(t),ze=d(e),I=n(e,"P",{});var Je=o(I);ha=l(Je,"The original codebase can be found "),U=n(Je,"A",{href:!0,rel:!0});var ut=o(U);ua=l(ut,"here"),ut.forEach(t),ga=l(Je,"."),Je.forEach(t),Ge=d(e),v=n(e,"H2",{class:!0});var Qe=o(v);T=n(Qe,"A",{id:!0,class:!0,href:!0});var gt=o(T);_e=n(gt,"SPAN",{});var _t=o(_e);M(W.$$.fragment,_t),_t.forEach(t),gt.forEach(t),_a=d(Qe),ve=n(Qe,"SPAN",{});var vt=o(ve);va=l(vt,"Available Pipelines:"),vt.forEach(t),Qe.forEach(t),He=d(e),$=n(e,"TABLE",{});var ea=o($);ye=n(ea,"THEAD",{});var yt=o(ye);y=n(yt,"TR",{});var le=o(y);be=n(le,"TH",{});var bt=o(be);ya=l(bt,"Pipeline"),bt.forEach(t),ba=d(le),xe=n(le,"TH",{});var xt=o(xe);xa=l(xt,"Tasks"),xt.forEach(t),Pa=d(le),oe=n(le,"TH",{align:!0});var Pt=o(oe);wa=l(Pt,"Colab"),Pt.forEach(t),le.forEach(t),yt.forEach(t),Ea=d(ea),Pe=n(ea,"TBODY",{});var wt=o(Pe);b=n(wt,"TR",{});var pe=o(b);we=n(pe,"TD",{});var Et=o(we);V=n(Et,"A",{href:!0,rel:!0});var kt=o(V);ka=l(kt,"pipeline_paint_by_example.py"),kt.forEach(t),Et.forEach(t),Ia=d(pe),Ee=n(pe,"TD",{});var It=o(Ee);ke=n(It,"EM",{});var Tt=o(ke);Ta=l(Tt,"Image-Guided Image Painting"),Tt.forEach(t),It.forEach(t),$a=d(pe),se=n(pe,"TD",{align:!0});var $t=o(se);Sa=l($t,"-"),$t.forEach(t),pe.forEach(t),wt.forEach(t),ea.forEach(t),Ue=d(e),x=n(e,"H2",{class:!0});var aa=o(x);S=n(aa,"A",{id:!0,class:!0,href:!0});var St=o(S);Ie=n(St,"SPAN",{});var Bt=o(Ie);M(R.$$.fragment,Bt),Bt.forEach(t),St.forEach(t),Ba=d(aa),Te=n(aa,"SPAN",{});var Dt=o(Te);Da=l(Dt,"Tips"),Dt.forEach(t),aa.forEach(t),We=d(e),h=n(e,"UL",{});var ce=o(h);P=n(ce,"LI",{});var de=o(P);La=l(de,"PaintByExample is supported by the official "),Y=n(de,"A",{href:!0,rel:!0});var Lt=o(Y);Ca=l(Lt,"Fantasy-Studio/Paint-by-Example"),Lt.forEach(t),Aa=l(de," checkpoint. The checkpoint has been warm-started from the "),X=n(de,"A",{href:!0,rel:!0});var Ct=o(X);Ma=l(Ct,"CompVis/stable-diffusion-v1-4"),Ct.forEach(t),ja=l(de," and with the objective to inpaint partly masked images conditioned on example / reference images"),de.forEach(t),Fa=d(ce),B=n(ce,"LI",{});var Ae=o(B);qa=l(Ae,"To quickly demo "),$e=n(Ae,"EM",{});var At=o($e);Na=l(At,"PaintByExample"),At.forEach(t),Oa=l(Ae,", please have a look at "),Z=n(Ae,"A",{href:!0,rel:!0});var Mt=o(Z);za=l(Mt,"this demo"),Mt.forEach(t),Ae.forEach(t),Ga=d(ce),Se=n(ce,"LI",{});var jt=o(Se);Ha=l(jt,"You can run the following code snippet as an example:"),jt.forEach(t),ce.forEach(t),Ve=d(e),M(K.$$.fragment,e),Re=d(e),w=n(e,"H2",{class:!0});var ta=o(w);D=n(ta,"A",{id:!0,class:!0,href:!0});var Ft=o(D);Be=n(Ft,"SPAN",{});var qt=o(Be);M(J.$$.fragment,qt),qt.forEach(t),Ft.forEach(t),Ua=d(ta),De=n(ta,"SPAN",{});var Nt=o(De);Wa=l(Nt,"PaintByExamplePipeline"),Nt.forEach(t),ta.forEach(t),Ye=d(e),f=n(e,"DIV",{class:!0});var C=o(f);M(Q.$$.fragment,C),Va=d(C),ee=n(C,"P",{});var ia=o(ee);Ra=l(ia,"Pipeline for text-guided image inpainting using Stable Diffusion. "),Le=n(ia,"EM",{});var Ot=o(Le);Ya=l(Ot,"This is an experimental feature"),Ot.forEach(t),Xa=l(ia,"."),ia.forEach(t),Za=d(C),ae=n(C,"P",{});var na=o(ae);Ka=l(na,"This model inherits from "),re=n(na,"A",{href:!0});var zt=o(re);Ja=l(zt,"DiffusionPipeline"),zt.forEach(t),Qa=l(na,`. 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.)`),na.forEach(t),et=d(C),L=n(C,"DIV",{class:!0});var oa=o(L);M(te.$$.fragment,oa),at=d(oa),Ce=n(oa,"P",{});var Gt=o(Ce);tt=l(Gt,"Function invoked when calling the pipeline for generation."),Gt.forEach(t),oa.forEach(t),C.forEach(t),this.h()},h(){s(u,"name","hf:doc:metadata"),s(u,"content",JSON.stringify(Jt)),s(E,"id","paintbyexample"),s(E,"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"),s(E,"href","#paintbyexample"),s(g,"class","relative group"),s(k,"id","overview"),s(k,"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"),s(k,"href","#overview"),s(_,"class","relative group"),s(H,"href","https://arxiv.org/abs/2211.13227"),s(H,"rel","nofollow"),s(U,"href","https://github.com/Fantasy-Studio/Paint-by-Example"),s(U,"rel","nofollow"),s(T,"id","available-pipelines"),s(T,"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"),s(T,"href","#available-pipelines"),s(v,"class","relative group"),s(oe,"align","center"),s(V,"href","https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/paint_by_example/pipeline_paint_by_example.py"),s(V,"rel","nofollow"),s(se,"align","center"),s(S,"id","tips"),s(S,"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"),s(S,"href","#tips"),s(x,"class","relative group"),s(Y,"href","https://huggingface.co/Fantasy-Studio/Paint-by-Example"),s(Y,"rel","nofollow"),s(X,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4"),s(X,"rel","nofollow"),s(Z,"href","https://huggingface.co/spaces/Fantasy-Studio/Paint-by-Example"),s(Z,"rel","nofollow"),s(D,"id","diffusers.PaintByExamplePipeline"),s(D,"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"),s(D,"href","#diffusers.PaintByExamplePipeline"),s(w,"class","relative group"),s(re,"href","/docs/diffusers/v0.11.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),s(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),s(f,"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,p){a(document.head,u),m(e,je,p),m(e,g,p),a(g,E),a(E,me),j(O,me,null),a(g,sa),a(g,fe),a(fe,ra),m(e,Fe,p),m(e,_,p),a(_,k),a(k,he),j(z,he,null),a(_,la),a(_,ue),a(ue,pa),m(e,qe,p),m(e,G,p),a(G,H),a(H,ca),a(G,da),m(e,Ne,p),m(e,ie,p),a(ie,ma),m(e,Oe,p),m(e,ne,p),a(ne,ge),a(ge,fa),m(e,ze,p),m(e,I,p),a(I,ha),a(I,U),a(U,ua),a(I,ga),m(e,Ge,p),m(e,v,p),a(v,T),a(T,_e),j(W,_e,null),a(v,_a),a(v,ve),a(ve,va),m(e,He,p),m(e,$,p),a($,ye),a(ye,y),a(y,be),a(be,ya),a(y,ba),a(y,xe),a(xe,xa),a(y,Pa),a(y,oe),a(oe,wa),a($,Ea),a($,Pe),a(Pe,b),a(b,we),a(we,V),a(V,ka),a(b,Ia),a(b,Ee),a(Ee,ke),a(ke,Ta),a(b,$a),a(b,se),a(se,Sa),m(e,Ue,p),m(e,x,p),a(x,S),a(S,Ie),j(R,Ie,null),a(x,Ba),a(x,Te),a(Te,Da),m(e,We,p),m(e,h,p),a(h,P),a(P,La),a(P,Y),a(Y,Ca),a(P,Aa),a(P,X),a(X,Ma),a(P,ja),a(h,Fa),a(h,B),a(B,qa),a(B,$e),a($e,Na),a(B,Oa),a(B,Z),a(Z,za),a(h,Ga),a(h,Se),a(Se,Ha),m(e,Ve,p),j(K,e,p),m(e,Re,p),m(e,w,p),a(w,D),a(D,Be),j(J,Be,null),a(w,Ua),a(w,De),a(De,Wa),m(e,Ye,p),m(e,f,p),j(Q,f,null),a(f,Va),a(f,ee),a(ee,Ra),a(ee,Le),a(Le,Ya),a(ee,Xa),a(f,Za),a(f,ae),a(ae,Ka),a(ae,re),a(re,Ja),a(ae,Qa),a(f,et),a(f,L),j(te,L,null),a(L,at),a(L,Ce),a(Ce,tt),Xe=!0},p:Yt,i(e){Xe||(F(O.$$.fragment,e),F(z.$$.fragment,e),F(W.$$.fragment,e),F(R.$$.fragment,e),F(K.$$.fragment,e),F(J.$$.fragment,e),F(Q.$$.fragment,e),F(te.$$.fragment,e),Xe=!0)},o(e){q(O.$$.fragment,e),q(z.$$.fragment,e),q(W.$$.fragment,e),q(R.$$.fragment,e),q(K.$$.fragment,e),q(J.$$.fragment,e),q(Q.$$.fragment,e),q(te.$$.fragment,e),Xe=!1},d(e){t(u),e&&t(je),e&&t(g),N(O),e&&t(Fe),e&&t(_),N(z),e&&t(qe),e&&t(G),e&&t(Ne),e&&t(ie),e&&t(Oe),e&&t(ne),e&&t(ze),e&&t(I),e&&t(Ge),e&&t(v),N(W),e&&t(He),e&&t($),e&&t(Ue),e&&t(x),N(R),e&&t(We),e&&t(h),e&&t(Ve),N(K,e),e&&t(Re),e&&t(w),N(J),e&&t(Ye),e&&t(f),N(Q),N(te)}}}const Jt={local:"paintbyexample",sections:[{local:"overview",title:"Overview"},{local:"available-pipelines",title:"Available Pipelines:"},{local:"tips",title:"Tips"},{local:"diffusers.PaintByExamplePipeline",title:"PaintByExamplePipeline"}],title:"PaintByExample"};function Qt(nt){return Xt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ni extends Ut{constructor(u){super();Wt(this,u,Qt,Kt,Vt,{})}}export{ni as default,Jt as metadata};
