import{s as Ge,n as je,o as Be}from"../chunks/scheduler.8c3d61f6.js";import{S as Fe,i as Ke,g as d,s as n,r as u,A as Re,h as a,f as t,c as o,j as b,u as p,x as m,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 W}from"../chunks/Docstring.ee4b6913.js";import{H as Ee,E as Ue}from"../chunks/EditOnGithub.1e64e623.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,G,ke="<code>ScoreSdeVeScheduler</code> is a variance exploding stochastic differential equation (SDE) scheduler.",_e,j,He=`This model inherits from <a href="/docs/diffusers/pr_7873/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/pr_7873/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,We="Output class for the scheduler’s <code>step</code> function output.",de,z,ae,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 W({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/vr_7873/src/diffusers/schedulers/scheduling_sde_ve.py#L46"}}),P=new W({props:{name:"scale_model_input",anchor:"diffusers.ScoreSdeVeScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": Optional = 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/vr_7873/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 W({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/vr_7873/src/diffusers/schedulers/scheduling_sde_ve.py#L125"}}),H=new W({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:": Union = 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/vr_7873/src/diffusers/schedulers/scheduling_sde_ve.py#L106"}}),I=new W({props:{name:"step_correct",anchor:"diffusers.ScoreSdeVeScheduler.step_correct",parameters:[{name:"model_output",val:": Tensor"},{name:"sample",val:": Tensor"},{name:"generator",val:": Optional = 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/pr_7873/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/vr_7873/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/pr_7873/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/pr_7873/en/api/schedulers/score_sde_ve#diffusers.schedulers.scheduling_sde_ve.SdeVeOutput"
>SdeVeOutput</a> or <code>tuple</code></p>
`}}),A=new W({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:": Optional = 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/pr_7873/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/vr_7873/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/pr_7873/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/pr_7873/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 W({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/vr_7873/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=d("meta"),X=n(),Y=d("p"),Z=n(),u(D.$$.fragment),ee=n(),C=d("p"),C.innerHTML=Le,te=n(),E=d("p"),E.textContent=Me,se=n(),O=d("p"),O.innerHTML=Pe,re=n(),u(L.$$.fragment),ne=n(),i=d("div"),u(M.$$.fragment),ge=n(),G=d("p"),G.innerHTML=ke,_e=n(),j=d("p"),j.innerHTML=He,ve=n(),$=d("div"),u(P.$$.fragment),Se=n(),B=d("p"),B.textContent=Ie,be=n(),V=d("div"),u(k.$$.fragment),xe=n(),F=d("p"),F.innerHTML=Ae,$e=n(),T=d("div"),u(H.$$.fragment),Ve=n(),K=d("p"),K.textContent=Ne,Te=n(),w=d("div"),u(I.$$.fragment),we=n(),R=d("p"),R.innerHTML=qe,ye=n(),y=d("div"),u(A.$$.fragment),De=n(),U=d("p"),U.textContent=ze,oe=n(),u(N.$$.fragment),ie=n(),S=d("div"),u(q.$$.fragment),Ce=n(),J=d("p"),J.innerHTML=We,de=n(),u(z.$$.fragment),ae=n(),Q=d("p"),this.h()},l(e){const r=Re("svelte-u9bgzb",document.head);v=a(r,"META",{name:!0,content:!0}),r.forEach(t),X=o(e),Y=a(e,"P",{}),b(Y).forEach(t),Z=o(e),p(D.$$.fragment,e),ee=o(e),C=a(e,"P",{"data-svelte-h":!0}),m(C)!=="svelte-avzcwn"&&(C.innerHTML=Le),te=o(e),E=a(e,"P",{"data-svelte-h":!0}),m(E)!=="svelte-1cwsb16"&&(E.textContent=Me),se=o(e),O=a(e,"P",{"data-svelte-h":!0}),m(O)!=="svelte-omf9ly"&&(O.innerHTML=Pe),re=o(e),p(L.$$.fragment,e),ne=o(e),i=a(e,"DIV",{class:!0});var l=b(i);p(M.$$.fragment,l),ge=o(l),G=a(l,"P",{"data-svelte-h":!0}),m(G)!=="svelte-yg0j2l"&&(G.innerHTML=ke),_e=o(l),j=a(l,"P",{"data-svelte-h":!0}),m(j)!=="svelte-ig84y1"&&(j.innerHTML=He),ve=o(l),$=a(l,"DIV",{class:!0});var le=b($);p(P.$$.fragment,le),Se=o(le),B=a(le,"P",{"data-svelte-h":!0}),m(B)!=="svelte-1rkfgpx"&&(B.textContent=Ie),le.forEach(t),be=o(l),V=a(l,"DIV",{class:!0});var ue=b(V);p(k.$$.fragment,ue),xe=o(ue),F=a(ue,"P",{"data-svelte-h":!0}),m(F)!=="svelte-gdzf1v"&&(F.innerHTML=Ae),ue.forEach(t),$e=o(l),T=a(l,"DIV",{class:!0});var pe=b(T);p(H.$$.fragment,pe),Ve=o(pe),K=a(pe,"P",{"data-svelte-h":!0}),m(K)!=="svelte-8cg672"&&(K.textContent=Ne),pe.forEach(t),Te=o(l),w=a(l,"DIV",{class:!0});var me=b(w);p(I.$$.fragment,me),we=o(me),R=a(me,"P",{"data-svelte-h":!0}),m(R)!=="svelte-17m1bpv"&&(R.innerHTML=qe),me.forEach(t),ye=o(l),y=a(l,"DIV",{class:!0});var fe=b(y);p(A.$$.fragment,fe),De=o(fe),U=a(fe,"P",{"data-svelte-h":!0}),m(U)!=="svelte-hi84tp"&&(U.textContent=ze),fe.forEach(t),l.forEach(t),oe=o(e),p(N.$$.fragment,e),ie=o(e),S=a(e,"DIV",{class:!0});var he=b(S);p(q.$$.fragment,he),Ce=o(he),J=a(he,"P",{"data-svelte-h":!0}),m(J)!=="svelte-id9kic"&&(J.innerHTML=We),he.forEach(t),de=o(e),p(z.$$.fragment,e),ae=o(e),Q=a(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,G),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,de,r),f(z,e,r),c(e,ae,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(de),t(ae),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,Ge,{})}}export{st as component};
