import{S as _t,i as bt,s as vt,e as s,k as h,w as S,t as d,M as Pt,c as a,d as t,m as g,a as i,x as k,h as c,b as p,G as n,g as f,y as T,q as j,o as A,B as O,v as yt,L as $t}from"../../../chunks/vendor-hf-doc-builder.js";import{T as Dt}from"../../../chunks/Tip-hf-doc-builder.js";import{D as Qe}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as wt}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ye}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Mt}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Et(X){let l,y,u,m,_,r,b,M;return{c(){l=s("p"),y=d("Make sure to check out the Schedulers "),u=s("a"),m=d("guide"),_=d(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),r=s("a"),b=d("reuse components across pipelines"),M=d(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(E){l=a(E,"P",{});var v=i(l);y=c(v,"Make sure to check out the Schedulers "),u=a(v,"A",{href:!0});var $=i(u);m=c($,"guide"),$.forEach(t),_=c(v," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),r=a(v,"A",{href:!0});var D=i(r);b=c(D,"reuse components across pipelines"),D.forEach(t),M=c(v," section to learn how to efficiently load the same components into multiple pipelines."),v.forEach(t),this.h()},h(){p(u,"href","/using-diffusers/schedulers"),p(r,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(E,v){f(E,l,v),n(l,y),n(l,u),n(u,m),n(l,_),n(l,r),n(r,b),n(l,M)},d(E){E&&t(l)}}}function It(X){let l,y,u,m,_;return m=new wt({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEREUE1QaXBlbGluZSUwQSUwQSUyMyUyMGxvYWQlMjBtb2RlbCUyMGFuZCUyMHNjaGVkdWxlciUwQXBpcGUlMjAlM0QlMjBERFBNUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRmRkcG0tY2F0LTI1NiUyMiklMEElMEElMjMlMjBydW4lMjBwaXBlbGluZSUyMGluJTIwaW5mZXJlbmNlJTIwKHNhbXBsZSUyMHJhbmRvbSUyMG5vaXNlJTIwYW5kJTIwZGVub2lzZSklMEFpbWFnZSUyMCUzRCUyMHBpcGUoKS5pbWFnZXMlNUIwJTVEJTBBJTBBJTIzJTIwc2F2ZSUyMGltYWdlJTBBaW1hZ2Uuc2F2ZSglMjJkZHBtX2dlbmVyYXRlZF9pbWFnZS5wbmclMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDPMPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load model and scheduler</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = DDPMPipeline.from_pretrained(<span class="hljs-string">&quot;google/ddpm-cat-256&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># run pipeline in inference (sample random noise and denoise)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe().images[<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># save image</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;ddpm_generated_image.png&quot;</span>)`}}),{c(){l=s("p"),y=d("Example:"),u=h(),S(m.$$.fragment)},l(r){l=a(r,"P",{});var b=i(l);y=c(b,"Example:"),b.forEach(t),u=g(r),k(m.$$.fragment,r)},m(r,b){f(r,l,b),n(l,y),f(r,u,b),T(m,r,b),_=!0},p:$t,i(r){_||(j(m.$$.fragment,r),_=!0)},o(r){A(m.$$.fragment,r),_=!1},d(r){r&&t(l),r&&t(u),O(m,r)}}}function xt(X){let l,y,u,m,_,r,b,M,E,v,$,D,Ee,Ie,te,xe,Ue,fe,Q,Se,ue,Y,ne,ke,me,G,Te,L,je,Ae,he,N,ge,I,Z,se,q,Oe,ae,Ge,_e,P,F,Ne,ie,Ze,Be,W,Je,K,Ce,Le,qe,w,R,Fe,re,We,Re,B,be,x,J,oe,z,ze,le,Ve,ve,U,V,He,pe,Xe,Pe;return r=new Ye({}),N=new Dt({props:{$$slots:{default:[Et]},$$scope:{ctx:X}}}),q=new Ye({}),F=new Qe({props:{name:"class diffusers.DDPMPipeline",anchor:"diffusers.DDPMPipeline",parameters:[{name:"unet",val:""},{name:"scheduler",val:""}],parametersDescription:[{anchor:"diffusers.DDPMPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet2d#diffusers.UNet2DModel">UNet2DModel</a>) &#x2014;
A <code>UNet2DModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.DDPMPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image. Can be one of
<a href="/docs/diffusers/main/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>, or <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L24"}}),R=new Qe({props:{name:"__call__",anchor:"diffusers.DDPMPipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"num_inference_steps",val:": int = 1000"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DDPMPipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate.`,name:"batch_size"},{anchor:"diffusers.DDPMPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.DDPMPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1000) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.DDPMPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.DDPMPipeline.__call__.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/pipelines/latent_diffusion_uncond#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L43",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/latent_diffusion_uncond#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated images</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/latent_diffusion_uncond#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),B=new Mt({props:{anchor:"diffusers.DDPMPipeline.__call__.example",$$slots:{default:[It]},$$scope:{ctx:X}}}),z=new Ye({}),V=new Qe({props:{name:"class diffusers.ImagePipelineOutput",anchor:"diffusers.ImagePipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"}],parametersDescription:[{anchor:"diffusers.ImagePipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L112"}}),{c(){l=s("meta"),y=h(),u=s("h1"),m=s("a"),_=s("span"),S(r.$$.fragment),b=h(),M=s("span"),E=d("DDPM"),v=h(),$=s("p"),D=s("a"),Ee=d("Denoising Diffusion Probabilistic Models"),Ie=d(" (DDPM) by Jonathan Ho, Ajay Jain and Pieter Abbeel proposes a diffusion based model of the same name. In the \u{1F917} Diffusers library, DDPM refers to the "),te=s("em"),xe=d("discrete denoising scheduler"),Ue=d(" from the paper as well as the pipeline."),fe=h(),Q=s("p"),Se=d("The abstract from the paper is:"),ue=h(),Y=s("p"),ne=s("em"),ke=d("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."),me=h(),G=s("p"),Te=d("The original codebase can be found at "),L=s("a"),je=d("hohonathanho/diffusion"),Ae=d("."),he=h(),S(N.$$.fragment),ge=h(),I=s("h1"),Z=s("a"),se=s("span"),S(q.$$.fragment),Oe=h(),ae=s("span"),Ge=d("DDPMPipeline"),_e=h(),P=s("div"),S(F.$$.fragment),Ne=h(),ie=s("p"),Ze=d("Pipeline for image generation."),Be=h(),W=s("p"),Je=d("This model inherits from "),K=s("a"),Ce=d("DiffusionPipeline"),Le=d(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),qe=h(),w=s("div"),S(R.$$.fragment),Fe=h(),re=s("p"),We=d("The call function to the pipeline for generation."),Re=h(),S(B.$$.fragment),be=h(),x=s("h2"),J=s("a"),oe=s("span"),S(z.$$.fragment),ze=h(),le=s("span"),Ve=d("ImagePipelineOutput"),ve=h(),U=s("div"),S(V.$$.fragment),He=h(),pe=s("p"),Xe=d("Output class for image pipelines."),this.h()},l(e){const o=Pt('[data-svelte="svelte-1phssyn"]',document.head);l=a(o,"META",{name:!0,content:!0}),o.forEach(t),y=g(e),u=a(e,"H1",{class:!0});var H=i(u);m=a(H,"A",{id:!0,class:!0,href:!0});var de=i(m);_=a(de,"SPAN",{});var Ke=i(_);k(r.$$.fragment,Ke),Ke.forEach(t),de.forEach(t),b=g(H),M=a(H,"SPAN",{});var et=i(M);E=c(et,"DDPM"),et.forEach(t),H.forEach(t),v=g(e),$=a(e,"P",{});var ce=i($);D=a(ce,"A",{href:!0,rel:!0});var tt=i(D);Ee=c(tt,"Denoising Diffusion Probabilistic Models"),tt.forEach(t),Ie=c(ce," (DDPM) by Jonathan Ho, Ajay Jain and Pieter Abbeel proposes a diffusion based model of the same name. In the \u{1F917} Diffusers library, DDPM refers to the "),te=a(ce,"EM",{});var nt=i(te);xe=c(nt,"discrete denoising scheduler"),nt.forEach(t),Ue=c(ce," from the paper as well as the pipeline."),ce.forEach(t),fe=g(e),Q=a(e,"P",{});var st=i(Q);Se=c(st,"The abstract from the paper is:"),st.forEach(t),ue=g(e),Y=a(e,"P",{});var at=i(Y);ne=a(at,"EM",{});var it=i(ne);ke=c(it,"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."),it.forEach(t),at.forEach(t),me=g(e),G=a(e,"P",{});var ye=i(G);Te=c(ye,"The original codebase can be found at "),L=a(ye,"A",{href:!0,rel:!0});var rt=i(L);je=c(rt,"hohonathanho/diffusion"),rt.forEach(t),Ae=c(ye,"."),ye.forEach(t),he=g(e),k(N.$$.fragment,e),ge=g(e),I=a(e,"H1",{class:!0});var $e=i(I);Z=a($e,"A",{id:!0,class:!0,href:!0});var ot=i(Z);se=a(ot,"SPAN",{});var lt=i(se);k(q.$$.fragment,lt),lt.forEach(t),ot.forEach(t),Oe=g($e),ae=a($e,"SPAN",{});var pt=i(ae);Ge=c(pt,"DDPMPipeline"),pt.forEach(t),$e.forEach(t),_e=g(e),P=a(e,"DIV",{class:!0});var C=i(P);k(F.$$.fragment,C),Ne=g(C),ie=a(C,"P",{});var dt=i(ie);Ze=c(dt,"Pipeline for image generation."),dt.forEach(t),Be=g(C),W=a(C,"P",{});var De=i(W);Je=c(De,"This model inherits from "),K=a(De,"A",{href:!0});var ct=i(K);Ce=c(ct,"DiffusionPipeline"),ct.forEach(t),Le=c(De,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),De.forEach(t),qe=g(C),w=a(C,"DIV",{class:!0});var ee=i(w);k(R.$$.fragment,ee),Fe=g(ee),re=a(ee,"P",{});var ft=i(re);We=c(ft,"The call function to the pipeline for generation."),ft.forEach(t),Re=g(ee),k(B.$$.fragment,ee),ee.forEach(t),C.forEach(t),be=g(e),x=a(e,"H2",{class:!0});var we=i(x);J=a(we,"A",{id:!0,class:!0,href:!0});var ut=i(J);oe=a(ut,"SPAN",{});var mt=i(oe);k(z.$$.fragment,mt),mt.forEach(t),ut.forEach(t),ze=g(we),le=a(we,"SPAN",{});var ht=i(le);Ve=c(ht,"ImagePipelineOutput"),ht.forEach(t),we.forEach(t),ve=g(e),U=a(e,"DIV",{class:!0});var Me=i(U);k(V.$$.fragment,Me),He=g(Me),pe=a(Me,"P",{});var gt=i(pe);Xe=c(gt,"Output class for image pipelines."),gt.forEach(t),Me.forEach(t),this.h()},h(){p(l,"name","hf:doc:metadata"),p(l,"content",JSON.stringify(Ut)),p(m,"id","ddpm"),p(m,"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"),p(m,"href","#ddpm"),p(u,"class","relative group"),p(D,"href","https://huggingface.co/papers/2006.11239"),p(D,"rel","nofollow"),p(L,"href","https://github.com/hojonathanho/diffusion"),p(L,"rel","nofollow"),p(Z,"id","diffusers.DDPMPipeline"),p(Z,"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"),p(Z,"href","#diffusers.DDPMPipeline"),p(I,"class","relative group"),p(K,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),p(w,"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"),p(J,"id","diffusers.ImagePipelineOutput"),p(J,"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"),p(J,"href","#diffusers.ImagePipelineOutput"),p(x,"class","relative group"),p(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,o){n(document.head,l),f(e,y,o),f(e,u,o),n(u,m),n(m,_),T(r,_,null),n(u,b),n(u,M),n(M,E),f(e,v,o),f(e,$,o),n($,D),n(D,Ee),n($,Ie),n($,te),n(te,xe),n($,Ue),f(e,fe,o),f(e,Q,o),n(Q,Se),f(e,ue,o),f(e,Y,o),n(Y,ne),n(ne,ke),f(e,me,o),f(e,G,o),n(G,Te),n(G,L),n(L,je),n(G,Ae),f(e,he,o),T(N,e,o),f(e,ge,o),f(e,I,o),n(I,Z),n(Z,se),T(q,se,null),n(I,Oe),n(I,ae),n(ae,Ge),f(e,_e,o),f(e,P,o),T(F,P,null),n(P,Ne),n(P,ie),n(ie,Ze),n(P,Be),n(P,W),n(W,Je),n(W,K),n(K,Ce),n(W,Le),n(P,qe),n(P,w),T(R,w,null),n(w,Fe),n(w,re),n(re,We),n(w,Re),T(B,w,null),f(e,be,o),f(e,x,o),n(x,J),n(J,oe),T(z,oe,null),n(x,ze),n(x,le),n(le,Ve),f(e,ve,o),f(e,U,o),T(V,U,null),n(U,He),n(U,pe),n(pe,Xe),Pe=!0},p(e,[o]){const H={};o&2&&(H.$$scope={dirty:o,ctx:e}),N.$set(H);const de={};o&2&&(de.$$scope={dirty:o,ctx:e}),B.$set(de)},i(e){Pe||(j(r.$$.fragment,e),j(N.$$.fragment,e),j(q.$$.fragment,e),j(F.$$.fragment,e),j(R.$$.fragment,e),j(B.$$.fragment,e),j(z.$$.fragment,e),j(V.$$.fragment,e),Pe=!0)},o(e){A(r.$$.fragment,e),A(N.$$.fragment,e),A(q.$$.fragment,e),A(F.$$.fragment,e),A(R.$$.fragment,e),A(B.$$.fragment,e),A(z.$$.fragment,e),A(V.$$.fragment,e),Pe=!1},d(e){t(l),e&&t(y),e&&t(u),O(r),e&&t(v),e&&t($),e&&t(fe),e&&t(Q),e&&t(ue),e&&t(Y),e&&t(me),e&&t(G),e&&t(he),O(N,e),e&&t(ge),e&&t(I),O(q),e&&t(_e),e&&t(P),O(F),O(R),O(B),e&&t(be),e&&t(x),O(z),e&&t(ve),e&&t(U),O(V)}}}const Ut={local:"diffusers.DDPMPipeline",sections:[{local:"diffusers.ImagePipelineOutput",title:"ImagePipelineOutput"}],title:"DDPMPipeline"};function St(X){return yt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nt extends _t{constructor(l){super();bt(this,l,St,xt,vt,{})}}export{Nt as default,Ut as metadata};
