import{s as Oe,n as He,o as Ie}from"../chunks/scheduler.53228c21.js";import{S as qe,i as ze,e as a,s as r,c as p,h as Fe,a as d,d as t,b as i,f as S,g as u,j as v,k as M,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 Ne}from"../chunks/CopyLLMTxtMenu.9360b11d.js";import{D as G}from"../chunks/Docstring.22cc8849.js";import{H as ye,E as Ue}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.c9001d7a.js";function Ve(Se){let _,Y,R,J,P,Q,T,X,w,Me='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>.',Z,K,Pe='The original codebase can be found at <a href="https://github.com/crowsonkb/k-diffusion" rel="nofollow">crowsonkb/k-diffusion</a>.',ee,C,te,o,k,ue,F,Te=`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.`,me,N,we=`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.`,fe,D,L,he,U,Ke=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,ge,$,E,_e,V,Ce="Sets the begin index for the scheduler. This function should be run from pipeline before the inference.",be,x,O,ve,A,ke="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",De,y,H,$e,B,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).`,se,I,ne,b,q,xe,W,Ee="Base class for the output of a scheduler’s <code>step</code> function.",re,z,ie,j,oe;return P=new Ne({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),T=new ye({props:{title:"KDPM2DiscreteScheduler",local:"kdpm2discretescheduler",headingTag:"h1"}}),C=new ye({props:{title:"KDPM2DiscreteScheduler",local:"diffusers.KDPM2DiscreteScheduler",headingTag:"h2"}}),k=new G({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:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{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:"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.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.KDPM2DiscreteScheduler.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.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#L95"}}),L=new G({props:{name:"scale_model_input",anchor:"diffusers.KDPM2DiscreteScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": typing.Union[float, torch.Tensor]"}],parametersDescription:[{anchor:"diffusers.KDPM2DiscreteScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.Tensor</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#L214",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>
`}}),E=new G({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#L204"}}),O=new G({props:{name:"set_timesteps",anchor:"diffusers.KDPM2DiscreteScheduler.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.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#L244"}}),H=new G({props:{name:"step",anchor:"diffusers.KDPM2DiscreteScheduler.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.KDPM2DiscreteScheduler.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.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.Tensor</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 <code>KDPM2DiscreteSchedulerOutput</code> or
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py#L460",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


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