import{S as Ze,i as et,s as tt,e as a,k as c,w as G,t as f,M as rt,c as s,d as t,m as d,a as i,x as C,h,b as o,G as r,g as p,y as U,q as z,o as F,B,v as at}from"../../../chunks/vendor-hf-doc-builder.js";import{T as st}from"../../../chunks/Tip-hf-doc-builder.js";import{D as Oe}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as Ne}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function it(se){let l,T,u,_,b,m,K,P;return{c(){l=a("p"),T=f("Make sure to check out the Schedulers "),u=a("a"),_=f("guide"),b=f(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),m=a("a"),K=f("reuse components across pipelines"),P=f(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(E){l=s(E,"P",{});var g=i(l);T=h(g,"Make sure to check out the Schedulers "),u=s(g,"A",{href:!0});var y=i(u);_=h(y,"guide"),y.forEach(t),b=h(g," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),m=s(g,"A",{href:!0});var $=i(m);K=h($,"reuse components across pipelines"),$.forEach(t),P=h(g," section to learn how to efficiently load the same components into multiple pipelines."),g.forEach(t),this.h()},h(){o(u,"href","/using-diffusers/schedulers"),o(m,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(E,g){p(E,l,g),r(l,T),r(l,u),r(u,_),r(l,b),r(l,m),r(m,K),r(l,P)},d(E){E&&t(l)}}}function nt(se){let l,T,u,_,b,m,K,P,E,g,y,$,ge,_e,ie,H,ve,ne,R,j,ye,oe,V,le,k,S,Q,D,$e,X,we,pe,v,O,be,Y,Pe,Ee,w,N,ke,Z,Ie,xe,ee,Te,ce,I,A,te,L,Ve,re,Se,de,x,M,Ae,ae,Ke,ue;return m=new Ne({}),V=new st({props:{$$slots:{default:[it]},$$scope:{ctx:se}}}),D=new Ne({}),O=new Oe({props:{name:"class diffusers.KarrasVePipeline",anchor:"diffusers.KarrasVePipeline",parameters:[{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": KarrasVeScheduler"}],parametersDescription:[{anchor:"diffusers.KarrasVePipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.20.0/en/api/models/unet2d#diffusers.UNet2DModel">UNet2DModel</a>) &#x2014;
A <code>UNet2DModel</code> to denoise the encoded image.`,name:"unet"},{anchor:"diffusers.KarrasVePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.20.0/en/api/schedulers/stochastic_karras_ve#diffusers.KarrasVeScheduler">KarrasVeScheduler</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.20.0/src/diffusers/pipelines/stochastic_karras_ve/pipeline_stochastic_karras_ve.py#L25"}}),N=new Oe({props:{name:"__call__",anchor:"diffusers.KarrasVePipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"num_inference_steps",val:": int = 50"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.KarrasVePipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate.`,name:"batch_size"},{anchor:"diffusers.KarrasVePipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.KarrasVePipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.KarrasVePipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.KarrasVePipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/v0.20.0/en/api/pipelines/ddim#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.20.0/src/diffusers/pipelines/stochastic_karras_ve/pipeline_stochastic_karras_ve.py#L44",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.20.0/en/api/pipelines/ddim#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated images.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.20.0/en/api/pipelines/ddim#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),L=new Ne({}),M=new Oe({props:{name:"class diffusers.ImagePipelineOutput",anchor:"diffusers.ImagePipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"}],parametersDescription:[{anchor:"diffusers.ImagePipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"}],source:"https://github.com/huggingface/diffusers/blob/v0.20.0/src/diffusers/pipelines/pipeline_utils.py#L112"}}),{c(){l=a("meta"),T=c(),u=a("h1"),_=a("a"),b=a("span"),G(m.$$.fragment),K=c(),P=a("span"),E=f("Stochastic Karras VE"),g=c(),y=a("p"),$=a("a"),ge=f("Elucidating the Design Space of Diffusion-Based Generative Models"),_e=f(" is by Tero Karras, Miika Aittala, Timo Aila and Samuli Laine. This pipeline implements the stochastic sampling tailored to variance expanding (VE) models."),ie=c(),H=a("p"),ve=f("The abstract from the paper:"),ne=c(),R=a("p"),j=a("em"),ye=f("We argue that the theory and practice of diffusion-based generative models are currently unnecessarily convoluted and seek to remedy the situation by presenting a design space that clearly separates the concrete design choices. This lets us identify several changes to both the sampling and training processes, as well as preconditioning of the score networks. Together, our improvements yield new state-of-the-art FID of 1.79 for CIFAR-10 in a class-conditional setting and 1.97 in an unconditional setting, with much faster sampling (35 network evaluations per image) than prior designs. To further demonstrate their modular nature, we show that our design changes dramatically improve both the efficiency and quality obtainable with pre-trained score networks from previous work, including improving the FID of an existing ImageNet-64 model from 2.07 to near-SOTA 1.55."),oe=c(),G(V.$$.fragment),le=c(),k=a("h2"),S=a("a"),Q=a("span"),G(D.$$.fragment),$e=c(),X=a("span"),we=f("KarrasVePipeline"),pe=c(),v=a("div"),G(O.$$.fragment),be=c(),Y=a("p"),Pe=f("Pipeline for unconditional image generation."),Ee=c(),w=a("div"),G(N.$$.fragment),ke=c(),Z=a("p"),Ie=f("The call function to the pipeline for generation."),xe=c(),ee=a("p"),Te=f("Example:"),ce=c(),I=a("h2"),A=a("a"),te=a("span"),G(L.$$.fragment),Ve=c(),re=a("span"),Se=f("ImagePipelineOutput"),de=c(),x=a("div"),G(M.$$.fragment),Ae=c(),ae=a("p"),Ke=f("Output class for image pipelines."),this.h()},l(e){const n=rt('[data-svelte="svelte-1phssyn"]',document.head);l=s(n,"META",{name:!0,content:!0}),n.forEach(t),T=d(e),u=s(e,"H1",{class:!0});var q=i(u);_=s(q,"A",{id:!0,class:!0,href:!0});var Le=i(_);b=s(Le,"SPAN",{});var Me=i(b);C(m.$$.fragment,Me),Me.forEach(t),Le.forEach(t),K=d(q),P=s(q,"SPAN",{});var qe=i(P);E=h(qe,"Stochastic Karras VE"),qe.forEach(t),q.forEach(t),g=d(e),y=s(e,"P",{});var De=i(y);$=s(De,"A",{href:!0,rel:!0});var Ge=i($);ge=h(Ge,"Elucidating the Design Space of Diffusion-Based Generative Models"),Ge.forEach(t),_e=h(De," is by Tero Karras, Miika Aittala, Timo Aila and Samuli Laine. This pipeline implements the stochastic sampling tailored to variance expanding (VE) models."),De.forEach(t),ie=d(e),H=s(e,"P",{});var Ce=i(H);ve=h(Ce,"The abstract from the paper:"),Ce.forEach(t),ne=d(e),R=s(e,"P",{});var Ue=i(R);j=s(Ue,"EM",{});var ze=i(j);ye=h(ze,"We argue that the theory and practice of diffusion-based generative models are currently unnecessarily convoluted and seek to remedy the situation by presenting a design space that clearly separates the concrete design choices. This lets us identify several changes to both the sampling and training processes, as well as preconditioning of the score networks. Together, our improvements yield new state-of-the-art FID of 1.79 for CIFAR-10 in a class-conditional setting and 1.97 in an unconditional setting, with much faster sampling (35 network evaluations per image) than prior designs. To further demonstrate their modular nature, we show that our design changes dramatically improve both the efficiency and quality obtainable with pre-trained score networks from previous work, including improving the FID of an existing ImageNet-64 model from 2.07 to near-SOTA 1.55."),ze.forEach(t),Ue.forEach(t),oe=d(e),C(V.$$.fragment,e),le=d(e),k=s(e,"H2",{class:!0});var fe=i(k);S=s(fe,"A",{id:!0,class:!0,href:!0});var Fe=i(S);Q=s(Fe,"SPAN",{});var Be=i(Q);C(D.$$.fragment,Be),Be.forEach(t),Fe.forEach(t),$e=d(fe),X=s(fe,"SPAN",{});var He=i(X);we=h(He,"KarrasVePipeline"),He.forEach(t),fe.forEach(t),pe=d(e),v=s(e,"DIV",{class:!0});var W=i(v);C(O.$$.fragment,W),be=d(W),Y=s(W,"P",{});var Re=i(Y);Pe=h(Re,"Pipeline for unconditional image generation."),Re.forEach(t),Ee=d(W),w=s(W,"DIV",{class:!0});var J=i(w);C(N.$$.fragment,J),ke=d(J),Z=s(J,"P",{});var We=i(Z);Ie=h(We,"The call function to the pipeline for generation."),We.forEach(t),xe=d(J),ee=s(J,"P",{});var Je=i(ee);Te=h(Je,"Example:"),Je.forEach(t),J.forEach(t),W.forEach(t),ce=d(e),I=s(e,"H2",{class:!0});var he=i(I);A=s(he,"A",{id:!0,class:!0,href:!0});var je=i(A);te=s(je,"SPAN",{});var Qe=i(te);C(L.$$.fragment,Qe),Qe.forEach(t),je.forEach(t),Ve=d(he),re=s(he,"SPAN",{});var Xe=i(re);Se=h(Xe,"ImagePipelineOutput"),Xe.forEach(t),he.forEach(t),de=d(e),x=s(e,"DIV",{class:!0});var me=i(x);C(M.$$.fragment,me),Ae=d(me),ae=s(me,"P",{});var Ye=i(ae);Ke=h(Ye,"Output class for image pipelines."),Ye.forEach(t),me.forEach(t),this.h()},h(){o(l,"name","hf:doc:metadata"),o(l,"content",JSON.stringify(ot)),o(_,"id","stochastic-karras-ve"),o(_,"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"),o(_,"href","#stochastic-karras-ve"),o(u,"class","relative group"),o($,"href","https://huggingface.co/papers/2206.00364"),o($,"rel","nofollow"),o(S,"id","diffusers.KarrasVePipeline"),o(S,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),o(S,"href","#diffusers.KarrasVePipeline"),o(k,"class","relative group"),o(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),o(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),o(A,"id","diffusers.ImagePipelineOutput"),o(A,"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"),o(A,"href","#diffusers.ImagePipelineOutput"),o(I,"class","relative group"),o(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,n){r(document.head,l),p(e,T,n),p(e,u,n),r(u,_),r(_,b),U(m,b,null),r(u,K),r(u,P),r(P,E),p(e,g,n),p(e,y,n),r(y,$),r($,ge),r(y,_e),p(e,ie,n),p(e,H,n),r(H,ve),p(e,ne,n),p(e,R,n),r(R,j),r(j,ye),p(e,oe,n),U(V,e,n),p(e,le,n),p(e,k,n),r(k,S),r(S,Q),U(D,Q,null),r(k,$e),r(k,X),r(X,we),p(e,pe,n),p(e,v,n),U(O,v,null),r(v,be),r(v,Y),r(Y,Pe),r(v,Ee),r(v,w),U(N,w,null),r(w,ke),r(w,Z),r(Z,Ie),r(w,xe),r(w,ee),r(ee,Te),p(e,ce,n),p(e,I,n),r(I,A),r(A,te),U(L,te,null),r(I,Ve),r(I,re),r(re,Se),p(e,de,n),p(e,x,n),U(M,x,null),r(x,Ae),r(x,ae),r(ae,Ke),ue=!0},p(e,[n]){const q={};n&2&&(q.$$scope={dirty:n,ctx:e}),V.$set(q)},i(e){ue||(z(m.$$.fragment,e),z(V.$$.fragment,e),z(D.$$.fragment,e),z(O.$$.fragment,e),z(N.$$.fragment,e),z(L.$$.fragment,e),z(M.$$.fragment,e),ue=!0)},o(e){F(m.$$.fragment,e),F(V.$$.fragment,e),F(D.$$.fragment,e),F(O.$$.fragment,e),F(N.$$.fragment,e),F(L.$$.fragment,e),F(M.$$.fragment,e),ue=!1},d(e){t(l),e&&t(T),e&&t(u),B(m),e&&t(g),e&&t(y),e&&t(ie),e&&t(H),e&&t(ne),e&&t(R),e&&t(oe),B(V,e),e&&t(le),e&&t(k),B(D),e&&t(pe),e&&t(v),B(O),B(N),e&&t(ce),e&&t(I),B(L),e&&t(de),e&&t(x),B(M)}}}const ot={local:"stochastic-karras-ve",sections:[{local:"diffusers.KarrasVePipeline",title:"KarrasVePipeline"},{local:"diffusers.ImagePipelineOutput",title:"ImagePipelineOutput"}],title:"Stochastic Karras VE"};function lt(se){return at(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ft extends Ze{constructor(l){super();et(this,l,lt,nt,tt,{})}}export{ft as default,ot as metadata};
