import{S as Mt,i as Bt,s as Gt,e as r,k as d,w as R,t as p,M as Lt,c as o,d as t,m as c,a,x as F,h,b as n,G as i,g as l,y as K,L as zt,q as J,o as Y,B as j,v as Ht}from"../../../chunks/vendor-hf-doc-builder.js";import{D as qt}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as Ae}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Ut(st){let f,he,u,S,Q,k,Ie,X,Ce,fe,m,y,Z,x,Ne,ee,Oe,ue,T,V,qe,Me,me,M,Be,ve,B,Ge,ge,E,Le,A,ze,He,_e,G,Ue,be,v,P,te,I,We,ie,Re,we,$,re,g,oe,Fe,Ke,ae,Je,Ye,L,je,Qe,ne,_,se,C,Xe,Ze,le,de,et,tt,z,it,Se,b,D,ce,N,rt,pe,ot,ye,w,O,at,H,q,Ee;return k=new Ae({}),x=new Ae({}),I=new Ae({}),N=new Ae({}),O=new qt({props:{name:"class diffusers.ScoreSdeVePipeline",anchor:"diffusers.ScoreSdeVePipeline",parameters:[{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": DiffusionPipeline"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVePipeline.This",description:'<strong>This</strong> model inherits from <a href="/docs/diffusers/v0.11.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods the &#x2014;',name:"This"},{anchor:"diffusers.ScoreSdeVePipeline.library",description:`<strong>library</strong> implements for all the pipelines (such as downloading or saving, running on a particular device, etc.) &#x2014;
unet (<a href="/docs/diffusers/v0.11.0/en/api/models#diffusers.UNet2DModel">UNet2DModel</a>): U-Net architecture to denoise the encoded image. scheduler (<a href="/docs/diffusers/v0.11.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>):
The <a href="/docs/diffusers/v0.11.0/en/api/schedulers/score_sde_ve#diffusers.ScoreSdeVeScheduler">ScoreSdeVeScheduler</a> scheduler to be used in combination with <code>unet</code> to denoise the encoded image.`,name:"library"}],source:"https://github.com/huggingface/diffusers/blob/v0.11.0/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py#L24"}}),q=new qt({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>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.ScoreSdeVePipeline.__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 generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.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/v0.11.0/en/api/diffusion_pipeline#diffusers.pipeline_utils.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.11.0/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py#L39",returnDescription:`
<p><code>~pipelines.utils.ImagePipelineOutput</code> if
<code>return_dict</code> is True, otherwise a \`tuple. When returning a tuple, the first element is a list with the
generated images.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.11.0/en/api/diffusion_pipeline#diffusers.pipeline_utils.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),{c(){f=r("meta"),he=d(),u=r("h1"),S=r("a"),Q=r("span"),R(k.$$.fragment),Ie=d(),X=r("span"),Ce=p("Score SDE VE"),fe=d(),m=r("h2"),y=r("a"),Z=r("span"),R(x.$$.fragment),Ne=d(),ee=r("span"),Oe=p("Overview"),ue=d(),T=r("p"),V=r("a"),qe=p("Score-Based Generative Modeling through Stochastic Differential Equations"),Me=p(" (Score SDE) by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon and Ben Poole."),me=d(),M=r("p"),Be=p("The abstract of the paper is the following:"),ve=d(),B=r("p"),Ge=p("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."),ge=d(),E=r("p"),Le=p("The original codebase can be found "),A=r("a"),ze=p("here"),He=p("."),_e=d(),G=r("p"),Ue=p("This pipeline implements the Variance Expanding (VE) variant of the method."),be=d(),v=r("h2"),P=r("a"),te=r("span"),R(I.$$.fragment),We=d(),ie=r("span"),Re=p("Available Pipelines:"),we=d(),$=r("table"),re=r("thead"),g=r("tr"),oe=r("th"),Fe=p("Pipeline"),Ke=d(),ae=r("th"),Je=p("Tasks"),Ye=d(),L=r("th"),je=p("Colab"),Qe=d(),ne=r("tbody"),_=r("tr"),se=r("td"),C=r("a"),Xe=p("pipeline_score_sde_ve.py"),Ze=d(),le=r("td"),de=r("em"),et=p("Unconditional Image Generation"),tt=d(),z=r("td"),it=p("-"),Se=d(),b=r("h2"),D=r("a"),ce=r("span"),R(N.$$.fragment),rt=d(),pe=r("span"),ot=p("ScoreSdeVePipeline"),ye=d(),w=r("div"),R(O.$$.fragment),at=d(),H=r("div"),R(q.$$.fragment),this.h()},l(e){const s=Lt('[data-svelte="svelte-1phssyn"]',document.head);f=o(s,"META",{name:!0,content:!0}),s.forEach(t),he=c(e),u=o(e,"H1",{class:!0});var Pe=a(u);S=o(Pe,"A",{id:!0,class:!0,href:!0});var lt=a(S);Q=o(lt,"SPAN",{});var dt=a(Q);F(k.$$.fragment,dt),dt.forEach(t),lt.forEach(t),Ie=c(Pe),X=o(Pe,"SPAN",{});var ct=a(X);Ce=h(ct,"Score SDE VE"),ct.forEach(t),Pe.forEach(t),fe=c(e),m=o(e,"H2",{class:!0});var $e=a(m);y=o($e,"A",{id:!0,class:!0,href:!0});var pt=a(y);Z=o(pt,"SPAN",{});var ht=a(Z);F(x.$$.fragment,ht),ht.forEach(t),pt.forEach(t),Ne=c($e),ee=o($e,"SPAN",{});var ft=a(ee);Oe=h(ft,"Overview"),ft.forEach(t),$e.forEach(t),ue=c(e),T=o(e,"P",{});var nt=a(T);V=o(nt,"A",{href:!0,rel:!0});var ut=a(V);qe=h(ut,"Score-Based Generative Modeling through Stochastic Differential Equations"),ut.forEach(t),Me=h(nt," (Score SDE) by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon and Ben Poole."),nt.forEach(t),me=c(e),M=o(e,"P",{});var mt=a(M);Be=h(mt,"The abstract of the paper is the following:"),mt.forEach(t),ve=c(e),B=o(e,"P",{});var vt=a(B);Ge=h(vt,"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."),vt.forEach(t),ge=c(e),E=o(e,"P",{});var De=a(E);Le=h(De,"The original codebase can be found "),A=o(De,"A",{href:!0,rel:!0});var gt=a(A);ze=h(gt,"here"),gt.forEach(t),He=h(De,"."),De.forEach(t),_e=c(e),G=o(e,"P",{});var _t=a(G);Ue=h(_t,"This pipeline implements the Variance Expanding (VE) variant of the method."),_t.forEach(t),be=c(e),v=o(e,"H2",{class:!0});var ke=a(v);P=o(ke,"A",{id:!0,class:!0,href:!0});var bt=a(P);te=o(bt,"SPAN",{});var wt=a(te);F(I.$$.fragment,wt),wt.forEach(t),bt.forEach(t),We=c(ke),ie=o(ke,"SPAN",{});var St=a(ie);Re=h(St,"Available Pipelines:"),St.forEach(t),ke.forEach(t),we=c(e),$=o(e,"TABLE",{});var xe=a($);re=o(xe,"THEAD",{});var yt=a(re);g=o(yt,"TR",{});var U=a(g);oe=o(U,"TH",{});var Et=a(oe);Fe=h(Et,"Pipeline"),Et.forEach(t),Ke=c(U),ae=o(U,"TH",{});var Pt=a(ae);Je=h(Pt,"Tasks"),Pt.forEach(t),Ye=c(U),L=o(U,"TH",{align:!0});var $t=a(L);je=h($t,"Colab"),$t.forEach(t),U.forEach(t),yt.forEach(t),Qe=c(xe),ne=o(xe,"TBODY",{});var Dt=a(ne);_=o(Dt,"TR",{});var W=a(_);se=o(W,"TD",{});var kt=a(se);C=o(kt,"A",{href:!0,rel:!0});var xt=a(C);Xe=h(xt,"pipeline_score_sde_ve.py"),xt.forEach(t),kt.forEach(t),Ze=c(W),le=o(W,"TD",{});var Tt=a(le);de=o(Tt,"EM",{});var Vt=a(de);et=h(Vt,"Unconditional Image Generation"),Vt.forEach(t),Tt.forEach(t),tt=c(W),z=o(W,"TD",{align:!0});var At=a(z);it=h(At,"-"),At.forEach(t),W.forEach(t),Dt.forEach(t),xe.forEach(t),Se=c(e),b=o(e,"H2",{class:!0});var Te=a(b);D=o(Te,"A",{id:!0,class:!0,href:!0});var It=a(D);ce=o(It,"SPAN",{});var Ct=a(ce);F(N.$$.fragment,Ct),Ct.forEach(t),It.forEach(t),rt=c(Te),pe=o(Te,"SPAN",{});var Nt=a(pe);ot=h(Nt,"ScoreSdeVePipeline"),Nt.forEach(t),Te.forEach(t),ye=c(e),w=o(e,"DIV",{class:!0});var Ve=a(w);F(O.$$.fragment,Ve),at=c(Ve),H=o(Ve,"DIV",{class:!0});var Ot=a(H);F(q.$$.fragment,Ot),Ot.forEach(t),Ve.forEach(t),this.h()},h(){n(f,"name","hf:doc:metadata"),n(f,"content",JSON.stringify(Wt)),n(S,"id","score-sde-ve"),n(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"),n(S,"href","#score-sde-ve"),n(u,"class","relative group"),n(y,"id","overview"),n(y,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(y,"href","#overview"),n(m,"class","relative group"),n(V,"href","https://arxiv.org/abs/2011.13456"),n(V,"rel","nofollow"),n(A,"href","https://github.com/yang-song/score_sde_pytorch"),n(A,"rel","nofollow"),n(P,"id","available-pipelines"),n(P,"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"),n(P,"href","#available-pipelines"),n(v,"class","relative group"),n(L,"align","center"),n(C,"href","https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py"),n(C,"rel","nofollow"),n(z,"align","center"),n(D,"id","diffusers.ScoreSdeVePipeline"),n(D,"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"),n(D,"href","#diffusers.ScoreSdeVePipeline"),n(b,"class","relative group"),n(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),n(w,"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,s){i(document.head,f),l(e,he,s),l(e,u,s),i(u,S),i(S,Q),K(k,Q,null),i(u,Ie),i(u,X),i(X,Ce),l(e,fe,s),l(e,m,s),i(m,y),i(y,Z),K(x,Z,null),i(m,Ne),i(m,ee),i(ee,Oe),l(e,ue,s),l(e,T,s),i(T,V),i(V,qe),i(T,Me),l(e,me,s),l(e,M,s),i(M,Be),l(e,ve,s),l(e,B,s),i(B,Ge),l(e,ge,s),l(e,E,s),i(E,Le),i(E,A),i(A,ze),i(E,He),l(e,_e,s),l(e,G,s),i(G,Ue),l(e,be,s),l(e,v,s),i(v,P),i(P,te),K(I,te,null),i(v,We),i(v,ie),i(ie,Re),l(e,we,s),l(e,$,s),i($,re),i(re,g),i(g,oe),i(oe,Fe),i(g,Ke),i(g,ae),i(ae,Je),i(g,Ye),i(g,L),i(L,je),i($,Qe),i($,ne),i(ne,_),i(_,se),i(se,C),i(C,Xe),i(_,Ze),i(_,le),i(le,de),i(de,et),i(_,tt),i(_,z),i(z,it),l(e,Se,s),l(e,b,s),i(b,D),i(D,ce),K(N,ce,null),i(b,rt),i(b,pe),i(pe,ot),l(e,ye,s),l(e,w,s),K(O,w,null),i(w,at),i(w,H),K(q,H,null),Ee=!0},p:zt,i(e){Ee||(J(k.$$.fragment,e),J(x.$$.fragment,e),J(I.$$.fragment,e),J(N.$$.fragment,e),J(O.$$.fragment,e),J(q.$$.fragment,e),Ee=!0)},o(e){Y(k.$$.fragment,e),Y(x.$$.fragment,e),Y(I.$$.fragment,e),Y(N.$$.fragment,e),Y(O.$$.fragment,e),Y(q.$$.fragment,e),Ee=!1},d(e){t(f),e&&t(he),e&&t(u),j(k),e&&t(fe),e&&t(m),j(x),e&&t(ue),e&&t(T),e&&t(me),e&&t(M),e&&t(ve),e&&t(B),e&&t(ge),e&&t(E),e&&t(_e),e&&t(G),e&&t(be),e&&t(v),j(I),e&&t(we),e&&t($),e&&t(Se),e&&t(b),j(N),e&&t(ye),e&&t(w),j(O),j(q)}}}const Wt={local:"score-sde-ve",sections:[{local:"overview",title:"Overview"},{local:"available-pipelines",title:"Available Pipelines:"},{local:"diffusers.ScoreSdeVePipeline",title:"ScoreSdeVePipeline"}],title:"Score SDE VE"};function Rt(st){return Ht(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Yt extends Mt{constructor(f){super();Bt(this,f,Rt,Ut,Gt,{})}}export{Yt as default,Wt as metadata};
