import{s as Le,n as Oe,o as Ne}from"../chunks/scheduler.53228c21.js";import{S as qe,i as Ie,e as d,s as n,c as p,h as Ee,a as c,d as t,b as o,f as H,g as u,j as D,k as z,l as r,m as i,n as m,t as f,o as h,p as g}from"../chunks/index.100fac89.js";import{C as He}from"../chunks/CopyLLMTxtMenu.2cdbb51f.js";import{D as G}from"../chunks/Docstring.d46840f1.js";import{H as De,E as ze}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.3fcbbc76.js";function Ae(ve){let _,J,W,B,y,K,P,Q,M,xe='<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.',X,S,$e="The abstract from the paper is:",Y,T,ye='<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>',Z,w,ee,a,C,le,A,Pe="<code>DDPMScheduler</code> explores the connections between denoising score matching and Langevin dynamics sampling.",pe,V,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.`,ue,v,L,me,F,Se=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,fe,x,O,he,k,Te="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",ge,$,N,_e,R,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).`,te,q,se,b,I,be,U,Ce="Output class for the scheduler’s <code>step</code> function output.",ne,E,oe,j,re;return y=new He({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),P=new De({props:{title:"DDPMScheduler",local:"ddpmscheduler",headingTag:"h1"}}),w=new De({props:{title:"DDPMScheduler",local:"diffusers.DDPMScheduler",headingTag:"h2"}}),C=new G({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"},{name:"rescale_betas_zero_snr",val:": bool = False"}],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>, <code>squaredcos_cap_v2</code>, or <code>sigmoid</code>.`,name:"beta_schedule"},{anchor:"diffusers.DDPMScheduler.trained_betas",description:`<strong>trained_betas</strong> (<code>np.ndarray</code>, <em>optional</em>) &#x2014;
An array of betas to pass directly to the constructor without using <code>beta_start</code> and <code>beta_end</code>.`,name:"trained_betas"},{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, as required by some model families.`,name:"steps_offset"},{anchor:"diffusers.DDPMScheduler.rescale_betas_zero_snr",description:`<strong>rescale_betas_zero_snr</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to rescale the betas to have zero terminal SNR. This enables the model to generate very bright and
dark samples instead of limiting it to samples with medium brightness. Loosely related to
<a href="https://github.com/huggingface/diffusers/blob/74fd735eb073eb1d774b1ab4154a0876eb82f055/examples/dreambooth/train_dreambooth.py#L506" rel="nofollow"><code>--offset_noise</code></a>.`,name:"rescale_betas_zero_snr"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddpm.py#L129"}}),L=new G({props:{name:"scale_model_input",anchor:"diffusers.DDPMScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.Tensor</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/main/src/diffusers/schedulers/scheduling_ddpm.py#L234",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>
`}}),O=new G({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/main/src/diffusers/schedulers/scheduling_ddpm.py#L251"}}),N=new G({props:{name:"step",anchor:"diffusers.DDPMScheduler.step",parameters:[{name:"model_output",val:": Tensor"},{name:"timestep",val:": int"},{name:"sample",val:": Tensor"},{name:"generator",val:" = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.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.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.Tensor</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/main/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/main/src/diffusers/schedulers/scheduling_ddpm.py#L398",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/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/main/en/api/schedulers/ddpm#diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput"
>DDPMSchedulerOutput</a> or <code>tuple</code></p>
`}}),q=new De({props:{title:"DDPMSchedulerOutput",local:"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput",headingTag:"h2"}}),I=new G({props:{name:"class diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput",anchor:"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput",parameters:[{name:"prev_sample",val:": Tensor"},{name:"pred_original_sample",val:": typing.Optional[torch.Tensor] = None"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput.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"},{anchor:"diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput.pred_original_sample",description:`<strong>pred_original_sample</strong> (<code>torch.Tensor</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/main/src/diffusers/schedulers/scheduling_ddpm.py#L31"}}),E=new ze({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/schedulers/ddpm.md"}}),{c(){_=d("meta"),J=n(),W=d("p"),B=n(),p(y.$$.fragment),K=n(),p(P.$$.fragment),Q=n(),M=d("p"),M.innerHTML=xe,X=n(),S=d("p"),S.textContent=$e,Y=n(),T=d("p"),T.innerHTML=ye,Z=n(),p(w.$$.fragment),ee=n(),a=d("div"),p(C.$$.fragment),le=n(),A=d("p"),A.innerHTML=Pe,pe=n(),V=d("p"),V.innerHTML=Me,ue=n(),v=d("div"),p(L.$$.fragment),me=n(),F=d("p"),F.textContent=Se,fe=n(),x=d("div"),p(O.$$.fragment),he=n(),k=d("p"),k.textContent=Te,ge=n(),$=d("div"),p(N.$$.fragment),_e=n(),R=d("p"),R.textContent=we,te=n(),p(q.$$.fragment),se=n(),b=d("div"),p(I.$$.fragment),be=n(),U=d("p"),U.innerHTML=Ce,ne=n(),p(E.$$.fragment),oe=n(),j=d("p"),this.h()},l(e){const s=Ee("svelte-u9bgzb",document.head);_=c(s,"META",{name:!0,content:!0}),s.forEach(t),J=o(e),W=c(e,"P",{}),H(W).forEach(t),B=o(e),u(y.$$.fragment,e),K=o(e),u(P.$$.fragment,e),Q=o(e),M=c(e,"P",{"data-svelte-h":!0}),D(M)!=="svelte-18lgwlw"&&(M.innerHTML=xe),X=o(e),S=c(e,"P",{"data-svelte-h":!0}),D(S)!=="svelte-1cwsb16"&&(S.textContent=$e),Y=o(e),T=c(e,"P",{"data-svelte-h":!0}),D(T)!=="svelte-ndelhy"&&(T.innerHTML=ye),Z=o(e),u(w.$$.fragment,e),ee=o(e),a=c(e,"DIV",{class:!0});var l=H(a);u(C.$$.fragment,l),le=o(l),A=c(l,"P",{"data-svelte-h":!0}),D(A)!=="svelte-s0ec9y"&&(A.innerHTML=Pe),pe=o(l),V=c(l,"P",{"data-svelte-h":!0}),D(V)!=="svelte-linuuh"&&(V.innerHTML=Me),ue=o(l),v=c(l,"DIV",{class:!0});var ie=H(v);u(L.$$.fragment,ie),me=o(ie),F=c(ie,"P",{"data-svelte-h":!0}),D(F)!=="svelte-1rkfgpx"&&(F.textContent=Se),ie.forEach(t),fe=o(l),x=c(l,"DIV",{class:!0});var ae=H(x);u(O.$$.fragment,ae),he=o(ae),k=c(ae,"P",{"data-svelte-h":!0}),D(k)!=="svelte-1vzm9q"&&(k.textContent=Te),ae.forEach(t),ge=o(l),$=c(l,"DIV",{class:!0});var de=H($);u(N.$$.fragment,de),_e=o(de),R=c(de,"P",{"data-svelte-h":!0}),D(R)!=="svelte-hi84tp"&&(R.textContent=we),de.forEach(t),l.forEach(t),te=o(e),u(q.$$.fragment,e),se=o(e),b=c(e,"DIV",{class:!0});var ce=H(b);u(I.$$.fragment,ce),be=o(ce),U=c(ce,"P",{"data-svelte-h":!0}),D(U)!=="svelte-id9kic"&&(U.innerHTML=Ce),ce.forEach(t),ne=o(e),u(E.$$.fragment,e),oe=o(e),j=c(e,"P",{}),H(j).forEach(t),this.h()},h(){z(_,"name","hf:doc:metadata"),z(_,"content",Ve),z(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(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){r(document.head,_),i(e,J,s),i(e,W,s),i(e,B,s),m(y,e,s),i(e,K,s),m(P,e,s),i(e,Q,s),i(e,M,s),i(e,X,s),i(e,S,s),i(e,Y,s),i(e,T,s),i(e,Z,s),m(w,e,s),i(e,ee,s),i(e,a,s),m(C,a,null),r(a,le),r(a,A),r(a,pe),r(a,V),r(a,ue),r(a,v),m(L,v,null),r(v,me),r(v,F),r(a,fe),r(a,x),m(O,x,null),r(x,he),r(x,k),r(a,ge),r(a,$),m(N,$,null),r($,_e),r($,R),i(e,te,s),m(q,e,s),i(e,se,s),i(e,b,s),m(I,b,null),r(b,be),r(b,U),i(e,ne,s),m(E,e,s),i(e,oe,s),i(e,j,s),re=!0},p:Oe,i(e){re||(f(y.$$.fragment,e),f(P.$$.fragment,e),f(w.$$.fragment,e),f(C.$$.fragment,e),f(L.$$.fragment,e),f(O.$$.fragment,e),f(N.$$.fragment,e),f(q.$$.fragment,e),f(I.$$.fragment,e),f(E.$$.fragment,e),re=!0)},o(e){h(y.$$.fragment,e),h(P.$$.fragment,e),h(w.$$.fragment,e),h(C.$$.fragment,e),h(L.$$.fragment,e),h(O.$$.fragment,e),h(N.$$.fragment,e),h(q.$$.fragment,e),h(I.$$.fragment,e),h(E.$$.fragment,e),re=!1},d(e){e&&(t(J),t(W),t(B),t(K),t(Q),t(M),t(X),t(S),t(Y),t(T),t(Z),t(ee),t(a),t(te),t(se),t(b),t(ne),t(oe),t(j)),t(_),g(y,e),g(P,e),g(w,e),g(C),g(L),g(O),g(N),g(q,e),g(I),g(E,e)}}}const Ve='{"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 Fe(ve){return Ne(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ge extends qe{constructor(_){super(),Ie(this,_,Fe,Ae,Le,{})}}export{Ge as component};
