import{S as Ct,i as Pt,s as Ft,e as s,k as u,w as q,t as a,M as Mt,c as n,d as r,m as p,a as o,x as B,h as i,b as c,G as e,g,y as U,L as Nt,q as K,o as V,B as G,v as Lt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as ye}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as it}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Ot(ct){let _,ie,v,y,j,k,we,z,Se,ce,b,w,Q,T,$e,X,Ae,le,S,De,C,xe,ke,de,E,$,Z,P,Te,ee,Ce,ue,d,F,Pe,H,Fe,M,Me,Ne,l,R,Le,Oe,te,Ie,qe,re,Be,Ue,se,Ke,Ve,J,Ge,He,W,Re,Je,Y,We,Ye,je,A,N,ze,L,Qe,ne,Xe,Ze,et,D,O,tt,oe,rt,st,x,I,nt,ae,ot,pe;return k=new it({}),T=new it({}),P=new it({}),F=new ye({props:{name:"class diffusers.EulerAncestralDiscreteScheduler",anchor:"diffusers.EulerAncestralDiscreteScheduler",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:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.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.EulerAncestralDiscreteScheduler.beta_start",description:"<strong>beta_start</strong> (<code>float</code>) &#x2014; the starting <code>beta</code> value of inference.",name:"beta_start"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.beta_end",description:"<strong>beta_end</strong> (<code>float</code>) &#x2014; the final <code>beta</code> value.",name:"beta_end"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.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.EulerAncestralDiscreteScheduler.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.EulerAncestralDiscreteScheduler.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, default <code>epsilon</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.EulerAncestralDiscreteScheduler.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.EulerAncestralDiscreteScheduler.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/v0.19.0/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L94"}}),N=new ye({props:{name:"scale_model_input",anchor:"diffusers.EulerAncestralDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.scale_model_input.sample",description:"<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014; input sample",name:"sample"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.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.19.0/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L177",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),O=new ye({props:{name:"set_timesteps",anchor:"diffusers.EulerAncestralDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.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.EulerAncestralDiscreteScheduler.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.19.0/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L198"}}),I=new ye({props:{name:"step",anchor:"diffusers.EulerAncestralDiscreteScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"},{name:"sample",val:": FloatTensor"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.model_output",description:"<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014; direct output from learned diffusion model.",name:"model_output"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.timestep",description:"<strong>timestep</strong> (<code>float</code>) &#x2014; current timestep in the diffusion chain.",name:"timestep"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
current instance of sample being created by diffusion process.`,name:"sample"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.generator",description:"<strong>generator</strong> (<code>torch.Generator</code>, optional) &#x2014; Random number generator.",name:"generator"},{anchor:"diffusers.EulerAncestralDiscreteScheduler.step.return_dict",description:"<strong>return_dict</strong> (<code>bool</code>) &#x2014; option for returning tuple rather than EulerAncestralDiscreteSchedulerOutput class",name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py#L242",returnDescription:`
<p><code>~schedulers.scheduling_utils.EulerAncestralDiscreteSchedulerOutput</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.EulerAncestralDiscreteSchedulerOutput</code> or <code>tuple</code></p>
`}}),{c(){_=s("meta"),ie=u(),v=s("h1"),y=s("a"),j=s("span"),q(k.$$.fragment),we=u(),z=s("span"),Se=a("Euler Ancestral scheduler"),ce=u(),b=s("h2"),w=s("a"),Q=s("span"),q(T.$$.fragment),$e=u(),X=s("span"),Ae=a("Overview"),le=u(),S=s("p"),De=a("Ancestral sampling with Euler method steps. Based on the original "),C=s("a"),xe=a("k-diffusion"),ke=a(` implementation by Katherine Crowson.
Fast scheduler which often times generates good outputs with 20-30 steps.`),de=u(),E=s("h2"),$=s("a"),Z=s("span"),q(P.$$.fragment),Te=u(),ee=s("span"),Ce=a("EulerAncestralDiscreteScheduler"),ue=u(),d=s("div"),q(F.$$.fragment),Pe=u(),H=s("p"),Fe=a(`Ancestral sampling with Euler method steps. Based on the original k-diffusion implementation by Katherine Crowson:
`),M=s("a"),Me=a("https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L72"),Ne=u(),l=s("p"),R=s("a"),Le=a("~ConfigMixin"),Oe=a(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),te=s("code"),Ie=a("__init__"),qe=a(`
function, such as `),re=s("code"),Be=a("num_train_timesteps"),Ue=a(". They can be accessed via "),se=s("code"),Ke=a("scheduler.config.num_train_timesteps"),Ve=a(`.
`),J=s("a"),Ge=a("SchedulerMixin"),He=a(" provides general loading and saving functionality via the "),W=s("a"),Re=a("SchedulerMixin.save_pretrained()"),Je=a(` and
`),Y=s("a"),We=a("from_pretrained()"),Ye=a(" functions."),je=u(),A=s("div"),q(N.$$.fragment),ze=u(),L=s("p"),Qe=a("Scales the denoising model input by "),ne=s("code"),Xe=a("(sigma**2 + 1) ** 0.5"),Ze=a(" to match the Euler algorithm."),et=u(),D=s("div"),q(O.$$.fragment),tt=u(),oe=s("p"),rt=a("Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),st=u(),x=s("div"),q(I.$$.fragment),nt=u(),ae=s("p"),ot=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=Mt('[data-svelte="svelte-1phssyn"]',document.head);_=n(h,"META",{name:!0,content:!0}),h.forEach(r),ie=p(t),v=n(t,"H1",{class:!0});var fe=o(v);y=n(fe,"A",{id:!0,class:!0,href:!0});var lt=o(y);j=n(lt,"SPAN",{});var dt=o(j);B(k.$$.fragment,dt),dt.forEach(r),lt.forEach(r),we=p(fe),z=n(fe,"SPAN",{});var ut=o(z);Se=i(ut,"Euler Ancestral scheduler"),ut.forEach(r),fe.forEach(r),ce=p(t),b=n(t,"H2",{class:!0});var he=o(b);w=n(he,"A",{id:!0,class:!0,href:!0});var pt=o(w);Q=n(pt,"SPAN",{});var ft=o(Q);B(T.$$.fragment,ft),ft.forEach(r),pt.forEach(r),$e=p(he),X=n(he,"SPAN",{});var ht=o(X);Ae=i(ht,"Overview"),ht.forEach(r),he.forEach(r),le=p(t),S=n(t,"P",{});var me=o(S);De=i(me,"Ancestral sampling with Euler method steps. Based on the original "),C=n(me,"A",{href:!0,rel:!0});var mt=o(C);xe=i(mt,"k-diffusion"),mt.forEach(r),ke=i(me,` implementation by Katherine Crowson.
Fast scheduler which often times generates good outputs with 20-30 steps.`),me.forEach(r),de=p(t),E=n(t,"H2",{class:!0});var ge=o(E);$=n(ge,"A",{id:!0,class:!0,href:!0});var gt=o($);Z=n(gt,"SPAN",{});var _t=o(Z);B(P.$$.fragment,_t),_t.forEach(r),gt.forEach(r),Te=p(ge),ee=n(ge,"SPAN",{});var vt=o(ee);Ce=i(vt,"EulerAncestralDiscreteScheduler"),vt.forEach(r),ge.forEach(r),ue=p(t),d=n(t,"DIV",{class:!0});var m=o(d);B(F.$$.fragment,m),Pe=p(m),H=n(m,"P",{});var at=o(H);Fe=i(at,`Ancestral sampling with Euler method steps. Based on the original k-diffusion implementation by Katherine Crowson:
`),M=n(at,"A",{href:!0,rel:!0});var bt=o(M);Me=i(bt,"https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L72"),bt.forEach(r),at.forEach(r),Ne=p(m),l=n(m,"P",{});var f=o(l);R=n(f,"A",{href:!0});var Et=o(R);Le=i(Et,"~ConfigMixin"),Et.forEach(r),Oe=i(f," takes care of storing all config attributes that are passed in the scheduler\u2019s "),te=n(f,"CODE",{});var yt=o(te);Ie=i(yt,"__init__"),yt.forEach(r),qe=i(f,`
function, such as `),re=n(f,"CODE",{});var wt=o(re);Be=i(wt,"num_train_timesteps"),wt.forEach(r),Ue=i(f,". They can be accessed via "),se=n(f,"CODE",{});var St=o(se);Ke=i(St,"scheduler.config.num_train_timesteps"),St.forEach(r),Ve=i(f,`.
`),J=n(f,"A",{href:!0});var $t=o(J);Ge=i($t,"SchedulerMixin"),$t.forEach(r),He=i(f," provides general loading and saving functionality via the "),W=n(f,"A",{href:!0});var At=o(W);Re=i(At,"SchedulerMixin.save_pretrained()"),At.forEach(r),Je=i(f,` and
`),Y=n(f,"A",{href:!0});var Dt=o(Y);We=i(Dt,"from_pretrained()"),Dt.forEach(r),Ye=i(f," functions."),f.forEach(r),je=p(m),A=n(m,"DIV",{class:!0});var _e=o(A);B(N.$$.fragment,_e),ze=p(_e),L=n(_e,"P",{});var ve=o(L);Qe=i(ve,"Scales the denoising model input by "),ne=n(ve,"CODE",{});var xt=o(ne);Xe=i(xt,"(sigma**2 + 1) ** 0.5"),xt.forEach(r),Ze=i(ve," to match the Euler algorithm."),ve.forEach(r),_e.forEach(r),et=p(m),D=n(m,"DIV",{class:!0});var be=o(D);B(O.$$.fragment,be),tt=p(be),oe=n(be,"P",{});var kt=o(oe);rt=i(kt,"Sets the timesteps used for the diffusion chain. Supporting function to be run before inference."),kt.forEach(r),be.forEach(r),st=p(m),x=n(m,"DIV",{class:!0});var Ee=o(x);B(I.$$.fragment,Ee),nt=p(Ee),ae=n(Ee,"P",{});var Tt=o(ae);ot=i(Tt,`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).`),Tt.forEach(r),Ee.forEach(r),m.forEach(r),this.h()},h(){c(_,"name","hf:doc:metadata"),c(_,"content",JSON.stringify(It)),c(y,"id","euler-ancestral-scheduler"),c(y,"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(y,"href","#euler-ancestral-scheduler"),c(v,"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(b,"class","relative group"),c(C,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L72"),c(C,"rel","nofollow"),c($,"id","diffusers.EulerAncestralDiscreteScheduler"),c($,"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($,"href","#diffusers.EulerAncestralDiscreteScheduler"),c(E,"class","relative group"),c(M,"href","https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L72"),c(M,"rel","nofollow"),c(R,"href","/docs/diffusers/v0.19.0/en/api/configuration#diffusers.ConfigMixin"),c(J,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),c(W,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),c(Y,"href","/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),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"),c(x,"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,_),g(t,ie,h),g(t,v,h),e(v,y),e(y,j),U(k,j,null),e(v,we),e(v,z),e(z,Se),g(t,ce,h),g(t,b,h),e(b,w),e(w,Q),U(T,Q,null),e(b,$e),e(b,X),e(X,Ae),g(t,le,h),g(t,S,h),e(S,De),e(S,C),e(C,xe),e(S,ke),g(t,de,h),g(t,E,h),e(E,$),e($,Z),U(P,Z,null),e(E,Te),e(E,ee),e(ee,Ce),g(t,ue,h),g(t,d,h),U(F,d,null),e(d,Pe),e(d,H),e(H,Fe),e(H,M),e(M,Me),e(d,Ne),e(d,l),e(l,R),e(R,Le),e(l,Oe),e(l,te),e(te,Ie),e(l,qe),e(l,re),e(re,Be),e(l,Ue),e(l,se),e(se,Ke),e(l,Ve),e(l,J),e(J,Ge),e(l,He),e(l,W),e(W,Re),e(l,Je),e(l,Y),e(Y,We),e(l,Ye),e(d,je),e(d,A),U(N,A,null),e(A,ze),e(A,L),e(L,Qe),e(L,ne),e(ne,Xe),e(L,Ze),e(d,et),e(d,D),U(O,D,null),e(D,tt),e(D,oe),e(oe,rt),e(d,st),e(d,x),U(I,x,null),e(x,nt),e(x,ae),e(ae,ot),pe=!0},p:Nt,i(t){pe||(K(k.$$.fragment,t),K(T.$$.fragment,t),K(P.$$.fragment,t),K(F.$$.fragment,t),K(N.$$.fragment,t),K(O.$$.fragment,t),K(I.$$.fragment,t),pe=!0)},o(t){V(k.$$.fragment,t),V(T.$$.fragment,t),V(P.$$.fragment,t),V(F.$$.fragment,t),V(N.$$.fragment,t),V(O.$$.fragment,t),V(I.$$.fragment,t),pe=!1},d(t){r(_),t&&r(ie),t&&r(v),G(k),t&&r(ce),t&&r(b),G(T),t&&r(le),t&&r(S),t&&r(de),t&&r(E),G(P),t&&r(ue),t&&r(d),G(F),G(N),G(O),G(I)}}}const It={local:"euler-ancestral-scheduler",sections:[{local:"overview",title:"Overview"},{local:"diffusers.EulerAncestralDiscreteScheduler",title:"EulerAncestralDiscreteScheduler"}],title:"Euler Ancestral scheduler"};function qt(ct){return Lt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Vt extends Ct{constructor(_){super();Pt(this,_,qt,Ot,Ft,{})}}export{Vt as default,It as metadata};
