import{s as Pe,o as Me,n as $e}from"../chunks/scheduler.182ea377.js";import{S as ve,i as ye,g as p,s as r,r as v,A as De,h as d,f as n,c as o,j as F,u as y,x as $,k as W,y as f,a as i,v as D,d as w,t as x,w as I}from"../chunks/index.1ea56653.js";import{H as pe,g as we}from"../chunks/Heading.71ac6e9f.js";import{T as xe}from"../chunks/Tip.67abc998.js";import{D as de}from"../chunks/Docstring.59aaf0cd.js";import{C as Ie}from"../chunks/CodeBlock.82c2494b.js";import{E as Te}from"../chunks/ExampleCodeBlock.95ae1d71.js";function Ce(B){let s,_='Make sure to check out the Schedulers <a href="../../using-diffusers/schedulers">guide</a> to learn how to explore the tradeoff between scheduler speed and quality, and see the <a href="../../using-diffusers/loading#reuse-components-across-pipelines">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.';return{c(){s=p("p"),s.innerHTML=_},l(l){s=d(l,"P",{"data-svelte-h":!0}),$(s)!=="svelte-1wmc0l4"&&(s.innerHTML=_)},m(l,m){i(l,s,m)},p:$e,d(l){l&&n(s)}}}function Ue(B){let s,_="Example:",l,m,u;return m=new Ie({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>)`,wrap:!1}}),{c(){s=p("p"),s.textContent=_,l=r(),v(m.$$.fragment)},l(a){s=d(a,"P",{"data-svelte-h":!0}),$(s)!=="svelte-11lpom8"&&(s.textContent=_),l=o(a),y(m.$$.fragment,a)},m(a,g){i(a,s,g),i(a,l,g),D(m,a,g),u=!0},p:$e,i(a){u||(w(m.$$.fragment,a),u=!0)},o(a){x(m.$$.fragment,a),u=!1},d(a){a&&(n(s),n(l)),I(m,a)}}}function je(B){let s,_,l,m,u,a,g,me='<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 🤗 Diffusers library, DDPM refers to the <em>discrete denoising scheduler</em> from the paper as well as the pipeline.',z,U,ce="The abstract from the paper is:",R,j,ue="<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.</em>",V,L,fe='The original codebase can be found at <a href="https://github.com/hojonathanho/diffusion" rel="nofollow">hohonathanho/diffusion</a>.',A,T,X,S,Q,c,G,se,H,ge="Pipeline for image generation.",ie,J,he=`This model inherits from <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,ae,b,k,re,O,_e="The call function to the pipeline for generation.",oe,C,Y,Z,K,P,E,le,N,be="Output class for image pipelines.",ee,q,te;return u=new pe({props:{title:"DDPM",local:"ddpm",headingTag:"h1"}}),T=new xe({props:{$$slots:{default:[Ce]},$$scope:{ctx:B}}}),S=new pe({props:{title:"DDPMPipeline",local:"diffusers.DDPMPipeline",headingTag:"h1"}}),G=new de({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"}}),k=new de({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/ddim#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#L44",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/ddim#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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/main/en/api/pipelines/ddim#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),C=new Te({props:{anchor:"diffusers.DDPMPipeline.__call__.example",$$slots:{default:[Ue]},$$scope:{ctx:B}}}),Z=new pe({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),E=new de({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#L111"}}),{c(){s=p("meta"),_=r(),l=p("p"),m=r(),v(u.$$.fragment),a=r(),g=p("p"),g.innerHTML=me,z=r(),U=p("p"),U.textContent=ce,R=r(),j=p("p"),j.innerHTML=ue,V=r(),L=p("p"),L.innerHTML=fe,A=r(),v(T.$$.fragment),X=r(),v(S.$$.fragment),Q=r(),c=p("div"),v(G.$$.fragment),se=r(),H=p("p"),H.textContent=ge,ie=r(),J=p("p"),J.innerHTML=he,ae=r(),b=p("div"),v(k.$$.fragment),re=r(),O=p("p"),O.textContent=_e,oe=r(),v(C.$$.fragment),Y=r(),v(Z.$$.fragment),K=r(),P=p("div"),v(E.$$.fragment),le=r(),N=p("p"),N.textContent=be,ee=r(),q=p("p"),this.h()},l(e){const t=De("svelte-u9bgzb",document.head);s=d(t,"META",{name:!0,content:!0}),t.forEach(n),_=o(e),l=d(e,"P",{}),F(l).forEach(n),m=o(e),y(u.$$.fragment,e),a=o(e),g=d(e,"P",{"data-svelte-h":!0}),$(g)!=="svelte-1n7ba1u"&&(g.innerHTML=me),z=o(e),U=d(e,"P",{"data-svelte-h":!0}),$(U)!=="svelte-1cwsb16"&&(U.textContent=ce),R=o(e),j=d(e,"P",{"data-svelte-h":!0}),$(j)!=="svelte-lc79cq"&&(j.innerHTML=ue),V=o(e),L=d(e,"P",{"data-svelte-h":!0}),$(L)!=="svelte-si8dkt"&&(L.innerHTML=fe),A=o(e),y(T.$$.fragment,e),X=o(e),y(S.$$.fragment,e),Q=o(e),c=d(e,"DIV",{class:!0});var h=F(c);y(G.$$.fragment,h),se=o(h),H=d(h,"P",{"data-svelte-h":!0}),$(H)!=="svelte-2egq7o"&&(H.textContent=ge),ie=o(h),J=d(h,"P",{"data-svelte-h":!0}),$(J)!=="svelte-496sm0"&&(J.innerHTML=he),ae=o(h),b=d(h,"DIV",{class:!0});var M=F(b);y(k.$$.fragment,M),re=o(M),O=d(M,"P",{"data-svelte-h":!0}),$(O)!=="svelte-50j04k"&&(O.textContent=_e),oe=o(M),y(C.$$.fragment,M),M.forEach(n),h.forEach(n),Y=o(e),y(Z.$$.fragment,e),K=o(e),P=d(e,"DIV",{class:!0});var ne=F(P);y(E.$$.fragment,ne),le=o(ne),N=d(ne,"P",{"data-svelte-h":!0}),$(N)!=="svelte-19wetgi"&&(N.textContent=be),ne.forEach(n),ee=o(e),q=d(e,"P",{}),F(q).forEach(n),this.h()},h(){W(s,"name","hf:doc:metadata"),W(s,"content",Le),W(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(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(e,t){f(document.head,s),i(e,_,t),i(e,l,t),i(e,m,t),D(u,e,t),i(e,a,t),i(e,g,t),i(e,z,t),i(e,U,t),i(e,R,t),i(e,j,t),i(e,V,t),i(e,L,t),i(e,A,t),D(T,e,t),i(e,X,t),D(S,e,t),i(e,Q,t),i(e,c,t),D(G,c,null),f(c,se),f(c,H),f(c,ie),f(c,J),f(c,ae),f(c,b),D(k,b,null),f(b,re),f(b,O),f(b,oe),D(C,b,null),i(e,Y,t),D(Z,e,t),i(e,K,t),i(e,P,t),D(E,P,null),f(P,le),f(P,N),i(e,ee,t),i(e,q,t),te=!0},p(e,[t]){const h={};t&2&&(h.$$scope={dirty:t,ctx:e}),T.$set(h);const M={};t&2&&(M.$$scope={dirty:t,ctx:e}),C.$set(M)},i(e){te||(w(u.$$.fragment,e),w(T.$$.fragment,e),w(S.$$.fragment,e),w(G.$$.fragment,e),w(k.$$.fragment,e),w(C.$$.fragment,e),w(Z.$$.fragment,e),w(E.$$.fragment,e),te=!0)},o(e){x(u.$$.fragment,e),x(T.$$.fragment,e),x(S.$$.fragment,e),x(G.$$.fragment,e),x(k.$$.fragment,e),x(C.$$.fragment,e),x(Z.$$.fragment,e),x(E.$$.fragment,e),te=!1},d(e){e&&(n(_),n(l),n(m),n(a),n(g),n(z),n(U),n(R),n(j),n(V),n(L),n(A),n(X),n(Q),n(c),n(Y),n(K),n(P),n(ee),n(q)),n(s),I(u,e),I(T,e),I(S,e),I(G),I(k),I(C),I(Z,e),I(E)}}}const Le='{"title":"DDPM","local":"ddpm","sections":[],"depth":1}';function Se(B){return Me(()=>{new URLSearchParams(window.location.search).get("fw"),window.hfDocGoto=we}),[]}class Oe extends ve{constructor(s){super(),ye(this,s,Se,je,Pe,{})}}export{Oe as component};
