import{S as Wt,i as jt,s as zt,e as s,k as l,w as H,t as i,M as Bt,c as n,d as r,m as c,a as o,x as J,h as a,b as d,G as e,g as h,y as U,L as Kt,q as V,o as G,B as R,v as Qt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as Me}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as _t}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Xt(bt){let v,pe,_,y,Y,E,Ee,Z,Ae,fe,b,w,ee,A,Te,te,Oe,ue,T,O,Ne,ke,he,W,Ce,me,j,Le,ge,P,Fe,N,Ie,qe,ve,D,$,re,k,He,se,Je,_e,p,C,Ue,ne,Ve,Ge,u,z,Re,We,oe,je,ze,ie,Be,Ke,ae,Qe,Xe,B,Ye,Ze,K,et,tt,Q,rt,st,nt,X,ot,L,it,at,x,F,dt,de,lt,ct,S,I,pt,le,ft,ut,M,q,ht,ce,mt,be;return E=new _t({}),A=new _t({}),k=new _t({}),C=new Me({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:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.num_train_timesteps",description:"<strong>num_train_timesteps</strong> (<code>int</code>) &#x2014; number of diffusion steps used to train the model.",name:"num_train_timesteps"},{anchor:"diffusers.DDPMScheduler.beta_start",description:"<strong>beta_start</strong> (<code>float</code>) &#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>) &#x2014; the final <code>beta</code> value.",name:"beta_end"},{anchor:"diffusers.DDPMScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</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.trained_betas",description:`<strong>trained_betas</strong> (<code>np.ndarray</code>, optional) &#x2014;
option to pass an array of betas directly to the constructor to bypass <code>beta_start</code>, <code>beta_end</code> etc.`,name:"trained_betas"},{anchor:"diffusers.DDPMScheduler.variance_type",description:`<strong>variance_type</strong> (<code>str</code>) &#x2014;
options to clip the variance used 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>, default <code>True</code>) &#x2014;
option to clip predicted sample between -1 and 1 for numerical stability.`,name:"clip_sample"},{anchor:"diffusers.DDPMScheduler.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, default <code>epsilon</code>, optional) &#x2014;
prediction type of the scheduler function, one of <code>epsilon</code> (predicting the noise of the diffusion
process), <code>sample</code> (directly predicting the noisy sample<code>) or </code>v_prediction\` (see section 2.4
<a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">https://imagen.research.google/video/paper.pdf</a>)`,name:"prediction_type"}],source:"https://github.com/huggingface/diffusers/blob/v0.12.0/src/diffusers/schedulers/scheduling_ddpm.py#L76"}}),F=new Me({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; input sample",name:"sample"},{anchor:"diffusers.DDPMScheduler.scale_model_input.timestep",description:"<strong>timestep</strong> (<code>int</code>, optional) &#x2014; current timestep",name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/v0.12.0/src/diffusers/schedulers/scheduling_ddpm.py#L165",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),I=new Me({props:{name:"set_timesteps",anchor:"diffusers.DDPMScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = 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.`,name:"num_inference_steps"}],source:"https://github.com/huggingface/diffusers/blob/v0.12.0/src/diffusers/schedulers/scheduling_ddpm.py#L179"}}),q=new Me({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"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.DDPMScheduler.step.model_output",description:"<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014; direct output from learned diffusion model.",name:"model_output"},{anchor:"diffusers.DDPMScheduler.step.timestep",description:"<strong>timestep</strong> (<code>int</code>) &#x2014; current discrete timestep in the diffusion chain.",name:"timestep"},{anchor:"diffusers.DDPMScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
current instance of sample being created by diffusion process.
generator &#x2014; random number generator.`,name:"sample"},{anchor:"diffusers.DDPMScheduler.step.return_dict",description:"<strong>return_dict</strong> (<code>bool</code>) &#x2014; option for returning tuple rather than DDPMSchedulerOutput class",name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.12.0/src/diffusers/schedulers/scheduling_ddpm.py#L235",returnDescription:`
<p><code>~schedulers.scheduling_utils.DDPMSchedulerOutput</code> if <code>return_dict</code> is True, otherwise a <code>tuple</code>. When
returning a tuple, the first element is the sample tensor.</p>
`,returnType:`
<p><code>~schedulers.scheduling_utils.DDPMSchedulerOutput</code> or <code>tuple</code></p>
`}}),{c(){v=s("meta"),pe=l(),_=s("h1"),y=s("a"),Y=s("span"),H(E.$$.fragment),Ee=l(),Z=s("span"),Ae=i("Denoising diffusion probabilistic models (DDPM)"),fe=l(),b=s("h2"),w=s("a"),ee=s("span"),H(A.$$.fragment),Te=l(),te=s("span"),Oe=i("Overview"),ue=l(),T=s("p"),O=s("a"),Ne=i("Denoising Diffusion Probabilistic Models"),ke=i(`
(DDPM) by Jonathan Ho, Ajay Jain and Pieter Abbeel proposes the diffusion based model of the same name, but in the context of the \u{1F917} Diffusers library, DDPM refers to the discrete denoising scheduler from the paper as well as the pipeline.`),he=l(),W=s("p"),Ce=i("The abstract of the paper is the following:"),me=l(),j=s("p"),Le=i("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."),ge=l(),P=s("p"),Fe=i("The original paper can be found "),N=s("a"),Ie=i("here"),qe=i("."),ve=l(),D=s("h2"),$=s("a"),re=s("span"),H(k.$$.fragment),He=l(),se=s("span"),Je=i("DDPMScheduler"),_e=l(),p=s("div"),H(C.$$.fragment),Ue=l(),ne=s("p"),Ve=i(`Denoising diffusion probabilistic models (DDPMs) explores the connections between denoising score matching and
Langevin dynamics sampling.`),Ge=l(),u=s("p"),z=s("a"),Re=i("~ConfigMixin"),We=i(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),oe=s("code"),je=i("__init__"),ze=i(`
function, such as `),ie=s("code"),Be=i("num_train_timesteps"),Ke=i(". They can be accessed via "),ae=s("code"),Qe=i("scheduler.config.num_train_timesteps"),Xe=i(`.
`),B=s("a"),Ye=i("SchedulerMixin"),Ze=i(" provides general loading and saving functionality via the "),K=s("a"),et=i("SchedulerMixin.save_pretrained()"),tt=i(` and
`),Q=s("a"),rt=i("from_pretrained()"),st=i(" functions."),nt=l(),X=s("p"),ot=i("For more details, see the original paper: "),L=s("a"),it=i("https://arxiv.org/abs/2006.11239"),at=l(),x=s("div"),H(F.$$.fragment),dt=l(),de=s("p"),lt=i(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),ct=l(),S=s("div"),H(I.$$.fragment),pt=l(),le=s("p"),ft=i("Sets the discrete timesteps used for the diffusion chain. Supporting function to be run before inference."),ut=l(),M=s("div"),H(q.$$.fragment),ht=l(),ce=s("p"),mt=i(`Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
process from the learned model outputs (most often the predicted noise).`),this.h()},l(t){const f=Bt('[data-svelte="svelte-1phssyn"]',document.head);v=n(f,"META",{name:!0,content:!0}),f.forEach(r),pe=c(t),_=n(t,"H1",{class:!0});var De=o(_);y=n(De,"A",{id:!0,class:!0,href:!0});var Dt=o(y);Y=n(Dt,"SPAN",{});var yt=o(Y);J(E.$$.fragment,yt),yt.forEach(r),Dt.forEach(r),Ee=c(De),Z=n(De,"SPAN",{});var wt=o(Z);Ae=a(wt,"Denoising diffusion probabilistic models (DDPM)"),wt.forEach(r),De.forEach(r),fe=c(t),b=n(t,"H2",{class:!0});var ye=o(b);w=n(ye,"A",{id:!0,class:!0,href:!0});var Pt=o(w);ee=n(Pt,"SPAN",{});var $t=o(ee);J(A.$$.fragment,$t),$t.forEach(r),Pt.forEach(r),Te=c(ye),te=n(ye,"SPAN",{});var xt=o(te);Oe=a(xt,"Overview"),xt.forEach(r),ye.forEach(r),ue=c(t),T=n(t,"P",{});var gt=o(T);O=n(gt,"A",{href:!0,rel:!0});var St=o(O);Ne=a(St,"Denoising Diffusion Probabilistic Models"),St.forEach(r),ke=a(gt,`
(DDPM) by Jonathan Ho, Ajay Jain and Pieter Abbeel proposes the diffusion based model of the same name, but in the context of the \u{1F917} Diffusers library, DDPM refers to the discrete denoising scheduler from the paper as well as the pipeline.`),gt.forEach(r),he=c(t),W=n(t,"P",{});var Mt=o(W);Ce=a(Mt,"The abstract of the paper is the following:"),Mt.forEach(r),me=c(t),j=n(t,"P",{});var Et=o(j);Le=a(Et,"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."),Et.forEach(r),ge=c(t),P=n(t,"P",{});var we=o(P);Fe=a(we,"The original paper can be found "),N=n(we,"A",{href:!0,rel:!0});var At=o(N);Ie=a(At,"here"),At.forEach(r),qe=a(we,"."),we.forEach(r),ve=c(t),D=n(t,"H2",{class:!0});var Pe=o(D);$=n(Pe,"A",{id:!0,class:!0,href:!0});var Tt=o($);re=n(Tt,"SPAN",{});var Ot=o(re);J(k.$$.fragment,Ot),Ot.forEach(r),Tt.forEach(r),He=c(Pe),se=n(Pe,"SPAN",{});var Nt=o(se);Je=a(Nt,"DDPMScheduler"),Nt.forEach(r),Pe.forEach(r),_e=c(t),p=n(t,"DIV",{class:!0});var g=o(p);J(C.$$.fragment,g),Ue=c(g),ne=n(g,"P",{});var kt=o(ne);Ve=a(kt,`Denoising diffusion probabilistic models (DDPMs) explores the connections between denoising score matching and
Langevin dynamics sampling.`),kt.forEach(r),Ge=c(g),u=n(g,"P",{});var m=o(u);z=n(m,"A",{href:!0});var Ct=o(z);Re=a(Ct,"~ConfigMixin"),Ct.forEach(r),We=a(m," takes care of storing all config attributes that are passed in the scheduler\u2019s "),oe=n(m,"CODE",{});var Lt=o(oe);je=a(Lt,"__init__"),Lt.forEach(r),ze=a(m,`
function, such as `),ie=n(m,"CODE",{});var Ft=o(ie);Be=a(Ft,"num_train_timesteps"),Ft.forEach(r),Ke=a(m,". They can be accessed via "),ae=n(m,"CODE",{});var It=o(ae);Qe=a(It,"scheduler.config.num_train_timesteps"),It.forEach(r),Xe=a(m,`.
`),B=n(m,"A",{href:!0});var qt=o(B);Ye=a(qt,"SchedulerMixin"),qt.forEach(r),Ze=a(m," provides general loading and saving functionality via the "),K=n(m,"A",{href:!0});var Ht=o(K);et=a(Ht,"SchedulerMixin.save_pretrained()"),Ht.forEach(r),tt=a(m,` and
`),Q=n(m,"A",{href:!0});var Jt=o(Q);rt=a(Jt,"from_pretrained()"),Jt.forEach(r),st=a(m," functions."),m.forEach(r),nt=c(g),X=n(g,"P",{});var vt=o(X);ot=a(vt,"For more details, see the original paper: "),L=n(vt,"A",{href:!0,rel:!0});var Ut=o(L);it=a(Ut,"https://arxiv.org/abs/2006.11239"),Ut.forEach(r),vt.forEach(r),at=c(g),x=n(g,"DIV",{class:!0});var $e=o(x);J(F.$$.fragment,$e),dt=c($e),de=n($e,"P",{});var Vt=o(de);lt=a(Vt,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),Vt.forEach(r),$e.forEach(r),ct=c(g),S=n(g,"DIV",{class:!0});var xe=o(S);J(I.$$.fragment,xe),pt=c(xe),le=n(xe,"P",{});var Gt=o(le);ft=a(Gt,"Sets the discrete timesteps used for the diffusion chain. Supporting function to be run before inference."),Gt.forEach(r),xe.forEach(r),ut=c(g),M=n(g,"DIV",{class:!0});var Se=o(M);J(q.$$.fragment,Se),ht=c(Se),ce=n(Se,"P",{});var Rt=o(ce);mt=a(Rt,`Predict the sample at the previous timestep by reversing the SDE. Core function to propagate the diffusion
process from the learned model outputs (most often the predicted noise).`),Rt.forEach(r),Se.forEach(r),g.forEach(r),this.h()},h(){d(v,"name","hf:doc:metadata"),d(v,"content",JSON.stringify(Yt)),d(y,"id","denoising-diffusion-probabilistic-models-ddpm"),d(y,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(y,"href","#denoising-diffusion-probabilistic-models-ddpm"),d(_,"class","relative group"),d(w,"id","overview"),d(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(w,"href","#overview"),d(b,"class","relative group"),d(O,"href","https://arxiv.org/abs/2006.11239"),d(O,"rel","nofollow"),d(N,"href","https://arxiv.org/abs/2010.02502"),d(N,"rel","nofollow"),d($,"id","diffusers.DDPMScheduler"),d($,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d($,"href","#diffusers.DDPMScheduler"),d(D,"class","relative group"),d(z,"href","/docs/diffusers/v0.12.0/en/api/configuration#diffusers.ConfigMixin"),d(B,"href","/docs/diffusers/v0.12.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),d(K,"href","/docs/diffusers/v0.12.0/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),d(Q,"href","/docs/diffusers/v0.12.0/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),d(L,"href","https://arxiv.org/abs/2006.11239"),d(L,"rel","nofollow"),d(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(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(t,f){e(document.head,v),h(t,pe,f),h(t,_,f),e(_,y),e(y,Y),U(E,Y,null),e(_,Ee),e(_,Z),e(Z,Ae),h(t,fe,f),h(t,b,f),e(b,w),e(w,ee),U(A,ee,null),e(b,Te),e(b,te),e(te,Oe),h(t,ue,f),h(t,T,f),e(T,O),e(O,Ne),e(T,ke),h(t,he,f),h(t,W,f),e(W,Ce),h(t,me,f),h(t,j,f),e(j,Le),h(t,ge,f),h(t,P,f),e(P,Fe),e(P,N),e(N,Ie),e(P,qe),h(t,ve,f),h(t,D,f),e(D,$),e($,re),U(k,re,null),e(D,He),e(D,se),e(se,Je),h(t,_e,f),h(t,p,f),U(C,p,null),e(p,Ue),e(p,ne),e(ne,Ve),e(p,Ge),e(p,u),e(u,z),e(z,Re),e(u,We),e(u,oe),e(oe,je),e(u,ze),e(u,ie),e(ie,Be),e(u,Ke),e(u,ae),e(ae,Qe),e(u,Xe),e(u,B),e(B,Ye),e(u,Ze),e(u,K),e(K,et),e(u,tt),e(u,Q),e(Q,rt),e(u,st),e(p,nt),e(p,X),e(X,ot),e(X,L),e(L,it),e(p,at),e(p,x),U(F,x,null),e(x,dt),e(x,de),e(de,lt),e(p,ct),e(p,S),U(I,S,null),e(S,pt),e(S,le),e(le,ft),e(p,ut),e(p,M),U(q,M,null),e(M,ht),e(M,ce),e(ce,mt),be=!0},p:Kt,i(t){be||(V(E.$$.fragment,t),V(A.$$.fragment,t),V(k.$$.fragment,t),V(C.$$.fragment,t),V(F.$$.fragment,t),V(I.$$.fragment,t),V(q.$$.fragment,t),be=!0)},o(t){G(E.$$.fragment,t),G(A.$$.fragment,t),G(k.$$.fragment,t),G(C.$$.fragment,t),G(F.$$.fragment,t),G(I.$$.fragment,t),G(q.$$.fragment,t),be=!1},d(t){r(v),t&&r(pe),t&&r(_),R(E),t&&r(fe),t&&r(b),R(A),t&&r(ue),t&&r(T),t&&r(he),t&&r(W),t&&r(me),t&&r(j),t&&r(ge),t&&r(P),t&&r(ve),t&&r(D),R(k),t&&r(_e),t&&r(p),R(C),R(F),R(I),R(q)}}}const Yt={local:"denoising-diffusion-probabilistic-models-ddpm",sections:[{local:"overview",title:"Overview"},{local:"diffusers.DDPMScheduler",title:"DDPMScheduler"}],title:"Denoising diffusion probabilistic models (DDPM)"};function Zt(bt){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class sr extends Wt{constructor(v){super();jt(this,v,Zt,Xt,zt,{})}}export{sr as default,Yt as metadata};
