import{s as Pe,n as ke,o as Ee}from"../chunks/scheduler.53228c21.js";import{S as Me,i as Ie,e as a,s as r,c as u,h as Ne,a as d,d as t,b as i,f as S,g as p,j as D,k as T,l as n,m as c,n as m,t as f,o as h,p as g}from"../chunks/index.100fac89.js";import{C as qe}from"../chunks/CopyLLMTxtMenu.0ee1b69b.js";import{D as B}from"../chunks/Docstring.db856a1e.js";import{H as xe,E as Fe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";function Ve(ye){let _,G,K,Y,H,J,w,Q,C,Se='The Heun scheduler (Algorithm 1) is from the <a href="https://huggingface.co/papers/2206.00364" rel="nofollow">Elucidating the Design Space of Diffusion-Based Generative Models</a> paper by Karras et al. The scheduler is ported from the <a href="https://github.com/crowsonkb/k-diffusion" rel="nofollow">k-diffusion</a> library and created by <a href="https://github.com/crowsonkb/" rel="nofollow">Katherine Crowson</a>.',X,L,Z,o,O,le,F,De="Scheduler with Heun steps for discrete beta schedules.",ue,V,Te=`This model inherits from <a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/main/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.`,pe,v,P,me,z,He=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,fe,$,k,he,U,we="Sets the begin index for the scheduler. This function should be run from pipeline before the inference.",ge,x,E,_e,A,Ce="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",be,y,M,ve,W,Le=`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).`,ee,I,te,b,N,$e,j,Oe="Base class for the output of a scheduler’s <code>step</code> function.",se,q,ne,R,re;return H=new qe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new xe({props:{title:"HeunDiscreteScheduler",local:"heundiscretescheduler",headingTag:"h1"}}),L=new xe({props:{title:"HeunDiscreteScheduler",local:"diffusers.HeunDiscreteScheduler",headingTag:"h2"}}),O=new B({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:"use_exponential_sigmas",val:": typing.Optional[bool] = False"},{name:"use_beta_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.use_exponential_sigmas",description:`<strong>use_exponential_sigmas</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use exponential sigmas for step sizes in the noise schedule during the sampling process.`,name:"use_exponential_sigmas"},{anchor:"diffusers.HeunDiscreteScheduler.use_beta_sigmas",description:`<strong>use_beta_sigmas</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use beta sigmas for step sizes in the noise schedule during the sampling process. Refer to <a href="https://huggingface.co/papers/2407.12173" rel="nofollow">Beta
Sampling is All You Need</a> for more information.`,name:"use_beta_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, as required by some model families.`,name:"steps_offset"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L95"}}),P=new B({props:{name:"scale_model_input",anchor:"diffusers.HeunDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": typing.Union[float, torch.Tensor]"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.Tensor</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#L237",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 B({props:{name:"set_begin_index",anchor:"diffusers.HeunDiscreteScheduler.set_begin_index",parameters:[{name:"begin_index",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.set_begin_index.begin_index",description:`<strong>begin_index</strong> (<code>int</code>) &#x2014;
The begin index for the scheduler.`,name:"begin_index"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L227"}}),E=new B({props:{name:"set_timesteps",anchor:"diffusers.HeunDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": typing.Optional[int] = None"},{name:"device",val:": typing.Union[str, torch.device] = None"},{name:"num_train_timesteps",val:": typing.Optional[int] = None"},{name:"timesteps",val:": typing.Optional[typing.List[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"},{anchor:"diffusers.HeunDiscreteScheduler.set_timesteps.num_train_timesteps",description:`<strong>num_train_timesteps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of diffusion steps used when training the model. If <code>None</code>, the default
<code>num_train_timesteps</code> attribute is used.`,name:"num_train_timesteps"},{anchor:"diffusers.HeunDiscreteScheduler.set_timesteps.timesteps",description:`<strong>timesteps</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Custom timesteps used to support arbitrary spacing between timesteps. If <code>None</code>, timesteps will be
generated based on the <code>timestep_spacing</code> attribute. If <code>timesteps</code> is passed, <code>num_inference_steps</code>
must be <code>None</code>, and <code>timestep_spacing</code> attribute will be ignored.`,name:"timesteps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L263"}}),M=new B({props:{name:"step",anchor:"diffusers.HeunDiscreteScheduler.step",parameters:[{name:"model_output",val:": typing.Union[torch.Tensor, numpy.ndarray]"},{name:"timestep",val:": typing.Union[float, torch.Tensor]"},{name:"sample",val:": typing.Union[torch.Tensor, numpy.ndarray]"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.HeunDiscreteScheduler.step.model_output",description:`<strong>model_output</strong> (<code>torch.Tensor</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.Tensor</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 <code>HeunDiscreteSchedulerOutput</code> or
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_heun_discrete.py#L472",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is <code>True</code>, <code>HeunDiscreteSchedulerOutput</code> 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><code>HeunDiscreteSchedulerOutput</code> or <code>tuple</code></p>
`}}),I=new xe({props:{title:"SchedulerOutput",local:"diffusers.schedulers.scheduling_utils.SchedulerOutput",headingTag:"h2"}}),N=new B({props:{name:"class diffusers.schedulers.scheduling_utils.SchedulerOutput",anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput",parameters:[{name:"prev_sample",val:": Tensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_utils.SchedulerOutput.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"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_utils.py#L62"}}),q=new Fe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/schedulers/heun.md"}}),{c(){_=a("meta"),G=r(),K=a("p"),Y=r(),u(H.$$.fragment),J=r(),u(w.$$.fragment),Q=r(),C=a("p"),C.innerHTML=Se,X=r(),u(L.$$.fragment),Z=r(),o=a("div"),u(O.$$.fragment),le=r(),F=a("p"),F.textContent=De,ue=r(),V=a("p"),V.innerHTML=Te,pe=r(),v=a("div"),u(P.$$.fragment),me=r(),z=a("p"),z.textContent=He,fe=r(),$=a("div"),u(k.$$.fragment),he=r(),U=a("p"),U.textContent=we,ge=r(),x=a("div"),u(E.$$.fragment),_e=r(),A=a("p"),A.textContent=Ce,be=r(),y=a("div"),u(M.$$.fragment),ve=r(),W=a("p"),W.textContent=Le,ee=r(),u(I.$$.fragment),te=r(),b=a("div"),u(N.$$.fragment),$e=r(),j=a("p"),j.innerHTML=Oe,se=r(),u(q.$$.fragment),ne=r(),R=a("p"),this.h()},l(e){const s=Ne("svelte-u9bgzb",document.head);_=d(s,"META",{name:!0,content:!0}),s.forEach(t),G=i(e),K=d(e,"P",{}),S(K).forEach(t),Y=i(e),p(H.$$.fragment,e),J=i(e),p(w.$$.fragment,e),Q=i(e),C=d(e,"P",{"data-svelte-h":!0}),D(C)!=="svelte-1r9m54f"&&(C.innerHTML=Se),X=i(e),p(L.$$.fragment,e),Z=i(e),o=d(e,"DIV",{class:!0});var l=S(o);p(O.$$.fragment,l),le=i(l),F=d(l,"P",{"data-svelte-h":!0}),D(F)!=="svelte-1k165jq"&&(F.textContent=De),ue=i(l),V=d(l,"P",{"data-svelte-h":!0}),D(V)!=="svelte-linuuh"&&(V.innerHTML=Te),pe=i(l),v=d(l,"DIV",{class:!0});var ie=S(v);p(P.$$.fragment,ie),me=i(ie),z=d(ie,"P",{"data-svelte-h":!0}),D(z)!=="svelte-1rkfgpx"&&(z.textContent=He),ie.forEach(t),fe=i(l),$=d(l,"DIV",{class:!0});var oe=S($);p(k.$$.fragment,oe),he=i(oe),U=d(oe,"P",{"data-svelte-h":!0}),D(U)!=="svelte-1k141rk"&&(U.textContent=we),oe.forEach(t),ge=i(l),x=d(l,"DIV",{class:!0});var ae=S(x);p(E.$$.fragment,ae),_e=i(ae),A=d(ae,"P",{"data-svelte-h":!0}),D(A)!=="svelte-1vzm9q"&&(A.textContent=Ce),ae.forEach(t),be=i(l),y=d(l,"DIV",{class:!0});var de=S(y);p(M.$$.fragment,de),ve=i(de),W=d(de,"P",{"data-svelte-h":!0}),D(W)!=="svelte-hi84tp"&&(W.textContent=Le),de.forEach(t),l.forEach(t),ee=i(e),p(I.$$.fragment,e),te=i(e),b=d(e,"DIV",{class:!0});var ce=S(b);p(N.$$.fragment,ce),$e=i(ce),j=d(ce,"P",{"data-svelte-h":!0}),D(j)!=="svelte-6ojmkw"&&(j.innerHTML=Oe),ce.forEach(t),se=i(e),p(q.$$.fragment,e),ne=i(e),R=d(e,"P",{}),S(R).forEach(t),this.h()},h(){T(_,"name","hf:doc:metadata"),T(_,"content",ze),T(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(b,"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,s){n(document.head,_),c(e,G,s),c(e,K,s),c(e,Y,s),m(H,e,s),c(e,J,s),m(w,e,s),c(e,Q,s),c(e,C,s),c(e,X,s),m(L,e,s),c(e,Z,s),c(e,o,s),m(O,o,null),n(o,le),n(o,F),n(o,ue),n(o,V),n(o,pe),n(o,v),m(P,v,null),n(v,me),n(v,z),n(o,fe),n(o,$),m(k,$,null),n($,he),n($,U),n(o,ge),n(o,x),m(E,x,null),n(x,_e),n(x,A),n(o,be),n(o,y),m(M,y,null),n(y,ve),n(y,W),c(e,ee,s),m(I,e,s),c(e,te,s),c(e,b,s),m(N,b,null),n(b,$e),n(b,j),c(e,se,s),m(q,e,s),c(e,ne,s),c(e,R,s),re=!0},p:ke,i(e){re||(f(H.$$.fragment,e),f(w.$$.fragment,e),f(L.$$.fragment,e),f(O.$$.fragment,e),f(P.$$.fragment,e),f(k.$$.fragment,e),f(E.$$.fragment,e),f(M.$$.fragment,e),f(I.$$.fragment,e),f(N.$$.fragment,e),f(q.$$.fragment,e),re=!0)},o(e){h(H.$$.fragment,e),h(w.$$.fragment,e),h(L.$$.fragment,e),h(O.$$.fragment,e),h(P.$$.fragment,e),h(k.$$.fragment,e),h(E.$$.fragment,e),h(M.$$.fragment,e),h(I.$$.fragment,e),h(N.$$.fragment,e),h(q.$$.fragment,e),re=!1},d(e){e&&(t(G),t(K),t(Y),t(J),t(Q),t(C),t(X),t(Z),t(o),t(ee),t(te),t(b),t(se),t(ne),t(R)),t(_),g(H,e),g(w,e),g(L,e),g(O),g(P),g(k),g(E),g(M),g(I,e),g(N),g(q,e)}}}const ze='{"title":"HeunDiscreteScheduler","local":"heundiscretescheduler","sections":[{"title":"HeunDiscreteScheduler","local":"diffusers.HeunDiscreteScheduler","sections":[],"depth":2},{"title":"SchedulerOutput","local":"diffusers.schedulers.scheduling_utils.SchedulerOutput","sections":[],"depth":2}],"depth":1}';function Ue(ye){return Ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends Me{constructor(_){super(),Ie(this,_,Ue,Ve,Pe,{})}}export{Re as component};
