import{S as dn,i as yn,s as bn,e as i,k as f,w as h,t as r,M as wn,c as o,d as t,m as c,a as n,x as m,h as a,b as u,N as rt,G as s,g as p,y as d,q as y,o as b,B as w,v as Mn}from"../chunks/vendor-hf-doc-builder.js";import{T as mn}from"../chunks/Tip-hf-doc-builder.js";import{I as be}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as _}from"../chunks/CodeBlock-hf-doc-builder.js";import{D as vn}from"../chunks/DocNotebookDropdown-hf-doc-builder.js";function gn(at){let M,T,v,U,Z;return{c(){M=i("p"),T=r("\u{1F4A1} If you don\u2019t have access to a GPU, you can use one for free from a GPU provider like "),v=i("a"),U=r("Colab"),Z=r("!"),this.h()},l(g){M=o(g,"P",{});var J=n(M);T=a(J,"\u{1F4A1} If you don\u2019t have access to a GPU, you can use one for free from a GPU provider like "),v=o(J,"A",{href:!0,rel:!0});var j=n(v);U=a(j,"Colab"),j.forEach(t),Z=a(J,"!"),J.forEach(t),this.h()},h(){u(v,"href","https://colab.research.google.com/"),u(v,"rel","nofollow")},m(g,J){p(g,M,J),s(M,T),s(M,v),s(v,U),s(M,Z)},d(g){g&&t(M)}}}function Jn(at){let M,T,v,U,Z;return{c(){M=i("p"),T=r("\u{1F4A1} We strongly suggest always running your pipelines in "),v=i("code"),U=r("float16"),Z=r(", and so far, we\u2019ve rarely seen any degradation in output quality.")},l(g){M=o(g,"P",{});var J=n(M);T=a(J,"\u{1F4A1} We strongly suggest always running your pipelines in "),v=o(J,"CODE",{});var j=n(v);U=a(j,"float16"),j.forEach(t),Z=a(J,", and so far, we\u2019ve rarely seen any degradation in output quality."),J.forEach(t)},m(g,J){p(g,M,J),s(M,T),s(M,v),s(v,U),s(M,Z)},d(g){g&&t(M)}}}function _n(at){let M,T,v,U,Z,g,J,j,ci,ks,we,Es,k,ui,nt,hi,mi,pt,di,yi,Ws,E,bi,Ct,wi,Mi,Dt,vi,gi,Is,Q,Ji,ft,_i,Ui,Vs,Y,Zi,Me,zt,Ti,Gi,Bs,ve,Ns,ct,$i,Ss,ge,Rs,X,F,Pt,Je,ji,At,ki,Xs,q,Cs,ut,Ei,Ds,_e,zs,W,Wi,Ue,Ht,Ii,Vi,ht,Bi,Ni,Ps,Ze,As,mt,Si,Hs,Te,xs,Ge,xt,Ir,Qs,G,Ri,dt,Xi,Ci,Qt,Di,zi,Yt,Pi,Ai,Ys,L,Hi,Ft,xi,Qi,Fs,$e,qs,je,qt,Vr,Ls,yt,Yi,Os,O,Ks,I,Fi,bt,qi,Li,Lt,Oi,Ki,el,ke,tl,$,eo,wt,to,so,Mt,lo,io,vt,oo,ro,sl,Ee,ll,K,ao,Ot,no,po,il,We,ol,Ie,Kt,Br,rl,gt,fo,al,C,ee,es,Ve,co,ts,uo,nl,te,ho,ss,mo,yo,pl,V,bo,ls,wo,Mo,is,vo,go,fl,Be,cl,se,Jo,os,_o,Uo,ul,Ne,hl,B,Zo,rs,To,Go,Jt,$o,jo,ml,Se,dl,le,ko,as,Eo,Wo,yl,Re,bl,Xe,ns,Nr,wl,_t,Io,Ml,D,ie,ps,Ce,Vo,fs,Bo,vl,oe,No,cs,So,Ro,gl,z,re,us,De,Xo,hs,Co,Jl,ae,Do,ze,zo,Po,_l,N,Ao,Pe,Ho,xo,Ae,Qo,Yo,Ul,P,ne,ms,He,Fo,ds,qo,Zl,pe,Lo,xe,Oo,Ko,Tl,Qe,Gl,Ye,ys,Sr,$l,A,fe,bs,Fe,er,ws,tr,jl,ce,sr,Ms,lr,ir,kl,ue,vs,or,rr,gs,ar,El,Ut,nr,Wl,qe,Il,Zt,pr,Vl,Le,Bl,Oe,Js,Rr,Nl,S,fr,_s,cr,ur,Us,hr,mr,Sl,Ke,Rl,et,Zs,Xr,Xl,H,he,Ts,tt,dr,Gs,yr,Cl,me,br,Tt,wr,Mr,Dl,R,x,vr,Gt,gr,Jr,st,$s,_r,Ur,Zr,lt,Tr,$t,Gr,$r,jr,it,kr,jt,Er,Wr,zl;return g=new be({}),we=new vn({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/stable_diffusion.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/stable_diffusion.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/stable_diffusion.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/stable_diffusion.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/stable_diffusion.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/stable_diffusion.ipynb"}]}}),ve=new _({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

model_id = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
pipeline = DiffusionPipeline.from_pretrained(model_id, use_safetensors=<span class="hljs-literal">True</span>)`}}),ge=new _({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIycG9ydHJhaXQlMjBwaG90byUyMG9mJTIwYSUyMG9sZCUyMHdhcnJpb3IlMjBjaGllZiUyMg==",highlighted:'prompt = <span class="hljs-string">&quot;portrait photo of a old warrior chief&quot;</span>'}}),Je=new be({}),q=new mn({props:{$$slots:{default:[gn]},$$scope:{ctx:at}}}),_e=new _({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZS50byglMjJjdWRhJTIyKQ==",highlighted:'pipeline = pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)'}}),Ze=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5HZW5lcmF0b3IoJTIyY3VkYSUyMikubWFudWFsX3NlZWQoMCk=",highlighted:`<span class="hljs-keyword">import</span> torch

generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)`}}),Te=new _({props:{code:"aW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`}}),$e=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZS50byglMjJjdWRhJTIyKSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLkdlbmVyYXRvciglMjJjdWRhJTIyKS5tYW51YWxfc2VlZCgwKSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2U=",highlighted:`<span class="hljs-keyword">import</span> torch

pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)
pipeline = pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)
generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)
image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>]
image`}}),O=new mn({props:{$$slots:{default:[Jn]},$$scope:{ctx:at}}}),ke=new _({props:{code:"cGlwZWxpbmUuc2NoZWR1bGVyLmNvbXBhdGlibGVzJTBBJTVCJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnNjaGVkdWxlcnMuc2NoZWR1bGluZ19sbXNfZGlzY3JldGUuTE1TRGlzY3JldGVTY2hlZHVsZXIlMkMlMEElMjAlMjAlMjAlMjBkaWZmdXNlcnMuc2NoZWR1bGVycy5zY2hlZHVsaW5nX3VuaXBjX211bHRpc3RlcC5VbmlQQ011bHRpc3RlcFNjaGVkdWxlciUyQyUwQSUyMCUyMCUyMCUyMGRpZmZ1c2Vycy5zY2hlZHVsZXJzLnNjaGVkdWxpbmdfa19kcG1fMl9kaXNjcmV0ZS5LRFBNMkRpc2NyZXRlU2NoZWR1bGVyJTJDJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnNjaGVkdWxlcnMuc2NoZWR1bGluZ19kZWlzX211bHRpc3RlcC5ERUlTTXVsdGlzdGVwU2NoZWR1bGVyJTJDJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnNjaGVkdWxlcnMuc2NoZWR1bGluZ19ldWxlcl9kaXNjcmV0ZS5FdWxlckRpc2NyZXRlU2NoZWR1bGVyJTJDJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnNjaGVkdWxlcnMuc2NoZWR1bGluZ19kcG1zb2x2ZXJfbXVsdGlzdGVwLkRQTVNvbHZlck11bHRpc3RlcFNjaGVkdWxlciUyQyUwQSUyMCUyMCUyMCUyMGRpZmZ1c2Vycy5zY2hlZHVsZXJzLnNjaGVkdWxpbmdfZGRwbS5ERFBNU2NoZWR1bGVyJTJDJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnNjaGVkdWxlcnMuc2NoZWR1bGluZ19kcG1zb2x2ZXJfc2luZ2xlc3RlcC5EUE1Tb2x2ZXJTaW5nbGVzdGVwU2NoZWR1bGVyJTJDJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnNjaGVkdWxlcnMuc2NoZWR1bGluZ19rX2RwbV8yX2FuY2VzdHJhbF9kaXNjcmV0ZS5LRFBNMkFuY2VzdHJhbERpc2NyZXRlU2NoZWR1bGVyJTJDJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnNjaGVkdWxlcnMuc2NoZWR1bGluZ19oZXVuX2Rpc2NyZXRlLkhldW5EaXNjcmV0ZVNjaGVkdWxlciUyQyUwQSUyMCUyMCUyMCUyMGRpZmZ1c2Vycy5zY2hlZHVsZXJzLnNjaGVkdWxpbmdfcG5kbS5QTkRNU2NoZWR1bGVyJTJDJTBBJTIwJTIwJTIwJTIwZGlmZnVzZXJzLnNjaGVkdWxlcnMuc2NoZWR1bGluZ19ldWxlcl9hbmNlc3RyYWxfZGlzY3JldGUuRXVsZXJBbmNlc3RyYWxEaXNjcmV0ZVNjaGVkdWxlciUyQyUwQSUyMCUyMCUyMCUyMGRpZmZ1c2Vycy5zY2hlZHVsZXJzLnNjaGVkdWxpbmdfZGRpbS5ERElNU2NoZWR1bGVyJTJDJTBBJTVE",highlighted:`pipeline.scheduler.compatibles
[
    diffusers.schedulers.scheduling_lms_discrete.LMSDiscreteScheduler,
    diffusers.schedulers.scheduling_unipc_multistep.UniPCMultistepScheduler,
    diffusers.schedulers.scheduling_k_dpm_2_discrete.KDPM2DiscreteScheduler,
    diffusers.schedulers.scheduling_deis_multistep.DEISMultistepScheduler,
    diffusers.schedulers.scheduling_euler_discrete.EulerDiscreteScheduler,
    diffusers.schedulers.scheduling_dpmsolver_multistep.DPMSolverMultistepScheduler,
    diffusers.schedulers.scheduling_ddpm.DDPMScheduler,
    diffusers.schedulers.scheduling_dpmsolver_singlestep.DPMSolverSinglestepScheduler,
    diffusers.schedulers.scheduling_k_dpm_2_ancestral_discrete.KDPM2AncestralDiscreteScheduler,
    diffusers.schedulers.scheduling_heun_discrete.HeunDiscreteScheduler,
    diffusers.schedulers.scheduling_pndm.PNDMScheduler,
    diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteScheduler,
    diffusers.schedulers.scheduling_ddim.DDIMScheduler,
]`}}),Ee=new _({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERQTVNvbHZlck11bHRpc3RlcFNjaGVkdWxlciUwQSUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMERQTVNvbHZlck11bHRpc3RlcFNjaGVkdWxlci5mcm9tX2NvbmZpZyhwaXBlbGluZS5zY2hlZHVsZXIuY29uZmlnKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DPMSolverMultistepScheduler

pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config)`}}),We=new _({props:{code:"Z2VuZXJhdG9yJTIwJTNEJTIwdG9yY2guR2VuZXJhdG9yKCUyMmN1ZGElMjIpLm1hbnVhbF9zZWVkKDApJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjApLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)
image = pipeline(prompt, generator=generator, num_inference_steps=<span class="hljs-number">20</span>).images[<span class="hljs-number">0</span>]
image`}}),Ve=new be({}),Be=new _({props:{code:"ZGVmJTIwZ2V0X2lucHV0cyhiYXRjaF9zaXplJTNEMSklM0ElMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlMjAlM0QlMjAlNUJ0b3JjaC5HZW5lcmF0b3IoJTIyY3VkYSUyMikubWFudWFsX3NlZWQoaSklMjBmb3IlMjBpJTIwaW4lMjByYW5nZShiYXRjaF9zaXplKSU1RCUwQSUyMCUyMCUyMCUyMHByb21wdHMlMjAlM0QlMjBiYXRjaF9zaXplJTIwKiUyMCU1QnByb21wdCU1RCUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlMjAlM0QlMjAyMCUwQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMCU3QiUyMnByb21wdCUyMiUzQSUyMHByb21wdHMlMkMlMjAlMjJnZW5lcmF0b3IlMjIlM0ElMjBnZW5lcmF0b3IlMkMlMjAlMjJudW1faW5mZXJlbmNlX3N0ZXBzJTIyJTNBJTIwbnVtX2luZmVyZW5jZV9zdGVwcyU3RA==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_inputs</span>(<span class="hljs-params">batch_size=<span class="hljs-number">1</span></span>):
    generator = [torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(i) <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(batch_size)]
    prompts = batch_size * [prompt]
    num_inference_steps = <span class="hljs-number">20</span>

    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;prompt&quot;</span>: prompts, <span class="hljs-string">&quot;generator&quot;</span>: generator, <span class="hljs-string">&quot;num_inference_steps&quot;</span>: num_inference_steps}`}}),Ne=new _({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMG1ha2VfaW1hZ2VfZ3JpZCUyMCUwQSUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lKCoqZ2V0X2lucHV0cyhiYXRjaF9zaXplJTNENCkpLmltYWdlcyUwQW1ha2VfaW1hZ2VfZ3JpZChpbWFnZXMlMkMlMjAyJTJDJTIwMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> make_image_grid 

images = pipeline(**get_inputs(batch_size=<span class="hljs-number">4</span>)).images
make_image_grid(images, <span class="hljs-number">2</span>, <span class="hljs-number">2</span>)`}}),Se=new _({props:{code:"cGlwZWxpbmUuZW5hYmxlX2F0dGVudGlvbl9zbGljaW5nKCk=",highlighted:"pipeline.enable_attention_slicing()"}}),Re=new _({props:{code:"aW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUoKipnZXRfaW5wdXRzKGJhdGNoX3NpemUlM0Q4KSkuaW1hZ2VzJTBBbWFrZV9pbWFnZV9ncmlkKGltYWdlcyUyQyUyMHJvd3MlM0QyJTJDJTIwY29scyUzRDQp",highlighted:`images = pipeline(**get_inputs(batch_size=<span class="hljs-number">8</span>)).images
make_image_grid(images, rows=<span class="hljs-number">2</span>, cols=<span class="hljs-number">4</span>)`}}),Ce=new be({}),De=new be({}),He=new be({}),Qe=new _({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9lbmNvZGVyS0wlMEElMEF2YWUlMjAlM0QlMjBBdXRvZW5jb2RlcktMLmZyb21fcHJldHJhaW5lZCglMjJzdGFiaWxpdHlhaSUyRnNkLXZhZS1mdC1tc2UlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUudmFlJTIwJTNEJTIwdmFlJTBBaW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUoKipnZXRfaW5wdXRzKGJhdGNoX3NpemUlM0Q4KSkuaW1hZ2VzJTBBbWFrZV9pbWFnZV9ncmlkKGltYWdlcyUyQyUyMHJvd3MlM0QyJTJDJTIwY29scyUzRDQp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKL

vae = AutoencoderKL.from_pretrained(<span class="hljs-string">&quot;stabilityai/sd-vae-ft-mse&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.vae = vae
images = pipeline(**get_inputs(batch_size=<span class="hljs-number">8</span>)).images
make_image_grid(images, rows=<span class="hljs-number">2</span>, cols=<span class="hljs-number">4</span>)`}}),Fe=new be({}),qe=new _({props:{code:"cHJvbXB0JTIwJTJCJTNEJTIwJTIyJTJDJTIwdHJpYmFsJTIwcGFudGhlciUyMG1ha2UlMjB1cCUyQyUyMGJsdWUlMjBvbiUyMHJlZCUyQyUyMHNpZGUlMjBwcm9maWxlJTJDJTIwbG9va2luZyUyMGF3YXklMkMlMjBzZXJpb3VzJTIwZXllcyUyMiUwQXByb21wdCUyMCUyQiUzRCUyMCUyMiUyMDUwbW0lMjBwb3J0cmFpdCUyMHBob3RvZ3JhcGh5JTJDJTIwaGFyZCUyMHJpbSUyMGxpZ2h0aW5nJTIwcGhvdG9ncmFwaHktLWJldGElMjAtLWFyJTIwMiUzQTMlMjAlMjAtLWJldGElMjAtLXVwYmV0YSUyMg==",highlighted:`prompt += <span class="hljs-string">&quot;, tribal panther make up, blue on red, side profile, looking away, serious eyes&quot;</span>
prompt += <span class="hljs-string">&quot; 50mm portrait photography, hard rim lighting photography--beta --ar 2:3  --beta --upbeta&quot;</span>`}}),Le=new _({props:{code:"aW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUoKipnZXRfaW5wdXRzKGJhdGNoX3NpemUlM0Q4KSkuaW1hZ2VzJTBBbWFrZV9pbWFnZV9ncmlkKGltYWdlcyUyQyUyMHJvd3MlM0QyJTJDJTIwY29scyUzRDQp",highlighted:`images = pipeline(**get_inputs(batch_size=<span class="hljs-number">8</span>)).images
make_image_grid(images, rows=<span class="hljs-number">2</span>, cols=<span class="hljs-number">4</span>)`}}),Ke=new _({props:{code:"cHJvbXB0cyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMnBvcnRyYWl0JTIwcGhvdG8lMjBvZiUyMHRoZSUyMG9sZGVzdCUyMHdhcnJpb3IlMjBjaGllZiUyQyUyMHRyaWJhbCUyMHBhbnRoZXIlMjBtYWtlJTIwdXAlMkMlMjBibHVlJTIwb24lMjByZWQlMkMlMjBzaWRlJTIwcHJvZmlsZSUyQyUyMGxvb2tpbmclMjBhd2F5JTJDJTIwc2VyaW91cyUyMGV5ZXMlMjA1MG1tJTIwcG9ydHJhaXQlMjBwaG90b2dyYXBoeSUyQyUyMGhhcmQlMjByaW0lMjBsaWdodGluZyUyMHBob3RvZ3JhcGh5LS1iZXRhJTIwLS1hciUyMDIlM0EzJTIwJTIwLS1iZXRhJTIwLS11cGJldGElMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJwb3J0cmFpdCUyMHBob3RvJTIwb2YlMjBhJTIwb2xkJTIwd2FycmlvciUyMGNoaWVmJTJDJTIwdHJpYmFsJTIwcGFudGhlciUyMG1ha2UlMjB1cCUyQyUyMGJsdWUlMjBvbiUyMHJlZCUyQyUyMHNpZGUlMjBwcm9maWxlJTJDJTIwbG9va2luZyUyMGF3YXklMkMlMjBzZXJpb3VzJTIwZXllcyUyMDUwbW0lMjBwb3J0cmFpdCUyMHBob3RvZ3JhcGh5JTJDJTIwaGFyZCUyMHJpbSUyMGxpZ2h0aW5nJTIwcGhvdG9ncmFwaHktLWJldGElMjAtLWFyJTIwMiUzQTMlMjAlMjAtLWJldGElMjAtLXVwYmV0YSUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMnBvcnRyYWl0JTIwcGhvdG8lMjBvZiUyMGElMjB3YXJyaW9yJTIwY2hpZWYlMkMlMjB0cmliYWwlMjBwYW50aGVyJTIwbWFrZSUyMHVwJTJDJTIwYmx1ZSUyMG9uJTIwcmVkJTJDJTIwc2lkZSUyMHByb2ZpbGUlMkMlMjBsb29raW5nJTIwYXdheSUyQyUyMHNlcmlvdXMlMjBleWVzJTIwNTBtbSUyMHBvcnRyYWl0JTIwcGhvdG9ncmFwaHklMkMlMjBoYXJkJTIwcmltJTIwbGlnaHRpbmclMjBwaG90b2dyYXBoeS0tYmV0YSUyMC0tYXIlMjAyJTNBMyUyMCUyMC0tYmV0YSUyMC0tdXBiZXRhJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIycG9ydHJhaXQlMjBwaG90byUyMG9mJTIwYSUyMHlvdW5nJTIwd2FycmlvciUyMGNoaWVmJTJDJTIwdHJpYmFsJTIwcGFudGhlciUyMG1ha2UlMjB1cCUyQyUyMGJsdWUlMjBvbiUyMHJlZCUyQyUyMHNpZGUlMjBwcm9maWxlJTJDJTIwbG9va2luZyUyMGF3YXklMkMlMjBzZXJpb3VzJTIwZXllcyUyMDUwbW0lMjBwb3J0cmFpdCUyMHBob3RvZ3JhcGh5JTJDJTIwaGFyZCUyMHJpbSUyMGxpZ2h0aW5nJTIwcGhvdG9ncmFwaHktLWJldGElMjAtLWFyJTIwMiUzQTMlMjAlMjAtLWJldGElMjAtLXVwYmV0YSUyMiUyQyUwQSU1RCUwQSUwQWdlbmVyYXRvciUyMCUzRCUyMCU1QnRvcmNoLkdlbmVyYXRvciglMjJjdWRhJTIyKS5tYW51YWxfc2VlZCgxKSUyMGZvciUyMF8lMjBpbiUyMHJhbmdlKGxlbihwcm9tcHRzKSklNUQlMEFpbWFnZXMlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHRzJTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDI1KS5pbWFnZXMlMEFtYWtlX2ltYWdlX2dyaWQoaW1hZ2VzJTJDJTIwMiUyQyUyMDIp",highlighted:`prompts = [
    <span class="hljs-string">&quot;portrait photo of the oldest warrior chief, tribal panther make up, blue on red, side profile, looking away, serious eyes 50mm portrait photography, hard rim lighting photography--beta --ar 2:3  --beta --upbeta&quot;</span>,
    <span class="hljs-string">&quot;portrait photo of a old warrior chief, tribal panther make up, blue on red, side profile, looking away, serious eyes 50mm portrait photography, hard rim lighting photography--beta --ar 2:3  --beta --upbeta&quot;</span>,
    <span class="hljs-string">&quot;portrait photo of a warrior chief, tribal panther make up, blue on red, side profile, looking away, serious eyes 50mm portrait photography, hard rim lighting photography--beta --ar 2:3  --beta --upbeta&quot;</span>,
    <span class="hljs-string">&quot;portrait photo of a young warrior chief, tribal panther make up, blue on red, side profile, looking away, serious eyes 50mm portrait photography, hard rim lighting photography--beta --ar 2:3  --beta --upbeta&quot;</span>,
]

generator = [torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">1</span>) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(prompts))]
images = pipeline(prompt=prompts, generator=generator, num_inference_steps=<span class="hljs-number">25</span>).images
make_image_grid(images, <span class="hljs-number">2</span>, <span class="hljs-number">2</span>)`}}),tt=new be({}),{c(){M=i("meta"),T=f(),v=i("h1"),U=i("a"),Z=i("span"),h(g.$$.fragment),J=f(),j=i("span"),ci=r("Effective and efficient diffusion"),ks=f(),h(we.$$.fragment),Es=f(),k=i("p"),ui=r("Getting the "),nt=i("a"),hi=r("DiffusionPipeline"),mi=r(" to generate images in a certain style or include what you want can be tricky. Often times, you have to run the "),pt=i("a"),di=r("DiffusionPipeline"),yi=r(" several times before you end up with an image you\u2019re happy with. But generating something out of nothing is a computationally intensive process, especially if you\u2019re running inference over and over again."),Ws=f(),E=i("p"),bi=r("This is why it\u2019s important to get the most "),Ct=i("em"),wi=r("computational"),Mi=r(" (speed) and "),Dt=i("em"),vi=r("memory"),gi=r(" (GPU RAM) efficiency from the pipeline to reduce the time between inference cycles so you can iterate faster."),Is=f(),Q=i("p"),Ji=r("This tutorial walks you through how to generate faster and better with the "),ft=i("a"),_i=r("DiffusionPipeline"),Ui=r("."),Vs=f(),Y=i("p"),Zi=r("Begin by loading the "),Me=i("a"),zt=i("code"),Ti=r("runwayml/stable-diffusion-v1-5"),Gi=r(" model:"),Bs=f(),h(ve.$$.fragment),Ns=f(),ct=i("p"),$i=r("The example prompt you\u2019ll use is a portrait of an old warrior chief, but feel free to use your own prompt:"),Ss=f(),h(ge.$$.fragment),Rs=f(),X=i("h2"),F=i("a"),Pt=i("span"),h(Je.$$.fragment),ji=f(),At=i("span"),ki=r("Speed"),Xs=f(),h(q.$$.fragment),Cs=f(),ut=i("p"),Ei=r("One of the simplest ways to speed up inference is to place the pipeline on a GPU the same way you would with any PyTorch module:"),Ds=f(),h(_e.$$.fragment),zs=f(),W=i("p"),Wi=r("To make sure you can use the same image and improve on it, use a "),Ue=i("a"),Ht=i("code"),Ii=r("Generator"),Vi=r(" and set a seed for "),ht=i("a"),Bi=r("reproducibility"),Ni=r(":"),Ps=f(),h(Ze.$$.fragment),As=f(),mt=i("p"),Si=r("Now you can generate an image:"),Hs=f(),h(Te.$$.fragment),xs=f(),Ge=i("div"),xt=i("img"),Qs=f(),G=i("p"),Ri=r("This process took ~30 seconds on a T4 GPU (it might be faster if your allocated GPU is better than a T4). By default, the "),dt=i("a"),Xi=r("DiffusionPipeline"),Ci=r(" runs inference with full "),Qt=i("code"),Di=r("float32"),zi=r(" precision for 50 inference steps. You can speed this up by switching to a lower precision like "),Yt=i("code"),Pi=r("float16"),Ai=r(" or running fewer inference steps."),Ys=f(),L=i("p"),Hi=r("Let\u2019s start by loading the model in "),Ft=i("code"),xi=r("float16"),Qi=r(" and generate an image:"),Fs=f(),h($e.$$.fragment),qs=f(),je=i("div"),qt=i("img"),Ls=f(),yt=i("p"),Yi=r("This time, it only took ~11 seconds to generate the image, which is almost 3x faster than before!"),Os=f(),h(O.$$.fragment),Ks=f(),I=i("p"),Fi=r("Another option is to reduce the number of inference steps. Choosing a more efficient scheduler could help decrease the number of steps without sacrificing output quality. You can find which schedulers are compatible with the current model in the "),bt=i("a"),qi=r("DiffusionPipeline"),Li=r(" by calling the "),Lt=i("code"),Oi=r("compatibles"),Ki=r(" method:"),el=f(),h(ke.$$.fragment),tl=f(),$=i("p"),eo=r("The Stable Diffusion model uses the "),wt=i("a"),to=r("PNDMScheduler"),so=r(" by default which usually requires ~50 inference steps, but more performant schedulers like "),Mt=i("a"),lo=r("DPMSolverMultistepScheduler"),io=r(", require only ~20 or 25 inference steps. Use the "),vt=i("a"),oo=r("ConfigMixin.from_config()"),ro=r(" method to load a new scheduler:"),sl=f(),h(Ee.$$.fragment),ll=f(),K=i("p"),ao=r("Now set the "),Ot=i("code"),no=r("num_inference_steps"),po=r(" to 20:"),il=f(),h(We.$$.fragment),ol=f(),Ie=i("div"),Kt=i("img"),rl=f(),gt=i("p"),fo=r("Great, you\u2019ve managed to cut the inference time to just 4 seconds! \u26A1\uFE0F"),al=f(),C=i("h2"),ee=i("a"),es=i("span"),h(Ve.$$.fragment),co=f(),ts=i("span"),uo=r("Memory"),nl=f(),te=i("p"),ho=r("The other key to improving pipeline performance is consuming less memory, which indirectly implies more speed, since you\u2019re often trying to maximize the number of images generated per second. The easiest way to see how many images you can generate at once is to try out different batch sizes until you get an "),ss=i("code"),mo=r("OutOfMemoryError"),yo=r(" (OOM)."),pl=f(),V=i("p"),bo=r("Create a function that\u2019ll generate a batch of images from a list of prompts and "),ls=i("code"),wo=r("Generators"),Mo=r(". Make sure to assign each "),is=i("code"),vo=r("Generator"),go=r(" a seed so you can reuse it if it produces a good result."),fl=f(),h(Be.$$.fragment),cl=f(),se=i("p"),Jo=r("Start with "),os=i("code"),_o=r("batch_size=4"),Uo=r(" and see how much memory you\u2019ve consumed:"),ul=f(),h(Ne.$$.fragment),hl=f(),B=i("p"),Zo=r("Unless you have a GPU with more RAM, the code above probably returned an "),rs=i("code"),To=r("OOM"),Go=r(" error! Most of the memory is taken up by the cross-attention layers. Instead of running this operation in a batch, you can run it sequentially to save a significant amount of memory. All you have to do is configure the pipeline to use the "),Jt=i("a"),$o=r("enable_attention_slicing()"),jo=r(" function:"),ml=f(),h(Se.$$.fragment),dl=f(),le=i("p"),ko=r("Now try increasing the "),as=i("code"),Eo=r("batch_size"),Wo=r(" to 8!"),yl=f(),h(Re.$$.fragment),bl=f(),Xe=i("div"),ns=i("img"),wl=f(),_t=i("p"),Io=r("Whereas before you couldn\u2019t even generate a batch of 4 images, now you can generate a batch of 8 images at ~3.5 seconds per image! This is probably the fastest you can go on a T4 GPU without sacrificing quality."),Ml=f(),D=i("h2"),ie=i("a"),ps=i("span"),h(Ce.$$.fragment),Vo=f(),fs=i("span"),Bo=r("Quality"),vl=f(),oe=i("p"),No=r("In the last two sections, you learned how to optimize the speed of your pipeline by using "),cs=i("code"),So=r("fp16"),Ro=r(", reducing the number of inference steps by using a more performant scheduler, and enabling attention slicing to reduce memory consumption. Now you\u2019re going to focus on how to improve the quality of generated images."),gl=f(),z=i("h3"),re=i("a"),us=i("span"),h(De.$$.fragment),Xo=f(),hs=i("span"),Co=r("Better checkpoints"),Jl=f(),ae=i("p"),Do=r("The most obvious step is to use better checkpoints. The Stable Diffusion model is a good starting point, and since its official launch, several improved versions have also been released. However, using a newer version doesn\u2019t automatically mean you\u2019ll get better results. You\u2019ll still have to experiment with different checkpoints yourself, and do a little research (such as using "),ze=i("a"),zo=r("negative prompts"),Po=r(") to get the best results."),_l=f(),N=i("p"),Ao=r("As the field grows, there are more and more high-quality checkpoints finetuned to produce certain styles. Try exploring the "),Pe=i("a"),Ho=r("Hub"),xo=r(" and "),Ae=i("a"),Qo=r("Diffusers Gallery"),Yo=r(" to find one you\u2019re interested in!"),Ul=f(),P=i("h3"),ne=i("a"),ms=i("span"),h(He.$$.fragment),Fo=f(),ds=i("span"),qo=r("Better pipeline components"),Zl=f(),pe=i("p"),Lo=r("You can also try replacing the current pipeline components with a newer version. Let\u2019s try loading the latest "),xe=i("a"),Oo=r("autodecoder"),Ko=r(" from Stability AI into the pipeline, and generate some images:"),Tl=f(),h(Qe.$$.fragment),Gl=f(),Ye=i("div"),ys=i("img"),$l=f(),A=i("h3"),fe=i("a"),bs=i("span"),h(Fe.$$.fragment),er=f(),ws=i("span"),tr=r("Better prompt engineering"),jl=f(),ce=i("p"),sr=r("The text prompt you use to generate an image is super important, so much so that it is called "),Ms=i("em"),lr=r("prompt engineering"),ir=r(". Some considerations to keep during prompt engineering are:"),kl=f(),ue=i("ul"),vs=i("li"),or=r("How is the image or similar images of the one I want to generate stored on the internet?"),rr=f(),gs=i("li"),ar=r("What additional detail can I give that steers the model towards the style I want?"),El=f(),Ut=i("p"),nr=r("With this in mind, let\u2019s improve the prompt to include color and higher quality details:"),Wl=f(),h(qe.$$.fragment),Il=f(),Zt=i("p"),pr=r("Generate a batch of images with the new prompt:"),Vl=f(),h(Le.$$.fragment),Bl=f(),Oe=i("div"),Js=i("img"),Nl=f(),S=i("p"),fr=r("Pretty impressive! Let\u2019s tweak the second image - corresponding to the "),_s=i("code"),cr=r("Generator"),ur=r(" with a seed of "),Us=i("code"),hr=r("1"),mr=r(" - a bit more by adding some text about the age of the subject:"),Sl=f(),h(Ke.$$.fragment),Rl=f(),et=i("div"),Zs=i("img"),Xl=f(),H=i("h2"),he=i("a"),Ts=i("span"),h(tt.$$.fragment),dr=f(),Gs=i("span"),yr=r("Next steps"),Cl=f(),me=i("p"),br=r("In this tutorial, you learned how to optimize a "),Tt=i("a"),wr=r("DiffusionPipeline"),Mr=r(" for computational and memory efficiency as well as improving the quality of generated outputs. If you\u2019re interested in making your pipeline even faster, take a look at the following resources:"),Dl=f(),R=i("ul"),x=i("li"),vr=r("Learn how "),Gt=i("a"),gr=r("PyTorch 2.0"),Jr=r(" and "),st=i("a"),$s=i("code"),_r=r("torch.compile"),Ur=r(" can yield 5 - 300% faster inference speed. On an A100 GPU, inference can be up to 50% faster!"),Zr=f(),lt=i("li"),Tr=r("If you can\u2019t use PyTorch 2, we recommend you install "),$t=i("a"),Gr=r("xFormers"),$r=r(". Its memory-efficient attention mechanism works great with PyTorch 1.13.1 for faster speed and reduced memory consumption."),jr=f(),it=i("li"),kr=r("Other optimization techniques, such as model offloading, are covered in "),jt=i("a"),Er=r("this guide"),Wr=r("."),this.h()},l(e){const l=wn('[data-svelte="svelte-1phssyn"]',document.head);M=o(l,"META",{name:!0,content:!0}),l.forEach(t),T=c(e),v=o(e,"H1",{class:!0});var ot=n(v);U=o(ot,"A",{id:!0,class:!0,href:!0});var js=n(U);Z=o(js,"SPAN",{});var Cr=n(Z);m(g.$$.fragment,Cr),Cr.forEach(t),js.forEach(t),J=c(ot),j=o(ot,"SPAN",{});var Dr=n(j);ci=a(Dr,"Effective and efficient diffusion"),Dr.forEach(t),ot.forEach(t),ks=c(e),m(we.$$.fragment,e),Es=c(e),k=o(e,"P",{});var kt=n(k);ui=a(kt,"Getting the "),nt=o(kt,"A",{href:!0});var zr=n(nt);hi=a(zr,"DiffusionPipeline"),zr.forEach(t),mi=a(kt," to generate images in a certain style or include what you want can be tricky. Often times, you have to run the "),pt=o(kt,"A",{href:!0});var Pr=n(pt);di=a(Pr,"DiffusionPipeline"),Pr.forEach(t),yi=a(kt," several times before you end up with an image you\u2019re happy with. But generating something out of nothing is a computationally intensive process, especially if you\u2019re running inference over and over again."),kt.forEach(t),Ws=c(e),E=o(e,"P",{});var Et=n(E);bi=a(Et,"This is why it\u2019s important to get the most "),Ct=o(Et,"EM",{});var Ar=n(Ct);wi=a(Ar,"computational"),Ar.forEach(t),Mi=a(Et," (speed) and "),Dt=o(Et,"EM",{});var Hr=n(Dt);vi=a(Hr,"memory"),Hr.forEach(t),gi=a(Et," (GPU RAM) efficiency from the pipeline to reduce the time between inference cycles so you can iterate faster."),Et.forEach(t),Is=c(e),Q=o(e,"P",{});var Pl=n(Q);Ji=a(Pl,"This tutorial walks you through how to generate faster and better with the "),ft=o(Pl,"A",{href:!0});var xr=n(ft);_i=a(xr,"DiffusionPipeline"),xr.forEach(t),Ui=a(Pl,"."),Pl.forEach(t),Vs=c(e),Y=o(e,"P",{});var Al=n(Y);Zi=a(Al,"Begin by loading the "),Me=o(Al,"A",{href:!0,rel:!0});var Qr=n(Me);zt=o(Qr,"CODE",{});var Yr=n(zt);Ti=a(Yr,"runwayml/stable-diffusion-v1-5"),Yr.forEach(t),Qr.forEach(t),Gi=a(Al," model:"),Al.forEach(t),Bs=c(e),m(ve.$$.fragment,e),Ns=c(e),ct=o(e,"P",{});var Fr=n(ct);$i=a(Fr,"The example prompt you\u2019ll use is a portrait of an old warrior chief, but feel free to use your own prompt:"),Fr.forEach(t),Ss=c(e),m(ge.$$.fragment,e),Rs=c(e),X=o(e,"H2",{class:!0});var Hl=n(X);F=o(Hl,"A",{id:!0,class:!0,href:!0});var qr=n(F);Pt=o(qr,"SPAN",{});var Lr=n(Pt);m(Je.$$.fragment,Lr),Lr.forEach(t),qr.forEach(t),ji=c(Hl),At=o(Hl,"SPAN",{});var Or=n(At);ki=a(Or,"Speed"),Or.forEach(t),Hl.forEach(t),Xs=c(e),m(q.$$.fragment,e),Cs=c(e),ut=o(e,"P",{});var Kr=n(ut);Ei=a(Kr,"One of the simplest ways to speed up inference is to place the pipeline on a GPU the same way you would with any PyTorch module:"),Kr.forEach(t),Ds=c(e),m(_e.$$.fragment,e),zs=c(e),W=o(e,"P",{});var Wt=n(W);Wi=a(Wt,"To make sure you can use the same image and improve on it, use a "),Ue=o(Wt,"A",{href:!0,rel:!0});var ea=n(Ue);Ht=o(ea,"CODE",{});var ta=n(Ht);Ii=a(ta,"Generator"),ta.forEach(t),ea.forEach(t),Vi=a(Wt," and set a seed for "),ht=o(Wt,"A",{href:!0});var sa=n(ht);Bi=a(sa,"reproducibility"),sa.forEach(t),Ni=a(Wt,":"),Wt.forEach(t),Ps=c(e),m(Ze.$$.fragment,e),As=c(e),mt=o(e,"P",{});var la=n(mt);Si=a(la,"Now you can generate an image:"),la.forEach(t),Hs=c(e),m(Te.$$.fragment,e),xs=c(e),Ge=o(e,"DIV",{class:!0});var ia=n(Ge);xt=o(ia,"IMG",{src:!0}),ia.forEach(t),Qs=c(e),G=o(e,"P",{});var de=n(G);Ri=a(de,"This process took ~30 seconds on a T4 GPU (it might be faster if your allocated GPU is better than a T4). By default, the "),dt=o(de,"A",{href:!0});var oa=n(dt);Xi=a(oa,"DiffusionPipeline"),oa.forEach(t),Ci=a(de," runs inference with full "),Qt=o(de,"CODE",{});var ra=n(Qt);Di=a(ra,"float32"),ra.forEach(t),zi=a(de," precision for 50 inference steps. You can speed this up by switching to a lower precision like "),Yt=o(de,"CODE",{});var aa=n(Yt);Pi=a(aa,"float16"),aa.forEach(t),Ai=a(de," or running fewer inference steps."),de.forEach(t),Ys=c(e),L=o(e,"P",{});var xl=n(L);Hi=a(xl,"Let\u2019s start by loading the model in "),Ft=o(xl,"CODE",{});var na=n(Ft);xi=a(na,"float16"),na.forEach(t),Qi=a(xl," and generate an image:"),xl.forEach(t),Fs=c(e),m($e.$$.fragment,e),qs=c(e),je=o(e,"DIV",{class:!0});var pa=n(je);qt=o(pa,"IMG",{src:!0}),pa.forEach(t),Ls=c(e),yt=o(e,"P",{});var fa=n(yt);Yi=a(fa,"This time, it only took ~11 seconds to generate the image, which is almost 3x faster than before!"),fa.forEach(t),Os=c(e),m(O.$$.fragment,e),Ks=c(e),I=o(e,"P",{});var It=n(I);Fi=a(It,"Another option is to reduce the number of inference steps. Choosing a more efficient scheduler could help decrease the number of steps without sacrificing output quality. You can find which schedulers are compatible with the current model in the "),bt=o(It,"A",{href:!0});var ca=n(bt);qi=a(ca,"DiffusionPipeline"),ca.forEach(t),Li=a(It," by calling the "),Lt=o(It,"CODE",{});var ua=n(Lt);Oi=a(ua,"compatibles"),ua.forEach(t),Ki=a(It," method:"),It.forEach(t),el=c(e),m(ke.$$.fragment,e),tl=c(e),$=o(e,"P",{});var ye=n($);eo=a(ye,"The Stable Diffusion model uses the "),wt=o(ye,"A",{href:!0});var ha=n(wt);to=a(ha,"PNDMScheduler"),ha.forEach(t),so=a(ye," by default which usually requires ~50 inference steps, but more performant schedulers like "),Mt=o(ye,"A",{href:!0});var ma=n(Mt);lo=a(ma,"DPMSolverMultistepScheduler"),ma.forEach(t),io=a(ye,", require only ~20 or 25 inference steps. Use the "),vt=o(ye,"A",{href:!0});var da=n(vt);oo=a(da,"ConfigMixin.from_config()"),da.forEach(t),ro=a(ye," method to load a new scheduler:"),ye.forEach(t),sl=c(e),m(Ee.$$.fragment,e),ll=c(e),K=o(e,"P",{});var Ql=n(K);ao=a(Ql,"Now set the "),Ot=o(Ql,"CODE",{});var ya=n(Ot);no=a(ya,"num_inference_steps"),ya.forEach(t),po=a(Ql," to 20:"),Ql.forEach(t),il=c(e),m(We.$$.fragment,e),ol=c(e),Ie=o(e,"DIV",{class:!0});var ba=n(Ie);Kt=o(ba,"IMG",{src:!0}),ba.forEach(t),rl=c(e),gt=o(e,"P",{});var wa=n(gt);fo=a(wa,"Great, you\u2019ve managed to cut the inference time to just 4 seconds! \u26A1\uFE0F"),wa.forEach(t),al=c(e),C=o(e,"H2",{class:!0});var Yl=n(C);ee=o(Yl,"A",{id:!0,class:!0,href:!0});var Ma=n(ee);es=o(Ma,"SPAN",{});var va=n(es);m(Ve.$$.fragment,va),va.forEach(t),Ma.forEach(t),co=c(Yl),ts=o(Yl,"SPAN",{});var ga=n(ts);uo=a(ga,"Memory"),ga.forEach(t),Yl.forEach(t),nl=c(e),te=o(e,"P",{});var Fl=n(te);ho=a(Fl,"The other key to improving pipeline performance is consuming less memory, which indirectly implies more speed, since you\u2019re often trying to maximize the number of images generated per second. The easiest way to see how many images you can generate at once is to try out different batch sizes until you get an "),ss=o(Fl,"CODE",{});var Ja=n(ss);mo=a(Ja,"OutOfMemoryError"),Ja.forEach(t),yo=a(Fl," (OOM)."),Fl.forEach(t),pl=c(e),V=o(e,"P",{});var Vt=n(V);bo=a(Vt,"Create a function that\u2019ll generate a batch of images from a list of prompts and "),ls=o(Vt,"CODE",{});var _a=n(ls);wo=a(_a,"Generators"),_a.forEach(t),Mo=a(Vt,". Make sure to assign each "),is=o(Vt,"CODE",{});var Ua=n(is);vo=a(Ua,"Generator"),Ua.forEach(t),go=a(Vt," a seed so you can reuse it if it produces a good result."),Vt.forEach(t),fl=c(e),m(Be.$$.fragment,e),cl=c(e),se=o(e,"P",{});var ql=n(se);Jo=a(ql,"Start with "),os=o(ql,"CODE",{});var Za=n(os);_o=a(Za,"batch_size=4"),Za.forEach(t),Uo=a(ql," and see how much memory you\u2019ve consumed:"),ql.forEach(t),ul=c(e),m(Ne.$$.fragment,e),hl=c(e),B=o(e,"P",{});var Bt=n(B);Zo=a(Bt,"Unless you have a GPU with more RAM, the code above probably returned an "),rs=o(Bt,"CODE",{});var Ta=n(rs);To=a(Ta,"OOM"),Ta.forEach(t),Go=a(Bt," error! Most of the memory is taken up by the cross-attention layers. Instead of running this operation in a batch, you can run it sequentially to save a significant amount of memory. All you have to do is configure the pipeline to use the "),Jt=o(Bt,"A",{href:!0});var Ga=n(Jt);$o=a(Ga,"enable_attention_slicing()"),Ga.forEach(t),jo=a(Bt," function:"),Bt.forEach(t),ml=c(e),m(Se.$$.fragment,e),dl=c(e),le=o(e,"P",{});var Ll=n(le);ko=a(Ll,"Now try increasing the "),as=o(Ll,"CODE",{});var $a=n(as);Eo=a($a,"batch_size"),$a.forEach(t),Wo=a(Ll," to 8!"),Ll.forEach(t),yl=c(e),m(Re.$$.fragment,e),bl=c(e),Xe=o(e,"DIV",{class:!0});var ja=n(Xe);ns=o(ja,"IMG",{src:!0}),ja.forEach(t),wl=c(e),_t=o(e,"P",{});var ka=n(_t);Io=a(ka,"Whereas before you couldn\u2019t even generate a batch of 4 images, now you can generate a batch of 8 images at ~3.5 seconds per image! This is probably the fastest you can go on a T4 GPU without sacrificing quality."),ka.forEach(t),Ml=c(e),D=o(e,"H2",{class:!0});var Ol=n(D);ie=o(Ol,"A",{id:!0,class:!0,href:!0});var Ea=n(ie);ps=o(Ea,"SPAN",{});var Wa=n(ps);m(Ce.$$.fragment,Wa),Wa.forEach(t),Ea.forEach(t),Vo=c(Ol),fs=o(Ol,"SPAN",{});var Ia=n(fs);Bo=a(Ia,"Quality"),Ia.forEach(t),Ol.forEach(t),vl=c(e),oe=o(e,"P",{});var Kl=n(oe);No=a(Kl,"In the last two sections, you learned how to optimize the speed of your pipeline by using "),cs=o(Kl,"CODE",{});var Va=n(cs);So=a(Va,"fp16"),Va.forEach(t),Ro=a(Kl,", reducing the number of inference steps by using a more performant scheduler, and enabling attention slicing to reduce memory consumption. Now you\u2019re going to focus on how to improve the quality of generated images."),Kl.forEach(t),gl=c(e),z=o(e,"H3",{class:!0});var ei=n(z);re=o(ei,"A",{id:!0,class:!0,href:!0});var Ba=n(re);us=o(Ba,"SPAN",{});var Na=n(us);m(De.$$.fragment,Na),Na.forEach(t),Ba.forEach(t),Xo=c(ei),hs=o(ei,"SPAN",{});var Sa=n(hs);Co=a(Sa,"Better checkpoints"),Sa.forEach(t),ei.forEach(t),Jl=c(e),ae=o(e,"P",{});var ti=n(ae);Do=a(ti,"The most obvious step is to use better checkpoints. The Stable Diffusion model is a good starting point, and since its official launch, several improved versions have also been released. However, using a newer version doesn\u2019t automatically mean you\u2019ll get better results. You\u2019ll still have to experiment with different checkpoints yourself, and do a little research (such as using "),ze=o(ti,"A",{href:!0,rel:!0});var Ra=n(ze);zo=a(Ra,"negative prompts"),Ra.forEach(t),Po=a(ti,") to get the best results."),ti.forEach(t),_l=c(e),N=o(e,"P",{});var Nt=n(N);Ao=a(Nt,"As the field grows, there are more and more high-quality checkpoints finetuned to produce certain styles. Try exploring the "),Pe=o(Nt,"A",{href:!0,rel:!0});var Xa=n(Pe);Ho=a(Xa,"Hub"),Xa.forEach(t),xo=a(Nt," and "),Ae=o(Nt,"A",{href:!0,rel:!0});var Ca=n(Ae);Qo=a(Ca,"Diffusers Gallery"),Ca.forEach(t),Yo=a(Nt," to find one you\u2019re interested in!"),Nt.forEach(t),Ul=c(e),P=o(e,"H3",{class:!0});var si=n(P);ne=o(si,"A",{id:!0,class:!0,href:!0});var Da=n(ne);ms=o(Da,"SPAN",{});var za=n(ms);m(He.$$.fragment,za),za.forEach(t),Da.forEach(t),Fo=c(si),ds=o(si,"SPAN",{});var Pa=n(ds);qo=a(Pa,"Better pipeline components"),Pa.forEach(t),si.forEach(t),Zl=c(e),pe=o(e,"P",{});var li=n(pe);Lo=a(li,"You can also try replacing the current pipeline components with a newer version. Let\u2019s try loading the latest "),xe=o(li,"A",{href:!0,rel:!0});var Aa=n(xe);Oo=a(Aa,"autodecoder"),Aa.forEach(t),Ko=a(li," from Stability AI into the pipeline, and generate some images:"),li.forEach(t),Tl=c(e),m(Qe.$$.fragment,e),Gl=c(e),Ye=o(e,"DIV",{class:!0});var Ha=n(Ye);ys=o(Ha,"IMG",{src:!0}),Ha.forEach(t),$l=c(e),A=o(e,"H3",{class:!0});var ii=n(A);fe=o(ii,"A",{id:!0,class:!0,href:!0});var xa=n(fe);bs=o(xa,"SPAN",{});var Qa=n(bs);m(Fe.$$.fragment,Qa),Qa.forEach(t),xa.forEach(t),er=c(ii),ws=o(ii,"SPAN",{});var Ya=n(ws);tr=a(Ya,"Better prompt engineering"),Ya.forEach(t),ii.forEach(t),jl=c(e),ce=o(e,"P",{});var oi=n(ce);sr=a(oi,"The text prompt you use to generate an image is super important, so much so that it is called "),Ms=o(oi,"EM",{});var Fa=n(Ms);lr=a(Fa,"prompt engineering"),Fa.forEach(t),ir=a(oi,". Some considerations to keep during prompt engineering are:"),oi.forEach(t),kl=c(e),ue=o(e,"UL",{});var ri=n(ue);vs=o(ri,"LI",{});var qa=n(vs);or=a(qa,"How is the image or similar images of the one I want to generate stored on the internet?"),qa.forEach(t),rr=c(ri),gs=o(ri,"LI",{});var La=n(gs);ar=a(La,"What additional detail can I give that steers the model towards the style I want?"),La.forEach(t),ri.forEach(t),El=c(e),Ut=o(e,"P",{});var Oa=n(Ut);nr=a(Oa,"With this in mind, let\u2019s improve the prompt to include color and higher quality details:"),Oa.forEach(t),Wl=c(e),m(qe.$$.fragment,e),Il=c(e),Zt=o(e,"P",{});var Ka=n(Zt);pr=a(Ka,"Generate a batch of images with the new prompt:"),Ka.forEach(t),Vl=c(e),m(Le.$$.fragment,e),Bl=c(e),Oe=o(e,"DIV",{class:!0});var en=n(Oe);Js=o(en,"IMG",{src:!0}),en.forEach(t),Nl=c(e),S=o(e,"P",{});var St=n(S);fr=a(St,"Pretty impressive! Let\u2019s tweak the second image - corresponding to the "),_s=o(St,"CODE",{});var tn=n(_s);cr=a(tn,"Generator"),tn.forEach(t),ur=a(St," with a seed of "),Us=o(St,"CODE",{});var sn=n(Us);hr=a(sn,"1"),sn.forEach(t),mr=a(St," - a bit more by adding some text about the age of the subject:"),St.forEach(t),Sl=c(e),m(Ke.$$.fragment,e),Rl=c(e),et=o(e,"DIV",{class:!0});var ln=n(et);Zs=o(ln,"IMG",{src:!0}),ln.forEach(t),Xl=c(e),H=o(e,"H2",{class:!0});var ai=n(H);he=o(ai,"A",{id:!0,class:!0,href:!0});var on=n(he);Ts=o(on,"SPAN",{});var rn=n(Ts);m(tt.$$.fragment,rn),rn.forEach(t),on.forEach(t),dr=c(ai),Gs=o(ai,"SPAN",{});var an=n(Gs);yr=a(an,"Next steps"),an.forEach(t),ai.forEach(t),Cl=c(e),me=o(e,"P",{});var ni=n(me);br=a(ni,"In this tutorial, you learned how to optimize a "),Tt=o(ni,"A",{href:!0});var nn=n(Tt);wr=a(nn,"DiffusionPipeline"),nn.forEach(t),Mr=a(ni," for computational and memory efficiency as well as improving the quality of generated outputs. If you\u2019re interested in making your pipeline even faster, take a look at the following resources:"),ni.forEach(t),Dl=c(e),R=o(e,"UL",{});var Rt=n(R);x=o(Rt,"LI",{});var Xt=n(x);vr=a(Xt,"Learn how "),Gt=o(Xt,"A",{href:!0});var pn=n(Gt);gr=a(pn,"PyTorch 2.0"),pn.forEach(t),Jr=a(Xt," and "),st=o(Xt,"A",{href:!0,rel:!0});var fn=n(st);$s=o(fn,"CODE",{});var cn=n($s);_r=a(cn,"torch.compile"),cn.forEach(t),fn.forEach(t),Ur=a(Xt," can yield 5 - 300% faster inference speed. On an A100 GPU, inference can be up to 50% faster!"),Xt.forEach(t),Zr=c(Rt),lt=o(Rt,"LI",{});var pi=n(lt);Tr=a(pi,"If you can\u2019t use PyTorch 2, we recommend you install "),$t=o(pi,"A",{href:!0});var un=n($t);Gr=a(un,"xFormers"),un.forEach(t),$r=a(pi,". Its memory-efficient attention mechanism works great with PyTorch 1.13.1 for faster speed and reduced memory consumption."),pi.forEach(t),jr=c(Rt),it=o(Rt,"LI",{});var fi=n(it);kr=a(fi,"Other optimization techniques, such as model offloading, are covered in "),jt=o(fi,"A",{href:!0});var hn=n(jt);Er=a(hn,"this guide"),hn.forEach(t),Wr=a(fi,"."),fi.forEach(t),Rt.forEach(t),this.h()},h(){u(M,"name","hf:doc:metadata"),u(M,"content",JSON.stringify(Un)),u(U,"id","effective-and-efficient-diffusion"),u(U,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(U,"href","#effective-and-efficient-diffusion"),u(v,"class","relative group"),u(nt,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(pt,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(ft,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(Me,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),u(Me,"rel","nofollow"),u(F,"id","speed"),u(F,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(F,"href","#speed"),u(X,"class","relative group"),u(Ue,"href","https://pytorch.org/docs/stable/generated/torch.Generator.html"),u(Ue,"rel","nofollow"),u(ht,"href","./using-diffusers/reproducibility"),rt(xt.src,Ir="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_1.png")||u(xt,"src",Ir),u(Ge,"class","flex justify-center"),u(dt,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),rt(qt.src,Vr="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_2.png")||u(qt,"src",Vr),u(je,"class","flex justify-center"),u(bt,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(wt,"href","/docs/diffusers/v0.21.0/en/api/schedulers/pndm#diffusers.PNDMScheduler"),u(Mt,"href","/docs/diffusers/v0.21.0/en/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler"),u(vt,"href","/docs/diffusers/v0.21.0/en/api/configuration#diffusers.ConfigMixin.from_config"),rt(Kt.src,Br="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_3.png")||u(Kt,"src",Br),u(Ie,"class","flex justify-center"),u(ee,"id","memory"),u(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"),u(ee,"href","#memory"),u(C,"class","relative group"),u(Jt,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.enable_attention_slicing"),rt(ns.src,Nr="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_5.png")||u(ns,"src",Nr),u(Xe,"class","flex justify-center"),u(ie,"id","quality"),u(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"),u(ie,"href","#quality"),u(D,"class","relative group"),u(re,"id","better-checkpoints"),u(re,"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"),u(re,"href","#better-checkpoints"),u(z,"class","relative group"),u(ze,"href","https://minimaxir.com/2022/11/stable-diffusion-negative-prompt/"),u(ze,"rel","nofollow"),u(Pe,"href","https://huggingface.co/models?library=diffusers&sort=downloads"),u(Pe,"rel","nofollow"),u(Ae,"href","https://huggingface.co/spaces/huggingface-projects/diffusers-gallery"),u(Ae,"rel","nofollow"),u(ne,"id","better-pipeline-components"),u(ne,"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"),u(ne,"href","#better-pipeline-components"),u(P,"class","relative group"),u(xe,"href","https://huggingface.co/stabilityai/stable-diffusion-2-1/tree/main/vae"),u(xe,"rel","nofollow"),rt(ys.src,Sr="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_6.png")||u(ys,"src",Sr),u(Ye,"class","flex justify-center"),u(fe,"id","better-prompt-engineering"),u(fe,"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"),u(fe,"href","#better-prompt-engineering"),u(A,"class","relative group"),rt(Js.src,Rr="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_7.png")||u(Js,"src",Rr),u(Oe,"class","flex justify-center"),rt(Zs.src,Xr="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_8.png")||u(Zs,"src",Xr),u(et,"class","flex justify-center"),u(he,"id","next-steps"),u(he,"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"),u(he,"href","#next-steps"),u(H,"class","relative group"),u(Tt,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(Gt,"href","./optimization/torch2.0"),u(st,"href","https://pytorch.org/docs/stable/generated/torch.compile.html"),u(st,"rel","nofollow"),u($t,"href","./optimization/xformers"),u(jt,"href","./optimization/fp16")},m(e,l){s(document.head,M),p(e,T,l),p(e,v,l),s(v,U),s(U,Z),d(g,Z,null),s(v,J),s(v,j),s(j,ci),p(e,ks,l),d(we,e,l),p(e,Es,l),p(e,k,l),s(k,ui),s(k,nt),s(nt,hi),s(k,mi),s(k,pt),s(pt,di),s(k,yi),p(e,Ws,l),p(e,E,l),s(E,bi),s(E,Ct),s(Ct,wi),s(E,Mi),s(E,Dt),s(Dt,vi),s(E,gi),p(e,Is,l),p(e,Q,l),s(Q,Ji),s(Q,ft),s(ft,_i),s(Q,Ui),p(e,Vs,l),p(e,Y,l),s(Y,Zi),s(Y,Me),s(Me,zt),s(zt,Ti),s(Y,Gi),p(e,Bs,l),d(ve,e,l),p(e,Ns,l),p(e,ct,l),s(ct,$i),p(e,Ss,l),d(ge,e,l),p(e,Rs,l),p(e,X,l),s(X,F),s(F,Pt),d(Je,Pt,null),s(X,ji),s(X,At),s(At,ki),p(e,Xs,l),d(q,e,l),p(e,Cs,l),p(e,ut,l),s(ut,Ei),p(e,Ds,l),d(_e,e,l),p(e,zs,l),p(e,W,l),s(W,Wi),s(W,Ue),s(Ue,Ht),s(Ht,Ii),s(W,Vi),s(W,ht),s(ht,Bi),s(W,Ni),p(e,Ps,l),d(Ze,e,l),p(e,As,l),p(e,mt,l),s(mt,Si),p(e,Hs,l),d(Te,e,l),p(e,xs,l),p(e,Ge,l),s(Ge,xt),p(e,Qs,l),p(e,G,l),s(G,Ri),s(G,dt),s(dt,Xi),s(G,Ci),s(G,Qt),s(Qt,Di),s(G,zi),s(G,Yt),s(Yt,Pi),s(G,Ai),p(e,Ys,l),p(e,L,l),s(L,Hi),s(L,Ft),s(Ft,xi),s(L,Qi),p(e,Fs,l),d($e,e,l),p(e,qs,l),p(e,je,l),s(je,qt),p(e,Ls,l),p(e,yt,l),s(yt,Yi),p(e,Os,l),d(O,e,l),p(e,Ks,l),p(e,I,l),s(I,Fi),s(I,bt),s(bt,qi),s(I,Li),s(I,Lt),s(Lt,Oi),s(I,Ki),p(e,el,l),d(ke,e,l),p(e,tl,l),p(e,$,l),s($,eo),s($,wt),s(wt,to),s($,so),s($,Mt),s(Mt,lo),s($,io),s($,vt),s(vt,oo),s($,ro),p(e,sl,l),d(Ee,e,l),p(e,ll,l),p(e,K,l),s(K,ao),s(K,Ot),s(Ot,no),s(K,po),p(e,il,l),d(We,e,l),p(e,ol,l),p(e,Ie,l),s(Ie,Kt),p(e,rl,l),p(e,gt,l),s(gt,fo),p(e,al,l),p(e,C,l),s(C,ee),s(ee,es),d(Ve,es,null),s(C,co),s(C,ts),s(ts,uo),p(e,nl,l),p(e,te,l),s(te,ho),s(te,ss),s(ss,mo),s(te,yo),p(e,pl,l),p(e,V,l),s(V,bo),s(V,ls),s(ls,wo),s(V,Mo),s(V,is),s(is,vo),s(V,go),p(e,fl,l),d(Be,e,l),p(e,cl,l),p(e,se,l),s(se,Jo),s(se,os),s(os,_o),s(se,Uo),p(e,ul,l),d(Ne,e,l),p(e,hl,l),p(e,B,l),s(B,Zo),s(B,rs),s(rs,To),s(B,Go),s(B,Jt),s(Jt,$o),s(B,jo),p(e,ml,l),d(Se,e,l),p(e,dl,l),p(e,le,l),s(le,ko),s(le,as),s(as,Eo),s(le,Wo),p(e,yl,l),d(Re,e,l),p(e,bl,l),p(e,Xe,l),s(Xe,ns),p(e,wl,l),p(e,_t,l),s(_t,Io),p(e,Ml,l),p(e,D,l),s(D,ie),s(ie,ps),d(Ce,ps,null),s(D,Vo),s(D,fs),s(fs,Bo),p(e,vl,l),p(e,oe,l),s(oe,No),s(oe,cs),s(cs,So),s(oe,Ro),p(e,gl,l),p(e,z,l),s(z,re),s(re,us),d(De,us,null),s(z,Xo),s(z,hs),s(hs,Co),p(e,Jl,l),p(e,ae,l),s(ae,Do),s(ae,ze),s(ze,zo),s(ae,Po),p(e,_l,l),p(e,N,l),s(N,Ao),s(N,Pe),s(Pe,Ho),s(N,xo),s(N,Ae),s(Ae,Qo),s(N,Yo),p(e,Ul,l),p(e,P,l),s(P,ne),s(ne,ms),d(He,ms,null),s(P,Fo),s(P,ds),s(ds,qo),p(e,Zl,l),p(e,pe,l),s(pe,Lo),s(pe,xe),s(xe,Oo),s(pe,Ko),p(e,Tl,l),d(Qe,e,l),p(e,Gl,l),p(e,Ye,l),s(Ye,ys),p(e,$l,l),p(e,A,l),s(A,fe),s(fe,bs),d(Fe,bs,null),s(A,er),s(A,ws),s(ws,tr),p(e,jl,l),p(e,ce,l),s(ce,sr),s(ce,Ms),s(Ms,lr),s(ce,ir),p(e,kl,l),p(e,ue,l),s(ue,vs),s(vs,or),s(ue,rr),s(ue,gs),s(gs,ar),p(e,El,l),p(e,Ut,l),s(Ut,nr),p(e,Wl,l),d(qe,e,l),p(e,Il,l),p(e,Zt,l),s(Zt,pr),p(e,Vl,l),d(Le,e,l),p(e,Bl,l),p(e,Oe,l),s(Oe,Js),p(e,Nl,l),p(e,S,l),s(S,fr),s(S,_s),s(_s,cr),s(S,ur),s(S,Us),s(Us,hr),s(S,mr),p(e,Sl,l),d(Ke,e,l),p(e,Rl,l),p(e,et,l),s(et,Zs),p(e,Xl,l),p(e,H,l),s(H,he),s(he,Ts),d(tt,Ts,null),s(H,dr),s(H,Gs),s(Gs,yr),p(e,Cl,l),p(e,me,l),s(me,br),s(me,Tt),s(Tt,wr),s(me,Mr),p(e,Dl,l),p(e,R,l),s(R,x),s(x,vr),s(x,Gt),s(Gt,gr),s(x,Jr),s(x,st),s(st,$s),s($s,_r),s(x,Ur),s(R,Zr),s(R,lt),s(lt,Tr),s(lt,$t),s($t,Gr),s(lt,$r),s(R,jr),s(R,it),s(it,kr),s(it,jt),s(jt,Er),s(it,Wr),zl=!0},p(e,[l]){const ot={};l&2&&(ot.$$scope={dirty:l,ctx:e}),q.$set(ot);const js={};l&2&&(js.$$scope={dirty:l,ctx:e}),O.$set(js)},i(e){zl||(y(g.$$.fragment,e),y(we.$$.fragment,e),y(ve.$$.fragment,e),y(ge.$$.fragment,e),y(Je.$$.fragment,e),y(q.$$.fragment,e),y(_e.$$.fragment,e),y(Ze.$$.fragment,e),y(Te.$$.fragment,e),y($e.$$.fragment,e),y(O.$$.fragment,e),y(ke.$$.fragment,e),y(Ee.$$.fragment,e),y(We.$$.fragment,e),y(Ve.$$.fragment,e),y(Be.$$.fragment,e),y(Ne.$$.fragment,e),y(Se.$$.fragment,e),y(Re.$$.fragment,e),y(Ce.$$.fragment,e),y(De.$$.fragment,e),y(He.$$.fragment,e),y(Qe.$$.fragment,e),y(Fe.$$.fragment,e),y(qe.$$.fragment,e),y(Le.$$.fragment,e),y(Ke.$$.fragment,e),y(tt.$$.fragment,e),zl=!0)},o(e){b(g.$$.fragment,e),b(we.$$.fragment,e),b(ve.$$.fragment,e),b(ge.$$.fragment,e),b(Je.$$.fragment,e),b(q.$$.fragment,e),b(_e.$$.fragment,e),b(Ze.$$.fragment,e),b(Te.$$.fragment,e),b($e.$$.fragment,e),b(O.$$.fragment,e),b(ke.$$.fragment,e),b(Ee.$$.fragment,e),b(We.$$.fragment,e),b(Ve.$$.fragment,e),b(Be.$$.fragment,e),b(Ne.$$.fragment,e),b(Se.$$.fragment,e),b(Re.$$.fragment,e),b(Ce.$$.fragment,e),b(De.$$.fragment,e),b(He.$$.fragment,e),b(Qe.$$.fragment,e),b(Fe.$$.fragment,e),b(qe.$$.fragment,e),b(Le.$$.fragment,e),b(Ke.$$.fragment,e),b(tt.$$.fragment,e),zl=!1},d(e){t(M),e&&t(T),e&&t(v),w(g),e&&t(ks),w(we,e),e&&t(Es),e&&t(k),e&&t(Ws),e&&t(E),e&&t(Is),e&&t(Q),e&&t(Vs),e&&t(Y),e&&t(Bs),w(ve,e),e&&t(Ns),e&&t(ct),e&&t(Ss),w(ge,e),e&&t(Rs),e&&t(X),w(Je),e&&t(Xs),w(q,e),e&&t(Cs),e&&t(ut),e&&t(Ds),w(_e,e),e&&t(zs),e&&t(W),e&&t(Ps),w(Ze,e),e&&t(As),e&&t(mt),e&&t(Hs),w(Te,e),e&&t(xs),e&&t(Ge),e&&t(Qs),e&&t(G),e&&t(Ys),e&&t(L),e&&t(Fs),w($e,e),e&&t(qs),e&&t(je),e&&t(Ls),e&&t(yt),e&&t(Os),w(O,e),e&&t(Ks),e&&t(I),e&&t(el),w(ke,e),e&&t(tl),e&&t($),e&&t(sl),w(Ee,e),e&&t(ll),e&&t(K),e&&t(il),w(We,e),e&&t(ol),e&&t(Ie),e&&t(rl),e&&t(gt),e&&t(al),e&&t(C),w(Ve),e&&t(nl),e&&t(te),e&&t(pl),e&&t(V),e&&t(fl),w(Be,e),e&&t(cl),e&&t(se),e&&t(ul),w(Ne,e),e&&t(hl),e&&t(B),e&&t(ml),w(Se,e),e&&t(dl),e&&t(le),e&&t(yl),w(Re,e),e&&t(bl),e&&t(Xe),e&&t(wl),e&&t(_t),e&&t(Ml),e&&t(D),w(Ce),e&&t(vl),e&&t(oe),e&&t(gl),e&&t(z),w(De),e&&t(Jl),e&&t(ae),e&&t(_l),e&&t(N),e&&t(Ul),e&&t(P),w(He),e&&t(Zl),e&&t(pe),e&&t(Tl),w(Qe,e),e&&t(Gl),e&&t(Ye),e&&t($l),e&&t(A),w(Fe),e&&t(jl),e&&t(ce),e&&t(kl),e&&t(ue),e&&t(El),e&&t(Ut),e&&t(Wl),w(qe,e),e&&t(Il),e&&t(Zt),e&&t(Vl),w(Le,e),e&&t(Bl),e&&t(Oe),e&&t(Nl),e&&t(S),e&&t(Sl),w(Ke,e),e&&t(Rl),e&&t(et),e&&t(Xl),e&&t(H),w(tt),e&&t(Cl),e&&t(me),e&&t(Dl),e&&t(R)}}}const Un={local:"effective-and-efficient-diffusion",sections:[{local:"speed",title:"Speed"},{local:"memory",title:"Memory"},{local:"quality",sections:[{local:"better-checkpoints",title:"Better checkpoints"},{local:"better-pipeline-components",title:"Better pipeline components"},{local:"better-prompt-engineering",title:"Better prompt engineering"}],title:"Quality"},{local:"next-steps",title:"Next steps"}],title:"Effective and efficient diffusion"};function Zn(at){return Mn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class En extends dn{constructor(M){super();yn(this,M,Zn,_n,bn,{})}}export{En as default,Un as metadata};
