import{s as Se,n as ye,o as Me}from"../chunks/scheduler.182ea377.js";import{S as Pe,i as Te,g as i,s as n,r as g,A as we,h as c,f as t,c as o,j as L,u as _,x as b,k as F,y as r,a as d,v,d as D,t as $,w as x}from"../chunks/index.abf12888.js";import{D as z}from"../chunks/Docstring.93f6f462.js";import{H as fe}from"../chunks/Heading.16916d63.js";function Ae(me){let u,G,U,B,S,j,y,he='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>.',R,M,ge='The original codebase can be found at <a href="https://github.com/crowsonkb/k-diffusion" rel="nofollow">crowsonkb/k-diffusion</a>.',W,P,Y,a,T,ne,O,_e=`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.`,oe,E,be=`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.`,ae,f,w,ie,H,ve=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,ce,m,A,de,I,De="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",le,h,K,ue,q,$e=`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).`,J,C,Q,p,k,pe,N,xe="Base class for the output of a scheduler’s <code>step</code> function.",X,V,Z;return S=new fe({props:{title:"KDPM2AncestralDiscreteScheduler",local:"kdpm2ancestraldiscretescheduler",headingTag:"h1"}}),P=new fe({props:{title:"KDPM2AncestralDiscreteScheduler",local:"diffusers.KDPM2AncestralDiscreteScheduler",headingTag:"h2"}}),T=new z({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:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"use_karras_sigmas",val:": typing.Optional[bool] = 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. 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_k_dpm_2_ancestral_discrete.py#L72"}}),w=new z({props:{name:"scale_model_input",anchor:"diffusers.KDPM2AncestralDiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Union[float, torch.FloatTensor]"}],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/main/src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py#L180",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>
`}}),A=new z({props:{name:"set_timesteps",anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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.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/main/src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py#L210"}}),K=new z({props:{name:"step",anchor:"diffusers.KDPM2AncestralDiscreteScheduler.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:"generator",val:": typing.Optional[torch._C.Generator] = 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/main/en/api/schedulers/dpm_discrete#diffusers.schedulers.scheduling_utils.SchedulerOutput">SchedulerOutput</a> or tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py#L361",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/main/en/api/schedulers/dpm_discrete#diffusers.schedulers.scheduling_utils.SchedulerOutput"
>SchedulerOutput</a> or <code>tuple</code></p>
`}}),C=new fe({props:{title:"SchedulerOutput",local:"diffusers.schedulers.scheduling_utils.SchedulerOutput",headingTag:"h2"}}),k=new z({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(){u=i("meta"),G=n(),U=i("p"),B=n(),g(S.$$.fragment),j=n(),y=i("p"),y.innerHTML=he,R=n(),M=i("p"),M.innerHTML=ge,W=n(),g(P.$$.fragment),Y=n(),a=i("div"),g(T.$$.fragment),ne=n(),O=i("p"),O.innerHTML=_e,oe=n(),E=i("p"),E.innerHTML=be,ae=n(),f=i("div"),g(w.$$.fragment),ie=n(),H=i("p"),H.textContent=ve,ce=n(),m=i("div"),g(A.$$.fragment),de=n(),I=i("p"),I.textContent=De,le=n(),h=i("div"),g(K.$$.fragment),ue=n(),q=i("p"),q.textContent=$e,J=n(),g(C.$$.fragment),Q=n(),p=i("div"),g(k.$$.fragment),pe=n(),N=i("p"),N.innerHTML=xe,X=n(),V=i("p"),this.h()},l(e){const s=we("svelte-u9bgzb",document.head);u=c(s,"META",{name:!0,content:!0}),s.forEach(t),G=o(e),U=c(e,"P",{}),L(U).forEach(t),B=o(e),_(S.$$.fragment,e),j=o(e),y=c(e,"P",{"data-svelte-h":!0}),b(y)!=="svelte-1xsfzct"&&(y.innerHTML=he),R=o(e),M=c(e,"P",{"data-svelte-h":!0}),b(M)!=="svelte-loovl7"&&(M.innerHTML=ge),W=o(e),_(P.$$.fragment,e),Y=o(e),a=c(e,"DIV",{class:!0});var l=L(a);_(T.$$.fragment,l),ne=o(l),O=c(l,"P",{"data-svelte-h":!0}),b(O)!=="svelte-lafslh"&&(O.innerHTML=_e),oe=o(l),E=c(l,"P",{"data-svelte-h":!0}),b(E)!=="svelte-linuuh"&&(E.innerHTML=be),ae=o(l),f=c(l,"DIV",{class:!0});var ee=L(f);_(w.$$.fragment,ee),ie=o(ee),H=c(ee,"P",{"data-svelte-h":!0}),b(H)!=="svelte-1rkfgpx"&&(H.textContent=ve),ee.forEach(t),ce=o(l),m=c(l,"DIV",{class:!0});var te=L(m);_(A.$$.fragment,te),de=o(te),I=c(te,"P",{"data-svelte-h":!0}),b(I)!=="svelte-1vzm9q"&&(I.textContent=De),te.forEach(t),le=o(l),h=c(l,"DIV",{class:!0});var se=L(h);_(K.$$.fragment,se),ue=o(se),q=c(se,"P",{"data-svelte-h":!0}),b(q)!=="svelte-hi84tp"&&(q.textContent=$e),se.forEach(t),l.forEach(t),J=o(e),_(C.$$.fragment,e),Q=o(e),p=c(e,"DIV",{class:!0});var re=L(p);_(k.$$.fragment,re),pe=o(re),N=c(re,"P",{"data-svelte-h":!0}),b(N)!=="svelte-6ojmkw"&&(N.innerHTML=xe),re.forEach(t),X=o(e),V=c(e,"P",{}),L(V).forEach(t),this.h()},h(){F(u,"name","hf:doc:metadata"),F(u,"content",Ke),F(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(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,s){r(document.head,u),d(e,G,s),d(e,U,s),d(e,B,s),v(S,e,s),d(e,j,s),d(e,y,s),d(e,R,s),d(e,M,s),d(e,W,s),v(P,e,s),d(e,Y,s),d(e,a,s),v(T,a,null),r(a,ne),r(a,O),r(a,oe),r(a,E),r(a,ae),r(a,f),v(w,f,null),r(f,ie),r(f,H),r(a,ce),r(a,m),v(A,m,null),r(m,de),r(m,I),r(a,le),r(a,h),v(K,h,null),r(h,ue),r(h,q),d(e,J,s),v(C,e,s),d(e,Q,s),d(e,p,s),v(k,p,null),r(p,pe),r(p,N),d(e,X,s),d(e,V,s),Z=!0},p:ye,i(e){Z||(D(S.$$.fragment,e),D(P.$$.fragment,e),D(T.$$.fragment,e),D(w.$$.fragment,e),D(A.$$.fragment,e),D(K.$$.fragment,e),D(C.$$.fragment,e),D(k.$$.fragment,e),Z=!0)},o(e){$(S.$$.fragment,e),$(P.$$.fragment,e),$(T.$$.fragment,e),$(w.$$.fragment,e),$(A.$$.fragment,e),$(K.$$.fragment,e),$(C.$$.fragment,e),$(k.$$.fragment,e),Z=!1},d(e){e&&(t(G),t(U),t(B),t(j),t(y),t(R),t(M),t(W),t(Y),t(a),t(J),t(Q),t(p),t(X),t(V)),t(u),x(S,e),x(P,e),x(T),x(w),x(A),x(K),x(C,e),x(k)}}}const Ke='{"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 Ce(me){return Me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ee extends Pe{constructor(u){super(),Te(this,u,Ce,Ae,Se,{})}}export{Ee as component};
