import{S as Kt,i as It,s as Bt,e as s,k as u,w as G,t as a,M as Gt,c as o,d as r,m as f,a as n,x as U,h as i,b as c,G as e,g as _,y as V,L as Ut,q as H,o as R,B as z,v as Vt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as De}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as pt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Ht(ht){let v,ue,b,S,X,T,xe,Z,$e,fe,E,w,ee,C,ke,te,Ae,pe,g,Te,P,Ce,Pe,q,qe,Fe,he,y,D,re,F,Me,se,Ne,me,d,M,Oe,x,Le,N,Ke,Ie,O,Be,Ge,l,J,Ue,Ve,oe,He,Re,ne,ze,Je,ae,We,Ye,W,je,Qe,Y,Xe,Ze,j,et,tt,rt,$,L,st,K,ot,ie,nt,at,it,k,I,ct,ce,lt,dt,A,B,ut,le,ft,ge;return T=new pt({}),C=new pt({}),F=new pt({}),M=new De({props:{name:"class diffusers.EulerDiscreteScheduler",anchor:"diffusers.EulerDiscreteScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.0001"},{name:"beta_end",val:": float = 0.02"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"interpolation_type",val:": str = 'linear'"},{name:"use_karras_sigmas",val:": typing.Optional[bool] = False"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.EulerDiscreteScheduler.num_train_timesteps",description:"<strong>num_train_timesteps</strong> (<code>int</code>) &#x2014; number of diffusion steps used to train the model.",name:"num_train_timesteps"},{anchor:"diffusers.EulerDiscreteScheduler.beta_start",description:"<strong>beta_start</strong> (<code>float</code>) &#x2014; the starting <code>beta</code> value of inference.",name:"beta_start"},{anchor:"diffusers.EulerDiscreteScheduler.beta_end",description:"<strong>beta_end</strong> (<code>float</code>) &#x2014; the final <code>beta</code> value.",name:"beta_end"},{anchor:"diffusers.EulerDiscreteScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</code>) &#x2014;
the beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
<code>linear</code> or <code>scaled_linear</code>.`,name:"beta_schedule"},{anchor:"diffusers.EulerDiscreteScheduler.trained_betas",description:`<strong>trained_betas</strong> (<code>np.ndarray</code>, optional) &#x2014;
option to pass an array of betas directly to the constructor to bypass <code>beta_start</code>, <code>beta_end</code> etc.`,name:"trained_betas"},{anchor:"diffusers.EulerDiscreteScheduler.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, default <code>&quot;epsilon&quot;</code>, optional) &#x2014;
prediction type of the scheduler function, one of <code>epsilon</code> (predicting the noise of the diffusion
process), <code>sample</code> (directly predicting the noisy sample<code>) or </code>v_prediction\` (see section 2.4
<a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">https://imagen.research.google/video/paper.pdf</a>)`,name:"prediction_type"},{anchor:"diffusers.EulerDiscreteScheduler.interpolation_type",description:`<strong>interpolation_type</strong> (<code>str</code>, default <code>&quot;linear&quot;</code>, optional) &#x2014;
interpolation type to compute intermediate sigmas for the scheduler denoising steps. Should be one of
[<code>&quot;linear&quot;</code>, <code>&quot;log_linear&quot;</code>].`,name:"interpolation_type"},{anchor:"diffusers.EulerDiscreteScheduler.use_karras_sigmas",description:`<strong>use_karras_sigmas</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
This parameter controls whether to use Karras sigmas (Karras et al. (2022) scheme) for step sizes in the
noise schedule during the sampling process. If True, the sigmas will be determined according to a sequence
of noise levels {&#x3C3;i} as defined in Equation (5) of the paper <a href="https://arxiv.org/pdf/2206.00364.pdf" rel="nofollow">https://arxiv.org/pdf/2206.00364.pdf</a>.`,name:"use_karras_sigmas"},{anchor:"diffusers.EulerDiscreteScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, default <code>&quot;linspace&quot;</code>) &#x2014;
The way the timesteps should be scaled. Refer to Table 2. of <a href="https://arxiv.org/abs/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and Sample
Steps are Flawed</a> for more information.`,name:"timestep_spacing"},{anchor:"diffusers.EulerDiscreteScheduler.steps_offset",description:`<strong>steps_offset</strong> (<code>int</code>, default <code>0</code>) &#x2014;
an offset added to the inference steps. You can use a combination of <code>offset=1</code> and
<code>set_alpha_to_one=False</code>, to make the last step use step 0 for the previous alpha product, as done in
stable diffusion.`,name:"steps_offset"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_discrete.py#L94"}}),L=new De({props:{name:"scale_model_input",anchor:"diffusers.EulerDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.EulerDiscreteScheduler.scale_model_input.sample",description:"<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014; input sample",name:"sample"},{anchor:"diffusers.EulerDiscreteScheduler.scale_model_input.timestep",description:"<strong>timestep</strong> (<code>float</code> or <code>torch.FloatTensor</code>) &#x2014; the current timestep in the diffusion chain",name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_discrete.py#L188",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),I=new De({props:{name:"set_timesteps",anchor:"diffusers.EulerDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.EulerDiscreteScheduler.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.EulerDiscreteScheduler.set_timesteps.device",description:`<strong>device</strong> (<code>str</code> or <code>torch.device</code>, optional) &#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_euler_discrete.py#L211"}}),B=new De({props:{name:"step",anchor:"diffusers.EulerDiscreteScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"},{name:"sample",val:": FloatTensor"},{name:"s_churn",val:": float = 0.0"},{name:"s_tmin",val:": float = 0.0"},{name:"s_tmax",val:": float = inf"},{name:"s_noise",val:": float = 1.0"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.EulerDiscreteScheduler.step.model_output",description:"<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014; direct output from learned diffusion model.",name:"model_output"},{anchor:"diffusers.EulerDiscreteScheduler.step.timestep",description:"<strong>timestep</strong> (<code>float</code>) &#x2014; current timestep in the diffusion chain.",name:"timestep"},{anchor:"diffusers.EulerDiscreteScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
current instance of sample being created by diffusion process.`,name:"sample"},{anchor:"diffusers.EulerDiscreteScheduler.step.s_churn",description:"<strong>s_churn</strong> (<code>float</code>) &#x2014;",name:"s_churn"},{anchor:"diffusers.EulerDiscreteScheduler.step.s_tmin",description:"<strong>s_tmin</strong>  (<code>float</code>) &#x2014;",name:"s_tmin"},{anchor:"diffusers.EulerDiscreteScheduler.step.s_tmax",description:"<strong>s_tmax</strong>  (<code>float</code>) &#x2014;",name:"s_tmax"},{anchor:"diffusers.EulerDiscreteScheduler.step.s_noise",description:"<strong>s_noise</strong> (<code>float</code>) &#x2014;",name:"s_noise"},{anchor:"diffusers.EulerDiscreteScheduler.step.generator",description:"<strong>generator</strong> (<code>torch.Generator</code>, optional) &#x2014; Random number generator.",name:"generator"},{anchor:"diffusers.EulerDiscreteScheduler.step.return_dict",description:"<strong>return_dict</strong> (<code>bool</code>) &#x2014; option for returning tuple rather than EulerDiscreteSchedulerOutput class",name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_euler_discrete.py#L307",returnDescription:`
<p><code>~schedulers.scheduling_utils.EulerDiscreteSchedulerOutput</code> if <code>return_dict</code> is True, otherwise a
<code>tuple</code>. When returning a tuple, the first element is the sample tensor.</p>
`,returnType:`
<p><code>~schedulers.scheduling_utils.EulerDiscreteSchedulerOutput</code> or <code>tuple</code></p>
`}}),{c(){v=s("meta"),ue=u(),b=s("h1"),S=s("a"),X=s("span"),G(T.$$.fragment),xe=u(),Z=s("span"),$e=a("Euler scheduler"),fe=u(),E=s("h2"),w=s("a"),ee=s("span"),G(C.$$.fragment),ke=u(),te=s("span"),Ae=a("Overview"),pe=u(),g=s("p"),Te=a("Euler scheduler (Algorithm 2) from the paper "),P=s("a"),Ce=a("Elucidating the Design Space of Diffusion-Based Generative Models"),Pe=a(" by Karras et al. (2022). Based on the original "),q=s("a"),qe=a("k-diffusion"),Fe=a(` implementation by Katherine Crowson.
Fast scheduler which often times generates good outputs with 20-30 steps.`),he=u(),y=s("h2"),D=s("a"),re=s("span"),G(F.$$.fragment),Me=u(),se=s("span"),Ne=a("EulerDiscreteScheduler"),me=u(),d=s("div"),G(M.$$.fragment),Oe=u(),x=s("p"),Le=a("Euler scheduler (Algorithm 2) from Karras et al. (2022) "),N=s("a"),Ke=a("https://arxiv.org/abs/2206.00364"),Ie=a(`. . Based on the original
k-diffusion implementation by Katherine Crowson:
`),O=s("a"),Be=a("https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L51"),Ge=u(),l=s("p"),J=s("a"),Ue=a("~ConfigMixin"),Ve=a(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),oe=s("code"),He=a("__init__"),Re=a(`
function, such as `),ne=s("code"),ze=a("num_train_timesteps"),Je=a(". They can be accessed via "),ae=s("code"),We=a("scheduler.config.num_train_timesteps"),Ye=a(`.
`),W=s("a"),je=a("SchedulerMixin"),Qe=a(" provides general loading and saving functionality via the "),Y=s("a"),Xe=a("SchedulerMixin.save_pretrained()"),Ze=a(` and
`),j=s("a"),et=a("from_pretrained()"),tt=a(" functions."),rt=u(),$=s("div"),G(L.$$.fragment),st=u(),K=s("p"),ot=a("Scales the denoising model input by "),ie=s("code"),nt=a("(sigma**2 + 1) ** 0.5"),at=a(" to match the Euler algorithm."),it=u(),k=s("div"),G(I.$$.fragment),ct=u(),ce=s("p"),lt=a("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),dt=u(),A=s("div"),G(B.$$.fragment),ut=u(),le=s("p"),ft=a(`Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
process from the learned model outputs (most often the predicted noise).`),this.h()},l(t){const h=Gt('[data-svelte="svelte-1phssyn"]',document.head);v=o(h,"META",{name:!0,content:!0}),h.forEach(r),ue=f(t),b=o(t,"H1",{class:!0});var _e=n(b);S=o(_e,"A",{id:!0,class:!0,href:!0});var mt=n(S);X=o(mt,"SPAN",{});var gt=n(X);U(T.$$.fragment,gt),gt.forEach(r),mt.forEach(r),xe=f(_e),Z=o(_e,"SPAN",{});var _t=n(Z);$e=i(_t,"Euler scheduler"),_t.forEach(r),_e.forEach(r),fe=f(t),E=o(t,"H2",{class:!0});var ve=n(E);w=o(ve,"A",{id:!0,class:!0,href:!0});var vt=n(w);ee=o(vt,"SPAN",{});var bt=n(ee);U(C.$$.fragment,bt),bt.forEach(r),vt.forEach(r),ke=f(ve),te=o(ve,"SPAN",{});var Et=n(te);Ae=i(Et,"Overview"),Et.forEach(r),ve.forEach(r),pe=f(t),g=o(t,"P",{});var Q=n(g);Te=i(Q,"Euler scheduler (Algorithm 2) from the paper "),P=o(Q,"A",{href:!0,rel:!0});var yt=n(P);Ce=i(yt,"Elucidating the Design Space of Diffusion-Based Generative Models"),yt.forEach(r),Pe=i(Q," by Karras et al. (2022). Based on the original "),q=o(Q,"A",{href:!0,rel:!0});var St=n(q);qe=i(St,"k-diffusion"),St.forEach(r),Fe=i(Q,` implementation by Katherine Crowson.
Fast scheduler which often times generates good outputs with 20-30 steps.`),Q.forEach(r),he=f(t),y=o(t,"H2",{class:!0});var be=n(y);D=o(be,"A",{id:!0,class:!0,href:!0});var wt=n(D);re=o(wt,"SPAN",{});var Dt=n(re);U(F.$$.fragment,Dt),Dt.forEach(r),wt.forEach(r),Me=f(be),se=o(be,"SPAN",{});var xt=n(se);Ne=i(xt,"EulerDiscreteScheduler"),xt.forEach(r),be.forEach(r),me=f(t),d=o(t,"DIV",{class:!0});var m=n(d);U(M.$$.fragment,m),Oe=f(m),x=o(m,"P",{});var de=n(x);Le=i(de,"Euler scheduler (Algorithm 2) from Karras et al. (2022) "),N=o(de,"A",{href:!0,rel:!0});var $t=n(N);Ke=i($t,"https://arxiv.org/abs/2206.00364"),$t.forEach(r),Ie=i(de,`. . Based on the original
k-diffusion implementation by Katherine Crowson:
`),O=o(de,"A",{href:!0,rel:!0});var kt=n(O);Be=i(kt,"https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L51"),kt.forEach(r),de.forEach(r),Ge=f(m),l=o(m,"P",{});var p=n(l);J=o(p,"A",{href:!0});var At=n(J);Ue=i(At,"~ConfigMixin"),At.forEach(r),Ve=i(p," takes care of storing all config attributes that are passed in the scheduler\u2019s "),oe=o(p,"CODE",{});var Tt=n(oe);He=i(Tt,"__init__"),Tt.forEach(r),Re=i(p,`
function, such as `),ne=o(p,"CODE",{});var Ct=n(ne);ze=i(Ct,"num_train_timesteps"),Ct.forEach(r),Je=i(p,". They can be accessed via "),ae=o(p,"CODE",{});var Pt=n(ae);We=i(Pt,"scheduler.config.num_train_timesteps"),Pt.forEach(r),Ye=i(p,`.
`),W=o(p,"A",{href:!0});var qt=n(W);je=i(qt,"SchedulerMixin"),qt.forEach(r),Qe=i(p," provides general loading and saving functionality via the "),Y=o(p,"A",{href:!0});var Ft=n(Y);Xe=i(Ft,"SchedulerMixin.save_pretrained()"),Ft.forEach(r),Ze=i(p,` and
`),j=o(p,"A",{href:!0});var Mt=n(j);et=i(Mt,"from_pretrained()"),Mt.forEach(r),tt=i(p," functions."),p.forEach(r),rt=f(m),$=o(m,"DIV",{class:!0});var Ee=n($);U(L.$$.fragment,Ee),st=f(Ee),K=o(Ee,"P",{});var ye=n(K);ot=i(ye,"Scales the denoising model input by "),ie=o(ye,"CODE",{});var Nt=n(ie);nt=i(Nt,"(sigma**2 + 1) ** 0.5"),Nt.forEach(r),at=i(ye," to match the Euler algorithm."),ye.forEach(r),Ee.forEach(r),it=f(m),k=o(m,"DIV",{class:!0});var Se=n(k);U(I.$$.fragment,Se),ct=f(Se),ce=o(Se,"P",{});var Ot=n(ce);lt=i(Ot,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),Ot.forEach(r),Se.forEach(r),dt=f(m),A=o(m,"DIV",{class:!0});var we=n(A);U(B.$$.fragment,we),ut=f(we),le=o(we,"P",{});var Lt=n(le);ft=i(Lt,`Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
process from the learned model outputs (most often the predicted noise).`),Lt.forEach(r),we.forEach(r),m.forEach(r),this.h()},h(){c(v,"name","hf:doc:metadata"),c(v,"content",JSON.stringify(Rt)),c(S,"id","euler-scheduler"),c(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"),c(S,"href","#euler-scheduler"),c(b,"class","relative group"),c(w,"id","overview"),c(w,"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"),c(w,"href","#overview"),c(E,"class","relative group"),c(P,"href","https://arxiv.org/abs/2206.00364"),c(P,"rel","nofollow"),c(q,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L51"),c(q,"rel","nofollow"),c(D,"id","diffusers.EulerDiscreteScheduler"),c(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"),c(D,"href","#diffusers.EulerDiscreteScheduler"),c(y,"class","relative group"),c(N,"href","https://arxiv.org/abs/2206.00364"),c(N,"rel","nofollow"),c(O,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L51"),c(O,"rel","nofollow"),c(J,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),c(W,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),c(Y,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),c(j,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),c($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,h){e(document.head,v),_(t,ue,h),_(t,b,h),e(b,S),e(S,X),V(T,X,null),e(b,xe),e(b,Z),e(Z,$e),_(t,fe,h),_(t,E,h),e(E,w),e(w,ee),V(C,ee,null),e(E,ke),e(E,te),e(te,Ae),_(t,pe,h),_(t,g,h),e(g,Te),e(g,P),e(P,Ce),e(g,Pe),e(g,q),e(q,qe),e(g,Fe),_(t,he,h),_(t,y,h),e(y,D),e(D,re),V(F,re,null),e(y,Me),e(y,se),e(se,Ne),_(t,me,h),_(t,d,h),V(M,d,null),e(d,Oe),e(d,x),e(x,Le),e(x,N),e(N,Ke),e(x,Ie),e(x,O),e(O,Be),e(d,Ge),e(d,l),e(l,J),e(J,Ue),e(l,Ve),e(l,oe),e(oe,He),e(l,Re),e(l,ne),e(ne,ze),e(l,Je),e(l,ae),e(ae,We),e(l,Ye),e(l,W),e(W,je),e(l,Qe),e(l,Y),e(Y,Xe),e(l,Ze),e(l,j),e(j,et),e(l,tt),e(d,rt),e(d,$),V(L,$,null),e($,st),e($,K),e(K,ot),e(K,ie),e(ie,nt),e(K,at),e(d,it),e(d,k),V(I,k,null),e(k,ct),e(k,ce),e(ce,lt),e(d,dt),e(d,A),V(B,A,null),e(A,ut),e(A,le),e(le,ft),ge=!0},p:Ut,i(t){ge||(H(T.$$.fragment,t),H(C.$$.fragment,t),H(F.$$.fragment,t),H(M.$$.fragment,t),H(L.$$.fragment,t),H(I.$$.fragment,t),H(B.$$.fragment,t),ge=!0)},o(t){R(T.$$.fragment,t),R(C.$$.fragment,t),R(F.$$.fragment,t),R(M.$$.fragment,t),R(L.$$.fragment,t),R(I.$$.fragment,t),R(B.$$.fragment,t),ge=!1},d(t){r(v),t&&r(ue),t&&r(b),z(T),t&&r(fe),t&&r(E),z(C),t&&r(pe),t&&r(g),t&&r(he),t&&r(y),z(F),t&&r(me),t&&r(d),z(M),z(L),z(I),z(B)}}}const Rt={local:"euler-scheduler",sections:[{local:"overview",title:"Overview"},{local:"diffusers.EulerDiscreteScheduler",title:"EulerDiscreteScheduler"}],title:"Euler scheduler"};function zt(ht){return Vt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends Kt{constructor(v){super();It(this,v,zt,Ht,Bt,{})}}export{jt as default,Rt as metadata};
