import{S as Am,i as Sm,s as $m,e as a,k as f,w as S,t as l,M as jm,c as o,d as t,m as d,a as s,x as $,h as r,b as i,N as Kt,G as e,g as h,y as j,L as Cm,q as C,o as O,B as G,v as Om}from"../../../chunks/vendor-hf-doc-builder.js";import{I as ue}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{C as Gp}from"../../../chunks/CodeBlock-hf-doc-builder.js";function Gm(Mp){let ae,mn,oe,me,eo,Fe,gl,to,_l,gn,Xt,vl,_n,ge,bl,We,El,yl,vn,b,ao,Zt,wl,Il,oo,ea,kl,Dl,so,Qe,Tl,Pl,Je,xl,ta,Al,Sl,$l,Ke,jl,Xe,Cl,Ol,Gl,Ze,Ml,aa,ql,Ll,bn,oa,Nl,En,k,no,lo,M,Rl,ro,Hl,Bl,et,Ul,Vl,tt,Yl,zl,Fl,io,sa,at,Wl,na,Ql,Jl,Kl,fo,la,ot,Xl,ra,Zl,er,tr,po,ia,st,ar,fa,or,sr,yn,q,ho,nr,lr,co,rr,ir,nt,fr,dr,wn,se,_e,uo,lt,pr,mo,hr,In,da,cr,kn,ve,go,L,_o,ur,mr,vo,gr,_r,pa,vr,br,ha,Er,yr,u,N,bo,ca,wr,Ir,Eo,rt,yo,kr,Dr,ua,Tr,Pr,wo,xr,R,Io,ma,Ar,Sr,ko,it,Do,$r,jr,ga,Cr,Or,_a,ft,va,qp,Gr,H,To,ba,Mr,qr,Po,dt,xo,Lr,Nr,Ea,Rr,Hr,Ao,Br,B,So,ya,Ur,Vr,$o,pt,jo,Yr,zr,wa,Fr,Wr,Co,Qr,U,Oo,Ia,Jr,Kr,Go,ht,Mo,Xr,Zr,ka,ei,ti,qo,ai,V,Lo,Da,oi,si,No,ct,Ro,ni,li,Ta,ri,ii,Ho,fi,Y,Bo,Pa,di,pi,Uo,ut,Vo,hi,ci,xa,ui,mi,Yo,gi,z,zo,Aa,_i,vi,Fo,mt,Wo,bi,Ei,Sa,yi,wi,$a,gt,ja,Lp,Ii,F,Qo,Ca,ki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,dn,bp,Un,ee,Ep,Bt,yp,wp,Ut,Ja,Bp,Ip,Vn,he,xe,pn,Vt,kp,hn,Dp,Yn,Ae,Tp,cn,Pp,xp,zn,Yt,Fn,zt,Ap,Ft,Ka,Up,Wn;return Fe=new ue({}),lt=new ue({}),It=new ue({}),$t=new ue({}),Ot=new ue({}),Gt=new ue({}),Mt=new Gp({props:{code:`# make sure you're logged in with \`huggingface-cli login\`
from torch import autocast
from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler

pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=True)
pipe = pipe.to("cuda")

prompt = "a photo of an astronaut riding a horse on mars"
with autocast("cuda"):
    image = pipe(prompt).images[0]

image.save("astronaut_rides_horse.png")`,highlighted:`<span class="hljs-comment"># make sure you&#x27;re logged in with \`huggingface-cli login\`</span>
<span class="hljs-keyword">from</span> torch <span class="hljs-keyword">import</span> autocast
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, LMSDiscreteScheduler

pipe = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>, use_auth_token=<span class="hljs-literal">True</span>)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>
<span class="hljs-keyword">with</span> autocast(<span class="hljs-string">&quot;cuda&quot;</span>):
    image = pipe(prompt).images[<span class="hljs-number">0</span>]

image.save(<span class="hljs-string">&quot;astronaut_rides_horse.png&quot;</span>)`}}),qt=new ue({}),Lt=new Gp({props:{code:`from torch import autocast
import requests
from PIL import Image
from io import BytesIO

from diffusers import StableDiffusionImg2ImgPipeline

# load the pipeline
device = "cuda"
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, use_auth_token=True
).to(device)

# let's download an initial image
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"

response = requests.get(url)
init_image = Image.open(BytesIO(response.content)).convert("RGB")
init_image = init_image.resize((768, 512))

prompt = "A fantasy landscape, trending on artstation"

with autocast("cuda"):
    images = pipe(prompt=prompt, init_image=init_image, strength=0.75, guidance_scale=7.5).images

images[0].save("fantasy_landscape.png")`,highlighted:`<span class="hljs-keyword">from</span> torch <span class="hljs-keyword">import</span> autocast
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<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> StableDiffusionImg2ImgPipeline

<span class="hljs-comment"># load the pipeline</span>
device = <span class="hljs-string">&quot;cuda&quot;</span>
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
    <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>, revision=<span class="hljs-string">&quot;fp16&quot;</span>, torch_dtype=torch.float16, use_auth_token=<span class="hljs-literal">True</span>
).to(device)

<span class="hljs-comment"># let&#x27;s download an initial image</span>
url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>

response = requests.get(url)
init_image = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
init_image = init_image.resize((<span class="hljs-number">768</span>, <span class="hljs-number">512</span>))

prompt = <span class="hljs-string">&quot;A fantasy landscape, trending on artstation&quot;</span>

<span class="hljs-keyword">with</span> autocast(<span class="hljs-string">&quot;cuda&quot;</span>):
    images = pipe(prompt=prompt, init_image=init_image, strength=<span class="hljs-number">0.75</span>, guidance_scale=<span class="hljs-number">7.5</span>).images

images[<span class="hljs-number">0</span>].save(<span class="hljs-string">&quot;fantasy_landscape.png&quot;</span>)`}}),Ht=new ue({}),Vt=new ue({}),Yt=new Gp({props:{code:`from io import BytesIO

from torch import autocast
import requests
import PIL

from diffusers import StableDiffusionInpaintPipeline


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


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

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

device = "cuda"
pipe = StableDiffusionInpaintPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, use_auth_token=True
).to(device)

prompt = "a cat sitting on a bench"
with autocast("cuda"):
    images = pipe(prompt=prompt, init_image=init_image, mask_image=mask_image, strength=0.75).images

images[0].save("cat_on_bench.png")`,highlighted:`<span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO

<span class="hljs-keyword">from</span> torch <span class="hljs-keyword">import</span> autocast
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> PIL

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


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


img_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png&quot;</span>
mask_url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png&quot;</span>

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

device = <span class="hljs-string">&quot;cuda&quot;</span>
pipe = StableDiffusionInpaintPipeline.from_pretrained(
    <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>, revision=<span class="hljs-string">&quot;fp16&quot;</span>, torch_dtype=torch.float16, use_auth_token=<span class="hljs-literal">True</span>
).to(device)

prompt = <span class="hljs-string">&quot;a cat sitting on a bench&quot;</span>
<span class="hljs-keyword">with</span> autocast(<span class="hljs-string">&quot;cuda&quot;</span>):
    images = pipe(prompt=prompt, init_image=init_image, mask_image=mask_image, strength=<span class="hljs-number">0.75</span>).images

images[<span class="hljs-number">0</span>].save(<span class="hljs-string">&quot;cat_on_bench.png&quot;</span>)`}}),{c(){ae=a("meta"),mn=f(),oe=a("h1"),me=a("a"),eo=a("span"),S(Fe.$$.fragment),gl=f(),to=a("span"),_l=l("Pipelines"),gn=f(),Xt=a("p"),vl=l(`Pipelines provide a simple way to run state-of-the-art diffusion models in inference.
Most diffusion systems consist of multiple independently-trained models and highly adaptable scheduler
components - all of which are needed to have a functioning end-to-end diffusion system.`),_n=f(),ge=a("p"),bl=l("As an example, "),We=a("a"),El=l("Stable Diffusion"),yl=l(" has three independently trained models:"),vn=f(),b=a("ul"),ao=a("li"),Zt=a("a"),wl=l("Autoencoder"),Il=f(),oo=a("li"),ea=a("a"),kl=l("Conditional Unet"),Dl=f(),so=a("li"),Qe=a("a"),Tl=l("CLIP text encoder"),Pl=f(),Je=a("li"),xl=l("a scheduler component, "),ta=a("a"),Al=l("scheduler"),Sl=l(","),$l=f(),Ke=a("li"),jl=l("a "),Xe=a("a"),Cl=l("CLIPFeatureExtractor"),Ol=l(","),Gl=f(),Ze=a("li"),Ml=l("as well as a "),aa=a("a"),ql=l("safety checker"),Ll=l(`.
All of these components are necessary to run stable diffusion in inference even though they were trained
or created independently from each other.`),bn=f(),oa=a("p"),Nl=l(`To that end, we strive to offer all open-sourced, state-of-the-art diffusion system under a unified API.
More specifically, we strive to provide pipelines that`),En=f(),k=a("ul"),no=a("li"),lo=a("ol"),M=a("li"),Rl=l("can load the officially published weights and yield 1-to-1 the same outputs as the original implementation according to the corresponding paper ("),ro=a("em"),Hl=l("e.g."),Bl=f(),et=a("a"),Ul=l("LatentDiffusionPipeline"),Vl=l(", uses the officially released weights of "),tt=a("a"),Yl=l("High-Resolution Image Synthesis with Latent Diffusion Models"),zl=l("),"),Fl=f(),io=a("li"),sa=a("ol"),at=a("li"),Wl=l("have a simple user interface to run the model in inference (see the "),na=a("a"),Ql=l("Pipelines API"),Jl=l(" section),"),Kl=f(),fo=a("li"),la=a("ol"),ot=a("li"),Xl=l("are easy to understand with code that is self-explanatory and can be read along-side the official paper (see "),ra=a("a"),Zl=l("Pipelines summary"),er=l("),"),tr=f(),po=a("li"),ia=a("ol"),st=a("li"),ar=l("can easily be contributed by the community (see the "),fa=a("a"),or=l("Contribution"),sr=l(" section)."),yn=f(),q=a("p"),ho=a("strong"),nr=l("Note"),lr=l(` that pipelines do not (and should not) offer any training functionality.
If you are looking for `),co=a("em"),rr=l("official"),ir=l(" training examples, please have a look at "),nt=a("a"),fr=l("examples"),dr=l("."),wn=f(),se=a("h2"),_e=a("a"),uo=a("span"),S(lt.$$.fragment),pr=f(),mo=a("span"),hr=l("\u{1F9E8} Diffusers Summary"),In=f(),da=a("p"),cr=l(`The following table summarizes all officially supported pipelines, their corresponding paper, and if
available a colab notebook to directly try them out.`),kn=f(),ve=a("table"),go=a("thead"),L=a("tr"),_o=a("th"),ur=l("Pipeline"),mr=f(),vo=a("th"),gr=l("Paper"),_r=f(),pa=a("th"),vr=l("Tasks"),br=f(),ha=a("th"),Er=l("Colab"),yr=f(),u=a("tbody"),N=a("tr"),bo=a("td"),ca=a("a"),wr=l("ddpm"),Ir=f(),Eo=a("td"),rt=a("a"),yo=a("strong"),kr=l("Denoising Diffusion Probabilistic Models"),Dr=f(),ua=a("td"),Tr=l("Unconditional Image Generation"),Pr=f(),wo=a("td"),xr=f(),R=a("tr"),Io=a("td"),ma=a("a"),Ar=l("ddim"),Sr=f(),ko=a("td"),it=a("a"),Do=a("strong"),$r=l("Denoising Diffusion Implicit Models"),jr=f(),ga=a("td"),Cr=l("Unconditional Image Generation"),Or=f(),_a=a("td"),ft=a("a"),va=a("img"),Gr=f(),H=a("tr"),To=a("td"),ba=a("a"),Mr=l("latent_diffusion"),qr=f(),Po=a("td"),dt=a("a"),xo=a("strong"),Lr=l("High-Resolution Image Synthesis with Latent Diffusion Models"),Nr=f(),Ea=a("td"),Rr=l("Text-to-Image Generation"),Hr=f(),Ao=a("td"),Br=f(),B=a("tr"),So=a("td"),ya=a("a"),Ur=l("latent_diffusion_uncond"),Vr=f(),$o=a("td"),pt=a("a"),jo=a("strong"),Yr=l("High-Resolution Image Synthesis with Latent Diffusion Models"),zr=f(),wa=a("td"),Fr=l("Unconditional Image Generation"),Wr=f(),Co=a("td"),Qr=f(),U=a("tr"),Oo=a("td"),Ia=a("a"),Jr=l("pndm"),Kr=f(),Go=a("td"),ht=a("a"),Mo=a("strong"),Xr=l("Pseudo Numerical Methods for Diffusion Models on Manifolds"),Zr=f(),ka=a("td"),ei=l("Unconditional Image Generation"),ti=f(),qo=a("td"),ai=f(),V=a("tr"),Lo=a("td"),Da=a("a"),oi=l("score_sde_ve"),si=f(),No=a("td"),ct=a("a"),Ro=a("strong"),ni=l("Score-Based Generative Modeling through Stochastic Differential Equations"),li=f(),Ta=a("td"),ri=l("Unconditional Image Generation"),ii=f(),Ho=a("td"),fi=f(),Y=a("tr"),Bo=a("td"),Pa=a("a"),di=l("score_sde_vp"),pi=f(),Uo=a("td"),ut=a("a"),Vo=a("strong"),hi=l("Score-Based Generative Modeling through Stochastic Differential Equations"),ci=f(),xa=a("td"),ui=l("Unconditional Image Generation"),mi=f(),Yo=a("td"),gi=f(),z=a("tr"),zo=a("td"),Aa=a("a"),_i=l("stable_diffusion"),vi=f(),Fo=a("td"),mt=a("a"),Wo=a("strong"),bi=l("Stable Diffusion"),Ei=f(),Sa=a("td"),yi=l("Text-to-Image Generation"),wi=f(),$a=a("td"),gt=a("a"),ja=a("img"),Ii=f(),F=a("tr"),Qo=a("td"),Ca=a("a"),ki=l("stable_diffusion"),Di=f(),Jo=a("td"),_t=a("a"),Ko=a("strong"),Ti=l("Stable Diffusion"),Pi=f(),Oa=a("td"),xi=l("Image-to-Image Text-Guided Generation"),Ai=f(),Ga=a("td"),vt=a("a"),Ma=a("img"),Si=f(),W=a("tr"),Xo=a("td"),qa=a("a"),$i=l("stable_diffusion"),ji=f(),Zo=a("td"),bt=a("a"),es=a("strong"),Ci=l("Stable Diffusion"),Oi=f(),La=a("td"),Gi=l("Text-Guided Image Inpainting"),Mi=f(),Na=a("td"),Et=a("a"),Ra=a("img"),qi=f(),Q=a("tr"),ts=a("td"),Ha=a("a"),Li=l("stochatic_karras_ve"),Ni=f(),as=a("td"),yt=a("a"),os=a("strong"),Ri=l("Elucidating the Design Space of Diffusion-Based Generative Models"),Hi=f(),Ba=a("td"),Bi=l("Unconditional Image Generation"),Ui=f(),ss=a("td"),Dn=f(),wt=a("p"),ns=a("strong"),Vi=l("Note"),Yi=l(": Pipelines are simple examples of how to play around with the diffusion systems as described in the corresponding papers."),Tn=f(),be=a("p"),zi=l("However, most of them can be adapted to use different scheduler components or even different model components. Some pipeline examples are shown in the "),Ua=a("a"),Fi=l("Examples"),Wi=l(" below."),Pn=f(),ne=a("h2"),Ee=a("a"),ls=a("span"),S(It.$$.fragment),Qi=f(),rs=a("span"),Ji=l("Pipelines API"),xn=f(),Va=a("p"),Ki=l("Diffusion models often consist of multiple independently-trained models or other previously existing components."),An=f(),K=a("p"),Xi=l(`Each model has been trained independently on a different task and the scheduler can easily be swapped out and replaced with a different one.
During inference, we however want to be able to easily load all components and use them in inference - even if one component, `),is=a("em"),Zi=l("e.g."),ef=l(" CLIP\u2019s text encoder, originates from a different library, such as "),kt=a("a"),tf=l("Transformers"),af=l(". To that end, all pipelines provide the following functionality:"),Sn=f(),D=a("ul"),c=a("li"),Dt=a("a"),fs=a("code"),of=l("from_pretrained"),sf=l(" method"),nf=l(" that accepts a Hugging Face Hub repository id, "),ds=a("em"),lf=l("e.g."),rf=f(),Tt=a("a"),ff=l("CompVis/stable-diffusion-v1-4"),df=l(" or a path to a local directory, "),ps=a("em"),pf=l("e.g."),hf=l(`
\u201D./stable-diffusion\u201D. To correctly retrieve which models and components should be loaded, one has to provide a `),hs=a("code"),cf=l("model_index.json"),uf=l(" file, "),cs=a("em"),mf=l("e.g."),gf=f(),Pt=a("a"),_f=l("CompVis/stable-diffusion-v1-4/model_index.json"),vf=l(`, which defines all components that should be
loaded into the pipelines. More specifically, for each model/component one needs to define the format `),us=a("code"),bf=l('<name>: ["<library>", "<class name>"]'),Ef=l(". "),ms=a("code"),yf=l("<name>"),wf=l(" is the attribute name given to the loaded instance of "),gs=a("code"),If=l("<class name>"),kf=l(" which can be found in the library or pipeline folder called "),_s=a("code"),Df=l('"<library>"'),Tf=l("."),Pf=f(),_=a("li"),Ya=a("a"),vs=a("code"),xf=l("save_pretrained"),Af=l(" that accepts a local path, "),bs=a("em"),Sf=l("e.g."),$f=f(),Es=a("code"),jf=l("./stable-diffusion"),Cf=l(" under which all models/components of the pipeline will be saved. For each component/model a folder is created inside the local path that is named after the given attribute name, "),ys=a("em"),Of=l("e.g."),Gf=f(),ws=a("code"),Mf=l("./stable_diffusion/unet"),qf=l(`.
In addition, a `),Is=a("code"),Lf=l("model_index.json"),Nf=l(" file is created at the root of the local path, "),ks=a("em"),Rf=l("e.g."),Hf=f(),Ds=a("code"),Bf=l("./stable_diffusion/model_index.json"),Uf=l(` so that the complete pipeline can again be instantiated
from the local path.`),Vf=f(),y=a("li"),za=a("a"),Ts=a("code"),Yf=l("to"),zf=l(" which accepts a "),Ps=a("code"),Ff=l("string"),Wf=l(" or "),xs=a("code"),Qf=l("torch.device"),Jf=l(" to move all models that are of type "),As=a("code"),Kf=l("torch.nn.Module"),Xf=l(" to the passed device. The behavior is fully analogous to "),le=a("a"),Zf=l("PyTorch\u2019s "),Ss=a("code"),ed=l("to"),td=l(" method"),ad=l("."),od=f(),E=a("li"),$s=a("code"),sd=l("__call__"),nd=l(" method to use the pipeline in inference. "),js=a("code"),ld=l("__call__"),rd=l(" defines inference logic of the pipeline and should ideally encompass all aspects of it, from pre-processing to forwarding tensors to the different models and schedulers, as well as post-processing. The API of the "),Cs=a("code"),id=l("__call__"),fd=l(" method can strongly vary from pipeline to pipeline. "),Os=a("em"),dd=l("E.g."),pd=l(" a text-to-image pipeline, such as "),Fa=a("a"),Gs=a("code"),hd=l("StableDiffusionPipeline"),cd=l(" should accept among other things the text prompt to generate the image. A pure image generation pipeline, such as "),xt=a("a"),ud=l("DDPMPipeline"),md=l(` on the other hand can be run without providing any inputs. To better understand what inputs can be adapted for
each pipeline, one should look directly into the respective pipeline.`),$n=f(),T=a("p"),Ms=a("strong"),gd=l("Note"),_d=l(": All pipelines have PyTorch\u2019s autograd disabled by decorating the "),qs=a("code"),vd=l("__call__"),bd=l(" method with a "),At=a("a"),Ls=a("code"),Ed=l("torch.no_grad"),yd=l(` decorator because pipelines should
not be used for training. If you want to store the gradients during the forward pass, we recommend writing your own pipeline, see also our `),St=a("a"),wd=l("community-examples"),jn=f(),re=a("h2"),ye=a("a"),Ns=a("span"),S($t.$$.fragment),Id=f(),Rs=a("span"),kd=l("Contribution"),Cn=f(),w=a("p"),Dd=l(`We are more than happy about any contribution to the officially supported pipelines \u{1F917}. We aspire
all of our pipelines to be  `),Hs=a("strong"),Td=l("self-contained"),Pd=l(", "),Bs=a("strong"),xd=l("easy-to-tweak"),Ad=l(", "),Us=a("strong"),Sd=l("beginner-friendly"),$d=l(" and for "),Vs=a("strong"),jd=l("one-purpose-only"),Cd=l("."),On=f(),P=a("ul"),we=a("li"),Ys=a("strong"),Od=l("Self-contained"),Gd=l(": A pipeline shall be as self-contained as possible. More specifically, this means that all functionality should be either directly defined in the pipeline file iteslf, should be inherited from (and only from) the "),jt=a("a"),zs=a("code"),Md=l("DiffusionPipeline"),qd=l(" class"),Ld=l(" or be directly attached to the model and scheduler components of the pipeline."),Nd=f(),X=a("li"),Fs=a("strong"),Rd=l("Easy-to-use"),Hd=l(`: Pipelines should be extremely easy to use - one should be able to load the pipeline and
use it for its designated task, `),Ws=a("em"),Bd=l("e.g."),Ud=l(` text-to-image generation, in just a couple of lines of code. Most
logic including pre-processing, an unrolled diffusion loop, and post-processing should all happen inside the `),Qs=a("code"),Vd=l("__call__"),Yd=l(" method."),zd=f(),Z=a("li"),Js=a("strong"),Fd=l("Easy-to-tweak"),Wd=l(": Certain pipelines will not be able to handle all use cases and tasks that you might like them to. If you want to use a certain pipeline for a specific use case that is not yet supported, you might have to copy the pipeline file and tweak the code to your needs. We try to make the pipeline code as readable as possible so that each part \u2013from pre-processing to diffusing to post-processing\u2013 can easily be adapted. If you would like the community to benefit from your customized pipeline, we would love to see a contribution to our "),Ct=a("a"),Qd=l("community-examples"),Jd=l(". If you feel that an important pipeline should be part of the official pipelines but isn\u2019t, a contribution to the "),Wa=a("a"),Kd=l("official pipelines"),Xd=l(" would be even better."),Zd=f(),x=a("li"),Ks=a("strong"),ep=l("One-purpose-only"),tp=l(": Pipelines should be used for one task and one task only. Even if two tasks are very similar from a modeling point of view, "),Xs=a("em"),ap=l("e.g."),op=l(" image2image translation and in-painting, pipelines shall be used for one task only to keep them "),Zs=a("em"),sp=l("easy-to-tweak"),np=l(" and "),en=a("em"),lp=l("readable"),rp=l("."),Gn=f(),ie=a("h2"),Ie=a("a"),tn=a("span"),S(Ot.$$.fragment),ip=f(),an=a("span"),fp=l("Examples"),Mn=f(),fe=a("h3"),ke=a("a"),on=a("span"),S(Gt.$$.fragment),dp=f(),sn=a("span"),pp=l("Text-to-Image generation with Stable Diffusion"),qn=f(),S(Mt.$$.fragment),Ln=f(),de=a("h3"),De=a("a"),nn=a("span"),S(qt.$$.fragment),hp=f(),ln=a("span"),cp=l("Image-to-Image text-guided generation with Stable Diffusion"),Nn=f(),Te=a("p"),up=l("The "),rn=a("code"),mp=l("StableDiffusionImg2ImgPipeline"),gp=l(" lets you pass a text prompt and an initial image to condition the generation of new images."),Rn=f(),S(Lt.$$.fragment),Hn=f(),Nt=a("p"),_p=l("You can also run this example on colab "),Rt=a("a"),Qa=a("img"),Bn=f(),pe=a("h3"),Pe=a("a"),fn=a("span"),S(Ht.$$.fragment),vp=f(),dn=a("span"),bp=l("Tweak prompts reusing seeds and latents"),Un=f(),ee=a("p"),Ep=l("You can generate your own latents to reproduce results, or tweak your prompt on a specific result you liked. "),Bt=a("a"),yp=l("This notebook"),wp=l(" shows how to do it step by step. You can also run it in Google Colab "),Ut=a("a"),Ja=a("img"),Ip=l("."),Vn=f(),he=a("h3"),xe=a("a"),pn=a("span"),S(Vt.$$.fragment),kp=f(),hn=a("span"),Dp=l("In-painting using Stable Diffusion"),Yn=f(),Ae=a("p"),Tp=l("The "),cn=a("code"),Pp=l("StableDiffusionInpaintPipeline"),xp=l(" lets you edit specific parts of an image by providing a mask and text prompt."),zn=f(),S(Yt.$$.fragment),Fn=f(),zt=a("p"),Ap=l("You can also run this example on colab "),Ft=a("a"),Ka=a("img"),this.h()},l(n){const p=jm('[data-svelte="svelte-1phssyn"]',document.head);ae=o(p,"META",{name:!0,content:!0}),p.forEach(t),mn=d(n),oe=o(n,"H1",{class:!0});var Qn=s(oe);me=o(Qn,"A",{id:!0,class:!0,href:!0});var Vp=s(me);eo=o(Vp,"SPAN",{});var Yp=s(eo);$(Fe.$$.fragment,Yp),Yp.forEach(t),Vp.forEach(t),gl=d(Qn),to=o(Qn,"SPAN",{});var zp=s(to);_l=r(zp,"Pipelines"),zp.forEach(t),Qn.forEach(t),gn=d(n),Xt=o(n,"P",{});var Fp=s(Xt);vl=r(Fp,`Pipelines provide a simple way to run state-of-the-art diffusion models in inference.
Most diffusion systems consist of multiple independently-trained models and highly adaptable scheduler
components - all of which are needed to have a functioning end-to-end diffusion system.`),Fp.forEach(t),_n=d(n),ge=o(n,"P",{});var Jn=s(ge);bl=r(Jn,"As an example, "),We=o(Jn,"A",{href:!0,rel:!0});var Wp=s(We);El=r(Wp,"Stable Diffusion"),Wp.forEach(t),yl=r(Jn," has three independently trained models:"),Jn.forEach(t),vn=d(n),b=o(n,"UL",{});var A=s(b);ao=o(A,"LI",{});var Qp=s(ao);Zt=o(Qp,"A",{href:!0});var Jp=s(Zt);wl=r(Jp,"Autoencoder"),Jp.forEach(t),Qp.forEach(t),Il=d(A),oo=o(A,"LI",{});var Kp=s(oo);ea=o(Kp,"A",{href:!0});var Xp=s(ea);kl=r(Xp,"Conditional Unet"),Xp.forEach(t),Kp.forEach(t),Dl=d(A),so=o(A,"LI",{});var Zp=s(so);Qe=o(Zp,"A",{href:!0,rel:!0});var eh=s(Qe);Tl=r(eh,"CLIP text encoder"),eh.forEach(t),Zp.forEach(t),Pl=d(A),Je=o(A,"LI",{});var Kn=s(Je);xl=r(Kn,"a scheduler component, "),ta=o(Kn,"A",{href:!0});var th=s(ta);Al=r(th,"scheduler"),th.forEach(t),Sl=r(Kn,","),Kn.forEach(t),$l=d(A),Ke=o(A,"LI",{});var Xn=s(Ke);jl=r(Xn,"a "),Xe=o(Xn,"A",{href:!0,rel:!0});var ah=s(Xe);Cl=r(ah,"CLIPFeatureExtractor"),ah.forEach(t),Ol=r(Xn,","),Xn.forEach(t),Gl=d(A),Ze=o(A,"LI",{});var Zn=s(Ze);Ml=r(Zn,"as well as a "),aa=o(Zn,"A",{href:!0});var oh=s(aa);ql=r(oh,"safety checker"),oh.forEach(t),Ll=r(Zn,`.
All of these components are necessary to run stable diffusion in inference even though they were trained
or created independently from each other.`),Zn.forEach(t),A.forEach(t),bn=d(n),oa=o(n,"P",{});var sh=s(oa);Nl=r(sh,`To that end, we strive to offer all open-sourced, state-of-the-art diffusion system under a unified API.
More specifically, we strive to provide pipelines that`),sh.forEach(t),En=d(n),k=o(n,"UL",{});var Se=s(k);no=o(Se,"LI",{});var nh=s(no);lo=o(nh,"OL",{});var lh=s(lo);M=o(lh,"LI",{});var $e=s(M);Rl=r($e,"can load the officially published weights and yield 1-to-1 the same outputs as the original implementation according to the corresponding paper ("),ro=o($e,"EM",{});var rh=s(ro);Hl=r(rh,"e.g."),rh.forEach(t),Bl=d($e),et=o($e,"A",{href:!0,rel:!0});var ih=s(et);Ul=r(ih,"LatentDiffusionPipeline"),ih.forEach(t),Vl=r($e,", uses the officially released weights of "),tt=o($e,"A",{href:!0,rel:!0});var fh=s(tt);Yl=r(fh,"High-Resolution Image Synthesis with Latent Diffusion Models"),fh.forEach(t),zl=r($e,"),"),$e.forEach(t),lh.forEach(t),nh.forEach(t),Fl=d(Se),io=o(Se,"LI",{});var dh=s(io);sa=o(dh,"OL",{start:!0});var ph=s(sa);at=o(ph,"LI",{});var el=s(at);Wl=r(el,"have a simple user interface to run the model in inference (see the "),na=o(el,"A",{href:!0});var hh=s(na);Ql=r(hh,"Pipelines API"),hh.forEach(t),Jl=r(el," section),"),el.forEach(t),ph.forEach(t),dh.forEach(t),Kl=d(Se),fo=o(Se,"LI",{});var ch=s(fo);la=o(ch,"OL",{start:!0});var uh=s(la);ot=o(uh,"LI",{});var tl=s(ot);Xl=r(tl,"are easy to understand with code that is self-explanatory and can be read along-side the official paper (see "),ra=o(tl,"A",{href:!0});var mh=s(ra);Zl=r(mh,"Pipelines summary"),mh.forEach(t),er=r(tl,"),"),tl.forEach(t),uh.forEach(t),ch.forEach(t),tr=d(Se),po=o(Se,"LI",{});var gh=s(po);ia=o(gh,"OL",{start:!0});var _h=s(ia);st=o(_h,"LI",{});var al=s(st);ar=r(al,"can easily be contributed by the community (see the "),fa=o(al,"A",{href:!0});var vh=s(fa);or=r(vh,"Contribution"),vh.forEach(t),sr=r(al," section)."),al.forEach(t),_h.forEach(t),gh.forEach(t),Se.forEach(t),yn=d(n),q=o(n,"P",{});var Wt=s(q);ho=o(Wt,"STRONG",{});var bh=s(ho);nr=r(bh,"Note"),bh.forEach(t),lr=r(Wt,` that pipelines do not (and should not) offer any training functionality.
If you are looking for `),co=o(Wt,"EM",{});var Eh=s(co);rr=r(Eh,"official"),Eh.forEach(t),ir=r(Wt," training examples, please have a look at "),nt=o(Wt,"A",{href:!0,rel:!0});var yh=s(nt);fr=r(yh,"examples"),yh.forEach(t),dr=r(Wt,"."),Wt.forEach(t),wn=d(n),se=o(n,"H2",{class:!0});var ol=s(se);_e=o(ol,"A",{id:!0,class:!0,href:!0});var wh=s(_e);uo=o(wh,"SPAN",{});var Ih=s(uo);$(lt.$$.fragment,Ih),Ih.forEach(t),wh.forEach(t),pr=d(ol),mo=o(ol,"SPAN",{});var kh=s(mo);hr=r(kh,"\u{1F9E8} Diffusers Summary"),kh.forEach(t),ol.forEach(t),In=d(n),da=o(n,"P",{});var Dh=s(da);cr=r(Dh,`The following table summarizes all officially supported pipelines, their corresponding paper, and if
available a colab notebook to directly try them out.`),Dh.forEach(t),kn=d(n),ve=o(n,"TABLE",{});var sl=s(ve);go=o(sl,"THEAD",{});var Th=s(go);L=o(Th,"TR",{});var je=s(L);_o=o(je,"TH",{});var Ph=s(_o);ur=r(Ph,"Pipeline"),Ph.forEach(t),mr=d(je),vo=o(je,"TH",{});var xh=s(vo);gr=r(xh,"Paper"),xh.forEach(t),_r=d(je),pa=o(je,"TH",{align:!0});var Ah=s(pa);vr=r(Ah,"Tasks"),Ah.forEach(t),br=d(je),ha=o(je,"TH",{align:!0});var Sh=s(ha);Er=r(Sh,"Colab"),Sh.forEach(t),je.forEach(t),Th.forEach(t),yr=d(sl),u=o(sl,"TBODY",{});var g=s(u);N=o(g,"TR",{});var Ce=s(N);bo=o(Ce,"TD",{});var $h=s(bo);ca=o($h,"A",{href:!0});var jh=s(ca);wr=r(jh,"ddpm"),jh.forEach(t),$h.forEach(t),Ir=d(Ce),Eo=o(Ce,"TD",{});var Ch=s(Eo);rt=o(Ch,"A",{href:!0,rel:!0});var Oh=s(rt);yo=o(Oh,"STRONG",{});var Gh=s(yo);kr=r(Gh,"Denoising Diffusion Probabilistic Models"),Gh.forEach(t),Oh.forEach(t),Ch.forEach(t),Dr=d(Ce),ua=o(Ce,"TD",{align:!0});var Mh=s(ua);Tr=r(Mh,"Unconditional Image Generation"),Mh.forEach(t),Pr=d(Ce),wo=o(Ce,"TD",{align:!0}),s(wo).forEach(t),Ce.forEach(t),xr=d(g),R=o(g,"TR",{});var Oe=s(R);Io=o(Oe,"TD",{});var qh=s(Io);ma=o(qh,"A",{href:!0});var Lh=s(ma);Ar=r(Lh,"ddim"),Lh.forEach(t),qh.forEach(t),Sr=d(Oe),ko=o(Oe,"TD",{});var Nh=s(ko);it=o(Nh,"A",{href:!0,rel:!0});var Rh=s(it);Do=o(Rh,"STRONG",{});var Hh=s(Do);$r=r(Hh,"Denoising Diffusion Implicit Models"),Hh.forEach(t),Rh.forEach(t),Nh.forEach(t),jr=d(Oe),ga=o(Oe,"TD",{align:!0});var Bh=s(ga);Cr=r(Bh,"Unconditional Image Generation"),Bh.forEach(t),Or=d(Oe),_a=o(Oe,"TD",{align:!0});var Uh=s(_a);ft=o(Uh,"A",{href:!0,rel:!0});var Vh=s(ft);va=o(Vh,"IMG",{src:!0,alt:!0}),Vh.forEach(t),Uh.forEach(t),Oe.forEach(t),Gr=d(g),H=o(g,"TR",{});var Ge=s(H);To=o(Ge,"TD",{});var Yh=s(To);ba=o(Yh,"A",{href:!0});var zh=s(ba);Mr=r(zh,"latent_diffusion"),zh.forEach(t),Yh.forEach(t),qr=d(Ge),Po=o(Ge,"TD",{});var Fh=s(Po);dt=o(Fh,"A",{href:!0,rel:!0});var Wh=s(dt);xo=o(Wh,"STRONG",{});var Qh=s(xo);Lr=r(Qh,"High-Resolution Image Synthesis with Latent Diffusion Models"),Qh.forEach(t),Wh.forEach(t),Fh.forEach(t),Nr=d(Ge),Ea=o(Ge,"TD",{align:!0});var Jh=s(Ea);Rr=r(Jh,"Text-to-Image Generation"),Jh.forEach(t),Hr=d(Ge),Ao=o(Ge,"TD",{align:!0}),s(Ao).forEach(t),Ge.forEach(t),Br=d(g),B=o(g,"TR",{});var Me=s(B);So=o(Me,"TD",{});var Kh=s(So);ya=o(Kh,"A",{href:!0});var Xh=s(ya);Ur=r(Xh,"latent_diffusion_uncond"),Xh.forEach(t),Kh.forEach(t),Vr=d(Me),$o=o(Me,"TD",{});var Zh=s($o);pt=o(Zh,"A",{href:!0,rel:!0});var ec=s(pt);jo=o(ec,"STRONG",{});var tc=s(jo);Yr=r(tc,"High-Resolution Image Synthesis with Latent Diffusion Models"),tc.forEach(t),ec.forEach(t),Zh.forEach(t),zr=d(Me),wa=o(Me,"TD",{align:!0});var ac=s(wa);Fr=r(ac,"Unconditional Image Generation"),ac.forEach(t),Wr=d(Me),Co=o(Me,"TD",{align:!0}),s(Co).forEach(t),Me.forEach(t),Qr=d(g),U=o(g,"TR",{});var qe=s(U);Oo=o(qe,"TD",{});var oc=s(Oo);Ia=o(oc,"A",{href:!0});var sc=s(Ia);Jr=r(sc,"pndm"),sc.forEach(t),oc.forEach(t),Kr=d(qe),Go=o(qe,"TD",{});var nc=s(Go);ht=o(nc,"A",{href:!0,rel:!0});var lc=s(ht);Mo=o(lc,"STRONG",{});var rc=s(Mo);Xr=r(rc,"Pseudo Numerical Methods for Diffusion Models on Manifolds"),rc.forEach(t),lc.forEach(t),nc.forEach(t),Zr=d(qe),ka=o(qe,"TD",{align:!0});var ic=s(ka);ei=r(ic,"Unconditional Image Generation"),ic.forEach(t),ti=d(qe),qo=o(qe,"TD",{align:!0}),s(qo).forEach(t),qe.forEach(t),ai=d(g),V=o(g,"TR",{});var Le=s(V);Lo=o(Le,"TD",{});var fc=s(Lo);Da=o(fc,"A",{href:!0});var dc=s(Da);oi=r(dc,"score_sde_ve"),dc.forEach(t),fc.forEach(t),si=d(Le),No=o(Le,"TD",{});var pc=s(No);ct=o(pc,"A",{href:!0,rel:!0});var hc=s(ct);Ro=o(hc,"STRONG",{});var cc=s(Ro);ni=r(cc,"Score-Based Generative Modeling through Stochastic Differential Equations"),cc.forEach(t),hc.forEach(t),pc.forEach(t),li=d(Le),Ta=o(Le,"TD",{align:!0});var uc=s(Ta);ri=r(uc,"Unconditional Image Generation"),uc.forEach(t),ii=d(Le),Ho=o(Le,"TD",{align:!0}),s(Ho).forEach(t),Le.forEach(t),fi=d(g),Y=o(g,"TR",{});var Ne=s(Y);Bo=o(Ne,"TD",{});var mc=s(Bo);Pa=o(mc,"A",{href:!0});var gc=s(Pa);di=r(gc,"score_sde_vp"),gc.forEach(t),mc.forEach(t),pi=d(Ne),Uo=o(Ne,"TD",{});var _c=s(Uo);ut=o(_c,"A",{href:!0,rel:!0});var vc=s(ut);Vo=o(vc,"STRONG",{});var bc=s(Vo);hi=r(bc,"Score-Based Generative Modeling through Stochastic Differential Equations"),bc.forEach(t),vc.forEach(t),_c.forEach(t),ci=d(Ne),xa=o(Ne,"TD",{align:!0});var Ec=s(xa);ui=r(Ec,"Unconditional Image Generation"),Ec.forEach(t),mi=d(Ne),Yo=o(Ne,"TD",{align:!0}),s(Yo).forEach(t),Ne.forEach(t),gi=d(g),z=o(g,"TR",{});var Re=s(z);zo=o(Re,"TD",{});var yc=s(zo);Aa=o(yc,"A",{href:!0});var wc=s(Aa);_i=r(wc,"stable_diffusion"),wc.forEach(t),yc.forEach(t),vi=d(Re),Fo=o(Re,"TD",{});var Ic=s(Fo);mt=o(Ic,"A",{href:!0,rel:!0});var kc=s(mt);Wo=o(kc,"STRONG",{});var Dc=s(Wo);bi=r(Dc,"Stable Diffusion"),Dc.forEach(t),kc.forEach(t),Ic.forEach(t),Ei=d(Re),Sa=o(Re,"TD",{align:!0});var Tc=s(Sa);yi=r(Tc,"Text-to-Image Generation"),Tc.forEach(t),wi=d(Re),$a=o(Re,"TD",{align:!0});var Pc=s($a);gt=o(Pc,"A",{href:!0,rel:!0});var xc=s(gt);ja=o(xc,"IMG",{src:!0,alt:!0}),xc.forEach(t),Pc.forEach(t),Re.forEach(t),Ii=d(g),F=o(g,"TR",{});var He=s(F);Qo=o(He,"TD",{});var Ac=s(Qo);Ca=o(Ac,"A",{href:!0});var Sc=s(Ca);ki=r(Sc,"stable_diffusion"),Sc.forEach(t),Ac.forEach(t),Di=d(He),Jo=o(He,"TD",{});var $c=s(Jo);_t=o($c,"A",{href:!0,rel:!0});var jc=s(_t);Ko=o(jc,"STRONG",{});var Cc=s(Ko);Ti=r(Cc,"Stable Diffusion"),Cc.forEach(t),jc.forEach(t),$c.forEach(t),Pi=d(He),Oa=o(He,"TD",{align:!0});var Oc=s(Oa);xi=r(Oc,"Image-to-Image Text-Guided Generation"),Oc.forEach(t),Ai=d(He),Ga=o(He,"TD",{align:!0});var Gc=s(Ga);vt=o(Gc,"A",{href:!0,rel:!0});var Mc=s(vt);Ma=o(Mc,"IMG",{src:!0,alt:!0}),Mc.forEach(t),Gc.forEach(t),He.forEach(t),Si=d(g),W=o(g,"TR",{});var Be=s(W);Xo=o(Be,"TD",{});var qc=s(Xo);qa=o(qc,"A",{href:!0});var Lc=s(qa);$i=r(Lc,"stable_diffusion"),Lc.forEach(t),qc.forEach(t),ji=d(Be),Zo=o(Be,"TD",{});var Nc=s(Zo);bt=o(Nc,"A",{href:!0,rel:!0});var Rc=s(bt);es=o(Rc,"STRONG",{});var Hc=s(es);Ci=r(Hc,"Stable Diffusion"),Hc.forEach(t),Rc.forEach(t),Nc.forEach(t),Oi=d(Be),La=o(Be,"TD",{align:!0});var Bc=s(La);Gi=r(Bc,"Text-Guided Image Inpainting"),Bc.forEach(t),Mi=d(Be),Na=o(Be,"TD",{align:!0});var Uc=s(Na);Et=o(Uc,"A",{href:!0,rel:!0});var Vc=s(Et);Ra=o(Vc,"IMG",{src:!0,alt:!0}),Vc.forEach(t),Uc.forEach(t),Be.forEach(t),qi=d(g),Q=o(g,"TR",{});var Ue=s(Q);ts=o(Ue,"TD",{});var Yc=s(ts);Ha=o(Yc,"A",{href:!0});var zc=s(Ha);Li=r(zc,"stochatic_karras_ve"),zc.forEach(t),Yc.forEach(t),Ni=d(Ue),as=o(Ue,"TD",{});var Fc=s(as);yt=o(Fc,"A",{href:!0,rel:!0});var Wc=s(yt);os=o(Wc,"STRONG",{});var Qc=s(os);Ri=r(Qc,"Elucidating the Design Space of Diffusion-Based Generative Models"),Qc.forEach(t),Wc.forEach(t),Fc.forEach(t),Hi=d(Ue),Ba=o(Ue,"TD",{align:!0});var Jc=s(Ba);Bi=r(Jc,"Unconditional Image Generation"),Jc.forEach(t),Ui=d(Ue),ss=o(Ue,"TD",{align:!0}),s(ss).forEach(t),Ue.forEach(t),g.forEach(t),sl.forEach(t),Dn=d(n),wt=o(n,"P",{});var Sp=s(wt);ns=o(Sp,"STRONG",{});var Kc=s(ns);Vi=r(Kc,"Note"),Kc.forEach(t),Yi=r(Sp,": Pipelines are simple examples of how to play around with the diffusion systems as described in the corresponding papers."),Sp.forEach(t),Tn=d(n),be=o(n,"P",{});var nl=s(be);zi=r(nl,"However, most of them can be adapted to use different scheduler components or even different model components. Some pipeline examples are shown in the "),Ua=o(nl,"A",{href:!0});var Xc=s(Ua);Fi=r(Xc,"Examples"),Xc.forEach(t),Wi=r(nl," below."),nl.forEach(t),Pn=d(n),ne=o(n,"H2",{class:!0});var ll=s(ne);Ee=o(ll,"A",{id:!0,class:!0,href:!0});var Zc=s(Ee);ls=o(Zc,"SPAN",{});var eu=s(ls);$(It.$$.fragment,eu),eu.forEach(t),Zc.forEach(t),Qi=d(ll),rs=o(ll,"SPAN",{});var tu=s(rs);Ji=r(tu,"Pipelines API"),tu.forEach(t),ll.forEach(t),xn=d(n),Va=o(n,"P",{});var au=s(Va);Ki=r(au,"Diffusion models often consist of multiple independently-trained models or other previously existing components."),au.forEach(t),An=d(n),K=o(n,"P",{});var Xa=s(K);Xi=r(Xa,`Each model has been trained independently on a different task and the scheduler can easily be swapped out and replaced with a different one.
During inference, we however want to be able to easily load all components and use them in inference - even if one component, `),is=o(Xa,"EM",{});var ou=s(is);Zi=r(ou,"e.g."),ou.forEach(t),ef=r(Xa," CLIP\u2019s text encoder, originates from a different library, such as "),kt=o(Xa,"A",{href:!0,rel:!0});var su=s(kt);tf=r(su,"Transformers"),su.forEach(t),af=r(Xa,". To that end, all pipelines provide the following functionality:"),Xa.forEach(t),Sn=d(n),D=o(n,"UL",{});var Ve=s(D);c=o(Ve,"LI",{});var m=s(c);Dt=o(m,"A",{href:!0});var $p=s(Dt);fs=o($p,"CODE",{});var nu=s(fs);of=r(nu,"from_pretrained"),nu.forEach(t),sf=r($p," method"),$p.forEach(t),nf=r(m," that accepts a Hugging Face Hub repository id, "),ds=o(m,"EM",{});var lu=s(ds);lf=r(lu,"e.g."),lu.forEach(t),rf=d(m),Tt=o(m,"A",{href:!0,rel:!0});var ru=s(Tt);ff=r(ru,"CompVis/stable-diffusion-v1-4"),ru.forEach(t),df=r(m," or a path to a local directory, "),ps=o(m,"EM",{});var iu=s(ps);pf=r(iu,"e.g."),iu.forEach(t),hf=r(m,`
\u201D./stable-diffusion\u201D. To correctly retrieve which models and components should be loaded, one has to provide a `),hs=o(m,"CODE",{});var fu=s(hs);cf=r(fu,"model_index.json"),fu.forEach(t),uf=r(m," file, "),cs=o(m,"EM",{});var du=s(cs);mf=r(du,"e.g."),du.forEach(t),gf=d(m),Pt=o(m,"A",{href:!0,rel:!0});var pu=s(Pt);_f=r(pu,"CompVis/stable-diffusion-v1-4/model_index.json"),pu.forEach(t),vf=r(m,`, which defines all components that should be
loaded into the pipelines. More specifically, for each model/component one needs to define the format `),us=o(m,"CODE",{});var hu=s(us);bf=r(hu,'<name>: ["<library>", "<class name>"]'),hu.forEach(t),Ef=r(m,". "),ms=o(m,"CODE",{});var cu=s(ms);yf=r(cu,"<name>"),cu.forEach(t),wf=r(m," is the attribute name given to the loaded instance of "),gs=o(m,"CODE",{});var uu=s(gs);If=r(uu,"<class name>"),uu.forEach(t),kf=r(m," which can be found in the library or pipeline folder called "),_s=o(m,"CODE",{});var mu=s(_s);Df=r(mu,'"<library>"'),mu.forEach(t),Tf=r(m,"."),m.forEach(t),Pf=d(Ve),_=o(Ve,"LI",{});var v=s(_);Ya=o(v,"A",{href:!0});var gu=s(Ya);vs=o(gu,"CODE",{});var _u=s(vs);xf=r(_u,"save_pretrained"),_u.forEach(t),gu.forEach(t),Af=r(v," that accepts a local path, "),bs=o(v,"EM",{});var vu=s(bs);Sf=r(vu,"e.g."),vu.forEach(t),$f=d(v),Es=o(v,"CODE",{});var bu=s(Es);jf=r(bu,"./stable-diffusion"),bu.forEach(t),Cf=r(v," under which all models/components of the pipeline will be saved. For each component/model a folder is created inside the local path that is named after the given attribute name, "),ys=o(v,"EM",{});var Eu=s(ys);Of=r(Eu,"e.g."),Eu.forEach(t),Gf=d(v),ws=o(v,"CODE",{});var yu=s(ws);Mf=r(yu,"./stable_diffusion/unet"),yu.forEach(t),qf=r(v,`.
In addition, a `),Is=o(v,"CODE",{});var wu=s(Is);Lf=r(wu,"model_index.json"),wu.forEach(t),Nf=r(v," file is created at the root of the local path, "),ks=o(v,"EM",{});var Iu=s(ks);Rf=r(Iu,"e.g."),Iu.forEach(t),Hf=d(v),Ds=o(v,"CODE",{});var ku=s(Ds);Bf=r(ku,"./stable_diffusion/model_index.json"),ku.forEach(t),Uf=r(v,` so that the complete pipeline can again be instantiated
from the local path.`),v.forEach(t),Vf=d(Ve),y=o(Ve,"LI",{});var J=s(y);za=o(J,"A",{href:!0});var Du=s(za);Ts=o(Du,"CODE",{});var Tu=s(Ts);Yf=r(Tu,"to"),Tu.forEach(t),Du.forEach(t),zf=r(J," which accepts a "),Ps=o(J,"CODE",{});var Pu=s(Ps);Ff=r(Pu,"string"),Pu.forEach(t),Wf=r(J," or "),xs=o(J,"CODE",{});var xu=s(xs);Qf=r(xu,"torch.device"),xu.forEach(t),Jf=r(J," to move all models that are of type "),As=o(J,"CODE",{});var Au=s(As);Kf=r(Au,"torch.nn.Module"),Au.forEach(t),Xf=r(J," to the passed device. The behavior is fully analogous to "),le=o(J,"A",{href:!0,rel:!0});var rl=s(le);Zf=r(rl,"PyTorch\u2019s "),Ss=o(rl,"CODE",{});var Su=s(Ss);ed=r(Su,"to"),Su.forEach(t),td=r(rl," method"),rl.forEach(t),ad=r(J,"."),J.forEach(t),od=d(Ve),E=o(Ve,"LI",{});var I=s(E);$s=o(I,"CODE",{});var $u=s($s);sd=r($u,"__call__"),$u.forEach(t),nd=r(I," method to use the pipeline in inference. "),js=o(I,"CODE",{});var ju=s(js);ld=r(ju,"__call__"),ju.forEach(t),rd=r(I," defines inference logic of the pipeline and should ideally encompass all aspects of it, from pre-processing to forwarding tensors to the different models and schedulers, as well as post-processing. The API of the "),Cs=o(I,"CODE",{});var Cu=s(Cs);id=r(Cu,"__call__"),Cu.forEach(t),fd=r(I," method can strongly vary from pipeline to pipeline. "),Os=o(I,"EM",{});var Ou=s(Os);dd=r(Ou,"E.g."),Ou.forEach(t),pd=r(I," a text-to-image pipeline, such as "),Fa=o(I,"A",{href:!0});var Gu=s(Fa);Gs=o(Gu,"CODE",{});var Mu=s(Gs);hd=r(Mu,"StableDiffusionPipeline"),Mu.forEach(t),Gu.forEach(t),cd=r(I," should accept among other things the text prompt to generate the image. A pure image generation pipeline, such as "),xt=o(I,"A",{href:!0,rel:!0});var qu=s(xt);ud=r(qu,"DDPMPipeline"),qu.forEach(t),md=r(I,` on the other hand can be run without providing any inputs. To better understand what inputs can be adapted for
each pipeline, one should look directly into the respective pipeline.`),I.forEach(t),Ve.forEach(t),$n=d(n),T=o(n,"P",{});var Ye=s(T);Ms=o(Ye,"STRONG",{});var Lu=s(Ms);gd=r(Lu,"Note"),Lu.forEach(t),_d=r(Ye,": All pipelines have PyTorch\u2019s autograd disabled by decorating the "),qs=o(Ye,"CODE",{});var Nu=s(qs);vd=r(Nu,"__call__"),Nu.forEach(t),bd=r(Ye," method with a "),At=o(Ye,"A",{href:!0,rel:!0});var Ru=s(At);Ls=o(Ru,"CODE",{});var Hu=s(Ls);Ed=r(Hu,"torch.no_grad"),Hu.forEach(t),Ru.forEach(t),yd=r(Ye,` decorator because pipelines should
not be used for training. If you want to store the gradients during the forward pass, we recommend writing your own pipeline, see also our `),St=o(Ye,"A",{href:!0,rel:!0});var Bu=s(St);wd=r(Bu,"community-examples"),Bu.forEach(t),Ye.forEach(t),jn=d(n),re=o(n,"H2",{class:!0});var il=s(re);ye=o(il,"A",{id:!0,class:!0,href:!0});var Uu=s(ye);Ns=o(Uu,"SPAN",{});var Vu=s(Ns);$($t.$$.fragment,Vu),Vu.forEach(t),Uu.forEach(t),Id=d(il),Rs=o(il,"SPAN",{});var Yu=s(Rs);kd=r(Yu,"Contribution"),Yu.forEach(t),il.forEach(t),Cn=d(n),w=o(n,"P",{});var te=s(w);Dd=r(te,`We are more than happy about any contribution to the officially supported pipelines \u{1F917}. We aspire
all of our pipelines to be  `),Hs=o(te,"STRONG",{});var zu=s(Hs);Td=r(zu,"self-contained"),zu.forEach(t),Pd=r(te,", "),Bs=o(te,"STRONG",{});var Fu=s(Bs);xd=r(Fu,"easy-to-tweak"),Fu.forEach(t),Ad=r(te,", "),Us=o(te,"STRONG",{});var Wu=s(Us);Sd=r(Wu,"beginner-friendly"),Wu.forEach(t),$d=r(te," and for "),Vs=o(te,"STRONG",{});var Qu=s(Vs);jd=r(Qu,"one-purpose-only"),Qu.forEach(t),Cd=r(te,"."),te.forEach(t),On=d(n),P=o(n,"UL",{});var ze=s(P);we=o(ze,"LI",{});var un=s(we);Ys=o(un,"STRONG",{});var Ju=s(Ys);Od=r(Ju,"Self-contained"),Ju.forEach(t),Gd=r(un,": A pipeline shall be as self-contained as possible. More specifically, this means that all functionality should be either directly defined in the pipeline file iteslf, should be inherited from (and only from) the "),jt=o(un,"A",{href:!0});var jp=s(jt);zs=o(jp,"CODE",{});var Ku=s(zs);Md=r(Ku,"DiffusionPipeline"),Ku.forEach(t),qd=r(jp," class"),jp.forEach(t),Ld=r(un," or be directly attached to the model and scheduler components of the pipeline."),un.forEach(t),Nd=d(ze),X=o(ze,"LI",{});var Qt=s(X);Fs=o(Qt,"STRONG",{});var Xu=s(Fs);Rd=r(Xu,"Easy-to-use"),Xu.forEach(t),Hd=r(Qt,`: Pipelines should be extremely easy to use - one should be able to load the pipeline and
use it for its designated task, `),Ws=o(Qt,"EM",{});var Zu=s(Ws);Bd=r(Zu,"e.g."),Zu.forEach(t),Ud=r(Qt,` text-to-image generation, in just a couple of lines of code. Most
logic including pre-processing, an unrolled diffusion loop, and post-processing should all happen inside the `),Qs=o(Qt,"CODE",{});var em=s(Qs);Vd=r(em,"__call__"),em.forEach(t),Yd=r(Qt," method."),Qt.forEach(t),zd=d(ze),Z=o(ze,"LI",{});var Jt=s(Z);Js=o(Jt,"STRONG",{});var tm=s(Js);Fd=r(tm,"Easy-to-tweak"),tm.forEach(t),Wd=r(Jt,": Certain pipelines will not be able to handle all use cases and tasks that you might like them to. If you want to use a certain pipeline for a specific use case that is not yet supported, you might have to copy the pipeline file and tweak the code to your needs. We try to make the pipeline code as readable as possible so that each part \u2013from pre-processing to diffusing to post-processing\u2013 can easily be adapted. If you would like the community to benefit from your customized pipeline, we would love to see a contribution to our "),Ct=o(Jt,"A",{href:!0,rel:!0});var am=s(Ct);Qd=r(am,"community-examples"),am.forEach(t),Jd=r(Jt,". If you feel that an important pipeline should be part of the official pipelines but isn\u2019t, a contribution to the "),Wa=o(Jt,"A",{href:!0});var om=s(Wa);Kd=r(om,"official pipelines"),om.forEach(t),Xd=r(Jt," would be even better."),Jt.forEach(t),Zd=d(ze),x=o(ze,"LI",{});var ce=s(x);Ks=o(ce,"STRONG",{});var sm=s(Ks);ep=r(sm,"One-purpose-only"),sm.forEach(t),tp=r(ce,": Pipelines should be used for one task and one task only. Even if two tasks are very similar from a modeling point of view, "),Xs=o(ce,"EM",{});var nm=s(Xs);ap=r(nm,"e.g."),nm.forEach(t),op=r(ce," image2image translation and in-painting, pipelines shall be used for one task only to keep them "),Zs=o(ce,"EM",{});var lm=s(Zs);sp=r(lm,"easy-to-tweak"),lm.forEach(t),np=r(ce," and "),en=o(ce,"EM",{});var rm=s(en);lp=r(rm,"readable"),rm.forEach(t),rp=r(ce,"."),ce.forEach(t),ze.forEach(t),Gn=d(n),ie=o(n,"H2",{class:!0});var fl=s(ie);Ie=o(fl,"A",{id:!0,class:!0,href:!0});var im=s(Ie);tn=o(im,"SPAN",{});var fm=s(tn);$(Ot.$$.fragment,fm),fm.forEach(t),im.forEach(t),ip=d(fl),an=o(fl,"SPAN",{});var dm=s(an);fp=r(dm,"Examples"),dm.forEach(t),fl.forEach(t),Mn=d(n),fe=o(n,"H3",{class:!0});var dl=s(fe);ke=o(dl,"A",{id:!0,class:!0,href:!0});var pm=s(ke);on=o(pm,"SPAN",{});var hm=s(on);$(Gt.$$.fragment,hm),hm.forEach(t),pm.forEach(t),dp=d(dl),sn=o(dl,"SPAN",{});var cm=s(sn);pp=r(cm,"Text-to-Image generation with Stable Diffusion"),cm.forEach(t),dl.forEach(t),qn=d(n),$(Mt.$$.fragment,n),Ln=d(n),de=o(n,"H3",{class:!0});var pl=s(de);De=o(pl,"A",{id:!0,class:!0,href:!0});var um=s(De);nn=o(um,"SPAN",{});var mm=s(nn);$(qt.$$.fragment,mm),mm.forEach(t),um.forEach(t),hp=d(pl),ln=o(pl,"SPAN",{});var gm=s(ln);cp=r(gm,"Image-to-Image text-guided generation with Stable Diffusion"),gm.forEach(t),pl.forEach(t),Nn=d(n),Te=o(n,"P",{});var hl=s(Te);up=r(hl,"The "),rn=o(hl,"CODE",{});var _m=s(rn);mp=r(_m,"StableDiffusionImg2ImgPipeline"),_m.forEach(t),gp=r(hl," lets you pass a text prompt and an initial image to condition the generation of new images."),hl.forEach(t),Rn=d(n),$(Lt.$$.fragment,n),Hn=d(n),Nt=o(n,"P",{});var Cp=s(Nt);_p=r(Cp,"You can also run this example on colab "),Rt=o(Cp,"A",{href:!0,rel:!0});var vm=s(Rt);Qa=o(vm,"IMG",{src:!0,alt:!0}),vm.forEach(t),Cp.forEach(t),Bn=d(n),pe=o(n,"H3",{class:!0});var cl=s(pe);Pe=o(cl,"A",{id:!0,class:!0,href:!0});var bm=s(Pe);fn=o(bm,"SPAN",{});var Em=s(fn);$(Ht.$$.fragment,Em),Em.forEach(t),bm.forEach(t),vp=d(cl),dn=o(cl,"SPAN",{});var ym=s(dn);bp=r(ym,"Tweak prompts reusing seeds and latents"),ym.forEach(t),cl.forEach(t),Un=d(n),ee=o(n,"P",{});var Za=s(ee);Ep=r(Za,"You can generate your own latents to reproduce results, or tweak your prompt on a specific result you liked. "),Bt=o(Za,"A",{href:!0,rel:!0});var wm=s(Bt);yp=r(wm,"This notebook"),wm.forEach(t),wp=r(Za," shows how to do it step by step. You can also run it in Google Colab "),Ut=o(Za,"A",{href:!0,rel:!0});var Im=s(Ut);Ja=o(Im,"IMG",{src:!0,alt:!0}),Im.forEach(t),Ip=r(Za,"."),Za.forEach(t),Vn=d(n),he=o(n,"H3",{class:!0});var ul=s(he);xe=o(ul,"A",{id:!0,class:!0,href:!0});var km=s(xe);pn=o(km,"SPAN",{});var Dm=s(pn);$(Vt.$$.fragment,Dm),Dm.forEach(t),km.forEach(t),kp=d(ul),hn=o(ul,"SPAN",{});var Tm=s(hn);Dp=r(Tm,"In-painting using Stable Diffusion"),Tm.forEach(t),ul.forEach(t),Yn=d(n),Ae=o(n,"P",{});var ml=s(Ae);Tp=r(ml,"The "),cn=o(ml,"CODE",{});var Pm=s(cn);Pp=r(Pm,"StableDiffusionInpaintPipeline"),Pm.forEach(t),xp=r(ml," lets you edit specific parts of an image by providing a mask and text prompt."),ml.forEach(t),zn=d(n),$(Yt.$$.fragment,n),Fn=d(n),zt=o(n,"P",{});var Op=s(zt);Ap=r(Op,"You can also run this example on colab "),Ft=o(Op,"A",{href:!0,rel:!0});var xm=s(Ft);Ka=o(xm,"IMG",{src:!0,alt:!0}),xm.forEach(t),Op.forEach(t),this.h()},h(){i(ae,"name","hf:doc:metadata"),i(ae,"content",JSON.stringify(Mm)),i(me,"id","pipelines"),i(me,"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"),i(me,"href","#pipelines"),i(oe,"class","relative group"),i(We,"href","https://huggingface.co/blog/stable_diffusion"),i(We,"rel","nofollow"),i(Zt,"href","./api/models#vae"),i(ea,"href","./api/models#UNet2DConditionModel"),i(Qe,"href","https://huggingface.co/docs/transformers/v4.21.2/en/model_doc/clip#transformers.CLIPTextModel"),i(Qe,"rel","nofollow"),i(ta,"href","./api/scheduler#pndm"),i(Xe,"href","https://huggingface.co/docs/transformers/v4.21.2/en/model_doc/clip#transformers.CLIPFeatureExtractor"),i(Xe,"rel","nofollow"),i(aa,"href","./stable_diffusion#safety_checker"),i(et,"href","https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines/latent_diffusion"),i(et,"rel","nofollow"),i(tt,"href","https://arxiv.org/abs/2112.10752"),i(tt,"rel","nofollow"),i(na,"href","#pipelines-api"),i(sa,"start","2"),i(ra,"href","#pipelines-summary"),i(la,"start","3"),i(fa,"href","#contribution"),i(ia,"start","4"),i(nt,"href","https://github.com/huggingface/diffusers/tree/main/examples"),i(nt,"rel","nofollow"),i(_e,"id","diffusers-summary"),i(_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"),i(_e,"href","#diffusers-summary"),i(se,"class","relative group"),i(pa,"align","center"),i(ha,"align","center"),i(ca,"href","./ddpm"),i(rt,"href","https://arxiv.org/abs/2006.11239"),i(rt,"rel","nofollow"),i(ua,"align","center"),i(wo,"align","center"),i(ma,"href","./ddim"),i(it,"href","https://arxiv.org/abs/2010.02502"),i(it,"rel","nofollow"),i(ga,"align","center"),Kt(va.src,qp="https://colab.research.google.com/assets/colab-badge.svg")||i(va,"src",qp),i(va,"alt","Open In Colab"),i(ft,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/training_example.ipynb"),i(ft,"rel","nofollow"),i(_a,"align","center"),i(ba,"href","./latent_diffusion"),i(dt,"href","https://arxiv.org/abs/2112.10752"),i(dt,"rel","nofollow"),i(Ea,"align","center"),i(Ao,"align","center"),i(ya,"href","./latent_diffusion_uncond"),i(pt,"href","https://arxiv.org/abs/2112.10752"),i(pt,"rel","nofollow"),i(wa,"align","center"),i(Co,"align","center"),i(Ia,"href","./pndm"),i(ht,"href","https://arxiv.org/abs/2202.09778"),i(ht,"rel","nofollow"),i(ka,"align","center"),i(qo,"align","center"),i(Da,"href","./score_sde_ve"),i(ct,"href","https://openreview.net/forum?id=PxTIG12RRHS"),i(ct,"rel","nofollow"),i(Ta,"align","center"),i(Ho,"align","center"),i(Pa,"href","./score_sde_vp"),i(ut,"href","https://openreview.net/forum?id=PxTIG12RRHS"),i(ut,"rel","nofollow"),i(xa,"align","center"),i(Yo,"align","center"),i(Aa,"href","./stable_diffusion"),i(mt,"href","https://stability.ai/blog/stable-diffusion-public-release"),i(mt,"rel","nofollow"),i(Sa,"align","center"),Kt(ja.src,Lp="https://colab.research.google.com/assets/colab-badge.svg")||i(ja,"src",Lp),i(ja,"alt","Open In Colab"),i(gt,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/training_example.ipynb"),i(gt,"rel","nofollow"),i($a,"align","center"),i(Ca,"href","./stable_diffusion"),i(_t,"href","https://stability.ai/blog/stable-diffusion-public-release"),i(_t,"rel","nofollow"),i(Oa,"align","center"),Kt(Ma.src,Np="https://colab.research.google.com/assets/colab-badge.svg")||i(Ma,"src",Np),i(Ma,"alt","Open In Colab"),i(vt,"href","https://colab.research.google.com/github/patil-suraj/Notebooks/blob/master/image_2_image_using_diffusers.ipynb"),i(vt,"rel","nofollow"),i(Ga,"align","center"),i(qa,"href","./stable_diffusion"),i(bt,"href","https://stability.ai/blog/stable-diffusion-public-release"),i(bt,"rel","nofollow"),i(La,"align","center"),Kt(Ra.src,Rp="https://colab.research.google.com/assets/colab-badge.svg")||i(Ra,"src",Rp),i(Ra,"alt","Open In Colab"),i(Et,"href","https://colab.research.google.com/github/patil-suraj/Notebooks/blob/master/in_painting_with_stable_diffusion_using_diffusers.ipynb"),i(Et,"rel","nofollow"),i(Na,"align","center"),i(Ha,"href","./stochatic_karras_ve"),i(yt,"href","https://arxiv.org/abs/2206.00364"),i(yt,"rel","nofollow"),i(Ba,"align","center"),i(ss,"align","center"),i(Ua,"href","#examples"),i(Ee,"id","pipelines-api"),i(Ee,"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"),i(Ee,"href","#pipelines-api"),i(ne,"class","relative group"),i(kt,"href","https://github.com/huggingface/transformers"),i(kt,"rel","nofollow"),i(Dt,"href","../diffusion_pipeline"),i(Tt,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4"),i(Tt,"rel","nofollow"),i(Pt,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4/blob/main/model_index.json"),i(Pt,"rel","nofollow"),i(Ya,"href","../diffusion_pipeline"),i(za,"href","../diffusion_pipeline"),i(le,"href","https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.to"),i(le,"rel","nofollow"),i(Fa,"href","./stable_diffusion"),i(xt,"href","https://github.com/huggingface/diffusers/tree/main/src/diffusers/pipelines/ddpm"),i(xt,"rel","nofollow"),i(At,"href","https://pytorch.org/docs/stable/generated/torch.no_grad.html"),i(At,"rel","nofollow"),i(St,"href","https://github.com/huggingface/diffusers/tree/main/examples/community"),i(St,"rel","nofollow"),i(ye,"id","contribution"),i(ye,"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"),i(ye,"href","#contribution"),i(re,"class","relative group"),i(jt,"href",".../diffusion_pipeline"),i(Ct,"href","https://github.com/huggingface/diffusers/tree/main/examples/community"),i(Ct,"rel","nofollow"),i(Wa,"href","./overview"),i(Ie,"id","examples"),i(Ie,"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"),i(Ie,"href","#examples"),i(ie,"class","relative group"),i(ke,"id","texttoimage-generation-with-stable-diffusion"),i(ke,"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"),i(ke,"href","#texttoimage-generation-with-stable-diffusion"),i(fe,"class","relative group"),i(De,"id","imagetoimage-textguided-generation-with-stable-diffusion"),i(De,"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"),i(De,"href","#imagetoimage-textguided-generation-with-stable-diffusion"),i(de,"class","relative group"),Kt(Qa.src,Hp="https://colab.research.google.com/assets/colab-badge.svg")||i(Qa,"src",Hp),i(Qa,"alt","Open In Colab"),i(Rt,"href","https://colab.research.google.com/github/patil-suraj/Notebooks/blob/master/image_2_image_using_diffusers.ipynb"),i(Rt,"rel","nofollow"),i(Pe,"id","tweak-prompts-reusing-seeds-and-latents"),i(Pe,"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"),i(Pe,"href","#tweak-prompts-reusing-seeds-and-latents"),i(pe,"class","relative group"),i(Bt,"href","https://github.com/pcuenca/diffusers-examples/blob/main/notebooks/stable-diffusion-seeds.ipynb"),i(Bt,"rel","nofollow"),Kt(Ja.src,Bp="https://colab.research.google.com/assets/colab-badge.svg")||i(Ja,"src",Bp),i(Ja,"alt","Open In Colab"),i(Ut,"href","https://colab.research.google.com/github/pcuenca/diffusers-examples/blob/main/notebooks/stable-diffusion-seeds.ipynb"),i(Ut,"rel","nofollow"),i(xe,"id","inpainting-using-stable-diffusion"),i(xe,"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"),i(xe,"href","#inpainting-using-stable-diffusion"),i(he,"class","relative group"),Kt(Ka.src,Up="https://colab.research.google.com/assets/colab-badge.svg")||i(Ka,"src",Up),i(Ka,"alt","Open In Colab"),i(Ft,"href","https://colab.research.google.com/github/patil-suraj/Notebooks/blob/master/in_painting_with_stable_diffusion_using_diffusers.ipynb"),i(Ft,"rel","nofollow")},m(n,p){e(document.head,ae),h(n,mn,p),h(n,oe,p),e(oe,me),e(me,eo),j(Fe,eo,null),e(oe,gl),e(oe,to),e(to,_l),h(n,gn,p),h(n,Xt,p),e(Xt,vl),h(n,_n,p),h(n,ge,p),e(ge,bl),e(ge,We),e(We,El),e(ge,yl),h(n,vn,p),h(n,b,p),e(b,ao),e(ao,Zt),e(Zt,wl),e(b,Il),e(b,oo),e(oo,ea),e(ea,kl),e(b,Dl),e(b,so),e(so,Qe),e(Qe,Tl),e(b,Pl),e(b,Je),e(Je,xl),e(Je,ta),e(ta,Al),e(Je,Sl),e(b,$l),e(b,Ke),e(Ke,jl),e(Ke,Xe),e(Xe,Cl),e(Ke,Ol),e(b,Gl),e(b,Ze),e(Ze,Ml),e(Ze,aa),e(aa,ql),e(Ze,Ll),h(n,bn,p),h(n,oa,p),e(oa,Nl),h(n,En,p),h(n,k,p),e(k,no),e(no,lo),e(lo,M),e(M,Rl),e(M,ro),e(ro,Hl),e(M,Bl),e(M,et),e(et,Ul),e(M,Vl),e(M,tt),e(tt,Yl),e(M,zl),e(k,Fl),e(k,io),e(io,sa),e(sa,at),e(at,Wl),e(at,na),e(na,Ql),e(at,Jl),e(k,Kl),e(k,fo),e(fo,la),e(la,ot),e(ot,Xl),e(ot,ra),e(ra,Zl),e(ot,er),e(k,tr),e(k,po),e(po,ia),e(ia,st),e(st,ar),e(st,fa),e(fa,or),e(st,sr),h(n,yn,p),h(n,q,p),e(q,ho),e(ho,nr),e(q,lr),e(q,co),e(co,rr),e(q,ir),e(q,nt),e(nt,fr),e(q,dr),h(n,wn,p),h(n,se,p),e(se,_e),e(_e,uo),j(lt,uo,null),e(se,pr),e(se,mo),e(mo,hr),h(n,In,p),h(n,da,p),e(da,cr),h(n,kn,p),h(n,ve,p),e(ve,go),e(go,L),e(L,_o),e(_o,ur),e(L,mr),e(L,vo),e(vo,gr),e(L,_r),e(L,pa),e(pa,vr),e(L,br),e(L,ha),e(ha,Er),e(ve,yr),e(ve,u),e(u,N),e(N,bo),e(bo,ca),e(ca,wr),e(N,Ir),e(N,Eo),e(Eo,rt),e(rt,yo),e(yo,kr),e(N,Dr),e(N,ua),e(ua,Tr),e(N,Pr),e(N,wo),e(u,xr),e(u,R),e(R,Io),e(Io,ma),e(ma,Ar),e(R,Sr),e(R,ko),e(ko,it),e(it,Do),e(Do,$r),e(R,jr),e(R,ga),e(ga,Cr),e(R,Or),e(R,_a),e(_a,ft),e(ft,va),e(u,Gr),e(u,H),e(H,To),e(To,ba),e(ba,Mr),e(H,qr),e(H,Po),e(Po,dt),e(dt,xo),e(xo,Lr),e(H,Nr),e(H,Ea),e(Ea,Rr),e(H,Hr),e(H,Ao),e(u,Br),e(u,B),e(B,So),e(So,ya),e(ya,Ur),e(B,Vr),e(B,$o),e($o,pt),e(pt,jo),e(jo,Yr),e(B,zr),e(B,wa),e(wa,Fr),e(B,Wr),e(B,Co),e(u,Qr),e(u,U),e(U,Oo),e(Oo,Ia),e(Ia,Jr),e(U,Kr),e(U,Go),e(Go,ht),e(ht,Mo),e(Mo,Xr),e(U,Zr),e(U,ka),e(ka,ei),e(U,ti),e(U,qo),e(u,ai),e(u,V),e(V,Lo),e(Lo,Da),e(Da,oi),e(V,si),e(V,No),e(No,ct),e(ct,Ro),e(Ro,ni),e(V,li),e(V,Ta),e(Ta,ri),e(V,ii),e(V,Ho),e(u,fi),e(u,Y),e(Y,Bo),e(Bo,Pa),e(Pa,di),e(Y,pi),e(Y,Uo),e(Uo,ut),e(ut,Vo),e(Vo,hi),e(Y,ci),e(Y,xa),e(xa,ui),e(Y,mi),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fragment,n),C(Mt.$$.fragment,n),C(qt.$$.fragment,n),C(Lt.$$.fragment,n),C(Ht.$$.fragment,n),C(Vt.$$.fragment,n),C(Yt.$$.fragment,n),Wn=!0)},o(n){O(Fe.$$.fragment,n),O(lt.$$.fragment,n),O(It.$$.fragment,n),O($t.$$.fragment,n),O(Ot.$$.fragment,n),O(Gt.$$.fragment,n),O(Mt.$$.fragment,n),O(qt.$$.fragment,n),O(Lt.$$.fragment,n),O(Ht.$$.fragment,n),O(Vt.$$.fragment,n),O(Yt.$$.fragment,n),Wn=!1},d(n){t(ae),n&&t(mn),n&&t(oe),G(Fe),n&&t(gn),n&&t(Xt),n&&t(_n),n&&t(ge),n&&t(vn),n&&t(b),n&&t(bn),n&&t(oa),n&&t(En),n&&t(k),n&&t(yn),n&&t(q),n&&t(wn),n&&t(se),G(lt),n&&t(In),n&&t(da),n&&t(kn),n&&t(ve),n&&t(Dn),n&&t(wt),n&&t(Tn),n&&t(be),n&&t(Pn),n&&t(ne),G(It),n&&t(xn),n&&t(Va),n&&t(An),n&&t(K),n&&t(Sn),n&&t(D),n&&t($n),n&&t(T),n&&t(jn),n&&t(re),G($t),n&&t(Cn),n&&t(w),n&&t(On),n&&t(P),n&&t(Gn),n&&t(ie),G(Ot),n&&t(Mn),n&&t(fe),G(Gt),n&&t(qn),G(Mt,n),n&&t(Ln),n&&t(de),G(qt),n&&t(Nn),n&&t(Te),n&&t(Rn),G(Lt,n),n&&t(Hn),n&&t(Nt),n&&t(Bn),n&&t(pe),G(Ht),n&&t(Un),n&&t(ee),n&&t(Vn),n&&t(he),G(Vt),n&&t(Yn),n&&t(Ae),n&&t(zn),G(Yt,n),n&&t(Fn),n&&t(zt)}}}const Mm={local:"pipelines",sections:[{local:"diffusers-summary",title:"\u{1F9E8} Diffusers Summary"},{local:"pipelines-api",title:"Pipelines API"},{local:"contribution",title:"Contribution"},{local:"examples",sections:[{local:"texttoimage-generation-with-stable-diffusion",title:"Text-to-Image generation with Stable Diffusion"},{local:"imagetoimage-textguided-generation-with-stable-diffusion",title:"Image-to-Image text-guided generation with Stable Diffusion"},{local:"tweak-prompts-reusing-seeds-and-latents",title:"Tweak prompts reusing seeds and latents"},{local:"inpainting-using-stable-diffusion",title:"In-painting using Stable Diffusion"}],title:"Examples"}],title:"Pipelines"};function qm(Mp){return Om(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Hm extends Am{constructor(ae){super();Sm(this,ae,qm,Gm,$m,{})}}export{Hm as default,Mm as metadata};
