import{s as ze,n as qe,o as Ge}from"../chunks/scheduler.182ea377.js";import{S as We,i as je,g as a,s as n,r as p,A as Be,h as d,f as t,c as o,j as b,u as m,x as u,k as x,y as s,a as c,v as f,d as h,t as g,w as _}from"../chunks/index.abf12888.js";import{D as z}from"../chunks/Docstring.93f6f462.js";import{H as De}from"../chunks/Heading.16916d63.js";function Ke(Ce){let v,Q,J,X,D,Z,C,Oe='<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.',ee,O,Ee="The abstract from the paper is:",te,E,Le="<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>.",se,L,re,i,M,fe,q,Me="<code>ScoreSdeVeScheduler</code> is a variance exploding stochastic differential equation (SDE) scheduler.",he,G,Pe=`This model inherits from <a href="/docs/diffusers/v0.22.1/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/v0.22.1/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.`,ge,$,P,_e,W,ke=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,ve,V,k,Se,j,Fe=`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.`,be,T,F,xe,B,He="Sets the continuous timesteps used for the diffusion chain (to be run before inference).",$e,w,H,Ve,K,Ie=`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.`,Te,y,I,we,R,Ae=`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).`,ne,A,oe,S,N,ye,U,Ne="Output class for the scheduler’s <code>step</code> function output.",ie,Y,ae;return D=new De({props:{title:"ScoreSdeVeScheduler",local:"scoresdevescheduler",headingTag:"h1"}}),L=new De({props:{title:"ScoreSdeVeScheduler",local:"diffusers.ScoreSdeVeScheduler",headingTag:"h2"}}),M=new z({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/v0.22.1/src/diffusers/schedulers/scheduling_sde_ve.py#L46"}}),P=new z({props:{name:"scale_model_input",anchor:"diffusers.ScoreSdeVeScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVeScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</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/v0.22.1/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.FloatTensor</code></p>
`}}),k=new z({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/v0.22.1/src/diffusers/schedulers/scheduling_sde_ve.py#L125"}}),F=new z({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/v0.22.1/src/diffusers/schedulers/scheduling_sde_ve.py#L106"}}),H=new z({props:{name:"step_correct",anchor:"diffusers.ScoreSdeVeScheduler.step_correct",parameters:[{name:"model_output",val:": FloatTensor"},{name:"sample",val:": FloatTensor"},{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.FloatTensor</code>) &#x2014;
The direct output from learned diffusion model.`,name:"model_output"},{anchor:"diffusers.ScoreSdeVeScheduler.step_correct.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</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/v0.22.1/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/v0.22.1/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/v0.22.1/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/v0.22.1/en/api/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput"
>SdeVeOutput</a> or <code>tuple</code></p>
`}}),I=new z({props:{name:"step_pred",anchor:"diffusers.ScoreSdeVeScheduler.step_pred",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": int"},{name:"sample",val:": FloatTensor"},{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.FloatTensor</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.FloatTensor</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/v0.22.1/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/v0.22.1/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/v0.22.1/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/v0.22.1/en/api/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput"
>SdeVeOutput</a> or <code>tuple</code></p>
`}}),A=new De({props:{title:"SdeVeOutput",local:"diffusers.schedulers.scheduling_sde_ve.SdeVeOutput",headingTag:"h2"}}),N=new z({props:{name:"class diffusers.schedulers.scheduling_sde_ve.SdeVeOutput",anchor:"diffusers.schedulers.scheduling_sde_ve.SdeVeOutput",parameters:[{name:"prev_sample",val:": FloatTensor"},{name:"prev_sample_mean",val:": FloatTensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_sde_ve.SdeVeOutput.prev_sample",description:`<strong>prev_sample</strong> (<code>torch.FloatTensor</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.FloatTensor</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/v0.22.1/src/diffusers/schedulers/scheduling_sde_ve.py#L30"}}),{c(){v=a("meta"),Q=n(),J=a("p"),X=n(),p(D.$$.fragment),Z=n(),C=a("p"),C.innerHTML=Oe,ee=n(),O=a("p"),O.textContent=Ee,te=n(),E=a("p"),E.innerHTML=Le,se=n(),p(L.$$.fragment),re=n(),i=a("div"),p(M.$$.fragment),fe=n(),q=a("p"),q.innerHTML=Me,he=n(),G=a("p"),G.innerHTML=Pe,ge=n(),$=a("div"),p(P.$$.fragment),_e=n(),W=a("p"),W.textContent=ke,ve=n(),V=a("div"),p(k.$$.fragment),Se=n(),j=a("p"),j.innerHTML=Fe,be=n(),T=a("div"),p(F.$$.fragment),xe=n(),B=a("p"),B.textContent=He,$e=n(),w=a("div"),p(H.$$.fragment),Ve=n(),K=a("p"),K.innerHTML=Ie,Te=n(),y=a("div"),p(I.$$.fragment),we=n(),R=a("p"),R.textContent=Ae,ne=n(),p(A.$$.fragment),oe=n(),S=a("div"),p(N.$$.fragment),ye=n(),U=a("p"),U.innerHTML=Ne,ie=n(),Y=a("p"),this.h()},l(e){const r=Be("svelte-u9bgzb",document.head);v=d(r,"META",{name:!0,content:!0}),r.forEach(t),Q=o(e),J=d(e,"P",{}),b(J).forEach(t),X=o(e),m(D.$$.fragment,e),Z=o(e),C=d(e,"P",{"data-svelte-h":!0}),u(C)!=="svelte-avzcwn"&&(C.innerHTML=Oe),ee=o(e),O=d(e,"P",{"data-svelte-h":!0}),u(O)!=="svelte-1cwsb16"&&(O.textContent=Ee),te=o(e),E=d(e,"P",{"data-svelte-h":!0}),u(E)!=="svelte-1m47iew"&&(E.innerHTML=Le),se=o(e),m(L.$$.fragment,e),re=o(e),i=d(e,"DIV",{class:!0});var l=b(i);m(M.$$.fragment,l),fe=o(l),q=d(l,"P",{"data-svelte-h":!0}),u(q)!=="svelte-yg0j2l"&&(q.innerHTML=Me),he=o(l),G=d(l,"P",{"data-svelte-h":!0}),u(G)!=="svelte-12yzxt5"&&(G.innerHTML=Pe),ge=o(l),$=d(l,"DIV",{class:!0});var de=b($);m(P.$$.fragment,de),_e=o(de),W=d(de,"P",{"data-svelte-h":!0}),u(W)!=="svelte-1rkfgpx"&&(W.textContent=ke),de.forEach(t),ve=o(l),V=d(l,"DIV",{class:!0});var ce=b(V);m(k.$$.fragment,ce),Se=o(ce),j=d(ce,"P",{"data-svelte-h":!0}),u(j)!=="svelte-gdzf1v"&&(j.innerHTML=Fe),ce.forEach(t),be=o(l),T=d(l,"DIV",{class:!0});var le=b(T);m(F.$$.fragment,le),xe=o(le),B=d(le,"P",{"data-svelte-h":!0}),u(B)!=="svelte-8cg672"&&(B.textContent=He),le.forEach(t),$e=o(l),w=d(l,"DIV",{class:!0});var ue=b(w);m(H.$$.fragment,ue),Ve=o(ue),K=d(ue,"P",{"data-svelte-h":!0}),u(K)!=="svelte-17m1bpv"&&(K.innerHTML=Ie),ue.forEach(t),Te=o(l),y=d(l,"DIV",{class:!0});var pe=b(y);m(I.$$.fragment,pe),we=o(pe),R=d(pe,"P",{"data-svelte-h":!0}),u(R)!=="svelte-hi84tp"&&(R.textContent=Ae),pe.forEach(t),l.forEach(t),ne=o(e),m(A.$$.fragment,e),oe=o(e),S=d(e,"DIV",{class:!0});var me=b(S);m(N.$$.fragment,me),ye=o(me),U=d(me,"P",{"data-svelte-h":!0}),u(U)!=="svelte-id9kic"&&(U.innerHTML=Ne),me.forEach(t),ie=o(e),Y=d(e,"P",{}),b(Y).forEach(t),this.h()},h(){x(v,"name","hf:doc:metadata"),x(v,"content",Re),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,Q,r),c(e,J,r),c(e,X,r),f(D,e,r),c(e,Z,r),c(e,C,r),c(e,ee,r),c(e,O,r),c(e,te,r),c(e,E,r),c(e,se,r),f(L,e,r),c(e,re,r),c(e,i,r),f(M,i,null),s(i,fe),s(i,q),s(i,he),s(i,G),s(i,ge),s(i,$),f(P,$,null),s($,_e),s($,W),s(i,ve),s(i,V),f(k,V,null),s(V,Se),s(V,j),s(i,be),s(i,T),f(F,T,null),s(T,xe),s(T,B),s(i,$e),s(i,w),f(H,w,null),s(w,Ve),s(w,K),s(i,Te),s(i,y),f(I,y,null),s(y,we),s(y,R),c(e,ne,r),f(A,e,r),c(e,oe,r),c(e,S,r),f(N,S,null),s(S,ye),s(S,U),c(e,ie,r),c(e,Y,r),ae=!0},p:qe,i(e){ae||(h(D.$$.fragment,e),h(L.$$.fragment,e),h(M.$$.fragment,e),h(P.$$.fragment,e),h(k.$$.fragment,e),h(F.$$.fragment,e),h(H.$$.fragment,e),h(I.$$.fragment,e),h(A.$$.fragment,e),h(N.$$.fragment,e),ae=!0)},o(e){g(D.$$.fragment,e),g(L.$$.fragment,e),g(M.$$.fragment,e),g(P.$$.fragment,e),g(k.$$.fragment,e),g(F.$$.fragment,e),g(H.$$.fragment,e),g(I.$$.fragment,e),g(A.$$.fragment,e),g(N.$$.fragment,e),ae=!1},d(e){e&&(t(Q),t(J),t(X),t(Z),t(C),t(ee),t(O),t(te),t(E),t(se),t(re),t(i),t(ne),t(oe),t(S),t(ie),t(Y)),t(v),_(D,e),_(L,e),_(M),_(P),_(k),_(F),_(H),_(I),_(A,e),_(N)}}}const Re='{"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 Ue(Ce){return Ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ze extends We{constructor(v){super(),je(this,v,Ue,Ke,ze,{})}}export{Ze as component};
