import{s as We,n as je,o as Be}from"../chunks/scheduler.8c3d61f6.js";import{S as Fe,i as Ke,g as a,s as n,r as u,A as Re,h as d,f as t,c as o,j as b,u as m,x as p,k as x,y as s,a as c,v as f,d as h,t as g,w as _}from"../chunks/index.da70eac4.js";import{D as G}from"../chunks/Docstring.932cdff3.js";import{H as Ee,E as Ue}from"../chunks/index.ef90fe87.js";function Je(Oe){let v,X,Y,Z,D,ee,C,Le='<code>ScoreSdeVeScheduler</code> is a variance exploding stochastic differential equation (SDE) scheduler. It was introduced in the <a href="https://huggingface.co/papers/2011.13456" rel="nofollow">Score-Based Generative Modeling through Stochastic Differential Equations</a> paper by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, Ben Poole.',te,E,Me="The abstract from the paper is:",se,O,Pe="<em>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.</em>",re,L,ne,i,M,ge,W,ke="<code>ScoreSdeVeScheduler</code> is a variance exploding stochastic differential equation (SDE) scheduler.",_e,j,He=`This model inherits from <a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin">ConfigMixin</a>. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`,ve,$,P,Se,B,Ie=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,be,V,k,xe,F,Ae=`Sets the noise scales used for the diffusion chain (to be run before inference). The sigmas control the weight
of the <code>drift</code> and <code>diffusion</code> components of the sample update.`,$e,T,H,Ve,K,Ne="Sets the continuous timesteps used for the diffusion chain (to be run before inference).",Te,w,I,we,R,qe=`Correct the predicted sample based on the <code>model_output</code> of the network. This is often run repeatedly after
making the prediction for the previous timestep.`,ye,y,A,De,U,ze=`Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion
process from the learned model outputs (most often the predicted noise).`,oe,N,ie,S,q,Ce,J,Ge="Output class for the scheduler’s <code>step</code> function output.",ae,z,de,Q,ce;return D=new Ee({props:{title:"ScoreSdeVeScheduler",local:"scoresdevescheduler",headingTag:"h1"}}),L=new Ee({props:{title:"ScoreSdeVeScheduler",local:"diffusers.ScoreSdeVeScheduler",headingTag:"h2"}}),M=new G({props:{name:"class diffusers.ScoreSdeVeScheduler",anchor:"diffusers.ScoreSdeVeScheduler",parameters:[{name:"num_train_timesteps",val:": int = 2000"},{name:"snr",val:": float = 0.15"},{name:"sigma_min",val:": float = 0.01"},{name:"sigma_max",val:": float = 1348.0"},{name:"sampling_eps",val:": float = 1e-05"},{name:"correct_steps",val:": int = 1"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVeScheduler.num_train_timesteps",description:`<strong>num_train_timesteps</strong> (<code>int</code>, defaults to 1000) &#x2014;
The number of diffusion steps to train the model.`,name:"num_train_timesteps"},{anchor:"diffusers.ScoreSdeVeScheduler.snr",description:`<strong>snr</strong> (<code>float</code>, defaults to 0.15) &#x2014;
A coefficient weighting the step from the <code>model_output</code> sample (from the network) to the random noise.`,name:"snr"},{anchor:"diffusers.ScoreSdeVeScheduler.sigma_min",description:`<strong>sigma_min</strong> (<code>float</code>, defaults to 0.01) &#x2014;
The initial noise scale for the sigma sequence in the sampling procedure. The minimum sigma should mirror
the distribution of the data.`,name:"sigma_min"},{anchor:"diffusers.ScoreSdeVeScheduler.sigma_max",description:`<strong>sigma_max</strong> (<code>float</code>, defaults to 1348.0) &#x2014;
The maximum value used for the range of continuous timesteps passed into the model.`,name:"sigma_max"},{anchor:"diffusers.ScoreSdeVeScheduler.sampling_eps",description:`<strong>sampling_eps</strong> (<code>float</code>, defaults to 1e-5) &#x2014;
The end value of sampling where timesteps decrease progressively from 1 to epsilon.`,name:"sampling_eps"},{anchor:"diffusers.ScoreSdeVeScheduler.correct_steps",description:`<strong>correct_steps</strong> (<code>int</code>, defaults to 1) &#x2014;
The number of correction steps performed on a produced sample.`,name:"correct_steps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_sde_ve.py#L46"}}),P=new G({props:{name:"scale_model_input",anchor:"diffusers.ScoreSdeVeScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVeScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.ScoreSdeVeScheduler.scale_model_input.timestep",description:`<strong>timestep</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The current timestep in the diffusion chain.`,name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_sde_ve.py#L89",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A scaled input sample.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.Tensor</code></p>
`}}),k=new G({props:{name:"set_sigmas",anchor:"diffusers.ScoreSdeVeScheduler.set_sigmas",parameters:[{name:"num_inference_steps",val:": int"},{name:"sigma_min",val:": float = None"},{name:"sigma_max",val:": float = None"},{name:"sampling_eps",val:": float = None"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVeScheduler.set_sigmas.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>) &#x2014;
The number of diffusion steps used when generating samples with a pre-trained model.`,name:"num_inference_steps"},{anchor:"diffusers.ScoreSdeVeScheduler.set_sigmas.sigma_min",description:`<strong>sigma_min</strong> (<code>float</code>, optional) &#x2014;
The initial noise scale value (overrides value given during scheduler instantiation).`,name:"sigma_min"},{anchor:"diffusers.ScoreSdeVeScheduler.set_sigmas.sigma_max",description:`<strong>sigma_max</strong> (<code>float</code>, optional) &#x2014;
The final noise scale value (overrides value given during scheduler instantiation).`,name:"sigma_max"},{anchor:"diffusers.ScoreSdeVeScheduler.set_sigmas.sampling_eps",description:`<strong>sampling_eps</strong> (<code>float</code>, optional) &#x2014;
The final timestep value (overrides value given during scheduler instantiation).`,name:"sampling_eps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_sde_ve.py#L125"}}),H=new G({props:{name:"set_timesteps",anchor:"diffusers.ScoreSdeVeScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"sampling_eps",val:": float = None"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVeScheduler.set_timesteps.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>) &#x2014;
The number of diffusion steps used when generating samples with a pre-trained model.`,name:"num_inference_steps"},{anchor:"diffusers.ScoreSdeVeScheduler.set_timesteps.sampling_eps",description:`<strong>sampling_eps</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The final timestep value (overrides value given during scheduler instantiation).`,name:"sampling_eps"},{anchor:"diffusers.ScoreSdeVeScheduler.set_timesteps.device",description:`<strong>device</strong> (<code>str</code> or <code>torch.device</code>, <em>optional</em>) &#x2014;
The device to which the timesteps should be moved to. If <code>None</code>, the timesteps are not moved.`,name:"device"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_sde_ve.py#L106"}}),I=new G({props:{name:"step_correct",anchor:"diffusers.ScoreSdeVeScheduler.step_correct",parameters:[{name:"model_output",val:": Tensor"},{name:"sample",val:": Tensor"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVeScheduler.step_correct.model_output",description:`<strong>model_output</strong> (<code>torch.Tensor</code>) &#x2014;
The direct output from learned diffusion model.`,name:"model_output"},{anchor:"diffusers.ScoreSdeVeScheduler.step_correct.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
A current instance of a sample created by the diffusion process.`,name:"sample"},{anchor:"diffusers.ScoreSdeVeScheduler.step_correct.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator.`,name:"generator"},{anchor:"diffusers.ScoreSdeVeScheduler.step_correct.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/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput">SdeVeOutput</a> or <code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_sde_ve.py#L228",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput"
>SdeVeOutput</a> is returned, otherwise a tuple
is returned where the first element is the sample tensor.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/main/en/api/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput"
>SdeVeOutput</a> or <code>tuple</code></p>
`}}),A=new G({props:{name:"step_pred",anchor:"diffusers.ScoreSdeVeScheduler.step_pred",parameters:[{name:"model_output",val:": Tensor"},{name:"timestep",val:": int"},{name:"sample",val:": Tensor"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVeScheduler.step_pred.model_output",description:`<strong>model_output</strong> (<code>torch.Tensor</code>) &#x2014;
The direct output from learned diffusion model.`,name:"model_output"},{anchor:"diffusers.ScoreSdeVeScheduler.step_pred.timestep",description:`<strong>timestep</strong> (<code>int</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.ScoreSdeVeScheduler.step_pred.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code>) &#x2014;
A current instance of a sample created by the diffusion process.`,name:"sample"},{anchor:"diffusers.ScoreSdeVeScheduler.step_pred.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator.`,name:"generator"},{anchor:"diffusers.ScoreSdeVeScheduler.step_pred.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/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput">SdeVeOutput</a> or <code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_sde_ve.py#L160",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput"
>SdeVeOutput</a> is returned, otherwise a tuple
is returned where the first element is the sample tensor.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/main/en/api/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput"
>SdeVeOutput</a> or <code>tuple</code></p>
`}}),N=new Ee({props:{title:"SdeVeOutput",local:"diffusers.schedulers.scheduling_sde_ve.SdeVeOutput",headingTag:"h2"}}),q=new G({props:{name:"class diffusers.schedulers.scheduling_sde_ve.SdeVeOutput",anchor:"diffusers.schedulers.scheduling_sde_ve.SdeVeOutput",parameters:[{name:"prev_sample",val:": Tensor"},{name:"prev_sample_mean",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_sde_ve.SdeVeOutput.prev_sample",description:`<strong>prev_sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
Computed sample <code>(x_{t-1})</code> of previous timestep. <code>prev_sample</code> should be used as next model input in the
denoising loop.`,name:"prev_sample"},{anchor:"diffusers.schedulers.scheduling_sde_ve.SdeVeOutput.prev_sample_mean",description:`<strong>prev_sample_mean</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
Mean averaged <code>prev_sample</code> over previous timesteps.`,name:"prev_sample_mean"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_sde_ve.py#L29"}}),z=new Ue({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/schedulers/score_sde_ve.md"}}),{c(){v=a("meta"),X=n(),Y=a("p"),Z=n(),u(D.$$.fragment),ee=n(),C=a("p"),C.innerHTML=Le,te=n(),E=a("p"),E.textContent=Me,se=n(),O=a("p"),O.innerHTML=Pe,re=n(),u(L.$$.fragment),ne=n(),i=a("div"),u(M.$$.fragment),ge=n(),W=a("p"),W.innerHTML=ke,_e=n(),j=a("p"),j.innerHTML=He,ve=n(),$=a("div"),u(P.$$.fragment),Se=n(),B=a("p"),B.textContent=Ie,be=n(),V=a("div"),u(k.$$.fragment),xe=n(),F=a("p"),F.innerHTML=Ae,$e=n(),T=a("div"),u(H.$$.fragment),Ve=n(),K=a("p"),K.textContent=Ne,Te=n(),w=a("div"),u(I.$$.fragment),we=n(),R=a("p"),R.innerHTML=qe,ye=n(),y=a("div"),u(A.$$.fragment),De=n(),U=a("p"),U.textContent=ze,oe=n(),u(N.$$.fragment),ie=n(),S=a("div"),u(q.$$.fragment),Ce=n(),J=a("p"),J.innerHTML=Ge,ae=n(),u(z.$$.fragment),de=n(),Q=a("p"),this.h()},l(e){const r=Re("svelte-u9bgzb",document.head);v=d(r,"META",{name:!0,content:!0}),r.forEach(t),X=o(e),Y=d(e,"P",{}),b(Y).forEach(t),Z=o(e),m(D.$$.fragment,e),ee=o(e),C=d(e,"P",{"data-svelte-h":!0}),p(C)!=="svelte-avzcwn"&&(C.innerHTML=Le),te=o(e),E=d(e,"P",{"data-svelte-h":!0}),p(E)!=="svelte-1cwsb16"&&(E.textContent=Me),se=o(e),O=d(e,"P",{"data-svelte-h":!0}),p(O)!=="svelte-omf9ly"&&(O.innerHTML=Pe),re=o(e),m(L.$$.fragment,e),ne=o(e),i=d(e,"DIV",{class:!0});var l=b(i);m(M.$$.fragment,l),ge=o(l),W=d(l,"P",{"data-svelte-h":!0}),p(W)!=="svelte-yg0j2l"&&(W.innerHTML=ke),_e=o(l),j=d(l,"P",{"data-svelte-h":!0}),p(j)!=="svelte-linuuh"&&(j.innerHTML=He),ve=o(l),$=d(l,"DIV",{class:!0});var le=b($);m(P.$$.fragment,le),Se=o(le),B=d(le,"P",{"data-svelte-h":!0}),p(B)!=="svelte-1rkfgpx"&&(B.textContent=Ie),le.forEach(t),be=o(l),V=d(l,"DIV",{class:!0});var ue=b(V);m(k.$$.fragment,ue),xe=o(ue),F=d(ue,"P",{"data-svelte-h":!0}),p(F)!=="svelte-gdzf1v"&&(F.innerHTML=Ae),ue.forEach(t),$e=o(l),T=d(l,"DIV",{class:!0});var me=b(T);m(H.$$.fragment,me),Ve=o(me),K=d(me,"P",{"data-svelte-h":!0}),p(K)!=="svelte-8cg672"&&(K.textContent=Ne),me.forEach(t),Te=o(l),w=d(l,"DIV",{class:!0});var pe=b(w);m(I.$$.fragment,pe),we=o(pe),R=d(pe,"P",{"data-svelte-h":!0}),p(R)!=="svelte-17m1bpv"&&(R.innerHTML=qe),pe.forEach(t),ye=o(l),y=d(l,"DIV",{class:!0});var fe=b(y);m(A.$$.fragment,fe),De=o(fe),U=d(fe,"P",{"data-svelte-h":!0}),p(U)!=="svelte-hi84tp"&&(U.textContent=ze),fe.forEach(t),l.forEach(t),oe=o(e),m(N.$$.fragment,e),ie=o(e),S=d(e,"DIV",{class:!0});var he=b(S);m(q.$$.fragment,he),Ce=o(he),J=d(he,"P",{"data-svelte-h":!0}),p(J)!=="svelte-id9kic"&&(J.innerHTML=Ge),he.forEach(t),ae=o(e),m(z.$$.fragment,e),de=o(e),Q=d(e,"P",{}),b(Q).forEach(t),this.h()},h(){x(v,"name","hf:doc:metadata"),x(v,"content",Ye),x($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(S,"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,r){s(document.head,v),c(e,X,r),c(e,Y,r),c(e,Z,r),f(D,e,r),c(e,ee,r),c(e,C,r),c(e,te,r),c(e,E,r),c(e,se,r),c(e,O,r),c(e,re,r),f(L,e,r),c(e,ne,r),c(e,i,r),f(M,i,null),s(i,ge),s(i,W),s(i,_e),s(i,j),s(i,ve),s(i,$),f(P,$,null),s($,Se),s($,B),s(i,be),s(i,V),f(k,V,null),s(V,xe),s(V,F),s(i,$e),s(i,T),f(H,T,null),s(T,Ve),s(T,K),s(i,Te),s(i,w),f(I,w,null),s(w,we),s(w,R),s(i,ye),s(i,y),f(A,y,null),s(y,De),s(y,U),c(e,oe,r),f(N,e,r),c(e,ie,r),c(e,S,r),f(q,S,null),s(S,Ce),s(S,J),c(e,ae,r),f(z,e,r),c(e,de,r),c(e,Q,r),ce=!0},p:je,i(e){ce||(h(D.$$.fragment,e),h(L.$$.fragment,e),h(M.$$.fragment,e),h(P.$$.fragment,e),h(k.$$.fragment,e),h(H.$$.fragment,e),h(I.$$.fragment,e),h(A.$$.fragment,e),h(N.$$.fragment,e),h(q.$$.fragment,e),h(z.$$.fragment,e),ce=!0)},o(e){g(D.$$.fragment,e),g(L.$$.fragment,e),g(M.$$.fragment,e),g(P.$$.fragment,e),g(k.$$.fragment,e),g(H.$$.fragment,e),g(I.$$.fragment,e),g(A.$$.fragment,e),g(N.$$.fragment,e),g(q.$$.fragment,e),g(z.$$.fragment,e),ce=!1},d(e){e&&(t(X),t(Y),t(Z),t(ee),t(C),t(te),t(E),t(se),t(O),t(re),t(ne),t(i),t(oe),t(ie),t(S),t(ae),t(de),t(Q)),t(v),_(D,e),_(L,e),_(M),_(P),_(k),_(H),_(I),_(A),_(N,e),_(q),_(z,e)}}}const Ye='{"title":"ScoreSdeVeScheduler","local":"scoresdevescheduler","sections":[{"title":"ScoreSdeVeScheduler","local":"diffusers.ScoreSdeVeScheduler","sections":[],"depth":2},{"title":"SdeVeOutput","local":"diffusers.schedulers.scheduling_sde_ve.SdeVeOutput","sections":[],"depth":2}],"depth":1}';function Qe(Oe){return Be(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class st extends Fe{constructor(v){super(),Ke(this,v,Qe,Je,We,{})}}export{st as component};
