import{s as Se,n as Te,o as we}from"../chunks/scheduler.182ea377.js";import{S as Ce,i as Le,g as d,s as n,r as _,A as Oe,h as a,f as t,c as o,j as N,u as v,x as m,k as q,y as r,a as c,v as D,d as b,t as x,w as y}from"../chunks/index.abf12888.js";import{D as j}from"../chunks/Docstring.93f6f462.js";import{H as he}from"../chunks/Heading.16916d63.js";function Fe(ge){let p,W,U,G,P,J,M,_e='<a href="https://huggingface.co/papers/2006.11239" rel="nofollow">Denoising Diffusion Probabilistic Models</a> (DDPM) by Jonathan Ho, Ajay Jain and Pieter Abbeel proposes a diffusion based model of the same name. In the context of the 🤗 Diffusers library, DDPM refers to the discrete denoising scheduler from the paper as well as the pipeline.',Y,$,ve="The abstract from the paper is:",B,S,De='<em>We present high quality image synthesis results using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics. Our best results are obtained by training on a weighted variational bound designed according to a novel connection between diffusion probabilistic models and denoising score matching with Langevin dynamics, and our models naturally admit a progressive lossy decompression scheme that can be interpreted as a generalization of autoregressive decoding. On the unconditional CIFAR10 dataset, we obtain an Inception score of 9.46 and a state-of-the-art FID score of 3.17. On 256x256 LSUN, we obtain sample quality similar to ProgressiveGAN. Our implementation is available at <a href="https://github.com/hojonathanho/diffusion" rel="nofollow">this https URL</a>.</em>',K,T,Q,i,w,ie,H,be="<code>DDPMScheduler</code> explores the connections between denoising score matching and Langevin dynamics sampling.",de,E,xe=`This model inherits from <a href="/docs/diffusers/v0.24.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/v0.24.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.`,ae,f,C,ce,A,ye=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,le,h,L,pe,V,Pe="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",ue,g,O,me,k,Me=`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).`,X,F,Z,u,I,fe,z,$e="Output class for the scheduler’s <code>step</code> function output.",ee,R,te;return P=new he({props:{title:"DDPMScheduler",local:"ddpmscheduler",headingTag:"h1"}}),T=new he({props:{title:"DDPMScheduler",local:"diffusers.DDPMScheduler",headingTag:"h2"}}),w=new j({props:{name:"class diffusers.DDPMScheduler",anchor:"diffusers.DDPMScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.0001"},{name:"beta_end",val:": float = 0.02"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"variance_type",val:": str = 'fixed_small'"},{name:"clip_sample",val:": bool = True"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"thresholding",val:": bool = False"},{name:"dynamic_thresholding_ratio",val:": float = 0.995"},{name:"clip_sample_range",val:": float = 1.0"},{name:"sample_max_value",val:": float = 1.0"},{name:"timestep_spacing",val:": str = 'leading'"},{name:"steps_offset",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.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.DDPMScheduler.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.DDPMScheduler.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.DDPMScheduler.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>, <code>scaled_linear</code>, or <code>squaredcos_cap_v2</code>.`,name:"beta_schedule"},{anchor:"diffusers.DDPMScheduler.variance_type",description:`<strong>variance_type</strong> (<code>str</code>, defaults to <code>&quot;fixed_small&quot;</code>) &#x2014;
Clip the variance when adding noise to the denoised sample. Choose from <code>fixed_small</code>, <code>fixed_small_log</code>,
<code>fixed_large</code>, <code>fixed_large_log</code>, <code>learned</code> or <code>learned_range</code>.`,name:"variance_type"},{anchor:"diffusers.DDPMScheduler.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.DDPMScheduler.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.DDPMScheduler.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.DDPMScheduler.thresholding",description:`<strong>thresholding</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to use the &#x201C;dynamic thresholding&#x201D; method. This is unsuitable for latent-space diffusion models such
as Stable Diffusion.`,name:"thresholding"},{anchor:"diffusers.DDPMScheduler.dynamic_thresholding_ratio",description:`<strong>dynamic_thresholding_ratio</strong> (<code>float</code>, defaults to 0.995) &#x2014;
The ratio for the dynamic thresholding method. Valid only when <code>thresholding=True</code>.`,name:"dynamic_thresholding_ratio"},{anchor:"diffusers.DDPMScheduler.sample_max_value",description:`<strong>sample_max_value</strong> (<code>float</code>, defaults to 1.0) &#x2014;
The threshold value for dynamic thresholding. Valid only when <code>thresholding=True</code>.`,name:"sample_max_value"},{anchor:"diffusers.DDPMScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, defaults to <code>&quot;leading&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.DDPMScheduler.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/v0.24.0/src/diffusers/schedulers/scheduling_ddpm.py#L92"}}),C=new j({props:{name:"scale_model_input",anchor:"diffusers.DDPMScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.DDPMScheduler.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.24.0/src/diffusers/schedulers/scheduling_ddpm.py#L188",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 j({props:{name:"set_timesteps",anchor:"diffusers.DDPMScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": typing.Optional[int] = None"},{name:"device",val:": typing.Union[str, torch.device] = None"},{name:"timesteps",val:": typing.Optional[typing.List[int]] = None"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.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. If used,
<code>timesteps</code> must be <code>None</code>.`,name:"num_inference_steps"},{anchor:"diffusers.DDPMScheduler.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.DDPMScheduler.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>, then the default
timestep spacing strategy of equal spacing between timesteps is used. If <code>timesteps</code> is passed,
<code>num_inference_steps</code> must be <code>None</code>.`,name:"timesteps"}],source:"https://github.com/huggingface/diffusers/blob/v0.24.0/src/diffusers/schedulers/scheduling_ddpm.py#L205"}}),O=new j({props:{name:"step",anchor:"diffusers.DDPMScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": int"},{name:"sample",val:": FloatTensor"},{name:"generator",val:" = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.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.DDPMScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.DDPMScheduler.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.DDPMScheduler.step.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator.`,name:"generator"},{anchor:"diffusers.DDPMScheduler.step.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/v0.24.0/en/api/schedulers/ddpm#diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput">DDPMSchedulerOutput</a> or <code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.24.0/src/diffusers/schedulers/scheduling_ddpm.py#L353",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/v0.24.0/en/api/schedulers/ddpm#diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput"
>DDPMSchedulerOutput</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/v0.24.0/en/api/schedulers/ddpm#diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput"
>DDPMSchedulerOutput</a> or <code>tuple</code></p>
`}}),F=new he({props:{title:"DDPMSchedulerOutput",local:"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput",headingTag:"h2"}}),I=new j({props:{name:"class diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput",anchor:"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput",parameters:[{name:"prev_sample",val:": FloatTensor"},{name:"pred_original_sample",val:": typing.Optional[torch.FloatTensor] = None"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput.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"},{anchor:"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput.pred_original_sample",description:`<strong>pred_original_sample</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
The predicted denoised sample <code>(x_{0})</code> based on the model output from the current timestep.
<code>pred_original_sample</code> can be used to preview progress or for guidance.`,name:"pred_original_sample"}],source:"https://github.com/huggingface/diffusers/blob/v0.24.0/src/diffusers/schedulers/scheduling_ddpm.py#L31"}}),{c(){p=d("meta"),W=n(),U=d("p"),G=n(),_(P.$$.fragment),J=n(),M=d("p"),M.innerHTML=_e,Y=n(),$=d("p"),$.textContent=ve,B=n(),S=d("p"),S.innerHTML=De,K=n(),_(T.$$.fragment),Q=n(),i=d("div"),_(w.$$.fragment),ie=n(),H=d("p"),H.innerHTML=be,de=n(),E=d("p"),E.innerHTML=xe,ae=n(),f=d("div"),_(C.$$.fragment),ce=n(),A=d("p"),A.textContent=ye,le=n(),h=d("div"),_(L.$$.fragment),pe=n(),V=d("p"),V.textContent=Pe,ue=n(),g=d("div"),_(O.$$.fragment),me=n(),k=d("p"),k.textContent=Me,X=n(),_(F.$$.fragment),Z=n(),u=d("div"),_(I.$$.fragment),fe=n(),z=d("p"),z.innerHTML=$e,ee=n(),R=d("p"),this.h()},l(e){const s=Oe("svelte-u9bgzb",document.head);p=a(s,"META",{name:!0,content:!0}),s.forEach(t),W=o(e),U=a(e,"P",{}),N(U).forEach(t),G=o(e),v(P.$$.fragment,e),J=o(e),M=a(e,"P",{"data-svelte-h":!0}),m(M)!=="svelte-18lgwlw"&&(M.innerHTML=_e),Y=o(e),$=a(e,"P",{"data-svelte-h":!0}),m($)!=="svelte-1cwsb16"&&($.textContent=ve),B=o(e),S=a(e,"P",{"data-svelte-h":!0}),m(S)!=="svelte-ndelhy"&&(S.innerHTML=De),K=o(e),v(T.$$.fragment,e),Q=o(e),i=a(e,"DIV",{class:!0});var l=N(i);v(w.$$.fragment,l),ie=o(l),H=a(l,"P",{"data-svelte-h":!0}),m(H)!=="svelte-s0ec9y"&&(H.innerHTML=be),de=o(l),E=a(l,"P",{"data-svelte-h":!0}),m(E)!=="svelte-dyuhxt"&&(E.innerHTML=xe),ae=o(l),f=a(l,"DIV",{class:!0});var se=N(f);v(C.$$.fragment,se),ce=o(se),A=a(se,"P",{"data-svelte-h":!0}),m(A)!=="svelte-1rkfgpx"&&(A.textContent=ye),se.forEach(t),le=o(l),h=a(l,"DIV",{class:!0});var ne=N(h);v(L.$$.fragment,ne),pe=o(ne),V=a(ne,"P",{"data-svelte-h":!0}),m(V)!=="svelte-1vzm9q"&&(V.textContent=Pe),ne.forEach(t),ue=o(l),g=a(l,"DIV",{class:!0});var oe=N(g);v(O.$$.fragment,oe),me=o(oe),k=a(oe,"P",{"data-svelte-h":!0}),m(k)!=="svelte-hi84tp"&&(k.textContent=Me),oe.forEach(t),l.forEach(t),X=o(e),v(F.$$.fragment,e),Z=o(e),u=a(e,"DIV",{class:!0});var re=N(u);v(I.$$.fragment,re),fe=o(re),z=a(re,"P",{"data-svelte-h":!0}),m(z)!=="svelte-id9kic"&&(z.innerHTML=$e),re.forEach(t),ee=o(e),R=a(e,"P",{}),N(R).forEach(t),this.h()},h(){q(p,"name","hf:doc:metadata"),q(p,"content",Ie),q(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(g,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(u,"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,p),c(e,W,s),c(e,U,s),c(e,G,s),D(P,e,s),c(e,J,s),c(e,M,s),c(e,Y,s),c(e,$,s),c(e,B,s),c(e,S,s),c(e,K,s),D(T,e,s),c(e,Q,s),c(e,i,s),D(w,i,null),r(i,ie),r(i,H),r(i,de),r(i,E),r(i,ae),r(i,f),D(C,f,null),r(f,ce),r(f,A),r(i,le),r(i,h),D(L,h,null),r(h,pe),r(h,V),r(i,ue),r(i,g),D(O,g,null),r(g,me),r(g,k),c(e,X,s),D(F,e,s),c(e,Z,s),c(e,u,s),D(I,u,null),r(u,fe),r(u,z),c(e,ee,s),c(e,R,s),te=!0},p:Te,i(e){te||(b(P.$$.fragment,e),b(T.$$.fragment,e),b(w.$$.fragment,e),b(C.$$.fragment,e),b(L.$$.fragment,e),b(O.$$.fragment,e),b(F.$$.fragment,e),b(I.$$.fragment,e),te=!0)},o(e){x(P.$$.fragment,e),x(T.$$.fragment,e),x(w.$$.fragment,e),x(C.$$.fragment,e),x(L.$$.fragment,e),x(O.$$.fragment,e),x(F.$$.fragment,e),x(I.$$.fragment,e),te=!1},d(e){e&&(t(W),t(U),t(G),t(J),t(M),t(Y),t($),t(B),t(S),t(K),t(Q),t(i),t(X),t(Z),t(u),t(ee),t(R)),t(p),y(P,e),y(T,e),y(w),y(C),y(L),y(O),y(F,e),y(I)}}}const Ie='{"title":"DDPMScheduler","local":"ddpmscheduler","sections":[{"title":"DDPMScheduler","local":"diffusers.DDPMScheduler","sections":[],"depth":2},{"title":"DDPMSchedulerOutput","local":"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput","sections":[],"depth":2}],"depth":1}';function Ne(ge){return we(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ve extends Ce{constructor(p){super(),Le(this,p,Ne,Fe,Se,{})}}export{Ve as component};
