import{s as ve,o as Pe,n as $e}from"../chunks/scheduler.182ea377.js";import{S as Me,i as ye,g as p,s as r,r as M,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.abf12888.js";import{T as we}from"../chunks/Tip.230e2334.js";import{D as pe}from"../chunks/Docstring.93f6f462.js";import{C as xe}from"../chunks/CodeBlock.57fe6e13.js";import{E as Ie}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as de}from"../chunks/Heading.16916d63.js";function Te(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,c){i(l,s,c)},p:$e,d(l){l&&n(s)}}}function Ce(B){let s,_="Example:",l,c,u;return c=new xe({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(),M(c.$$.fragment)},l(a){s=d(a,"P",{"data-svelte-h":!0}),$(s)!=="svelte-11lpom8"&&(s.textContent=_),l=o(a),y(c.$$.fragment,a)},m(a,g){i(a,s,g),i(a,l,g),D(c,a,g),u=!0},p:$e,i(a){u||(w(c.$$.fragment,a),u=!0)},o(a){x(c.$$.fragment,a),u=!1},d(a){a&&(n(s),n(l)),I(c,a)}}}function Ue(B){let s,_,l,c,u,a,g,ce='<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,me="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,m,k,se,H,ge="Pipeline for image generation.",ie,J,he=`This model inherits from <a href="/docs/diffusers/v0.24.0/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,G,re,O,_e="The call function to the pipeline for generation.",oe,C,Y,Z,K,v,E,le,q,be="Output class for image pipelines.",ee,N,te;return u=new de({props:{title:"DDPM",local:"ddpm",headingTag:"h1"}}),T=new we({props:{$$slots:{default:[Te]},$$scope:{ctx:B}}}),S=new de({props:{title:"DDPMPipeline",local:"diffusers.DDPMPipeline",headingTag:"h1"}}),k=new pe({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/v0.24.0/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/v0.24.0/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/v0.24.0/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>, or <a href="/docs/diffusers/v0.24.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.24.0/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L24"}}),G=new pe({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/v0.24.0/en/api/pipelines/ddim#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.24.0/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L45",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


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