Buckets:
| import{S as dn,i as yn,s as bn,e as i,k as f,w as m,t as a,M as wn,c as o,d as t,m as c,a as n,x as h,h as r,b as u,N as at,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 hn}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 gn}from"../chunks/DocNotebookDropdown-hf-doc-builder.js";function vn(rt){let M,T,g,U,Z;return{c(){M=i("p"),T=a("\u{1F4A1} If you don\u2019t have access to a GPU, you can use one for free from a GPU provider like "),g=i("a"),U=a("Colab"),Z=a("!"),this.h()},l(v){M=o(v,"P",{});var J=n(M);T=r(J,"\u{1F4A1} If you don\u2019t have access to a GPU, you can use one for free from a GPU provider like "),g=o(J,"A",{href:!0,rel:!0});var j=n(g);U=r(j,"Colab"),j.forEach(t),Z=r(J,"!"),J.forEach(t),this.h()},h(){u(g,"href","https://colab.research.google.com/"),u(g,"rel","nofollow")},m(v,J){p(v,M,J),s(M,T),s(M,g),s(g,U),s(M,Z)},d(v){v&&t(M)}}}function Jn(rt){let M,T,g,U,Z;return{c(){M=i("p"),T=a("\u{1F4A1} We strongly suggest always running your pipelines in "),g=i("code"),U=a("float16"),Z=a(", and so far, we\u2019ve rarely seen any degradation in output quality.")},l(v){M=o(v,"P",{});var J=n(M);T=r(J,"\u{1F4A1} We strongly suggest always running your pipelines in "),g=o(J,"CODE",{});var j=n(g);U=r(j,"float16"),j.forEach(t),Z=r(J,", and so far, we\u2019ve rarely seen any degradation in output quality."),J.forEach(t)},m(v,J){p(v,M,J),s(M,T),s(M,g),s(g,U),s(M,Z)},d(v){v&&t(M)}}}function _n(rt){let M,T,g,U,Z,v,J,j,ci,ks,we,Es,k,ui,nt,mi,hi,pt,di,yi,Ws,E,bi,Ct,wi,Mi,Dt,gi,vi,Is,Q,Ji,ft,_i,Ui,Vs,Y,Zi,Me,zt,Ti,Gi,Bs,ge,Ns,ct,$i,Ss,ve,Rs,X,F,Pt,Je,ji,At,ki,Xs,q,Cs,ut,Ei,Ds,_e,zs,W,Wi,Ue,Ht,Ii,Vi,mt,Bi,Ni,Ps,Ze,As,ht,Si,Hs,Te,xs,Ge,xt,Ia,Qs,G,Ri,dt,Xi,Ci,Qt,Di,zi,Yt,Pi,Ai,Ys,L,Hi,Ft,xi,Qi,Fs,$e,qs,je,qt,Va,Ls,yt,Yi,Os,O,Ks,I,Fi,bt,qi,Li,Lt,Oi,Ki,el,ke,tl,$,eo,wt,to,so,Mt,lo,io,gt,oo,ao,sl,Ee,ll,K,ro,Ot,no,po,il,We,ol,Ie,Kt,Ba,al,vt,fo,rl,C,ee,es,Ve,co,ts,uo,nl,te,mo,ss,ho,yo,pl,V,bo,ls,wo,Mo,is,go,vo,fl,Be,cl,se,Jo,os,_o,Uo,ul,Ne,ml,B,Zo,as,To,Go,Jt,$o,jo,hl,Se,dl,le,ko,rs,Eo,Wo,yl,Re,bl,Xe,ns,Na,wl,_t,Io,Ml,D,ie,ps,Ce,Vo,fs,Bo,gl,oe,No,cs,So,Ro,vl,z,ae,us,De,Xo,ms,Co,Jl,re,Do,ze,zo,Po,_l,N,Ao,Pe,Ho,xo,Ae,Qo,Yo,Ul,P,ne,hs,He,Fo,ds,qo,Zl,pe,Lo,xe,Oo,Ko,Tl,Qe,Gl,Ye,ys,Sa,$l,A,fe,bs,Fe,ea,ws,ta,jl,ce,sa,Ms,la,ia,kl,ue,gs,oa,aa,vs,ra,El,Ut,na,Wl,qe,Il,Zt,pa,Vl,Le,Bl,Oe,Js,Ra,Nl,S,fa,_s,ca,ua,Us,ma,ha,Sl,Ke,Rl,et,Zs,Xa,Xl,H,me,Ts,tt,da,Gs,ya,Cl,he,ba,Tt,wa,Ma,Dl,R,x,ga,Gt,va,Ja,st,$s,_a,Ua,Za,lt,Ta,$t,Ga,$a,ja,it,ka,jt,Ea,Wa,zl;return v=new be({}),we=new gn({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"}]}}),ge=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">"runwayml/stable-diffusion-v1-5"</span> | |
| pipeline = DiffusionPipeline.from_pretrained(model_id, use_safetensors=<span class="hljs-literal">True</span>)`}}),ve=new _({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIycG9ydHJhaXQlMjBwaG90byUyMG9mJTIwYSUyMG9sZCUyMHdhcnJpb3IlMjBjaGllZiUyMg==",highlighted:'prompt = <span class="hljs-string">"portrait photo of a old warrior chief"</span>'}}),Je=new be({}),q=new hn({props:{$$slots:{default:[vn]},$$scope:{ctx:rt}}}),_e=new _({props:{code:"cGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZS50byglMjJjdWRhJTIyKQ==",highlighted:'pipeline = pipeline.to(<span class="hljs-string">"cuda"</span>)'}}),Ze=new _({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5HZW5lcmF0b3IoJTIyY3VkYSUyMikubWFudWFsX3NlZWQoMCk=",highlighted:`<span class="hljs-keyword">import</span> torch | |
| generator = torch.Generator(<span class="hljs-string">"cuda"</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">"cuda"</span>) | |
| generator = torch.Generator(<span class="hljs-string">"cuda"</span>).manual_seed(<span class="hljs-number">0</span>) | |
| image = pipeline(prompt, generator=generator).images[<span class="hljs-number">0</span>] | |
| image`}}),O=new hn({props:{$$slots:{default:[Jn]},$$scope:{ctx:rt}}}),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">"cuda"</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">"cuda"</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">"prompt"</span>: prompts, <span class="hljs-string">"generator"</span>: generator, <span class="hljs-string">"num_inference_steps"</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">"stabilityai/sd-vae-ft-mse"</span>, torch_dtype=torch.float16).to(<span class="hljs-string">"cuda"</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">", tribal panther make up, blue on red, side profile, looking away, serious eyes"</span> | |
| prompt += <span class="hljs-string">" 50mm portrait photography, hard rim lighting photography--beta --ar 2:3 --beta --upbeta"</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">"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"</span>, | |
| <span class="hljs-string">"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"</span>, | |
| <span class="hljs-string">"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"</span>, | |
| <span class="hljs-string">"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"</span>, | |
| ] | |
| generator = [torch.Generator(<span class="hljs-string">"cuda"</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(),g=i("h1"),U=i("a"),Z=i("span"),m(v.$$.fragment),J=f(),j=i("span"),ci=a("Effective and efficient diffusion"),ks=f(),m(we.$$.fragment),Es=f(),k=i("p"),ui=a("Getting the "),nt=i("a"),mi=a("DiffusionPipeline"),hi=a(" 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=a("DiffusionPipeline"),yi=a(" 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=a("This is why it\u2019s important to get the most "),Ct=i("em"),wi=a("computational"),Mi=a(" (speed) and "),Dt=i("em"),gi=a("memory"),vi=a(" (GPU RAM) efficiency from the pipeline to reduce the time between inference cycles so you can iterate faster."),Is=f(),Q=i("p"),Ji=a("This tutorial walks you through how to generate faster and better with the "),ft=i("a"),_i=a("DiffusionPipeline"),Ui=a("."),Vs=f(),Y=i("p"),Zi=a("Begin by loading the "),Me=i("a"),zt=i("code"),Ti=a("runwayml/stable-diffusion-v1-5"),Gi=a(" model:"),Bs=f(),m(ge.$$.fragment),Ns=f(),ct=i("p"),$i=a("The example prompt you\u2019ll use is a portrait of an old warrior chief, but feel free to use your own prompt:"),Ss=f(),m(ve.$$.fragment),Rs=f(),X=i("h2"),F=i("a"),Pt=i("span"),m(Je.$$.fragment),ji=f(),At=i("span"),ki=a("Speed"),Xs=f(),m(q.$$.fragment),Cs=f(),ut=i("p"),Ei=a("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(),m(_e.$$.fragment),zs=f(),W=i("p"),Wi=a("To make sure you can use the same image and improve on it, use a "),Ue=i("a"),Ht=i("code"),Ii=a("Generator"),Vi=a(" and set a seed for "),mt=i("a"),Bi=a("reproducibility"),Ni=a(":"),Ps=f(),m(Ze.$$.fragment),As=f(),ht=i("p"),Si=a("Now you can generate an image:"),Hs=f(),m(Te.$$.fragment),xs=f(),Ge=i("div"),xt=i("img"),Qs=f(),G=i("p"),Ri=a("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=a("DiffusionPipeline"),Ci=a(" runs inference with full "),Qt=i("code"),Di=a("float32"),zi=a(" precision for 50 inference steps. You can speed this up by switching to a lower precision like "),Yt=i("code"),Pi=a("float16"),Ai=a(" or running fewer inference steps."),Ys=f(),L=i("p"),Hi=a("Let\u2019s start by loading the model in "),Ft=i("code"),xi=a("float16"),Qi=a(" and generate an image:"),Fs=f(),m($e.$$.fragment),qs=f(),je=i("div"),qt=i("img"),Ls=f(),yt=i("p"),Yi=a("This time, it only took ~11 seconds to generate the image, which is almost 3x faster than before!"),Os=f(),m(O.$$.fragment),Ks=f(),I=i("p"),Fi=a("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=a("DiffusionPipeline"),Li=a(" by calling the "),Lt=i("code"),Oi=a("compatibles"),Ki=a(" method:"),el=f(),m(ke.$$.fragment),tl=f(),$=i("p"),eo=a("The Stable Diffusion model uses the "),wt=i("a"),to=a("PNDMScheduler"),so=a(" by default which usually requires ~50 inference steps, but more performant schedulers like "),Mt=i("a"),lo=a("DPMSolverMultistepScheduler"),io=a(", require only ~20 or 25 inference steps. Use the "),gt=i("a"),oo=a("ConfigMixin.from_config()"),ao=a(" method to load a new scheduler:"),sl=f(),m(Ee.$$.fragment),ll=f(),K=i("p"),ro=a("Now set the "),Ot=i("code"),no=a("num_inference_steps"),po=a(" to 20:"),il=f(),m(We.$$.fragment),ol=f(),Ie=i("div"),Kt=i("img"),al=f(),vt=i("p"),fo=a("Great, you\u2019ve managed to cut the inference time to just 4 seconds! \u26A1\uFE0F"),rl=f(),C=i("h2"),ee=i("a"),es=i("span"),m(Ve.$$.fragment),co=f(),ts=i("span"),uo=a("Memory"),nl=f(),te=i("p"),mo=a("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"),ho=a("OutOfMemoryError"),yo=a(" (OOM)."),pl=f(),V=i("p"),bo=a("Create a function that\u2019ll generate a batch of images from a list of prompts and "),ls=i("code"),wo=a("Generators"),Mo=a(". Make sure to assign each "),is=i("code"),go=a("Generator"),vo=a(" a seed so you can reuse it if it produces a good result."),fl=f(),m(Be.$$.fragment),cl=f(),se=i("p"),Jo=a("Start with "),os=i("code"),_o=a("batch_size=4"),Uo=a(" and see how much memory you\u2019ve consumed:"),ul=f(),m(Ne.$$.fragment),ml=f(),B=i("p"),Zo=a("Unless you have a GPU with more RAM, the code above probably returned an "),as=i("code"),To=a("OOM"),Go=a(" 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=a("enable_attention_slicing()"),jo=a(" function:"),hl=f(),m(Se.$$.fragment),dl=f(),le=i("p"),ko=a("Now try increasing the "),rs=i("code"),Eo=a("batch_size"),Wo=a(" to 8!"),yl=f(),m(Re.$$.fragment),bl=f(),Xe=i("div"),ns=i("img"),wl=f(),_t=i("p"),Io=a("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"),m(Ce.$$.fragment),Vo=f(),fs=i("span"),Bo=a("Quality"),gl=f(),oe=i("p"),No=a("In the last two sections, you learned how to optimize the speed of your pipeline by using "),cs=i("code"),So=a("fp16"),Ro=a(", 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."),vl=f(),z=i("h3"),ae=i("a"),us=i("span"),m(De.$$.fragment),Xo=f(),ms=i("span"),Co=a("Better checkpoints"),Jl=f(),re=i("p"),Do=a("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=a("negative prompts"),Po=a(") to get the best results."),_l=f(),N=i("p"),Ao=a("As the field grows, there are more and more high-quality checkpoints finetuned to produce certain styles. Try exploring the "),Pe=i("a"),Ho=a("Hub"),xo=a(" and "),Ae=i("a"),Qo=a("Diffusers Gallery"),Yo=a(" to find one you\u2019re interested in!"),Ul=f(),P=i("h3"),ne=i("a"),hs=i("span"),m(He.$$.fragment),Fo=f(),ds=i("span"),qo=a("Better pipeline components"),Zl=f(),pe=i("p"),Lo=a("You can also try replacing the current pipeline components with a newer version. Let\u2019s try loading the latest "),xe=i("a"),Oo=a("autodecoder"),Ko=a(" from Stability AI into the pipeline, and generate some images:"),Tl=f(),m(Qe.$$.fragment),Gl=f(),Ye=i("div"),ys=i("img"),$l=f(),A=i("h3"),fe=i("a"),bs=i("span"),m(Fe.$$.fragment),ea=f(),ws=i("span"),ta=a("Better prompt engineering"),jl=f(),ce=i("p"),sa=a("The text prompt you use to generate an image is super important, so much so that it is called "),Ms=i("em"),la=a("prompt engineering"),ia=a(". Some considerations to keep during prompt engineering are:"),kl=f(),ue=i("ul"),gs=i("li"),oa=a("How is the image or similar images of the one I want to generate stored on the internet?"),aa=f(),vs=i("li"),ra=a("What additional detail can I give that steers the model towards the style I want?"),El=f(),Ut=i("p"),na=a("With this in mind, let\u2019s improve the prompt to include color and higher quality details:"),Wl=f(),m(qe.$$.fragment),Il=f(),Zt=i("p"),pa=a("Generate a batch of images with the new prompt:"),Vl=f(),m(Le.$$.fragment),Bl=f(),Oe=i("div"),Js=i("img"),Nl=f(),S=i("p"),fa=a("Pretty impressive! Let\u2019s tweak the second image - corresponding to the "),_s=i("code"),ca=a("Generator"),ua=a(" with a seed of "),Us=i("code"),ma=a("1"),ha=a(" - a bit more by adding some text about the age of the subject:"),Sl=f(),m(Ke.$$.fragment),Rl=f(),et=i("div"),Zs=i("img"),Xl=f(),H=i("h2"),me=i("a"),Ts=i("span"),m(tt.$$.fragment),da=f(),Gs=i("span"),ya=a("Next steps"),Cl=f(),he=i("p"),ba=a("In this tutorial, you learned how to optimize a "),Tt=i("a"),wa=a("DiffusionPipeline"),Ma=a(" 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"),ga=a("Learn how "),Gt=i("a"),va=a("PyTorch 2.0"),Ja=a(" and "),st=i("a"),$s=i("code"),_a=a("torch.compile"),Ua=a(" can yield 5 - 300% faster inference speed. On an A100 GPU, inference can be up to 50% faster!"),Za=f(),lt=i("li"),Ta=a("If you can\u2019t use PyTorch 2, we recommend you install "),$t=i("a"),Ga=a("xFormers"),$a=a(". Its memory-efficient attention mechanism works great with PyTorch 1.13.1 for faster speed and reduced memory consumption."),ja=f(),it=i("li"),ka=a("Other optimization techniques, such as model offloading, are covered in "),jt=i("a"),Ea=a("this guide"),Wa=a("."),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),g=o(e,"H1",{class:!0});var ot=n(g);U=o(ot,"A",{id:!0,class:!0,href:!0});var js=n(U);Z=o(js,"SPAN",{});var Ca=n(Z);h(v.$$.fragment,Ca),Ca.forEach(t),js.forEach(t),J=c(ot),j=o(ot,"SPAN",{});var Da=n(j);ci=r(Da,"Effective and efficient diffusion"),Da.forEach(t),ot.forEach(t),ks=c(e),h(we.$$.fragment,e),Es=c(e),k=o(e,"P",{});var kt=n(k);ui=r(kt,"Getting the "),nt=o(kt,"A",{href:!0});var za=n(nt);mi=r(za,"DiffusionPipeline"),za.forEach(t),hi=r(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 Pa=n(pt);di=r(Pa,"DiffusionPipeline"),Pa.forEach(t),yi=r(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=r(Et,"This is why it\u2019s important to get the most "),Ct=o(Et,"EM",{});var Aa=n(Ct);wi=r(Aa,"computational"),Aa.forEach(t),Mi=r(Et," (speed) and "),Dt=o(Et,"EM",{});var Ha=n(Dt);gi=r(Ha,"memory"),Ha.forEach(t),vi=r(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=r(Pl,"This tutorial walks you through how to generate faster and better with the "),ft=o(Pl,"A",{href:!0});var xa=n(ft);_i=r(xa,"DiffusionPipeline"),xa.forEach(t),Ui=r(Pl,"."),Pl.forEach(t),Vs=c(e),Y=o(e,"P",{});var Al=n(Y);Zi=r(Al,"Begin by loading the "),Me=o(Al,"A",{href:!0,rel:!0});var Qa=n(Me);zt=o(Qa,"CODE",{});var Ya=n(zt);Ti=r(Ya,"runwayml/stable-diffusion-v1-5"),Ya.forEach(t),Qa.forEach(t),Gi=r(Al," model:"),Al.forEach(t),Bs=c(e),h(ge.$$.fragment,e),Ns=c(e),ct=o(e,"P",{});var Fa=n(ct);$i=r(Fa,"The example prompt you\u2019ll use is a portrait of an old warrior chief, but feel free to use your own prompt:"),Fa.forEach(t),Ss=c(e),h(ve.$$.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 qa=n(F);Pt=o(qa,"SPAN",{});var La=n(Pt);h(Je.$$.fragment,La),La.forEach(t),qa.forEach(t),ji=c(Hl),At=o(Hl,"SPAN",{});var Oa=n(At);ki=r(Oa,"Speed"),Oa.forEach(t),Hl.forEach(t),Xs=c(e),h(q.$$.fragment,e),Cs=c(e),ut=o(e,"P",{});var Ka=n(ut);Ei=r(Ka,"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:"),Ka.forEach(t),Ds=c(e),h(_e.$$.fragment,e),zs=c(e),W=o(e,"P",{});var Wt=n(W);Wi=r(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 er=n(Ue);Ht=o(er,"CODE",{});var tr=n(Ht);Ii=r(tr,"Generator"),tr.forEach(t),er.forEach(t),Vi=r(Wt," and set a seed for "),mt=o(Wt,"A",{href:!0});var sr=n(mt);Bi=r(sr,"reproducibility"),sr.forEach(t),Ni=r(Wt,":"),Wt.forEach(t),Ps=c(e),h(Ze.$$.fragment,e),As=c(e),ht=o(e,"P",{});var lr=n(ht);Si=r(lr,"Now you can generate an image:"),lr.forEach(t),Hs=c(e),h(Te.$$.fragment,e),xs=c(e),Ge=o(e,"DIV",{class:!0});var ir=n(Ge);xt=o(ir,"IMG",{src:!0}),ir.forEach(t),Qs=c(e),G=o(e,"P",{});var de=n(G);Ri=r(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 or=n(dt);Xi=r(or,"DiffusionPipeline"),or.forEach(t),Ci=r(de," runs inference with full "),Qt=o(de,"CODE",{});var ar=n(Qt);Di=r(ar,"float32"),ar.forEach(t),zi=r(de," precision for 50 inference steps. You can speed this up by switching to a lower precision like "),Yt=o(de,"CODE",{});var rr=n(Yt);Pi=r(rr,"float16"),rr.forEach(t),Ai=r(de," or running fewer inference steps."),de.forEach(t),Ys=c(e),L=o(e,"P",{});var xl=n(L);Hi=r(xl,"Let\u2019s start by loading the model in "),Ft=o(xl,"CODE",{});var nr=n(Ft);xi=r(nr,"float16"),nr.forEach(t),Qi=r(xl," and generate an image:"),xl.forEach(t),Fs=c(e),h($e.$$.fragment,e),qs=c(e),je=o(e,"DIV",{class:!0});var pr=n(je);qt=o(pr,"IMG",{src:!0}),pr.forEach(t),Ls=c(e),yt=o(e,"P",{});var fr=n(yt);Yi=r(fr,"This time, it only took ~11 seconds to generate the image, which is almost 3x faster than before!"),fr.forEach(t),Os=c(e),h(O.$$.fragment,e),Ks=c(e),I=o(e,"P",{});var It=n(I);Fi=r(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 cr=n(bt);qi=r(cr,"DiffusionPipeline"),cr.forEach(t),Li=r(It," by calling the "),Lt=o(It,"CODE",{});var ur=n(Lt);Oi=r(ur,"compatibles"),ur.forEach(t),Ki=r(It," method:"),It.forEach(t),el=c(e),h(ke.$$.fragment,e),tl=c(e),$=o(e,"P",{});var ye=n($);eo=r(ye,"The Stable Diffusion model uses the "),wt=o(ye,"A",{href:!0});var mr=n(wt);to=r(mr,"PNDMScheduler"),mr.forEach(t),so=r(ye," by default which usually requires ~50 inference steps, but more performant schedulers like "),Mt=o(ye,"A",{href:!0});var hr=n(Mt);lo=r(hr,"DPMSolverMultistepScheduler"),hr.forEach(t),io=r(ye,", require only ~20 or 25 inference steps. Use the "),gt=o(ye,"A",{href:!0});var dr=n(gt);oo=r(dr,"ConfigMixin.from_config()"),dr.forEach(t),ao=r(ye," method to load a new scheduler:"),ye.forEach(t),sl=c(e),h(Ee.$$.fragment,e),ll=c(e),K=o(e,"P",{});var Ql=n(K);ro=r(Ql,"Now set the "),Ot=o(Ql,"CODE",{});var yr=n(Ot);no=r(yr,"num_inference_steps"),yr.forEach(t),po=r(Ql," to 20:"),Ql.forEach(t),il=c(e),h(We.$$.fragment,e),ol=c(e),Ie=o(e,"DIV",{class:!0});var br=n(Ie);Kt=o(br,"IMG",{src:!0}),br.forEach(t),al=c(e),vt=o(e,"P",{});var wr=n(vt);fo=r(wr,"Great, you\u2019ve managed to cut the inference time to just 4 seconds! \u26A1\uFE0F"),wr.forEach(t),rl=c(e),C=o(e,"H2",{class:!0});var Yl=n(C);ee=o(Yl,"A",{id:!0,class:!0,href:!0});var Mr=n(ee);es=o(Mr,"SPAN",{});var gr=n(es);h(Ve.$$.fragment,gr),gr.forEach(t),Mr.forEach(t),co=c(Yl),ts=o(Yl,"SPAN",{});var vr=n(ts);uo=r(vr,"Memory"),vr.forEach(t),Yl.forEach(t),nl=c(e),te=o(e,"P",{});var Fl=n(te);mo=r(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 Jr=n(ss);ho=r(Jr,"OutOfMemoryError"),Jr.forEach(t),yo=r(Fl," (OOM)."),Fl.forEach(t),pl=c(e),V=o(e,"P",{});var Vt=n(V);bo=r(Vt,"Create a function that\u2019ll generate a batch of images from a list of prompts and "),ls=o(Vt,"CODE",{});var _r=n(ls);wo=r(_r,"Generators"),_r.forEach(t),Mo=r(Vt,". Make sure to assign each "),is=o(Vt,"CODE",{});var Ur=n(is);go=r(Ur,"Generator"),Ur.forEach(t),vo=r(Vt," a seed so you can reuse it if it produces a good result."),Vt.forEach(t),fl=c(e),h(Be.$$.fragment,e),cl=c(e),se=o(e,"P",{});var ql=n(se);Jo=r(ql,"Start with "),os=o(ql,"CODE",{});var Zr=n(os);_o=r(Zr,"batch_size=4"),Zr.forEach(t),Uo=r(ql," and see how much memory you\u2019ve consumed:"),ql.forEach(t),ul=c(e),h(Ne.$$.fragment,e),ml=c(e),B=o(e,"P",{});var Bt=n(B);Zo=r(Bt,"Unless you have a GPU with more RAM, the code above probably returned an "),as=o(Bt,"CODE",{});var Tr=n(as);To=r(Tr,"OOM"),Tr.forEach(t),Go=r(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 Gr=n(Jt);$o=r(Gr,"enable_attention_slicing()"),Gr.forEach(t),jo=r(Bt," function:"),Bt.forEach(t),hl=c(e),h(Se.$$.fragment,e),dl=c(e),le=o(e,"P",{});var Ll=n(le);ko=r(Ll,"Now try increasing the "),rs=o(Ll,"CODE",{});var $r=n(rs);Eo=r($r,"batch_size"),$r.forEach(t),Wo=r(Ll," to 8!"),Ll.forEach(t),yl=c(e),h(Re.$$.fragment,e),bl=c(e),Xe=o(e,"DIV",{class:!0});var jr=n(Xe);ns=o(jr,"IMG",{src:!0}),jr.forEach(t),wl=c(e),_t=o(e,"P",{});var kr=n(_t);Io=r(kr,"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."),kr.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 Er=n(ie);ps=o(Er,"SPAN",{});var Wr=n(ps);h(Ce.$$.fragment,Wr),Wr.forEach(t),Er.forEach(t),Vo=c(Ol),fs=o(Ol,"SPAN",{});var Ir=n(fs);Bo=r(Ir,"Quality"),Ir.forEach(t),Ol.forEach(t),gl=c(e),oe=o(e,"P",{});var Kl=n(oe);No=r(Kl,"In the last two sections, you learned how to optimize the speed of your pipeline by using "),cs=o(Kl,"CODE",{});var Vr=n(cs);So=r(Vr,"fp16"),Vr.forEach(t),Ro=r(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),vl=c(e),z=o(e,"H3",{class:!0});var ei=n(z);ae=o(ei,"A",{id:!0,class:!0,href:!0});var Br=n(ae);us=o(Br,"SPAN",{});var Nr=n(us);h(De.$$.fragment,Nr),Nr.forEach(t),Br.forEach(t),Xo=c(ei),ms=o(ei,"SPAN",{});var Sr=n(ms);Co=r(Sr,"Better checkpoints"),Sr.forEach(t),ei.forEach(t),Jl=c(e),re=o(e,"P",{});var ti=n(re);Do=r(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 Rr=n(ze);zo=r(Rr,"negative prompts"),Rr.forEach(t),Po=r(ti,") to get the best results."),ti.forEach(t),_l=c(e),N=o(e,"P",{});var Nt=n(N);Ao=r(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 Xr=n(Pe);Ho=r(Xr,"Hub"),Xr.forEach(t),xo=r(Nt," and "),Ae=o(Nt,"A",{href:!0,rel:!0});var Cr=n(Ae);Qo=r(Cr,"Diffusers Gallery"),Cr.forEach(t),Yo=r(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 Dr=n(ne);hs=o(Dr,"SPAN",{});var zr=n(hs);h(He.$$.fragment,zr),zr.forEach(t),Dr.forEach(t),Fo=c(si),ds=o(si,"SPAN",{});var Pr=n(ds);qo=r(Pr,"Better pipeline components"),Pr.forEach(t),si.forEach(t),Zl=c(e),pe=o(e,"P",{});var li=n(pe);Lo=r(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 Ar=n(xe);Oo=r(Ar,"autodecoder"),Ar.forEach(t),Ko=r(li," from Stability AI into the pipeline, and generate some images:"),li.forEach(t),Tl=c(e),h(Qe.$$.fragment,e),Gl=c(e),Ye=o(e,"DIV",{class:!0});var Hr=n(Ye);ys=o(Hr,"IMG",{src:!0}),Hr.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 xr=n(fe);bs=o(xr,"SPAN",{});var Qr=n(bs);h(Fe.$$.fragment,Qr),Qr.forEach(t),xr.forEach(t),ea=c(ii),ws=o(ii,"SPAN",{});var Yr=n(ws);ta=r(Yr,"Better prompt engineering"),Yr.forEach(t),ii.forEach(t),jl=c(e),ce=o(e,"P",{});var oi=n(ce);sa=r(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 Fr=n(Ms);la=r(Fr,"prompt engineering"),Fr.forEach(t),ia=r(oi,". Some considerations to keep during prompt engineering are:"),oi.forEach(t),kl=c(e),ue=o(e,"UL",{});var ai=n(ue);gs=o(ai,"LI",{});var qr=n(gs);oa=r(qr,"How is the image or similar images of the one I want to generate stored on the internet?"),qr.forEach(t),aa=c(ai),vs=o(ai,"LI",{});var Lr=n(vs);ra=r(Lr,"What additional detail can I give that steers the model towards the style I want?"),Lr.forEach(t),ai.forEach(t),El=c(e),Ut=o(e,"P",{});var Or=n(Ut);na=r(Or,"With this in mind, let\u2019s improve the prompt to include color and higher quality details:"),Or.forEach(t),Wl=c(e),h(qe.$$.fragment,e),Il=c(e),Zt=o(e,"P",{});var Kr=n(Zt);pa=r(Kr,"Generate a batch of images with the new prompt:"),Kr.forEach(t),Vl=c(e),h(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);fa=r(St,"Pretty impressive! Let\u2019s tweak the second image - corresponding to the "),_s=o(St,"CODE",{});var tn=n(_s);ca=r(tn,"Generator"),tn.forEach(t),ua=r(St," with a seed of "),Us=o(St,"CODE",{});var sn=n(Us);ma=r(sn,"1"),sn.forEach(t),ha=r(St," - a bit more by adding some text about the age of the subject:"),St.forEach(t),Sl=c(e),h(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 ri=n(H);me=o(ri,"A",{id:!0,class:!0,href:!0});var on=n(me);Ts=o(on,"SPAN",{});var an=n(Ts);h(tt.$$.fragment,an),an.forEach(t),on.forEach(t),da=c(ri),Gs=o(ri,"SPAN",{});var rn=n(Gs);ya=r(rn,"Next steps"),rn.forEach(t),ri.forEach(t),Cl=c(e),he=o(e,"P",{});var ni=n(he);ba=r(ni,"In this tutorial, you learned how to optimize a "),Tt=o(ni,"A",{href:!0});var nn=n(Tt);wa=r(nn,"DiffusionPipeline"),nn.forEach(t),Ma=r(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);ga=r(Xt,"Learn how "),Gt=o(Xt,"A",{href:!0});var pn=n(Gt);va=r(pn,"PyTorch 2.0"),pn.forEach(t),Ja=r(Xt," and "),st=o(Xt,"A",{href:!0,rel:!0});var fn=n(st);$s=o(fn,"CODE",{});var cn=n($s);_a=r(cn,"torch.compile"),cn.forEach(t),fn.forEach(t),Ua=r(Xt," can yield 5 - 300% faster inference speed. On an A100 GPU, inference can be up to 50% faster!"),Xt.forEach(t),Za=c(Rt),lt=o(Rt,"LI",{});var pi=n(lt);Ta=r(pi,"If you can\u2019t use PyTorch 2, we recommend you install "),$t=o(pi,"A",{href:!0});var un=n($t);Ga=r(un,"xFormers"),un.forEach(t),$a=r(pi,". Its memory-efficient attention mechanism works great with PyTorch 1.13.1 for faster speed and reduced memory consumption."),pi.forEach(t),ja=c(Rt),it=o(Rt,"LI",{});var fi=n(it);ka=r(fi,"Other optimization techniques, such as model offloading, are covered in "),jt=o(fi,"A",{href:!0});var mn=n(jt);Ea=r(mn,"this guide"),mn.forEach(t),Wa=r(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(g,"class","relative group"),u(nt,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(pt,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(ft,"href","/docs/diffusers/main/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(mt,"href","./using-diffusers/reproducibility"),at(xt.src,Ia="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_1.png")||u(xt,"src",Ia),u(Ge,"class","flex justify-center"),u(dt,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),at(qt.src,Va="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_2.png")||u(qt,"src",Va),u(je,"class","flex justify-center"),u(bt,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(wt,"href","/docs/diffusers/main/en/api/schedulers/pndm#diffusers.PNDMScheduler"),u(Mt,"href","/docs/diffusers/main/en/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler"),u(gt,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin.from_config"),at(Kt.src,Ba="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_3.png")||u(Kt,"src",Ba),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/main/en/api/pipelines/stable_diffusion/image_variation#diffusers.StableDiffusionImageVariationPipeline.enable_attention_slicing"),at(ns.src,Na="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_5.png")||u(ns,"src",Na),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(ae,"id","better-checkpoints"),u(ae,"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(ae,"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"),at(ys.src,Sa="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_6.png")||u(ys,"src",Sa),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"),at(Js.src,Ra="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_7.png")||u(Js,"src",Ra),u(Oe,"class","flex justify-center"),at(Zs.src,Xa="https://huggingface.co/datasets/diffusers/docs-images/resolve/main/stable_diffusion_101/sd_101_8.png")||u(Zs,"src",Xa),u(et,"class","flex justify-center"),u(me,"id","next-steps"),u(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"),u(me,"href","#next-steps"),u(H,"class","relative group"),u(Tt,"href","/docs/diffusers/main/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,g,l),s(g,U),s(U,Z),d(v,Z,null),s(g,J),s(g,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,mi),s(k,hi),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,gi),s(E,vi),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(ge,e,l),p(e,Ns,l),p(e,ct,l),s(ct,$i),p(e,Ss,l),d(ve,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,mt),s(mt,Bi),s(W,Ni),p(e,Ps,l),d(Ze,e,l),p(e,As,l),p(e,ht,l),s(ht,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($,gt),s(gt,oo),s($,ao),p(e,sl,l),d(Ee,e,l),p(e,ll,l),p(e,K,l),s(K,ro),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,al,l),p(e,vt,l),s(vt,fo),p(e,rl,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,mo),s(te,ss),s(ss,ho),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,go),s(V,vo),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,ml,l),p(e,B,l),s(B,Zo),s(B,as),s(as,To),s(B,Go),s(B,Jt),s(Jt,$o),s(B,jo),p(e,hl,l),d(Se,e,l),p(e,dl,l),p(e,le,l),s(le,ko),s(le,rs),s(rs,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,gl,l),p(e,oe,l),s(oe,No),s(oe,cs),s(cs,So),s(oe,Ro),p(e,vl,l),p(e,z,l),s(z,ae),s(ae,us),d(De,us,null),s(z,Xo),s(z,ms),s(ms,Co),p(e,Jl,l),p(e,re,l),s(re,Do),s(re,ze),s(ze,zo),s(re,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,hs),d(He,hs,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,ea),s(A,ws),s(ws,ta),p(e,jl,l),p(e,ce,l),s(ce,sa),s(ce,Ms),s(Ms,la),s(ce,ia),p(e,kl,l),p(e,ue,l),s(ue,gs),s(gs,oa),s(ue,aa),s(ue,vs),s(vs,ra),p(e,El,l),p(e,Ut,l),s(Ut,na),p(e,Wl,l),d(qe,e,l),p(e,Il,l),p(e,Zt,l),s(Zt,pa),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,fa),s(S,_s),s(_s,ca),s(S,ua),s(S,Us),s(Us,ma),s(S,ha),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,me),s(me,Ts),d(tt,Ts,null),s(H,da),s(H,Gs),s(Gs,ya),p(e,Cl,l),p(e,he,l),s(he,ba),s(he,Tt),s(Tt,wa),s(he,Ma),p(e,Dl,l),p(e,R,l),s(R,x),s(x,ga),s(x,Gt),s(Gt,va),s(x,Ja),s(x,st),s(st,$s),s($s,_a),s(x,Ua),s(R,Za),s(R,lt),s(lt,Ta),s(lt,$t),s($t,Ga),s(lt,$a),s(R,ja),s(R,it),s(it,ka),s(it,jt),s(jt,Ea),s(it,Wa),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(v.$$.fragment,e),y(we.$$.fragment,e),y(ge.$$.fragment,e),y(ve.$$.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(v.$$.fragment,e),b(we.$$.fragment,e),b(ge.$$.fragment,e),b(ve.$$.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(g),w(v),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(ge,e),e&&t(Ns),e&&t(ct),e&&t(Ss),w(ve,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(ht),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(al),e&&t(vt),e&&t(rl),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(ml),e&&t(B),e&&t(hl),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(gl),e&&t(oe),e&&t(vl),e&&t(z),w(De),e&&t(Jl),e&&t(re),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(he),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(rt){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}; | |
Xet Storage Details
- Size:
- 53.8 kB
- Xet hash:
- 33dcab4864f4fd548239f34a0c06566e25f84dc4148fc556ecad8c7683906030
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.