import{s as Ke,n as Ce,o as ke}from"../chunks/scheduler.182ea377.js";import{S as Le,i as Oe,g as a,s as n,r as f,A as Ee,h as d,f as t,c as o,j as M,u as m,x as h,k as P,y as s,a as c,v as g,d as _,t as v,w as b}from"../chunks/index.abf12888.js";import{D as B}from"../chunks/Docstring.93f6f462.js";import{H as be}from"../chunks/Heading.16916d63.js";function He(De){let u,R,G,W,T,J,w,xe='The <code>KDPM2DiscreteScheduler</code> with ancestral sampling is inspired by the <a href="https://huggingface.co/papers/2206.00364" rel="nofollow">Elucidating the Design Space of Diffusion-Based Generative Models</a> paper, and the scheduler is ported from and created by <a href="https://github.com/crowsonkb/" rel="nofollow">Katherine Crowson</a>.',Q,y,$e='The original codebase can be found at <a href="https://github.com/crowsonkb/k-diffusion" rel="nofollow">crowsonkb/k-diffusion</a>.',X,A,Y,i,K,de,q,Se=`KDPM2DiscreteScheduler with ancestral sampling is inspired by the DPMSolver2 and Algorithm 2 from the <a href="https://huggingface.co/papers/2206.00364" rel="nofollow">Elucidating
the Design Space of Diffusion-Based Generative Models</a> paper.`,ce,F,Me=`This model inherits from <a href="/docs/diffusers/v0.27.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/v0.27.0/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.`,le,D,C,ue,I,Pe=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,pe,x,k,fe,U,Te="Sets the begin index for the scheduler. This function should be run from pipeline before the inference.",me,$,L,he,V,we="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",ge,S,O,_e,N,ye=`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).`,Z,E,ee,p,H,ve,z,Ae="Base class for the output of a scheduler’s <code>step</code> function.",te,j,se;return T=new be({props:{title:"KDPM2AncestralDiscreteScheduler",local:"kdpm2ancestraldiscretescheduler",headingTag:"h1"}}),A=new be({props:{title:"KDPM2AncestralDiscreteScheduler",local:"diffusers.KDPM2AncestralDiscreteScheduler",headingTag:"h2"}}),K=new B({props:{name:"class diffusers.KDPM2AncestralDiscreteScheduler",anchor:"diffusers.KDPM2AncestralDiscreteScheduler",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:": Union = None"},{name:"use_karras_sigmas",val:": Optional = False"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"timestep_spacing",val:": str = 'linspace'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.beta_start",description:`<strong>beta_start</strong> (<code>float</code>, defaults to 0.00085) &#x2014;
The starting <code>beta</code> value of inference.`,name:"beta_start"},{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.beta_end",description:`<strong>beta_end</strong> (<code>float</code>, defaults to 0.012) &#x2014;
The final <code>beta</code> value.`,name:"beta_end"},{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.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/v0.27.0/src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py#L71"}}),C=new B({props:{name:"scale_model_input",anchor:"diffusers.KDPM2AncestralDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": Union"}],parametersDescription:[{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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/v0.27.0/src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py#L176",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.FloatTensor</code></p>
`}}),k=new B({props:{name:"set_begin_index",anchor:"diffusers.KDPM2AncestralDiscreteScheduler.set_begin_index",parameters:[{name:"begin_index",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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/v0.27.0/src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py#L166"}}),L=new B({props:{name:"set_timesteps",anchor:"diffusers.KDPM2AncestralDiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": Union = None"},{name:"num_train_timesteps",val:": Optional = None"}],parametersDescription:[{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.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/v0.27.0/src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py#L206"}}),O=new B({props:{name:"step",anchor:"diffusers.KDPM2AncestralDiscreteScheduler.step",parameters:[{name:"model_output",val:": Union"},{name:"timestep",val:": Union"},{name:"sample",val:": Union"},{name:"generator",val:": Optional = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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.KDPM2AncestralDiscreteScheduler.step.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator.`,name:"generator"},{anchor:"diffusers.KDPM2AncestralDiscreteScheduler.step.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/v0.27.0/en/api/schedulers/overview#diffusers.schedulers.scheduling_utils.SchedulerOutput">SchedulerOutput</a> or tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.27.0/src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py#L377",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


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