import{s as Pe,o as Me,n as $e}from"../chunks/scheduler.182ea377.js";import{S as ve,i as De,g as p,s as r,r as v,A as ye,h as d,f as n,c as o,j as F,u as D,x as $,k as W,y as f,a as i,v as y,d as w,t as x,w as T}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 Te}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as de}from"../chunks/Heading.16916d63.js";function Ie(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(),v(c.$$.fragment)},l(a){s=d(a,"P",{"data-svelte-h":!0}),$(s)!=="svelte-11lpom8"&&(s.textContent=_),l=o(a),D(c.$$.fragment,a)},m(a,g){i(a,s,g),i(a,l,g),y(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)),T(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,S,fe='The original codebase can be found at <a href="https://github.com/hojonathanho/diffusion" rel="nofollow">hohonathanho/diffusion</a>.',A,I,X,L,Q,m,k,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,Z,re,O,_e="The call function to the pipeline for generation.",oe,C,Y,E,K,P,G,le,q,be="Output class for image pipelines.",ee,N,te;return u=new de({props:{title:"DDPM",local:"ddpm",headingTag:"h1"}}),I=new we({props:{$$slots:{default:[Ie]},$$scope:{ctx:B}}}),L=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/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"}}),Z=new pe({props:{name:"__call__",anchor:"diffusers.DDPMPipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"generator",val:": Union = None"},{name:"num_inference_steps",val:": int = 1000"},{name:"output_type",val:": Optional = '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/stable_unclip#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#L45",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/stable_unclip#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/stable_unclip#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),C=new Te({props:{anchor:"diffusers.DDPMPipeline.__call__.example",$$slots:{default:[Ce]},$$scope:{ctx:B}}}),E=new de({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),G=new pe({props:{name:"class diffusers.ImagePipelineOutput",anchor:"diffusers.ImagePipelineOutput",parameters:[{name:"images",val:": Union"}],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#L100"}}),{c(){s=p("meta"),_=r(),l=p("p"),c=r(),v(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(),S=p("p"),S.innerHTML=fe,A=r(),v(I.$$.fragment),X=r(),v(L.$$.fragment),Q=r(),m=p("div"),v(k.$$.fragment),se=r(),H=p("p"),H.textContent=ge,ie=r(),J=p("p"),J.innerHTML=he,ae=r(),b=p("div"),v(Z.$$.fragment),re=r(),O=p("p"),O.textContent=_e,oe=r(),v(C.$$.fragment),Y=r(),v(E.$$.fragment),K=r(),P=p("div"),v(G.$$.fragment),le=r(),q=p("p"),q.textContent=be,ee=r(),N=p("p"),this.h()},l(e){const t=ye("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),D(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),S=d(e,"P",{"data-svelte-h":!0}),$(S)!=="svelte-si8dkt"&&(S.innerHTML=fe),A=o(e),D(I.$$.fragment,e),X=o(e),D(L.$$.fragment,e),Q=o(e),m=d(e,"DIV",{class:!0});var h=F(m);D(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-496sm0"&&(J.innerHTML=he),ae=o(h),b=d(h,"DIV",{class:!0});var M=F(b);D(Z.$$.fragment,M),re=o(M),O=d(M,"P",{"data-svelte-h":!0}),$(O)!=="svelte-50j04k"&&(O.textContent=_e),oe=o(M),D(C.$$.fragment,M),M.forEach(n),h.forEach(n),Y=o(e),D(E.$$.fragment,e),K=o(e),P=d(e,"DIV",{class:!0});var ne=F(P);D(G.$$.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(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,c,t),y(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,S,t),i(e,A,t),y(I,e,t),i(e,X,t),y(L,e,t),i(e,Q,t),i(e,m,t),y(k,m,null),f(m,se),f(m,H),f(m,ie),f(m,J),f(m,ae),f(m,b),y(Z,b,null),f(b,re),f(b,O),f(b,oe),y(C,b,null),i(e,Y,t),y(E,e,t),i(e,K,t),i(e,P,t),y(G,P,null),f(P,le),f(P,q),i(e,ee,t),i(e,N,t),te=!0},p(e,[t]){const h={};t&2&&(h.$$scope={dirty:t,ctx:e}),I.$set(h);const M={};t&2&&(M.$$scope={dirty:t,ctx:e}),C.$set(M)},i(e){te||(w(u.$$.fragment,e),w(I.$$.fragment,e),w(L.$$.fragment,e),w(k.$$.fragment,e),w(Z.$$.fragment,e),w(C.$$.fragment,e),w(E.$$.fragment,e),w(G.$$.fragment,e),te=!0)},o(e){x(u.$$.fragment,e),x(I.$$.fragment,e),x(L.$$.fragment,e),x(k.$$.fragment,e),x(Z.$$.fragment,e),x(C.$$.fragment,e),x(E.$$.fragment,e),x(G.$$.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(S),n(A),n(X),n(Q),n(m),n(Y),n(K),n(P),n(ee),n(N)),n(s),T(u,e),T(I,e),T(L,e),T(k),T(Z),T(C),T(E,e),T(G)}}}const je='{"title":"DDPM","local":"ddpm","sections":[],"depth":1}';function Se(B){return Me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends ve{constructor(s){super(),De(this,s,Se,Ue,Pe,{})}}export{Je as component};
