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Di,be,Ws,Je,Bt,Xs,Pi,Ke,Js,ki;return K=new jl({}),Z=new L({props:{code:"pip install --upgrade diffusers accelerate transformers",highlighted:"pip install --upgrade diffusers accelerate transformers"}}),se=new jl({}),ue=new L({props:{code:`from diffusers import DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>)`}}),pe=new L({props:{code:'pipeline.to("cuda")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)'}}),de=new L({props:{code:'image = pipeline("An image of a squirrel in Picasso style").images[0]',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipeline(<span class="hljs-string">&quot;An image of a squirrel in Picasso style&quot;</span>).images[<span class="hljs-number">0</span>]'}}),ce=new L({props:{code:'image.save("image_of_squirrel_painting.png")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;image_of_squirrel_painting.png&quot;</span>)'}}),ge=new L({props:{code:`git lfs install
git clone https://huggingface.co/runwayml/stable-diffusion-v1-5`,highlighted:`git lfs install
git clone https:<span class="hljs-regexp">//</span>huggingface.co<span class="hljs-regexp">/runwayml/</span>stable-diffusion-v1-<span class="hljs-number">5</span>`}}),ve=new L({props:{code:'pipeline = DiffusionPipeline.from_pretrained("./stable-diffusion-v1-5")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;./stable-diffusion-v1-5&quot;</span>)'}}),_e=new L({props:{code:`generator.to("cuda")
image = generator("An image of a squirrel in Picasso style").images[0]
image.save("image_of_squirrel_painting.png")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>generator.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = generator(<span class="hljs-string">&quot;An image of a squirrel in Picasso style&quot;</span>).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;image_of_squirrel_painting.png&quot;</span>)`}}),we=new L({props:{code:`from diffusers import EulerDiscreteScheduler

pipeline = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")

# change scheduler to Euler
pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> EulerDiscreteScheduler

<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># change scheduler to Euler</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config)`}}),{c(){S=a("meta"),Ht=u(),j=a("h1"),Y=a("a"),lt=a("span"),w(K.$$.fragment),Li=u(),rt=a("span"),Yi=l("Quicktour"),Vt=u(),z=a("p"),zi=l(`Get up and running with \u{1F9E8} Diffusers quickly!
Whether you\u2019re a developer or an everyday user, this quick tour will help you get started and show you how to use `),$e=a("a"),Mi=l("DiffusionPipeline"),Ci=l(" for inference."),Qt=u(),De=a("p"),Bi=l("Before you begin, make sure you have all the necessary libraries installed:"),Wt=u(),w(Z.$$.fragment),Xt=u(),M=a("ul"),Pe=a("li"),ee=a("a"),nt=a("code"),Fi=l("accelerate"),Hi=l(" speeds up model loading for inference and training"),Vi=u(),te=a("li"),ie=a("a"),ft=a("code"),Qi=l("transformers"),Wi=l(" is required to run the most popular diffusion models, such as "),ae=a("a"),Xi=l("Stable Diffusion"),Jt=u(),x=a("h2"),C=a("a"),ut=a("span"),w(se.$$.fragment),Ji=u(),pt=a("span"),Ki=l("DiffusionPipeline"),Kt=u(),P=a("p"),Zi=l("The "),ke=a("a"),ea=l("DiffusionPipeline"),ta=l(" is the easiest way to use a pre-trained diffusion system for inference. You can use the "),Te=a("a"),ia=l("DiffusionPipeline"),aa=l(" out-of-the-box for many tasks across different modalities. Take a look at the table below for some supported tasks:"),Zt=u(),B=a("table"),dt=a("thead"),q=a("tr"),ht=a("th"),ct=a("strong"),sa=l("Task"),oa=u(),mt=a("th"),gt=a("strong"),la=l("Description"),ra=u(),vt=a("th"),_t=a("strong"),na=l("Pipeline"),fa=u(),g=a("tbody"),I=a("tr"),wt=a("td"),ua=l("Unconditional Image Generation"),pa=u(),yt=a("td"),da=l("generate an image from gaussian noise"),ha=u(),Et=a("td"),Ae=a("a"),ca=l("unconditional_image_generation"),ma=u(),N=a("tr"),bt=a("td"),ga=l("Text-Guided Image Generation"),va=u(),$t=a("td"),_a=l("generate an image given a text prompt"),wa=u(),Dt=a("td"),Se=a("a"),ya=l("conditional_image_generation"),Ea=u(),G=a("tr"),Pt=a("td"),ba=l("Text-Guided Image-to-Image Translation"),$a=u(),kt=a("td"),Da=l("adapt an image guided by a text prompt"),Pa=u(),Tt=a("td"),je=a("a"),ka=l("img2img"),Ta=u(),O=a("tr"),At=a("td"),Aa=l("Text-Guided Image-Inpainting"),Sa=u(),St=a("td"),ja=l("fill the masked part of an image given the image, the mask and a text prompt"),xa=u(),jt=a("td"),xe=a("a"),qa=l("inpaint"),Ia=u(),R=a("tr"),xt=a("td"),Na=l("Text-Guided Depth-to-Image Translation"),Ga=u(),qt=a("td"),Oa=l("adapt parts of an image guided by a text prompt while preserving structure via depth estimation"),Ra=u(),It=a("td"),qe=a("a"),Ua=l("depth2image"),ei=u(),F=a("p"),La=l("For more in-detail information on how diffusion pipelines function for the different tasks, please have a look at the "),Ie=a("a"),Nt=a("strong"),Ya=l("Using Diffusers"),za=l(" section."),ti=u(),h=a("p"),Ma=l("As an example, start by creating an instance of "),Ne=a("a"),Ca=l("DiffusionPipeline"),Ba=l(` and specify which pipeline checkpoint you would like to download.
You can use the `),Ge=a("a"),Fa=l("DiffusionPipeline"),Ha=l(" for any "),oe=a("a"),Va=l("Diffusers\u2019 checkpoint"),Qa=l(`.
In this guide though, you\u2019ll use `),Oe=a("a"),Wa=l("DiffusionPipeline"),Xa=l(" for text-to-image generation with "),le=a("a"),Ja=l("Stable Diffusion"),Ka=l("."),ii=u(),c=a("p"),Za=l("For "),re=a("a"),es=l("Stable Diffusion"),ts=l(", please carefully read its "),ne=a("a"),is=l("license"),as=l(` before running the model.
This is due to the improved image generation capabilities of the model and the potentially harmful content that could be produced with it.
Please, head over to your stable diffusion model of choice, `),Gt=a("em"),ss=l("e.g."),os=u(),fe=a("a"),Ot=a("code"),ls=l("runwayml/stable-diffusion-v1-5"),rs=l(", and read the license."),ai=u(),Re=a("p"),ns=l("You can load the model as follows:"),si=u(),w(ue.$$.fragment),oi=u(),H=a("p"),fs=l("The "),Ue=a("a"),us=l("DiffusionPipeline"),ps=l(` downloads and caches all modeling, tokenization, and scheduling components.
Because the model consists of roughly 1.4 billion parameters, we strongly recommend running it on GPU.
You can move the generator object to GPU, just like you would in PyTorch.`),li=u(),w(pe.$$.fragment),ri=u(),V=a("p"),ds=l("Now you can use the "),Rt=a("code"),hs=l("pipeline"),cs=l(" on your text prompt:"),ni=u(),w(de.$$.fragment),fi=u(),Q=a("p"),ms=l("The output is by default wrapped into a "),he=a("a"),gs=l("PIL Image object"),vs=l("."),ui=u(),Le=a("p"),_s=l("You can save the image by simply calling:"),pi=u(),w(ce.$$.fragment),di=u(),me=a("p"),Ut=a("strong"),ws=l("Note"),ys=l(": You can also use the pipeline locally by downloading the weights via:"),hi=u(),w(ge.$$.fragment),ci=u(),Ye=a("p"),Es=l("and then loading the saved weights into the pipeline."),mi=u(),w(ve.$$.fragment),gi=u(),ze=a("p"),bs=l("Running the pipeline is then identical to the code above as it\u2019s the same model architecture."),vi=u(),w(_e.$$.fragment),_i=u(),m=a("p"),$s=l("Diffusion systems can be used with multiple different "),Me=a("a"),Ds=l("schedulers"),Ps=l(` each with their
pros and cons. By default, Stable Diffusion runs with `),Ce=a("a"),ks=l("PNDMScheduler"),Ts=l(`, but it\u2019s very simple to
use a different scheduler. `),Lt=a("em"),As=l("E.g."),Ss=l(" if you would instead like to use the "),Be=a("a"),js=l("EulerDiscreteScheduler"),xs=l(` scheduler,
you could use it as follows:`),wi=u(),w(we.$$.fragment),yi=u(),W=a("p"),qs=l("For more in-detail information on how to change between schedulers, please refer to the "),Fe=a("a"),Is=l("Using Schedulers"),Ns=l(" guide."),Ei=u(),U=a("p"),ye=a("a"),Gs=l("Stability AI\u2019s"),Os=l(` Stable Diffusion model is an impressive image generation model
and can do much more than just generating images from text. We have dedicated a whole documentation page,
just for Stable Diffusion `),He=a("a"),Rs=l("here"),Us=l("."),bi=u(),X=a("p"),Ls=l("If you want to know how to optimize Stable Diffusion to run on less memory, higher inference speeds, on specific hardware, such as Mac, or with "),Ee=a("a"),Ys=l("ONNX Runtime"),zs=l(`, please have a look at our
optimization pages:`),$i=u(),v=a("ul"),Yt=a("li"),Ve=a("a"),Ms=l("Optimized PyTorch on GPU"),Cs=u(),zt=a("li"),Qe=a("a"),Bs=l("Mac OS with PyTorch"),Fs=u(),Mt=a("li"),We=a("a"),Hs=l("ONNX"),Vs=u(),Ct=a("li"),Xe=a("a"),Qs=l("OpenVINO"),Di=u(),be=a("p"),Ws=l("If you want to fine-tune or train your diffusion model, please have a look at the "),Je=a("a"),Bt=a("strong"),Xs=l("training section"),Pi=u(),Ke=a("p"),Js=l("Finally, please be considerate when distributing generated images publicly \u{1F917}."),this.h()},l(e){const n=Nl('[data-svelte="svelte-1phssyn"]',document.head);S=s(n,"META",{name:!0,content:!0}),n.forEach(i),Ht=p(e),j=s(e,"H1",{class:!0});var Ti=o(j);Y=s(Ti,"A",{id:!0,class:!0,href:!0});var io=o(Y);lt=s(io,"SPAN",{});var ao=o(lt);y(K.$$.fragment,ao),ao.forEach(i),io.forEach(i),Li=p(Ti),rt=s(Ti,"SPAN",{});var so=o(rt);Yi=r(so,"Quicktour"),so.forEach(i),Ti.forEach(i),Vt=p(e),z=s(e,"P",{});var Ai=o(z);zi=r(Ai,`Get up and running with \u{1F9E8} Diffusers quickly!
Whether you\u2019re a developer or an everyday user, this quick tour will help you get started and show you how to use `),$e=s(Ai,"A",{href:!0});var oo=o($e);Mi=r(oo,"DiffusionPipeline"),oo.forEach(i),Ci=r(Ai," for inference."),Ai.forEach(i),Qt=p(e),De=s(e,"P",{});var lo=o(De);Bi=r(lo,"Before you begin, make sure you have all the necessary libraries installed:"),lo.forEach(i),Wt=p(e),y(Z.$$.fragment,e),Xt=p(e),M=s(e,"UL",{});var Si=o(M);Pe=s(Si,"LI",{});var Ks=o(Pe);ee=s(Ks,"A",{href:!0,rel:!0});var ro=o(ee);nt=s(ro,"CODE",{});var no=o(nt);Fi=r(no,"accelerate"),no.forEach(i),ro.forEach(i),Hi=r(Ks," speeds up model loading for inference and training"),Ks.forEach(i),Vi=p(Si),te=s(Si,"LI",{});var ji=o(te);ie=s(ji,"A",{href:!0,rel:!0});var fo=o(ie);ft=s(fo,"CODE",{});var uo=o(ft);Qi=r(uo,"transformers"),uo.forEach(i),fo.forEach(i),Wi=r(ji," is required to run the most popular diffusion models, such as "),ae=s(ji,"A",{href:!0,rel:!0});var po=o(ae);Xi=r(po,"Stable Diffusion"),po.forEach(i),ji.forEach(i),Si.forEach(i),Jt=p(e),x=s(e,"H2",{class:!0});var xi=o(x);C=s(xi,"A",{id:!0,class:!0,href:!0});var ho=o(C);ut=s(ho,"SPAN",{});var co=o(ut);y(se.$$.fragment,co),co.forEach(i),ho.forEach(i),Ji=p(xi),pt=s(xi,"SPAN",{});var mo=o(pt);Ki=r(mo,"DiffusionPipeline"),mo.forEach(i),xi.forEach(i),Kt=p(e),P=s(e,"P",{});var Ze=o(P);Zi=r(Ze,"The "),ke=s(Ze,"A",{href:!0});var go=o(ke);ea=r(go,"DiffusionPipeline"),go.forEach(i),ta=r(Ze," is the easiest way to use a pre-trained diffusion system for inference. You can use the "),Te=s(Ze,"A",{href:!0});var vo=o(Te);ia=r(vo,"DiffusionPipeline"),vo.forEach(i),aa=r(Ze," out-of-the-box for many tasks across different modalities. Take a look at the table below for some supported tasks:"),Ze.forEach(i),Zt=p(e),B=s(e,"TABLE",{});var qi=o(B);dt=s(qi,"THEAD",{});var _o=o(dt);q=s(_o,"TR",{});var et=o(q);ht=s(et,"TH",{});var wo=o(ht);ct=s(wo,"STRONG",{});var yo=o(ct);sa=r(yo,"Task"),yo.forEach(i),wo.forEach(i),oa=p(et),mt=s(et,"TH",{});var Eo=o(mt);gt=s(Eo,"STRONG",{});var bo=o(gt);la=r(bo,"Description"),bo.forEach(i),Eo.forEach(i),ra=p(et),vt=s(et,"TH",{});var $o=o(vt);_t=s($o,"STRONG",{});var Do=o(_t);na=r(Do,"Pipeline"),Do.forEach(i),$o.forEach(i),et.forEach(i),_o.forEach(i),fa=p(qi),g=s(qi,"TBODY",{});var k=o(g);I=s(k,"TR",{});var tt=o(I);wt=s(tt,"TD",{});var Po=o(wt);ua=r(Po,"Unconditional Image Generation"),Po.forEach(i),pa=p(tt),yt=s(tt,"TD",{});var ko=o(yt);da=r(ko,"generate an image from gaussian noise"),ko.forEach(i),ha=p(tt),Et=s(tt,"TD",{});var To=o(Et);Ae=s(To,"A",{href:!0});var Ao=o(Ae);ca=r(Ao,"unconditional_image_generation"),Ao.forEach(i),To.forEach(i),tt.forEach(i),ma=p(k),N=s(k,"TR",{});var it=o(N);bt=s(it,"TD",{});var So=o(bt);ga=r(So,"Text-Guided Image Generation"),So.forEach(i),va=p(it),$t=s(it,"TD",{});var jo=o($t);_a=r(jo,"generate an image given a text prompt"),jo.forEach(i),wa=p(it),Dt=s(it,"TD",{});var xo=o(Dt);Se=s(xo,"A",{href:!0});var qo=o(Se);ya=r(qo,"conditional_image_generation"),qo.forEach(i),xo.forEach(i),it.forEach(i),Ea=p(k),G=s(k,"TR",{});var at=o(G);Pt=s(at,"TD",{});var Io=o(Pt);ba=r(Io,"Text-Guided Image-to-Image Translation"),Io.forEach(i),$a=p(at),kt=s(at,"TD",{});var No=o(kt);Da=r(No,"adapt an image guided by a text prompt"),No.forEach(i),Pa=p(at),Tt=s(at,"TD",{});var Go=o(Tt);je=s(Go,"A",{href:!0});var Oo=o(je);ka=r(Oo,"img2img"),Oo.forEach(i),Go.forEach(i),at.forEach(i),Ta=p(k),O=s(k,"TR",{});var st=o(O);At=s(st,"TD",{});var Ro=o(At);Aa=r(Ro,"Text-Guided Image-Inpainting"),Ro.forEach(i),Sa=p(st),St=s(st,"TD",{});var Uo=o(St);ja=r(Uo,"fill the masked part of an image given the image, the mask and a text prompt"),Uo.forEach(i),xa=p(st),jt=s(st,"TD",{});var Lo=o(jt);xe=s(Lo,"A",{href:!0});var Yo=o(xe);qa=r(Yo,"inpaint"),Yo.forEach(i),Lo.forEach(i),st.forEach(i),Ia=p(k),R=s(k,"TR",{});var ot=o(R);xt=s(ot,"TD",{});var zo=o(xt);Na=r(zo,"Text-Guided Depth-to-Image Translation"),zo.forEach(i),Ga=p(ot),qt=s(ot,"TD",{});var Mo=o(qt);Oa=r(Mo,"adapt parts of an image guided by a text prompt while preserving structure via depth estimation"),Mo.forEach(i),Ra=p(ot),It=s(ot,"TD",{});var Co=o(It);qe=s(Co,"A",{href:!0});var Bo=o(qe);Ua=r(Bo,"depth2image"),Bo.forEach(i),Co.forEach(i),ot.forEach(i),k.forEach(i),qi.forEach(i),ei=p(e),F=s(e,"P",{});var Ii=o(F);La=r(Ii,"For more in-detail information on how diffusion pipelines function for the different tasks, please have a look at the "),Ie=s(Ii,"A",{href:!0});var Fo=o(Ie);Nt=s(Fo,"STRONG",{});var Ho=o(Nt);Ya=r(Ho,"Using Diffusers"),Ho.forEach(i),Fo.forEach(i),za=r(Ii," section."),Ii.forEach(i),ti=p(e),h=s(e,"P",{});var _=o(h);Ma=r(_,"As an example, start by creating an instance of "),Ne=s(_,"A",{href:!0});var Vo=o(Ne);Ca=r(Vo,"DiffusionPipeline"),Vo.forEach(i),Ba=r(_,` and specify which pipeline checkpoint you would like to download.
You can use the `),Ge=s(_,"A",{href:!0});var Qo=o(Ge);Fa=r(Qo,"DiffusionPipeline"),Qo.forEach(i),Ha=r(_," for any "),oe=s(_,"A",{href:!0,rel:!0});var Wo=o(oe);Va=r(Wo,"Diffusers\u2019 checkpoint"),Wo.forEach(i),Qa=r(_,`.
In this guide though, you\u2019ll use `),Oe=s(_,"A",{href:!0});var Xo=o(Oe);Wa=r(Xo,"DiffusionPipeline"),Xo.forEach(i),Xa=r(_," for text-to-image generation with "),le=s(_,"A",{href:!0,rel:!0});var Jo=o(le);Ja=r(Jo,"Stable Diffusion"),Jo.forEach(i),Ka=r(_,"."),_.forEach(i),ii=p(e),c=s(e,"P",{});var T=o(c);Za=r(T,"For "),re=s(T,"A",{href:!0,rel:!0});var Ko=o(re);es=r(Ko,"Stable Diffusion"),Ko.forEach(i),ts=r(T,", please carefully read its "),ne=s(T,"A",{href:!0,rel:!0});var Zo=o(ne);is=r(Zo,"license"),Zo.forEach(i),as=r(T,` before running the model.
This is due to the improved image generation capabilities of the model and the potentially harmful content that could be produced with it.
Please, head over to your stable diffusion model of choice, `),Gt=s(T,"EM",{});var el=o(Gt);ss=r(el,"e.g."),el.forEach(i),os=p(T),fe=s(T,"A",{href:!0,rel:!0});var tl=o(fe);Ot=s(tl,"CODE",{});var il=o(Ot);ls=r(il,"runwayml/stable-diffusion-v1-5"),il.forEach(i),tl.forEach(i),rs=r(T,", and read the license."),T.forEach(i),ai=p(e),Re=s(e,"P",{});var al=o(Re);ns=r(al,"You can load the model as follows:"),al.forEach(i),si=p(e),y(ue.$$.fragment,e),oi=p(e),H=s(e,"P",{});var Ni=o(H);fs=r(Ni,"The "),Ue=s(Ni,"A",{href:!0});var sl=o(Ue);us=r(sl,"DiffusionPipeline"),sl.forEach(i),ps=r(Ni,` downloads and caches all modeling, tokenization, and scheduling components.
Because the model consists of roughly 1.4 billion parameters, we strongly recommend running it on GPU.
You can move the generator object to GPU, just like you would in PyTorch.`),Ni.forEach(i),li=p(e),y(pe.$$.fragment,e),ri=p(e),V=s(e,"P",{});var Gi=o(V);ds=r(Gi,"Now you can use the "),Rt=s(Gi,"CODE",{});var ol=o(Rt);hs=r(ol,"pipeline"),ol.forEach(i),cs=r(Gi," on your text prompt:"),Gi.forEach(i),ni=p(e),y(de.$$.fragment,e),fi=p(e),Q=s(e,"P",{});var Oi=o(Q);ms=r(Oi,"The output is by default wrapped into a "),he=s(Oi,"A",{href:!0,rel:!0});var ll=o(he);gs=r(ll,"PIL Image object"),ll.forEach(i),vs=r(Oi,"."),Oi.forEach(i),ui=p(e),Le=s(e,"P",{});var rl=o(Le);_s=r(rl,"You can save the image by simply calling:"),rl.forEach(i),pi=p(e),y(ce.$$.fragment,e),di=p(e),me=s(e,"P",{});var Zs=o(me);Ut=s(Zs,"STRONG",{});var nl=o(Ut);ws=r(nl,"Note"),nl.forEach(i),ys=r(Zs,": You can also use the pipeline locally by downloading the weights via:"),Zs.forEach(i),hi=p(e),y(ge.$$.fragment,e),ci=p(e),Ye=s(e,"P",{});var fl=o(Ye);Es=r(fl,"and then loading the saved weights into the pipeline."),fl.forEach(i),mi=p(e),y(ve.$$.fragment,e),gi=p(e),ze=s(e,"P",{});var ul=o(ze);bs=r(ul,"Running the pipeline is then identical to the code above as it\u2019s the same model architecture."),ul.forEach(i),vi=p(e),y(_e.$$.fragment,e),_i=p(e),m=s(e,"P",{});var A=o(m);$s=r(A,"Diffusion systems can be used with multiple different "),Me=s(A,"A",{href:!0});var pl=o(Me);Ds=r(pl,"schedulers"),pl.forEach(i),Ps=r(A,` each with their
pros and cons. By default, Stable Diffusion runs with `),Ce=s(A,"A",{href:!0});var dl=o(Ce);ks=r(dl,"PNDMScheduler"),dl.forEach(i),Ts=r(A,`, but it\u2019s very simple to
use a different scheduler. `),Lt=s(A,"EM",{});var hl=o(Lt);As=r(hl,"E.g."),hl.forEach(i),Ss=r(A," if you would instead like to use the "),Be=s(A,"A",{href:!0});var cl=o(Be);js=r(cl,"EulerDiscreteScheduler"),cl.forEach(i),xs=r(A,` scheduler,
you could use it as follows:`),A.forEach(i),wi=p(e),y(we.$$.fragment,e),yi=p(e),W=s(e,"P",{});var Ri=o(W);qs=r(Ri,"For more in-detail information on how to change between schedulers, please refer to the "),Fe=s(Ri,"A",{href:!0});var ml=o(Fe);Is=r(ml,"Using Schedulers"),ml.forEach(i),Ns=r(Ri," guide."),Ri.forEach(i),Ei=p(e),U=s(e,"P",{});var Ft=o(U);ye=s(Ft,"A",{href:!0,rel:!0});var gl=o(ye);Gs=r(gl,"Stability AI\u2019s"),gl.forEach(i),Os=r(Ft,` Stable Diffusion model is an impressive image generation model
and can do much more than just generating images from text. We have dedicated a whole documentation page,
just for Stable Diffusion `),He=s(Ft,"A",{href:!0});var vl=o(He);Rs=r(vl,"here"),vl.forEach(i),Us=r(Ft,"."),Ft.forEach(i),bi=p(e),X=s(e,"P",{});var Ui=o(X);Ls=r(Ui,"If you want to know how to optimize Stable Diffusion to run on less memory, higher inference speeds, on specific hardware, such as Mac, or with "),Ee=s(Ui,"A",{href:!0,rel:!0});var _l=o(Ee);Ys=r(_l,"ONNX Runtime"),_l.forEach(i),zs=r(Ui,`, please have a look at our
optimization pages:`),Ui.forEach(i),$i=p(e),v=s(e,"UL",{});var J=o(v);Yt=s(J,"LI",{});var wl=o(Yt);Ve=s(wl,"A",{href:!0});var yl=o(Ve);Ms=r(yl,"Optimized PyTorch on GPU"),yl.forEach(i),wl.forEach(i),Cs=p(J),zt=s(J,"LI",{});var El=o(zt);Qe=s(El,"A",{href:!0});var bl=o(Qe);Bs=r(bl,"Mac OS with PyTorch"),bl.forEach(i),El.forEach(i),Fs=p(J),Mt=s(J,"LI",{});var $l=o(Mt);We=s($l,"A",{href:!0});var Dl=o(We);Hs=r(Dl,"ONNX"),Dl.forEach(i),$l.forEach(i),Vs=p(J),Ct=s(J,"LI",{});var Pl=o(Ct);Xe=s(Pl,"A",{href:!0});var kl=o(Xe);Qs=r(kl,"OpenVINO"),kl.forEach(i),Pl.forEach(i),J.forEach(i),Di=p(e),be=s(e,"P",{});var eo=o(be);Ws=r(eo,"If you want to fine-tune or train your diffusion model, please have a look at the "),Je=s(eo,"A",{href:!0});var Tl=o(Je);Bt=s(Tl,"STRONG",{});var Al=o(Bt);Xs=r(Al,"training section"),Al.forEach(i),Tl.forEach(i),eo.forEach(i),Pi=p(e),Ke=s(e,"P",{});var Sl=o(Ke);Js=r(Sl,"Finally, please be considerate when distributing generated images publicly \u{1F917}."),Sl.forEach(i),this.h()},h(){d(S,"name","hf:doc:metadata"),d(S,"content",JSON.stringify(Ul)),d(Y,"id","quicktour"),d(Y,"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"),d(Y,"href","#quicktour"),d(j,"class","relative group"),d($e,"href","/docs/diffusers/v0.12.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),d(ee,"href","https://huggingface.co/docs/accelerate/index"),d(ee,"rel","nofollow"),d(ie,"href","https://huggingface.co/docs/transformers/index"),d(ie,"rel","nofollow"),d(ae,"href","https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/overview"),d(ae,"rel","nofollow"),d(C,"id","diffusionpipeline"),d(C,"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"),d(C,"href","#diffusionpipeline"),d(x,"class","relative group"),d(ke,"href","/docs/diffusers/v0.12.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),d(Te,"href","/docs/diffusers/v0.12.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),d(Ae,"href","./using-diffusers/unconditional_image_generation%60"),d(Se,"href","./using-diffusers/conditional_image_generation"),d(je,"href","./using-diffusers/img2img"),d(xe,"href","./using-diffusers/inpaint"),d(qe,"href","./using-diffusers/depth2image"),d(Ie,"href","./using-diffusers/overview"),d(Ne,"href","/docs/diffusers/v0.12.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),d(Ge,"href","/docs/diffusers/v0.12.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),d(oe,"href","https://huggingface.co/models?library=diffusers&sort=downloads"),d(oe,"rel","nofollow"),d(Oe,"href","/docs/diffusers/v0.12.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),d(le,"href","https://huggingface.co/CompVis/stable-diffusion"),d(le,"rel","nofollow"),d(re,"href","https://huggingface.co/CompVis/stable-diffusion"),d(re,"rel","nofollow"),d(ne,"href","https://huggingface.co/spaces/CompVis/stable-diffusion-license"),d(ne,"rel","nofollow"),d(fe,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),d(fe,"rel","nofollow"),d(Ue,"href","/docs/diffusers/v0.12.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),d(he,"href","https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class"),d(he,"rel","nofollow"),d(Me,"href","./api/schedulers/overview"),d(Ce,"href","/docs/diffusers/v0.12.0/en/api/schedulers/pndm#diffusers.PNDMScheduler"),d(Be,"href","/docs/diffusers/v0.12.0/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler"),d(Fe,"href","./using-diffusers/schedulers"),d(ye,"href","https://stability.ai/"),d(ye,"rel","nofollow"),d(He,"href","./conceptual/stable_diffusion"),d(Ee,"href","https://onnxruntime.ai/"),d(Ee,"rel","nofollow"),d(Ve,"href","./optimization/fp16"),d(Qe,"href","./optimization/mps"),d(We,"href","./optimization/onnx"),d(Xe,"href","./optimization/open_vino"),d(Je,"href","./training/overview")},m(e,n){t(document.head,S),f(e,Ht,n),f(e,j,n),t(j,Y),t(Y,lt),E(K,lt,null),t(j,Li),t(j,rt),t(rt,Yi),f(e,Vt,n),f(e,z,n),t(z,zi),t(z,$e),t($e,Mi),t(z,Ci),f(e,Qt,n),f(e,De,n),t(De,Bi),f(e,Wt,n),E(Z,e,n),f(e,Xt,n),f(e,M,n),t(M,Pe),t(Pe,ee),t(ee,nt),t(nt,Fi),t(Pe,Hi),t(M,Vi),t(M,te),t(te,ie),t(ie,ft),t(ft,Qi),t(te,Wi),t(te,ae),t(ae,Xi),f(e,Jt,n),f(e,x,n),t(x,C),t(C,ut),E(se,ut,null),t(x,Ji),t(x,pt),t(pt,Ki),f(e,Kt,n),f(e,P,n),t(P,Zi),t(P,ke),t(ke,ea),t(P,ta),t(P,Te),t(Te,ia),t(P,aa),f(e,Zt,n),f(e,B,n),t(B,dt),t(dt,q),t(q,ht),t(ht,ct),t(ct,sa),t(q,oa),t(q,mt),t(mt,gt),t(gt,la),t(q,ra),t(q,vt),t(vt,_t),t(_t,na),t(B,fa),t(B,g),t(g,I),t(I,wt),t(wt,ua),t(I,pa),t(I,yt),t(yt,da),t(I,ha),t(I,Et),t(Et,Ae),t(Ae,ca),t(g,ma),t(g,N),t(N,bt),t(bt,ga),t(N,va),t(N,$t),t($t,_a),t(N,wa),t(N,Dt),t(Dt,Se),t(Se,ya),t(g,Ea),t(g,G),t(G,Pt),t(Pt,ba),t(G,$a),t(G,kt),t(kt,Da),t(G,Pa),t(G,Tt),t(Tt,je),t(je,ka),t(g,Ta),t(g,O),t(O,At),t(At,Aa),t(O,Sa),t(O,St),t(St,ja),t(O,xa),t(O,jt),t(jt,xe),t(xe,qa),t(g,Ia),t(g,R),t(R,xt),t(xt,Na),t(R,Ga),t(R,qt),t(qt,Oa),t(R,Ra),t(R,It),t(It,qe),t(qe,Ua),f(e,ei,n),f(e,F,n),t(F,La),t(F,Ie),t(Ie,Nt),t(Nt,Ya),t(F,za),f(e,ti,n),f(e,h,n),t(h,Ma),t(h,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(v,Fs),t(v,Mt),t(Mt,We),t(We,Hs),t(v,Vs),t(v,Ct),t(Ct,Xe),t(Xe,Qs),f(e,Di,n),f(e,be,n),t(be,Ws),t(be,Je),t(Je,Bt),t(Bt,Xs),f(e,Pi,n),f(e,Ke,n),t(Ke,Js),ki=!0},p:Gl,i(e){ki||(b(K.$$.fragment,e),b(Z.$$.fragment,e),b(se.$$.fragment,e),b(ue.$$.fragment,e),b(pe.$$.fragment,e),b(de.$$.fragment,e),b(ce.$$.fragment,e),b(ge.$$.fragment,e),b(ve.$$.fragment,e),b(_e.$$.fragment,e),b(we.$$.fragment,e),ki=!0)},o(e){$(K.$$.fragment,e),$(Z.$$.fragment,e),$(se.$$.fragment,e),$(ue.$$.fragment,e),$(pe.$$.fragment,e),$(de.$$.fragment,e),$(ce.$$.fragment,e),$(ge.$$.fragment,e),$(ve.$$.fragment,e),$(_e.$$.fragment,e),$(we.$$.fragment,e),ki=!1},d(e){i(S),e&&i(Ht),e&&i(j),D(K),e&&i(Vt),e&&i(z),e&&i(Qt),e&&i(De),e&&i(Wt),D(Z,e),e&&i(Xt),e&&i(M),e&&i(Jt),e&&i(x),D(se),e&&i(Kt),e&&i(P),e&&i(Zt),e&&i(B),e&&i(ei),e&&i(F),e&&i(ti),e&&i(h),e&&i(ii),e&&i(c),e&&i(ai),e&&i(Re),e&&i(si),D(ue,e),e&&i(oi),e&&i(H),e&&i(li),D(pe,e),e&&i(ri),e&&i(V),e&&i(ni),D(de,e),e&&i(fi),e&&i(Q),e&&i(ui),e&&i(Le),e&&i(pi),D(ce,e),e&&i(di),e&&i(me),e&&i(hi),D(ge,e),e&&i(ci),e&&i(Ye),e&&i(mi),D(ve,e),e&&i(gi),e&&i(ze),e&&i(vi),D(_e,e),e&&i(_i),e&&i(m),e&&i(wi),D(we,e),e&&i(yi),e&&i(W),e&&i(Ei),e&&i(U),e&&i(bi),e&&i(X),e&&i($i),e&&i(v),e&&i(Di),e&&i(be),e&&i(Pi),e&&i(Ke)}}}const Ul={local:"quicktour",sections:[{local:"diffusionpipeline",title:"DiffusionPipeline"}],title:"Quicktour"};function Ll(to){return Ol(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Cl extends xl{constructor(S){super();ql(this,S,Ll,Rl,Il,{})}}export{Cl as default,Ul as metadata};
