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 l,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 $e}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,Y,T,De,Z,xe,fe,E,w,ee,C,ke,te,Ae,pe,g,Te,P,Ce,Pe,M,Me,qe,he,y,$,re,q,Fe,se,Oe,me,d,F,Le,D,Ne,O,Ke,Ie,L,Be,Ge,c,J,Ue,Ve,oe,He,Re,ne,ze,Je,ae,We,je,W,Qe,Xe,j,Ye,Ze,Q,et,tt,rt,x,N,st,K,ot,ie,nt,at,it,k,I,lt,le,ct,dt,A,B,ut,ce,ft,ge;return T=new pt({}),C=new pt({}),q=new pt({}),F=new $e({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"}],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"}],source:"https://github.com/huggingface/diffusers/blob/v0.17.1/src/diffusers/schedulers/scheduling_euler_discrete.py#L79"}}),N=new $e({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/v0.17.1/src/diffusers/schedulers/scheduling_euler_discrete.py#L159",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),I=new $e({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/v0.17.1/src/diffusers/schedulers/scheduling_euler_discrete.py#L182"}}),B=new $e({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/v0.17.1/src/diffusers/schedulers/scheduling_euler_discrete.py#L257",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"),Y=s("span"),G(T.$$.fragment),De=u(),Z=s("span"),xe=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 "),M=s("a"),Me=a("k-diffusion"),qe=a(` implementation by Katherine Crowson.
Fast scheduler which often times generates good outputs with 20-30 steps.`),he=u(),y=s("h2"),$=s("a"),re=s("span"),G(q.$$.fragment),Fe=u(),se=s("span"),Oe=a("EulerDiscreteScheduler"),me=u(),d=s("div"),G(F.$$.fragment),Le=u(),D=s("p"),Ne=a("Euler scheduler (Algorithm 2) from Karras et al. (2022) "),O=s("a"),Ke=a("https://arxiv.org/abs/2206.00364"),Ie=a(`. . Based on the original
k-diffusion implementation by Katherine Crowson:
`),L=s("a"),Be=a("https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L51"),Ge=u(),c=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"),je=a(`.
`),W=s("a"),Qe=a("SchedulerMixin"),Xe=a(" provides general loading and saving functionality via the "),j=s("a"),Ye=a("SchedulerMixin.save_pretrained()"),Ze=a(` and
`),Q=s("a"),et=a("from_pretrained()"),tt=a(" functions."),rt=u(),x=s("div"),G(N.$$.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),lt=u(),le=s("p"),ct=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(),ce=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);Y=o(mt,"SPAN",{});var gt=n(Y);U(T.$$.fragment,gt),gt.forEach(r),mt.forEach(r),De=f(_e),Z=o(_e,"SPAN",{});var _t=n(Z);xe=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 X=n(g);Te=i(X,"Euler scheduler (Algorithm 2) from the paper "),P=o(X,"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(X," by Karras et al. (2022). Based on the original "),M=o(X,"A",{href:!0,rel:!0});var St=n(M);Me=i(St,"k-diffusion"),St.forEach(r),qe=i(X,` implementation by Katherine Crowson.
Fast scheduler which often times generates good outputs with 20-30 steps.`),X.forEach(r),he=f(t),y=o(t,"H2",{class:!0});var be=n(y);$=o(be,"A",{id:!0,class:!0,href:!0});var wt=n($);re=o(wt,"SPAN",{});var $t=n(re);U(q.$$.fragment,$t),$t.forEach(r),wt.forEach(r),Fe=f(be),se=o(be,"SPAN",{});var Dt=n(se);Oe=i(Dt,"EulerDiscreteScheduler"),Dt.forEach(r),be.forEach(r),me=f(t),d=o(t,"DIV",{class:!0});var m=n(d);U(F.$$.fragment,m),Le=f(m),D=o(m,"P",{});var de=n(D);Ne=i(de,"Euler scheduler (Algorithm 2) from Karras et al. (2022) "),O=o(de,"A",{href:!0,rel:!0});var xt=n(O);Ke=i(xt,"https://arxiv.org/abs/2206.00364"),xt.forEach(r),Ie=i(de,`. . Based on the original
k-diffusion implementation by Katherine Crowson:
`),L=o(de,"A",{href:!0,rel:!0});var kt=n(L);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),c=o(m,"P",{});var p=n(c);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),je=i(p,`.
`),W=o(p,"A",{href:!0});var Mt=n(W);Qe=i(Mt,"SchedulerMixin"),Mt.forEach(r),Xe=i(p," provides general loading and saving functionality via the "),j=o(p,"A",{href:!0});var qt=n(j);Ye=i(qt,"SchedulerMixin.save_pretrained()"),qt.forEach(r),Ze=i(p,` and
`),Q=o(p,"A",{href:!0});var Ft=n(Q);et=i(Ft,"from_pretrained()"),Ft.forEach(r),tt=i(p," functions."),p.forEach(r),rt=f(m),x=o(m,"DIV",{class:!0});var Ee=n(x);U(N.$$.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 Ot=n(ie);nt=i(Ot,"(sigma**2 + 1) ** 0.5"),Ot.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),lt=f(Se),le=o(Se,"P",{});var Lt=n(le);ct=i(Lt,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),Lt.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),ce=o(we,"P",{});var Nt=n(ce);ft=i(Nt,`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).`),Nt.forEach(r),we.forEach(r),m.forEach(r),this.h()},h(){l(v,"name","hf:doc:metadata"),l(v,"content",JSON.stringify(Rt)),l(S,"id","euler-scheduler"),l(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"),l(S,"href","#euler-scheduler"),l(b,"class","relative group"),l(w,"id","overview"),l(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"),l(w,"href","#overview"),l(E,"class","relative group"),l(P,"href","https://arxiv.org/abs/2206.00364"),l(P,"rel","nofollow"),l(M,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L51"),l(M,"rel","nofollow"),l($,"id","diffusers.EulerDiscreteScheduler"),l($,"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"),l($,"href","#diffusers.EulerDiscreteScheduler"),l(y,"class","relative group"),l(O,"href","https://arxiv.org/abs/2206.00364"),l(O,"rel","nofollow"),l(L,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L51"),l(L,"rel","nofollow"),l(J,"href","/docs/diffusers/v0.17.1/en/api/configuration#diffusers.ConfigMixin"),l(W,"href","/docs/diffusers/v0.17.1/en/api/schedulers/overview#diffusers.SchedulerMixin"),l(j,"href","/docs/diffusers/v0.17.1/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),l(Q,"href","/docs/diffusers/v0.17.1/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),l(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(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,Y),V(T,Y,null),e(b,De),e(b,Z),e(Z,xe),_(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,M),e(M,Me),e(g,qe),_(t,he,h),_(t,y,h),e(y,$),e($,re),V(q,re,null),e(y,Fe),e(y,se),e(se,Oe),_(t,me,h),_(t,d,h),V(F,d,null),e(d,Le),e(d,D),e(D,Ne),e(D,O),e(O,Ke),e(D,Ie),e(D,L),e(L,Be),e(d,Ge),e(d,c),e(c,J),e(J,Ue),e(c,Ve),e(c,oe),e(oe,He),e(c,Re),e(c,ne),e(ne,ze),e(c,Je),e(c,ae),e(ae,We),e(c,je),e(c,W),e(W,Qe),e(c,Xe),e(c,j),e(j,Ye),e(c,Ze),e(c,Q),e(Q,et),e(c,tt),e(d,rt),e(d,x),V(N,x,null),e(x,st),e(x,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,lt),e(k,le),e(le,ct),e(d,dt),e(d,A),V(B,A,null),e(A,ut),e(A,ce),e(ce,ft),ge=!0},p:Ut,i(t){ge||(H(T.$$.fragment,t),H(C.$$.fragment,t),H(q.$$.fragment,t),H(F.$$.fragment,t),H(N.$$.fragment,t),H(I.$$.fragment,t),H(B.$$.fragment,t),ge=!0)},o(t){R(T.$$.fragment,t),R(C.$$.fragment,t),R(q.$$.fragment,t),R(F.$$.fragment,t),R(N.$$.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(q),t&&r(me),t&&r(d),z(F),z(N),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 Qt extends Kt{constructor(v){super();It(this,v,zt,Ht,Bt,{})}}export{Qt as default,Rt as metadata};
