import{s as ve,o as ye,n as Me}from"../chunks/scheduler.8c3d61f6.js";import{S as De,i as we,g as p,s as a,r as $,A as xe,h as d,f as n,c as r,j as W,u as P,x as w,k as z,y as f,a as i,v as M,d as v,t as y,w as D}from"../chunks/index.da70eac4.js";import{T as Ie}from"../chunks/Tip.1d9b8c37.js";import{D as ce}from"../chunks/Docstring.6b390b9a.js";import{C as Te}from"../chunks/CodeBlock.00a903b3.js";import{E as Ce}from"../chunks/ExampleCodeBlock.db12be95.js";import{H as me,E as Ue}from"../chunks/EditOnGithub.1e64e623.js";function je(H){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}),w(s)!=="svelte-1wmc0l4"&&(s.innerHTML=_)},m(l,c){i(l,s,c)},p:Me,d(l){l&&n(s)}}}function Le(H){let s,_="Example:",l,c,u;return c=new Te({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=a(),$(c.$$.fragment)},l(o){s=d(o,"P",{"data-svelte-h":!0}),w(s)!=="svelte-11lpom8"&&(s.textContent=_),l=r(o),P(c.$$.fragment,o)},m(o,g){i(o,s,g),i(o,l,g),M(c,o,g),u=!0},p:Me,i(o){u||(v(c.$$.fragment,o),u=!0)},o(o){y(c.$$.fragment,o),u=!1},d(o){o&&(n(s),n(l)),D(c,o)}}}function Se(H){let s,_,l,c,u,o,g,ue='<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.',R,U,fe="The abstract from the paper is:",V,j,ge="<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>",A,L,he='The original codebase can be found at <a href="https://github.com/hojonathanho/diffusion" rel="nofollow">hohonathanho/diffusion</a>.',X,T,Q,S,Y,m,G,ae,J,_e="Pipeline for image generation.",re,O,be=`This model inherits from <a href="/docs/diffusers/pr_10011/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.).`,oe,b,E,le,N,$e="The call function to the pipeline for generation.",pe,C,K,k,ee,x,Z,de,q,Pe="Output class for image pipelines.",te,B,ne,F,se;return u=new me({props:{title:"DDPM",local:"ddpm",headingTag:"h1"}}),T=new Ie({props:{$$slots:{default:[je]},$$scope:{ctx:H}}}),S=new me({props:{title:"DDPMPipeline",local:"diffusers.DDPMPipeline",headingTag:"h1"}}),G=new ce({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/pr_10011/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/pr_10011/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/pr_10011/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>, or <a href="/docs/diffusers/pr_10011/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/vr_10011/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L24"}}),E=new ce({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/pr_10011/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_10011/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/pr_10011/en/api/pipelines/latent_diffusion#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/pr_10011/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),C=new Ce({props:{anchor:"diffusers.DDPMPipeline.__call__.example",$$slots:{default:[Le]},$$scope:{ctx:H}}}),k=new me({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),Z=new ce({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/vr_10011/src/diffusers/pipelines/pipeline_utils.py#L106"}}),B=new Ue({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/ddpm.md"}}),{c(){s=p("meta"),_=a(),l=p("p"),c=a(),$(u.$$.fragment),o=a(),g=p("p"),g.innerHTML=ue,R=a(),U=p("p"),U.textContent=fe,V=a(),j=p("p"),j.innerHTML=ge,A=a(),L=p("p"),L.innerHTML=he,X=a(),$(T.$$.fragment),Q=a(),$(S.$$.fragment),Y=a(),m=p("div"),$(G.$$.fragment),ae=a(),J=p("p"),J.textContent=_e,re=a(),O=p("p"),O.innerHTML=be,oe=a(),b=p("div"),$(E.$$.fragment),le=a(),N=p("p"),N.textContent=$e,pe=a(),$(C.$$.fragment),K=a(),$(k.$$.fragment),ee=a(),x=p("div"),$(Z.$$.fragment),de=a(),q=p("p"),q.textContent=Pe,te=a(),$(B.$$.fragment),ne=a(),F=p("p"),this.h()},l(e){const t=xe("svelte-u9bgzb",document.head);s=d(t,"META",{name:!0,content:!0}),t.forEach(n),_=r(e),l=d(e,"P",{}),W(l).forEach(n),c=r(e),P(u.$$.fragment,e),o=r(e),g=d(e,"P",{"data-svelte-h":!0}),w(g)!=="svelte-1n7ba1u"&&(g.innerHTML=ue),R=r(e),U=d(e,"P",{"data-svelte-h":!0}),w(U)!=="svelte-1cwsb16"&&(U.textContent=fe),V=r(e),j=d(e,"P",{"data-svelte-h":!0}),w(j)!=="svelte-lc79cq"&&(j.innerHTML=ge),A=r(e),L=d(e,"P",{"data-svelte-h":!0}),w(L)!=="svelte-si8dkt"&&(L.innerHTML=he),X=r(e),P(T.$$.fragment,e),Q=r(e),P(S.$$.fragment,e),Y=r(e),m=d(e,"DIV",{class:!0});var h=W(m);P(G.$$.fragment,h),ae=r(h),J=d(h,"P",{"data-svelte-h":!0}),w(J)!=="svelte-2egq7o"&&(J.textContent=_e),re=r(h),O=d(h,"P",{"data-svelte-h":!0}),w(O)!=="svelte-m5bs7f"&&(O.innerHTML=be),oe=r(h),b=d(h,"DIV",{class:!0});var I=W(b);P(E.$$.fragment,I),le=r(I),N=d(I,"P",{"data-svelte-h":!0}),w(N)!=="svelte-50j04k"&&(N.textContent=$e),pe=r(I),P(C.$$.fragment,I),I.forEach(n),h.forEach(n),K=r(e),P(k.$$.fragment,e),ee=r(e),x=d(e,"DIV",{class:!0});var ie=W(x);P(Z.$$.fragment,ie),de=r(ie),q=d(ie,"P",{"data-svelte-h":!0}),w(q)!=="svelte-19wetgi"&&(q.textContent=Pe),ie.forEach(n),te=r(e),P(B.$$.fragment,e),ne=r(e),F=d(e,"P",{}),W(F).forEach(n),this.h()},h(){z(s,"name","hf:doc:metadata"),z(s,"content",Ge),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"),z(m,"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")},m(e,t){f(document.head,s),i(e,_,t),i(e,l,t),i(e,c,t),M(u,e,t),i(e,o,t),i(e,g,t),i(e,R,t),i(e,U,t),i(e,V,t),i(e,j,t),i(e,A,t),i(e,L,t),i(e,X,t),M(T,e,t),i(e,Q,t),M(S,e,t),i(e,Y,t),i(e,m,t),M(G,m,null),f(m,ae),f(m,J),f(m,re),f(m,O),f(m,oe),f(m,b),M(E,b,null),f(b,le),f(b,N),f(b,pe),M(C,b,null),i(e,K,t),M(k,e,t),i(e,ee,t),i(e,x,t),M(Z,x,null),f(x,de),f(x,q),i(e,te,t),M(B,e,t),i(e,ne,t),i(e,F,t),se=!0},p(e,[t]){const h={};t&2&&(h.$$scope={dirty:t,ctx:e}),T.$set(h);const I={};t&2&&(I.$$scope={dirty:t,ctx:e}),C.$set(I)},i(e){se||(v(u.$$.fragment,e),v(T.$$.fragment,e),v(S.$$.fragment,e),v(G.$$.fragment,e),v(E.$$.fragment,e),v(C.$$.fragment,e),v(k.$$.fragment,e),v(Z.$$.fragment,e),v(B.$$.fragment,e),se=!0)},o(e){y(u.$$.fragment,e),y(T.$$.fragment,e),y(S.$$.fragment,e),y(G.$$.fragment,e),y(E.$$.fragment,e),y(C.$$.fragment,e),y(k.$$.fragment,e),y(Z.$$.fragment,e),y(B.$$.fragment,e),se=!1},d(e){e&&(n(_),n(l),n(c),n(o),n(g),n(R),n(U),n(V),n(j),n(A),n(L),n(X),n(Q),n(Y),n(m),n(K),n(ee),n(x),n(te),n(ne),n(F)),n(s),D(u,e),D(T,e),D(S,e),D(G),D(E),D(C),D(k,e),D(Z),D(B,e)}}}const Ge='{"title":"DDPM","local":"ddpm","sections":[],"depth":1}';function Ee(H){return ye(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qe extends De{constructor(s){super(),we(this,s,Ee,Se,ve,{})}}export{qe as component};
