import{s as ve,o as De,n as Me}from"../chunks/scheduler.8c3d61f6.js";import{S as ye,i as we,g as p,s as a,r as b,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 D,w as y}from"../chunks/index.589a98e8.js";import{T as Te}from"../chunks/Tip.42aa8582.js";import{D as me}from"../chunks/Docstring.27406313.js";import{C as Ie}from"../chunks/CodeBlock.36627b28.js";import{E as Ce}from"../chunks/ExampleCodeBlock.3dc467a7.js";import{H as ce,E as Ue}from"../chunks/EditOnGithub.e5a8d9cb.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,m){i(l,s,m)},p:Me,d(l){l&&n(s)}}}function Se(H){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=a(),b(m.$$.fragment)},l(o){s=d(o,"P",{"data-svelte-h":!0}),w(s)!=="svelte-11lpom8"&&(s.textContent=_),l=r(o),P(m.$$.fragment,o)},m(o,g){i(o,s,g),i(o,l,g),M(m,o,g),u=!0},p:Me,i(o){u||(v(m.$$.fragment,o),u=!0)},o(o){D(m.$$.fragment,o),u=!1},d(o){o&&(n(s),n(l)),y(m,o)}}}function Ee(H){let s,_,l,m,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,S,he='The original codebase can be found at <a href="https://github.com/hojonathanho/diffusion" rel="nofollow">hohonathanho/diffusion</a>.',X,I,Q,E,Y,c,L,ae,J,_e="Pipeline for image generation.",re,O,$e=`This model inherits from <a href="/docs/diffusers/pr_8475/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,$,k,le,q,be="The call function to the pipeline for generation.",pe,C,K,G,ee,x,Z,de,N,Pe="Output class for image pipelines.",te,B,ne,F,se;return u=new ce({props:{title:"DDPM",local:"ddpm",headingTag:"h1"}}),I=new Te({props:{$$slots:{default:[je]},$$scope:{ctx:H}}}),E=new ce({props:{title:"DDPMPipeline",local:"diffusers.DDPMPipeline",headingTag:"h1"}}),L=new me({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_8475/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_8475/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_8475/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>, or <a href="/docs/diffusers/pr_8475/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/vr_8475/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L24"}}),k=new me({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/pr_8475/en/api/pipelines/ddim#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_8475/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_8475/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/pr_8475/en/api/pipelines/ddim#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),C=new Ce({props:{anchor:"diffusers.DDPMPipeline.__call__.example",$$slots:{default:[Se]},$$scope:{ctx:H}}}),G=new ce({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),Z=new me({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/vr_8475/src/diffusers/pipelines/pipeline_utils.py#L100"}}),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"),m=a(),b(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(),S=p("p"),S.innerHTML=he,X=a(),b(I.$$.fragment),Q=a(),b(E.$$.fragment),Y=a(),c=p("div"),b(L.$$.fragment),ae=a(),J=p("p"),J.textContent=_e,re=a(),O=p("p"),O.innerHTML=$e,oe=a(),$=p("div"),b(k.$$.fragment),le=a(),q=p("p"),q.textContent=be,pe=a(),b(C.$$.fragment),K=a(),b(G.$$.fragment),ee=a(),x=p("div"),b(Z.$$.fragment),de=a(),N=p("p"),N.textContent=Pe,te=a(),b(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),m=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),S=d(e,"P",{"data-svelte-h":!0}),w(S)!=="svelte-si8dkt"&&(S.innerHTML=he),X=r(e),P(I.$$.fragment,e),Q=r(e),P(E.$$.fragment,e),Y=r(e),c=d(e,"DIV",{class:!0});var h=W(c);P(L.$$.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-9nmd14"&&(O.innerHTML=$e),oe=r(h),$=d(h,"DIV",{class:!0});var T=W($);P(k.$$.fragment,T),le=r(T),q=d(T,"P",{"data-svelte-h":!0}),w(q)!=="svelte-50j04k"&&(q.textContent=be),pe=r(T),P(C.$$.fragment,T),T.forEach(n),h.forEach(n),K=r(e),P(G.$$.fragment,e),ee=r(e),x=d(e,"DIV",{class:!0});var ie=W(x);P(Z.$$.fragment,ie),de=r(ie),N=d(ie,"P",{"data-svelte-h":!0}),w(N)!=="svelte-19wetgi"&&(N.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",Le),z($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(c,"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,m,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,S,t),i(e,X,t),M(I,e,t),i(e,Q,t),M(E,e,t),i(e,Y,t),i(e,c,t),M(L,c,null),f(c,ae),f(c,J),f(c,re),f(c,O),f(c,oe),f(c,$),M(k,$,null),f($,le),f($,q),f($,pe),M(C,$,null),i(e,K,t),M(G,e,t),i(e,ee,t),i(e,x,t),M(Z,x,null),f(x,de),f(x,N),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}),I.$set(h);const T={};t&2&&(T.$$scope={dirty:t,ctx:e}),C.$set(T)},i(e){se||(v(u.$$.fragment,e),v(I.$$.fragment,e),v(E.$$.fragment,e),v(L.$$.fragment,e),v(k.$$.fragment,e),v(C.$$.fragment,e),v(G.$$.fragment,e),v(Z.$$.fragment,e),v(B.$$.fragment,e),se=!0)},o(e){D(u.$$.fragment,e),D(I.$$.fragment,e),D(E.$$.fragment,e),D(L.$$.fragment,e),D(k.$$.fragment,e),D(C.$$.fragment,e),D(G.$$.fragment,e),D(Z.$$.fragment,e),D(B.$$.fragment,e),se=!1},d(e){e&&(n(_),n(l),n(m),n(o),n(g),n(R),n(U),n(V),n(j),n(A),n(S),n(X),n(Q),n(Y),n(c),n(K),n(ee),n(x),n(te),n(ne),n(F)),n(s),y(u,e),y(I,e),y(E,e),y(L),y(k),y(C),y(G,e),y(Z),y(B,e)}}}const Le='{"title":"DDPM","local":"ddpm","sections":[],"depth":1}';function ke(H){return De(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ne extends ye{constructor(s){super(),we(this,s,ke,Ee,ve,{})}}export{Ne as component};
