import{s as Ce,n as ke,o as Le}from"../chunks/scheduler.182ea377.js";import{S as Oe,i as Ee,g as d,s as n,r as f,A as He,h as a,f as t,c as i,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 b,w as v}from"../chunks/index.abf12888.js";import{D as B}from"../chunks/Docstring.93f6f462.js";import{H as ve}from"../chunks/Heading.16916d63.js";function Fe(De){let u,R,j,W,T,J,y,$e='The <code>KDPM2DiscreteScheduler</code> 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,w,xe='The original codebase can be found at <a href="https://github.com/crowsonkb/k-diffusion" rel="nofollow">crowsonkb/k-diffusion</a>.',X,K,Y,o,C,ae,I,Se=`KDPM2DiscreteScheduler 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,q,Me=`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.`,le,D,k,ue,U,Pe=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,pe,$,L,fe,V,Te="Sets the begin index for the scheduler. This function should be run from pipeline before the inference.",me,x,O,he,A,ye="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",ge,S,E,_e,N,we=`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,H,ee,p,F,be,z,Ke="Base class for the output of a scheduler’s <code>step</code> function.",te,G,se;return T=new ve({props:{title:"KDPM2DiscreteScheduler",local:"kdpm2discretescheduler",headingTag:"h1"}}),K=new ve({props:{title:"KDPM2DiscreteScheduler",local:"diffusers.KDPM2DiscreteScheduler",headingTag:"h2"}}),C=new B({props:{name:"class diffusers.KDPM2DiscreteScheduler",anchor:"diffusers.KDPM2DiscreteScheduler",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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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_k_dpm_2_discrete.py#L70"}}),k=new B({props:{name:"scale_model_input",anchor:"diffusers.KDPM2DiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": Union"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.KDPM2DiscreteScheduler.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_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>
`}}),L=new B({props:{name:"set_begin_index",anchor:"diffusers.KDPM2DiscreteScheduler.set_begin_index",parameters:[{name:"begin_index",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.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_k_dpm_2_discrete.py#L166"}}),O=new B({props:{name:"set_timesteps",anchor:"diffusers.KDPM2DiscreteScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": Union = None"},{name:"num_train_timesteps",val:": Optional = None"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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_discrete.py#L206"}}),E=new B({props:{name:"step",anchor:"diffusers.KDPM2DiscreteScheduler.step",parameters:[{name:"model_output",val:": Union"},{name:"timestep",val:": Union"},{name:"sample",val:": Union"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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_sde#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_discrete.py#L362",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


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