import{s as ve,o as xe,n as we}from"../chunks/scheduler.53228c21.js";import{S as Ce,i as Ie,e as l,s as i,c as _,h as Te,a as p,d as n,b as a,f as z,g as $,j as M,k as F,l as u,m as s,n as P,t as y,o as D,p as v}from"../chunks/index.100fac89.js";import{C as Ue}from"../chunks/CopyLLMTxtMenu.0ee1b69b.js";import{D as ue}from"../chunks/Docstring.db856a1e.js";import{C as je}from"../chunks/CodeBlock.d30a6509.js";import{E as Le}from"../chunks/ExampleCodeBlock.3eb26ae1.js";import{H as fe,E as Se}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";function ke(R){let o,I="Example:",h,m,c;return m=new je({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(){o=l("p"),o.textContent=I,h=i(),_(m.$$.fragment)},l(r){o=p(r,"P",{"data-svelte-h":!0}),M(o)!=="svelte-11lpom8"&&(o.textContent=I),h=a(r),$(m.$$.fragment,r)},m(r,f){s(r,o,f),s(r,h,f),P(m,r,f),c=!0},p:we,i(r){c||(y(m.$$.fragment,r),c=!0)},o(r){D(m.$$.fragment,r),c=!1},d(r){r&&(n(o),n(h)),v(m,r)}}}function Ee(R){let o,I,h,m,c,r,f,V,T,ge='<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.',A,U,he="The abstract from the paper is:",X,j,be="<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>",Q,L,_e='The original codebase can be found at <a href="https://github.com/hojonathanho/diffusion" rel="nofollow">hohonathanho/diffusion</a>.',Y,w,$e='<p>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.</p>',K,S,ee,d,k,oe,O,Me="Pipeline for image generation.",le,H,Pe=`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.).`,pe,b,E,de,q,ye="The call function to the pipeline for generation.",me,C,te,G,ne,x,Z,ce,J,De="Output class for image pipelines.",se,B,ie,W,ae;return c=new Ue({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new fe({props:{title:"DDPM",local:"ddpm",headingTag:"h1"}}),S=new fe({props:{title:"DDPMPipeline",local:"diffusers.DDPMPipeline",headingTag:"h1"}}),k=new ue({props:{name:"class diffusers.DDPMPipeline",anchor:"diffusers.DDPMPipeline",parameters:[{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": DDPMScheduler"}],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#L35"}}),E=new ue({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/dit#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#L56",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/dit#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/dit#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),C=new Le({props:{anchor:"diffusers.DDPMPipeline.__call__.example",$$slots:{default:[ke]},$$scope:{ctx:R}}}),G=new fe({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),Z=new ue({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#L118"}}),B=new Se({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/ddpm.md"}}),{c(){o=l("meta"),I=i(),h=l("p"),m=i(),_(c.$$.fragment),r=i(),_(f.$$.fragment),V=i(),T=l("p"),T.innerHTML=ge,A=i(),U=l("p"),U.textContent=he,X=i(),j=l("p"),j.innerHTML=be,Q=i(),L=l("p"),L.innerHTML=_e,Y=i(),w=l("blockquote"),w.innerHTML=$e,K=i(),_(S.$$.fragment),ee=i(),d=l("div"),_(k.$$.fragment),oe=i(),O=l("p"),O.textContent=Me,le=i(),H=l("p"),H.innerHTML=Pe,pe=i(),b=l("div"),_(E.$$.fragment),de=i(),q=l("p"),q.textContent=ye,me=i(),_(C.$$.fragment),te=i(),_(G.$$.fragment),ne=i(),x=l("div"),_(Z.$$.fragment),ce=i(),J=l("p"),J.textContent=De,se=i(),_(B.$$.fragment),ie=i(),W=l("p"),this.h()},l(e){const t=Te("svelte-u9bgzb",document.head);o=p(t,"META",{name:!0,content:!0}),t.forEach(n),I=a(e),h=p(e,"P",{}),z(h).forEach(n),m=a(e),$(c.$$.fragment,e),r=a(e),$(f.$$.fragment,e),V=a(e),T=p(e,"P",{"data-svelte-h":!0}),M(T)!=="svelte-1n7ba1u"&&(T.innerHTML=ge),A=a(e),U=p(e,"P",{"data-svelte-h":!0}),M(U)!=="svelte-1cwsb16"&&(U.textContent=he),X=a(e),j=p(e,"P",{"data-svelte-h":!0}),M(j)!=="svelte-lc79cq"&&(j.innerHTML=be),Q=a(e),L=p(e,"P",{"data-svelte-h":!0}),M(L)!=="svelte-si8dkt"&&(L.innerHTML=_e),Y=a(e),w=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),M(w)!=="svelte-r1jcqf"&&(w.innerHTML=$e),K=a(e),$(S.$$.fragment,e),ee=a(e),d=p(e,"DIV",{class:!0});var g=z(d);$(k.$$.fragment,g),oe=a(g),O=p(g,"P",{"data-svelte-h":!0}),M(O)!=="svelte-2egq7o"&&(O.textContent=Me),le=a(g),H=p(g,"P",{"data-svelte-h":!0}),M(H)!=="svelte-496sm0"&&(H.innerHTML=Pe),pe=a(g),b=p(g,"DIV",{class:!0});var N=z(b);$(E.$$.fragment,N),de=a(N),q=p(N,"P",{"data-svelte-h":!0}),M(q)!=="svelte-50j04k"&&(q.textContent=ye),me=a(N),$(C.$$.fragment,N),N.forEach(n),g.forEach(n),te=a(e),$(G.$$.fragment,e),ne=a(e),x=p(e,"DIV",{class:!0});var re=z(x);$(Z.$$.fragment,re),ce=a(re),J=p(re,"P",{"data-svelte-h":!0}),M(J)!=="svelte-19wetgi"&&(J.textContent=De),re.forEach(n),se=a(e),$(B.$$.fragment,e),ie=a(e),W=p(e,"P",{}),z(W).forEach(n),this.h()},h(){F(o,"name","hf:doc:metadata"),F(o,"content",Ge),F(w,"class","tip"),F(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(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){u(document.head,o),s(e,I,t),s(e,h,t),s(e,m,t),P(c,e,t),s(e,r,t),P(f,e,t),s(e,V,t),s(e,T,t),s(e,A,t),s(e,U,t),s(e,X,t),s(e,j,t),s(e,Q,t),s(e,L,t),s(e,Y,t),s(e,w,t),s(e,K,t),P(S,e,t),s(e,ee,t),s(e,d,t),P(k,d,null),u(d,oe),u(d,O),u(d,le),u(d,H),u(d,pe),u(d,b),P(E,b,null),u(b,de),u(b,q),u(b,me),P(C,b,null),s(e,te,t),P(G,e,t),s(e,ne,t),s(e,x,t),P(Z,x,null),u(x,ce),u(x,J),s(e,se,t),P(B,e,t),s(e,ie,t),s(e,W,t),ae=!0},p(e,[t]){const g={};t&2&&(g.$$scope={dirty:t,ctx:e}),C.$set(g)},i(e){ae||(y(c.$$.fragment,e),y(f.$$.fragment,e),y(S.$$.fragment,e),y(k.$$.fragment,e),y(E.$$.fragment,e),y(C.$$.fragment,e),y(G.$$.fragment,e),y(Z.$$.fragment,e),y(B.$$.fragment,e),ae=!0)},o(e){D(c.$$.fragment,e),D(f.$$.fragment,e),D(S.$$.fragment,e),D(k.$$.fragment,e),D(E.$$.fragment,e),D(C.$$.fragment,e),D(G.$$.fragment,e),D(Z.$$.fragment,e),D(B.$$.fragment,e),ae=!1},d(e){e&&(n(I),n(h),n(m),n(r),n(V),n(T),n(A),n(U),n(X),n(j),n(Q),n(L),n(Y),n(w),n(K),n(ee),n(d),n(te),n(ne),n(x),n(se),n(ie),n(W)),n(o),v(c,e),v(f,e),v(S,e),v(k),v(E),v(C),v(G,e),v(Z),v(B,e)}}}const Ge='{"title":"DDPM","local":"ddpm","sections":[],"depth":1}';function Ze(R){return xe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class We extends Ce{constructor(o){super(),Ie(this,o,Ze,Ee,ve,{})}}export{We as component};
