import{S as wt,i as xt,s as Ht,e as r,k as d,w as k,t as a,M as Tt,c as n,d as s,m as l,a as o,x as A,h as c,b as i,G as e,g as m,y as O,L as Et,q as P,o as F,B as C,v as kt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as ae}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as rt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function At(nt){let g,ce,_,$,j,N,De,Q,we,de,h,xe,I,He,Te,M,Ee,ke,q,Ae,Oe,le,v,D,X,L,Pe,Z,Fe,ue,u,U,Ce,ee,Ne,Ie,b,Me,W,qe,Le,J,Ue,Ve,Be,w,V,Ke,te,Ge,ze,x,B,Re,se,We,Je,H,K,Ye,re,je,pe,y,T,ne,G,Qe,oe,Xe,he,S,z,Ze,R,et,ie,tt,st,fe;return N=new rt({}),L=new rt({}),U=new ae({props:{name:"class diffusers.HeunDiscreteScheduler",anchor:"diffusers.HeunDiscreteScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.00085"},{name:"beta_end",val:": float = 0.012"},{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:"use_karras_sigmas",val:": typing.Optional[bool] = False"},{name:"clip_sample",val:": typing.Optional[bool] = False"},{name:"clip_sample_range",val:": float = 1.0"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.beta_start",description:`<strong>beta_start</strong> (<code>float</code>, defaults to 0.0001) &#x2014;
The starting <code>beta</code> value of inference.`,name:"beta_start"},{anchor:"diffusers.HeunDiscreteScheduler.beta_end",description:`<strong>beta_end</strong> (<code>float</code>, defaults to 0.02) &#x2014;
The final <code>beta</code> value.`,name:"beta_end"},{anchor:"diffusers.HeunDiscreteScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</code>, defaults to <code>&quot;linear&quot;</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.HeunDiscreteScheduler.trained_betas",description:`<strong>trained_betas</strong> (<code>np.ndarray</code>, <em>optional</em>) &#x2014;
Pass an array of betas directly to the constructor to bypass <code>beta_start</code> and <code>beta_end</code>.`,name:"trained_betas"},{anchor:"diffusers.HeunDiscreteScheduler.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, defaults to <code>epsilon</code>, <em>optional</em>) &#x2014;
Prediction type of the scheduler function; can be <code>epsilon</code> (predicts the noise of the diffusion process),
<code>sample</code> (directly predicts the noisy sample<code>) or </code>v_prediction\` (see section 2.4 of <a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">Imagen
Video</a> paper).`,name:"prediction_type"},{anchor:"diffusers.HeunDiscreteScheduler.clip_sample",description:`<strong>clip_sample</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Clip the predicted sample for numerical stability.`,name:"clip_sample"},{anchor:"diffusers.HeunDiscreteScheduler.clip_sample_range",description:`<strong>clip_sample_range</strong> (<code>float</code>, defaults to 1.0) &#x2014;
The maximum magnitude for sample clipping. Valid only when <code>clip_sample=True</code>.`,name:"clip_sample_range"},{anchor:"diffusers.HeunDiscreteScheduler.use_karras_sigmas",description:`<strong>use_karras_sigmas</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If <code>True</code>,
the sigmas are determined according to a sequence of noise levels {&#x3C3;i}.`,name:"use_karras_sigmas"},{anchor:"diffusers.HeunDiscreteScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, defaults to <code>&quot;linspace&quot;</code>) &#x2014;
The way the timesteps should be scaled. Refer to Table 2 of the <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and
Sample Steps are Flawed</a> for more information.`,name:"timestep_spacing"},{anchor:"diffusers.HeunDiscreteScheduler.steps_offset",description:`<strong>steps_offset</strong> (<code>int</code>, defaults to 0) &#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 like in Stable
Diffusion.`,name:"steps_offset"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L71"}}),V=new ae({props:{name:"scale_model_input",anchor:"diffusers.HeunDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.HeunDiscreteScheduler.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/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L187",returnDescription:`
<p>A scaled input sample.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),B=new ae({props:{name:"set_timesteps",anchor:"diffusers.HeunDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"},{name:"num_train_timesteps",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.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.HeunDiscreteScheduler.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/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L213"}}),K=new ae({props:{name:"step",anchor:"diffusers.HeunDiscreteScheduler.step",parameters:[{name:"model_output",val:": typing.Union[torch.FloatTensor, numpy.ndarray]"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"},{name:"sample",val:": typing.Union[torch.FloatTensor, numpy.ndarray]"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.step.model_output",description:`<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014;
The direct output from learned diffusion model.`,name:"model_output"},{anchor:"diffusers.HeunDiscreteScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.HeunDiscreteScheduler.step.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.HeunDiscreteScheduler.step.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/main/en/api/schedulers/singlestep_dpm_solver#diffusers.schedulers.scheduling_utils.SchedulerOutput">SchedulerOutput</a> or tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L340",returnDescription:`
<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/schedulers/singlestep_dpm_solver#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> is returned, otherwise a
tuple is returned where the first element is the sample tensor.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/schedulers/singlestep_dpm_solver#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),G=new rt({}),z=new ae({props:{name:"class diffusers.schedulers.scheduling_utils.SchedulerOutput",anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput",parameters:[{name:"prev_sample",val:": FloatTensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput.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"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_utils.py#L50"}}),{c(){g=r("meta"),ce=d(),_=r("h1"),$=r("a"),j=r("span"),k(N.$$.fragment),De=d(),Q=r("span"),we=a("HeunDiscreteScheduler"),de=d(),h=r("p"),xe=a("The Heun scheduler (Algorithm 1) is from the "),I=r("a"),He=a("Elucidating the Design Space of Diffusion-Based Generative Models"),Te=a(" paper by Karras et al. The scheduler is ported from the "),M=r("a"),Ee=a("k-diffusion"),ke=a(" library and created by "),q=r("a"),Ae=a("Katherine Crowson"),Oe=a("."),le=d(),v=r("h2"),D=r("a"),X=r("span"),k(L.$$.fragment),Pe=d(),Z=r("span"),Fe=a("HeunDiscreteScheduler"),ue=d(),u=r("div"),k(U.$$.fragment),Ce=d(),ee=r("p"),Ne=a("Scheduler with Heun steps for discrete beta schedules."),Ie=d(),b=r("p"),Me=a("This model inherits from "),W=r("a"),qe=a("SchedulerMixin"),Le=a(" and "),J=r("a"),Ue=a("ConfigMixin"),Ve=a(`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),Be=d(),w=r("div"),k(V.$$.fragment),Ke=d(),te=r("p"),Ge=a(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),ze=d(),x=r("div"),k(B.$$.fragment),Re=d(),se=r("p"),We=a("Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),Je=d(),H=r("div"),k(K.$$.fragment),Ye=d(),re=r("p"),je=a(`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).`),pe=d(),y=r("h2"),T=r("a"),ne=r("span"),k(G.$$.fragment),Qe=d(),oe=r("span"),Xe=a("SchedulerOutput"),he=d(),S=r("div"),k(z.$$.fragment),Ze=d(),R=r("p"),et=a("Base class for the output of a scheduler\u2019s "),ie=r("code"),tt=a("step"),st=a(" function."),this.h()},l(t){const p=Tt('[data-svelte="svelte-1phssyn"]',document.head);g=n(p,"META",{name:!0,content:!0}),p.forEach(s),ce=l(t),_=n(t,"H1",{class:!0});var me=o(_);$=n(me,"A",{id:!0,class:!0,href:!0});var ot=o($);j=n(ot,"SPAN",{});var it=o(j);A(N.$$.fragment,it),it.forEach(s),ot.forEach(s),De=l(me),Q=n(me,"SPAN",{});var at=o(Q);we=c(at,"HeunDiscreteScheduler"),at.forEach(s),me.forEach(s),de=l(t),h=n(t,"P",{});var E=o(h);xe=c(E,"The Heun scheduler (Algorithm 1) is from the "),I=n(E,"A",{href:!0,rel:!0});var ct=o(I);He=c(ct,"Elucidating the Design Space of Diffusion-Based Generative Models"),ct.forEach(s),Te=c(E," paper by Karras et al. The scheduler is ported from the "),M=n(E,"A",{href:!0,rel:!0});var dt=o(M);Ee=c(dt,"k-diffusion"),dt.forEach(s),ke=c(E," library and created by "),q=n(E,"A",{href:!0,rel:!0});var lt=o(q);Ae=c(lt,"Katherine Crowson"),lt.forEach(s),Oe=c(E,"."),E.forEach(s),le=l(t),v=n(t,"H2",{class:!0});var ge=o(v);D=n(ge,"A",{id:!0,class:!0,href:!0});var ut=o(D);X=n(ut,"SPAN",{});var pt=o(X);A(L.$$.fragment,pt),pt.forEach(s),ut.forEach(s),Pe=l(ge),Z=n(ge,"SPAN",{});var ht=o(Z);Fe=c(ht,"HeunDiscreteScheduler"),ht.forEach(s),ge.forEach(s),ue=l(t),u=n(t,"DIV",{class:!0});var f=o(u);A(U.$$.fragment,f),Ce=l(f),ee=n(f,"P",{});var ft=o(ee);Ne=c(ft,"Scheduler with Heun steps for discrete beta schedules."),ft.forEach(s),Ie=l(f),b=n(f,"P",{});var Y=o(b);Me=c(Y,"This model inherits from "),W=n(Y,"A",{href:!0});var mt=o(W);qe=c(mt,"SchedulerMixin"),mt.forEach(s),Le=c(Y," and "),J=n(Y,"A",{href:!0});var gt=o(J);Ue=c(gt,"ConfigMixin"),gt.forEach(s),Ve=c(Y,`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),Y.forEach(s),Be=l(f),w=n(f,"DIV",{class:!0});var _e=o(w);A(V.$$.fragment,_e),Ke=l(_e),te=n(_e,"P",{});var _t=o(te);Ge=c(_t,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),_t.forEach(s),_e.forEach(s),ze=l(f),x=n(f,"DIV",{class:!0});var ve=o(x);A(B.$$.fragment,ve),Re=l(ve),se=n(ve,"P",{});var vt=o(se);We=c(vt,"Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),vt.forEach(s),ve.forEach(s),Je=l(f),H=n(f,"DIV",{class:!0});var be=o(H);A(K.$$.fragment,be),Ye=l(be),re=n(be,"P",{});var bt=o(re);je=c(bt,`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).`),bt.forEach(s),be.forEach(s),f.forEach(s),pe=l(t),y=n(t,"H2",{class:!0});var ye=o(y);T=n(ye,"A",{id:!0,class:!0,href:!0});var yt=o(T);ne=n(yt,"SPAN",{});var St=o(ne);A(G.$$.fragment,St),St.forEach(s),yt.forEach(s),Qe=l(ye),oe=n(ye,"SPAN",{});var $t=o(oe);Xe=c($t,"SchedulerOutput"),$t.forEach(s),ye.forEach(s),he=l(t),S=n(t,"DIV",{class:!0});var Se=o(S);A(z.$$.fragment,Se),Ze=l(Se),R=n(Se,"P",{});var $e=o(R);et=c($e,"Base class for the output of a scheduler\u2019s "),ie=n($e,"CODE",{});var Dt=o(ie);tt=c(Dt,"step"),Dt.forEach(s),st=c($e," function."),$e.forEach(s),Se.forEach(s),this.h()},h(){i(g,"name","hf:doc:metadata"),i(g,"content",JSON.stringify(Ot)),i($,"id","heundiscretescheduler"),i($,"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"),i($,"href","#heundiscretescheduler"),i(_,"class","relative group"),i(I,"href","https://huggingface.co/papers/2206.00364"),i(I,"rel","nofollow"),i(M,"href","https://github.com/crowsonkb/k-diffusion"),i(M,"rel","nofollow"),i(q,"href","https://github.com/crowsonkb/"),i(q,"rel","nofollow"),i(D,"id","diffusers.HeunDiscreteScheduler"),i(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"),i(D,"href","#diffusers.HeunDiscreteScheduler"),i(v,"class","relative group"),i(W,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),i(J,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),i(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),i(T,"id","diffusers.schedulers.scheduling_utils.SchedulerOutput"),i(T,"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"),i(T,"href","#diffusers.schedulers.scheduling_utils.SchedulerOutput"),i(y,"class","relative group"),i(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(t,p){e(document.head,g),m(t,ce,p),m(t,_,p),e(_,$),e($,j),O(N,j,null),e(_,De),e(_,Q),e(Q,we),m(t,de,p),m(t,h,p),e(h,xe),e(h,I),e(I,He),e(h,Te),e(h,M),e(M,Ee),e(h,ke),e(h,q),e(q,Ae),e(h,Oe),m(t,le,p),m(t,v,p),e(v,D),e(D,X),O(L,X,null),e(v,Pe),e(v,Z),e(Z,Fe),m(t,ue,p),m(t,u,p),O(U,u,null),e(u,Ce),e(u,ee),e(ee,Ne),e(u,Ie),e(u,b),e(b,Me),e(b,W),e(W,qe),e(b,Le),e(b,J),e(J,Ue),e(b,Ve),e(u,Be),e(u,w),O(V,w,null),e(w,Ke),e(w,te),e(te,Ge),e(u,ze),e(u,x),O(B,x,null),e(x,Re),e(x,se),e(se,We),e(u,Je),e(u,H),O(K,H,null),e(H,Ye),e(H,re),e(re,je),m(t,pe,p),m(t,y,p),e(y,T),e(T,ne),O(G,ne,null),e(y,Qe),e(y,oe),e(oe,Xe),m(t,he,p),m(t,S,p),O(z,S,null),e(S,Ze),e(S,R),e(R,et),e(R,ie),e(ie,tt),e(R,st),fe=!0},p:Et,i(t){fe||(P(N.$$.fragment,t),P(L.$$.fragment,t),P(U.$$.fragment,t),P(V.$$.fragment,t),P(B.$$.fragment,t),P(K.$$.fragment,t),P(G.$$.fragment,t),P(z.$$.fragment,t),fe=!0)},o(t){F(N.$$.fragment,t),F(L.$$.fragment,t),F(U.$$.fragment,t),F(V.$$.fragment,t),F(B.$$.fragment,t),F(K.$$.fragment,t),F(G.$$.fragment,t),F(z.$$.fragment,t),fe=!1},d(t){s(g),t&&s(ce),t&&s(_),C(N),t&&s(de),t&&s(h),t&&s(le),t&&s(v),C(L),t&&s(ue),t&&s(u),C(U),C(V),C(B),C(K),t&&s(pe),t&&s(y),C(G),t&&s(he),t&&s(S),C(z)}}}const Ot={local:"heundiscretescheduler",sections:[{local:"diffusers.HeunDiscreteScheduler",title:"HeunDiscreteScheduler"},{local:"diffusers.schedulers.scheduling_utils.SchedulerOutput",title:"SchedulerOutput"}],title:"HeunDiscreteScheduler"};function Pt(nt){return kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class It extends wt{constructor(g){super();xt(this,g,Pt,At,Ht,{})}}export{It as default,Ot as metadata};
