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 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 y,w as D}from"../chunks/index.da70eac4.js";import{T as Ie}from"../chunks/Tip.1d9b8c37.js";import{D as me}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 ce,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-a-pipeline">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-1qn15hi"&&(s.innerHTML=_)},m(l,m){i(l,s,m)},p:Me,d(l){l&&n(s)}}}function Le(H){let s,_="Example:",l,m,u;return m=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(),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){y(m.$$.fragment,o),u=!1},d(o){o&&(n(s),n(l)),D(m,o)}}}function Se(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,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,c,G,ae,J,_e="Pipeline for image generation.",re,O,$e=`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.).`,oe,$,E,le,q,be="The call function to the pipeline for generation.",pe,C,K,k,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"}}),T=new Ie({props:{$$slots:{default:[je]},$$scope:{ctx:H}}}),S=new ce({props:{title:"DDPMPipeline",local:"diffusers.DDPMPipeline",headingTag:"h1"}}),G=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/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#L33"}}),E=new me({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/latent_diffusion#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#L54",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/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/main/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 ce({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),Z=new me({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#L110"}}),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(),L=p("p"),L.innerHTML=he,X=a(),b(T.$$.fragment),Q=a(),b(S.$$.fragment),Y=a(),c=p("div"),b(G.$$.fragment),ae=a(),J=p("p"),J.textContent=_e,re=a(),O=p("p"),O.innerHTML=$e,oe=a(),$=p("div"),b(E.$$.fragment),le=a(),q=p("p"),q.textContent=be,pe=a(),b(C.$$.fragment),K=a(),b(k.$$.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),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),c=d(e,"DIV",{class:!0});var h=W(c);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-496sm0"&&(O.innerHTML=$e),oe=r(h),$=d(h,"DIV",{class:!0});var I=W($);P(E.$$.fragment,I),le=r(I),q=d(I,"P",{"data-svelte-h":!0}),w(q)!=="svelte-50j04k"&&(q.textContent=be),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),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",Ge),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,L,t),i(e,X,t),M(T,e,t),i(e,Q,t),M(S,e,t),i(e,Y,t),i(e,c,t),M(G,c,null),f(c,ae),f(c,J),f(c,re),f(c,O),f(c,oe),f(c,$),M(E,$,null),f($,le),f($,q),f($,pe),M(C,$,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,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}),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(m),n(o),n(g),n(R),n(U),n(V),n(j),n(A),n(L),n(X),n(Q),n(Y),n(c),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 Ne extends De{constructor(s){super(),we(this,s,Ee,Se,ve,{})}}export{Ne as component};
