import{S as pt,i as ft,s as ut,e as r,k as f,w as W,t as l,M as ht,c as o,d as t,m as u,a as n,x as F,h as d,b as s,G as i,g as p,y as K,q as H,o as J,B as R,v as mt}from"../../../chunks/vendor-hf-doc-builder.js";import{T as gt}from"../../../chunks/Tip-hf-doc-builder.js";import{D as Ke}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as He}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function vt(ae){let c,D,h,_,S,m,q,y;return{c(){c=r("p"),D=l("Make sure to check out the Schedulers "),h=r("a"),_=l("guide"),S=l(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),m=r("a"),q=l("reuse components across pipelines"),y=l(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l($){c=o($,"P",{});var g=n(c);D=d(g,"Make sure to check out the Schedulers "),h=o(g,"A",{href:!0});var b=n(h);_=d(b,"guide"),b.forEach(t),S=d(g," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),m=o(g,"A",{href:!0});var w=n(m);q=d(w,"reuse components across pipelines"),w.forEach(t),y=d(g," section to learn how to efficiently load the same components into multiple pipelines."),g.forEach(t),this.h()},h(){s(h,"href","/using-diffusers/schedulers"),s(m,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m($,g){p($,c,g),i(c,D),i(c,h),i(h,_),i(c,S),i(c,m),i(m,q),i(c,y)},d($){$&&t(c)}}}function _t(ae){let c,D,h,_,S,m,q,y,$,g,b,w,ye,$e,se,j,Pe,le,Y,X,Ee,de,I,ke,C,De,Ie,ce,x,pe,P,V,Z,N,xe,ee,Ve,fe,v,L,Ae,te,Oe,Te,M,qe,Q,Ce,Ne,Le,A,z,Me,ie,ze,ue,E,O,re,G,Ge,oe,Be,he,k,B,Ue,ne,We,me;return m=new He({}),x=new gt({props:{$$slots:{default:[vt]},$$scope:{ctx:ae}}}),N=new He({}),L=new Ke({props:{name:"class diffusers.ScoreSdeVePipeline",anchor:"diffusers.ScoreSdeVePipeline",parameters:[{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": ScoreSdeVeScheduler"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVePipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet2d#diffusers.UNet2DModel">UNet2DModel</a>) &#x2014;
A <code>UNet2DModel</code> to denoise the encoded image.`,name:"unet"},{anchor:"diffusers.ScoreSdeVePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/score_sde_ve#diffusers.ScoreSdeVeScheduler">ScoreSdeVeScheduler</a>) &#x2014;
A <code>ScoreSdeVeScheduler</code> to be used in combination with <code>unet</code> to denoise the encoded image.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py#L25"}}),z=new Ke({props:{name:"__call__",anchor:"diffusers.ScoreSdeVePipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"num_inference_steps",val:": int = 2000"},{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.ScoreSdeVePipeline.__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.ScoreSdeVePipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <code>optional</code>) &#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.ScoreSdeVePipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <code>optional</code>, 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.ScoreSdeVePipeline.__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/main/en/api/pipelines/ddim#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py#L45",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/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/main/en/api/pipelines/ddim#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),G=new He({}),B=new Ke({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/main/src/diffusers/pipelines/pipeline_utils.py#L112"}}),{c(){c=r("meta"),D=f(),h=r("h1"),_=r("a"),S=r("span"),W(m.$$.fragment),q=f(),y=r("span"),$=l("Score SDE VE"),g=f(),b=r("p"),w=r("a"),ye=l("Score-Based Generative Modeling through Stochastic Differential Equations"),$e=l(" (Score SDE) is by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon and Ben Poole. This pipeline implements the variance expanding (VE) variant of the stochastic differential equation method."),se=f(),j=r("p"),Pe=l("The abstract from the paper is:"),le=f(),Y=r("p"),X=r("em"),Ee=l("Creating noise from data is easy; creating data from noise is generative modeling. We present a stochastic differential equation (SDE) that smoothly transforms a complex data distribution to a known prior distribution by slowly injecting noise, and a corresponding reverse-time SDE that transforms the prior distribution back into the data distribution by slowly removing the noise. Crucially, the reverse-time SDE depends only on the time-dependent gradient field (\\aka, score) of the perturbed data distribution. By leveraging advances in score-based generative modeling, we can accurately estimate these scores with neural networks, and use numerical SDE solvers to generate samples. We show that this framework encapsulates previous approaches in score-based generative modeling and diffusion probabilistic modeling, allowing for new sampling procedures and new modeling capabilities. In particular, we introduce a predictor-corrector framework to correct errors in the evolution of the discretized reverse-time SDE. We also derive an equivalent neural ODE that samples from the same distribution as the SDE, but additionally enables exact likelihood computation, and improved sampling efficiency. In addition, we provide a new way to solve inverse problems with score-based models, as demonstrated with experiments on class-conditional generation, image inpainting, and colorization. Combined with multiple architectural improvements, we achieve record-breaking performance for unconditional image generation on CIFAR-10 with an Inception score of 9.89 and FID of 2.20, a competitive likelihood of 2.99 bits/dim, and demonstrate high fidelity generation of 1024 x 1024 images for the first time from a score-based generative model."),de=f(),I=r("p"),ke=l("The original codebase can be found at "),C=r("a"),De=l("yang-song/score_sde_pytorch"),Ie=l("."),ce=f(),W(x.$$.fragment),pe=f(),P=r("h2"),V=r("a"),Z=r("span"),W(N.$$.fragment),xe=f(),ee=r("span"),Ve=l("ScoreSdeVePipeline"),fe=f(),v=r("div"),W(L.$$.fragment),Ae=f(),te=r("p"),Oe=l("Pipeline for unconditional image generation."),Te=f(),M=r("p"),qe=l("This model inherits from "),Q=r("a"),Ce=l("DiffusionPipeline"),Ne=l(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Le=f(),A=r("div"),W(z.$$.fragment),Me=f(),ie=r("p"),ze=l("The call function to the pipeline for generation."),ue=f(),E=r("h2"),O=r("a"),re=r("span"),W(G.$$.fragment),Ge=f(),oe=r("span"),Be=l("ImagePipelineOutput"),he=f(),k=r("div"),W(B.$$.fragment),Ue=f(),ne=r("p"),We=l("Output class for image pipelines."),this.h()},l(e){const a=ht('[data-svelte="svelte-1phssyn"]',document.head);c=o(a,"META",{name:!0,content:!0}),a.forEach(t),D=u(e),h=o(e,"H1",{class:!0});var U=n(h);_=o(U,"A",{id:!0,class:!0,href:!0});var Je=n(_);S=o(Je,"SPAN",{});var Re=n(S);F(m.$$.fragment,Re),Re.forEach(t),Je.forEach(t),q=u(U),y=o(U,"SPAN",{});var je=n(y);$=d(je,"Score SDE VE"),je.forEach(t),U.forEach(t),g=u(e),b=o(e,"P",{});var Fe=n(b);w=o(Fe,"A",{href:!0,rel:!0});var Ye=n(w);ye=d(Ye,"Score-Based Generative Modeling through Stochastic Differential Equations"),Ye.forEach(t),$e=d(Fe," (Score SDE) is by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon and Ben Poole. This pipeline implements the variance expanding (VE) variant of the stochastic differential equation method."),Fe.forEach(t),se=u(e),j=o(e,"P",{});var Qe=n(j);Pe=d(Qe,"The abstract from the paper is:"),Qe.forEach(t),le=u(e),Y=o(e,"P",{});var Xe=n(Y);X=o(Xe,"EM",{});var Ze=n(X);Ee=d(Ze,"Creating noise from data is easy; creating data from noise is generative modeling. We present a stochastic differential equation (SDE) that smoothly transforms a complex data distribution to a known prior distribution by slowly injecting noise, and a corresponding reverse-time SDE that transforms the prior distribution back into the data distribution by slowly removing the noise. Crucially, the reverse-time SDE depends only on the time-dependent gradient field (\\aka, score) of the perturbed data distribution. By leveraging advances in score-based generative modeling, we can accurately estimate these scores with neural networks, and use numerical SDE solvers to generate samples. We show that this framework encapsulates previous approaches in score-based generative modeling and diffusion probabilistic modeling, allowing for new sampling procedures and new modeling capabilities. In particular, we introduce a predictor-corrector framework to correct errors in the evolution of the discretized reverse-time SDE. We also derive an equivalent neural ODE that samples from the same distribution as the SDE, but additionally enables exact likelihood computation, and improved sampling efficiency. In addition, we provide a new way to solve inverse problems with score-based models, as demonstrated with experiments on class-conditional generation, image inpainting, and colorization. Combined with multiple architectural improvements, we achieve record-breaking performance for unconditional image generation on CIFAR-10 with an Inception score of 9.89 and FID of 2.20, a competitive likelihood of 2.99 bits/dim, and demonstrate high fidelity generation of 1024 x 1024 images for the first time from a score-based generative model."),Ze.forEach(t),Xe.forEach(t),de=u(e),I=o(e,"P",{});var ge=n(I);ke=d(ge,"The original codebase can be found at "),C=o(ge,"A",{href:!0,rel:!0});var et=n(C);De=d(et,"yang-song/score_sde_pytorch"),et.forEach(t),Ie=d(ge,"."),ge.forEach(t),ce=u(e),F(x.$$.fragment,e),pe=u(e),P=o(e,"H2",{class:!0});var ve=n(P);V=o(ve,"A",{id:!0,class:!0,href:!0});var tt=n(V);Z=o(tt,"SPAN",{});var it=n(Z);F(N.$$.fragment,it),it.forEach(t),tt.forEach(t),xe=u(ve),ee=o(ve,"SPAN",{});var rt=n(ee);Ve=d(rt,"ScoreSdeVePipeline"),rt.forEach(t),ve.forEach(t),fe=u(e),v=o(e,"DIV",{class:!0});var T=n(v);F(L.$$.fragment,T),Ae=u(T),te=o(T,"P",{});var ot=n(te);Oe=d(ot,"Pipeline for unconditional image generation."),ot.forEach(t),Te=u(T),M=o(T,"P",{});var _e=n(M);qe=d(_e,"This model inherits from "),Q=o(_e,"A",{href:!0});var nt=n(Q);Ce=d(nt,"DiffusionPipeline"),nt.forEach(t),Ne=d(_e,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),_e.forEach(t),Le=u(T),A=o(T,"DIV",{class:!0});var be=n(A);F(z.$$.fragment,be),Me=u(be),ie=o(be,"P",{});var at=n(ie);ze=d(at,"The call function to the pipeline for generation."),at.forEach(t),be.forEach(t),T.forEach(t),ue=u(e),E=o(e,"H2",{class:!0});var we=n(E);O=o(we,"A",{id:!0,class:!0,href:!0});var st=n(O);re=o(st,"SPAN",{});var lt=n(re);F(G.$$.fragment,lt),lt.forEach(t),st.forEach(t),Ge=u(we),oe=o(we,"SPAN",{});var dt=n(oe);Be=d(dt,"ImagePipelineOutput"),dt.forEach(t),we.forEach(t),he=u(e),k=o(e,"DIV",{class:!0});var Se=n(k);F(B.$$.fragment,Se),Ue=u(Se),ne=o(Se,"P",{});var ct=n(ne);We=d(ct,"Output class for image pipelines."),ct.forEach(t),Se.forEach(t),this.h()},h(){s(c,"name","hf:doc:metadata"),s(c,"content",JSON.stringify(bt)),s(_,"id","score-sde-ve"),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"),s(_,"href","#score-sde-ve"),s(h,"class","relative group"),s(w,"href","https://huggingface.co/papers/2011.13456"),s(w,"rel","nofollow"),s(C,"href","https://github.com/yang-song/score_sde_pytorch"),s(C,"rel","nofollow"),s(V,"id","diffusers.ScoreSdeVePipeline"),s(V,"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"),s(V,"href","#diffusers.ScoreSdeVePipeline"),s(P,"class","relative group"),s(Q,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),s(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),s(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),s(O,"id","diffusers.ImagePipelineOutput"),s(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"),s(O,"href","#diffusers.ImagePipelineOutput"),s(E,"class","relative group"),s(k,"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,a){i(document.head,c),p(e,D,a),p(e,h,a),i(h,_),i(_,S),K(m,S,null),i(h,q),i(h,y),i(y,$),p(e,g,a),p(e,b,a),i(b,w),i(w,ye),i(b,$e),p(e,se,a),p(e,j,a),i(j,Pe),p(e,le,a),p(e,Y,a),i(Y,X),i(X,Ee),p(e,de,a),p(e,I,a),i(I,ke),i(I,C),i(C,De),i(I,Ie),p(e,ce,a),K(x,e,a),p(e,pe,a),p(e,P,a),i(P,V),i(V,Z),K(N,Z,null),i(P,xe),i(P,ee),i(ee,Ve),p(e,fe,a),p(e,v,a),K(L,v,null),i(v,Ae),i(v,te),i(te,Oe),i(v,Te),i(v,M),i(M,qe),i(M,Q),i(Q,Ce),i(M,Ne),i(v,Le),i(v,A),K(z,A,null),i(A,Me),i(A,ie),i(ie,ze),p(e,ue,a),p(e,E,a),i(E,O),i(O,re),K(G,re,null),i(E,Ge),i(E,oe),i(oe,Be),p(e,he,a),p(e,k,a),K(B,k,null),i(k,Ue),i(k,ne),i(ne,We),me=!0},p(e,[a]){const U={};a&2&&(U.$$scope={dirty:a,ctx:e}),x.$set(U)},i(e){me||(H(m.$$.fragment,e),H(x.$$.fragment,e),H(N.$$.fragment,e),H(L.$$.fragment,e),H(z.$$.fragment,e),H(G.$$.fragment,e),H(B.$$.fragment,e),me=!0)},o(e){J(m.$$.fragment,e),J(x.$$.fragment,e),J(N.$$.fragment,e),J(L.$$.fragment,e),J(z.$$.fragment,e),J(G.$$.fragment,e),J(B.$$.fragment,e),me=!1},d(e){t(c),e&&t(D),e&&t(h),R(m),e&&t(g),e&&t(b),e&&t(se),e&&t(j),e&&t(le),e&&t(Y),e&&t(de),e&&t(I),e&&t(ce),R(x,e),e&&t(pe),e&&t(P),R(N),e&&t(fe),e&&t(v),R(L),R(z),e&&t(ue),e&&t(E),R(G),e&&t(he),e&&t(k),R(B)}}}const bt={local:"score-sde-ve",sections:[{local:"diffusers.ScoreSdeVePipeline",title:"ScoreSdeVePipeline"},{local:"diffusers.ImagePipelineOutput",title:"ImagePipelineOutput"}],title:"Score SDE VE"};function wt(ae){return mt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Et extends pt{constructor(c){super();ft(this,c,wt,_t,ut,{})}}export{Et as default,bt as metadata};
