import{S as Gt,i as Zt,s as Rt,e as o,k as l,w as Y,t as p,M as jt,c as r,d as t,m as d,a,x as F,h as c,b as n,G as i,g as h,y as V,L as Wt,q as J,o as K,B as Q,v as Bt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as zt}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as ke}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Yt(ct){let f,fe,m,b,X,E,qe,ee,Se,me,g,w,te,T,Le,ie,Ce,ge,I,x,He,Oe,ve,O,Ue,_e,U,ze,De,y,Ge,A,Ze,Re,Pe,v,M,oe,k,je,re,We,be,$,ae,_,ne,Be,Ye,se,Fe,Ve,z,Je,Ke,le,D,de,q,Qe,Xe,pe,ce,et,tt,G,it,we,P,N,he,S,ot,ue,rt,ye,u,L,at,C,nt,Z,st,lt,dt,R,H,Me;return E=new ke({}),T=new ke({}),k=new ke({}),S=new ke({}),L=new zt({props:{name:"class diffusers.PNDMPipeline",anchor:"diffusers.PNDMPipeline",parameters:[{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": PNDMScheduler"}],parametersDescription:[{anchor:"diffusers.PNDMPipeline.unet",description:"<strong>unet</strong> (<code>UNet2DModel</code>) &#x2014; U-Net architecture to denoise the encoded image latents.",name:"unet"},{anchor:"diffusers.PNDMPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_1170/en/api/schedulers#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
The <code>PNDMScheduler</code> to be used in combination with <code>unet</code> to denoise the encoded image.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/vr_1170/src/diffusers/pipelines/pndm/pipeline_pndm.py#L26"}}),H=new zt({props:{name:"__call__",anchor:"diffusers.PNDMPipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"num_inference_steps",val:": int = 50"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.PNDMPipeline.__call__.batch_size",description:"<strong>batch_size</strong> (<code>int</code>, <code>optional</code>, defaults to 1) &#x2014; The number of images to generate.",name:"batch_size"},{anchor:"diffusers.PNDMPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <code>optional</code>, defaults to 50) &#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.PNDMPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <code>optional</code>) &#x2014; A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch
generator</a> to make generation
deterministic.`,name:"generator"},{anchor:"diffusers.PNDMPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <code>optional</code>, defaults to <code>&quot;pil&quot;</code>) &#x2014; The output format of the generate image. Choose
between <a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.PNDMPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <code>optional</code>, defaults to <code>True</code>) &#x2014; Whether or not to return a
<a href="/docs/diffusers/pr_1170/en/api/diffusion_pipeline#diffusers.pipeline_utils.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_1170/src/diffusers/pipelines/pndm/pipeline_pndm.py#L44",returnDescription:`
<p><code>~pipelines.utils.ImagePipelineOutput</code> if
<code>return_dict</code> is True, otherwise a \`tuple. When returning a tuple, the first element is a list with the
generated images.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/pr_1170/en/api/diffusion_pipeline#diffusers.pipeline_utils.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),{c(){f=o("meta"),fe=l(),m=o("h1"),b=o("a"),X=o("span"),Y(E.$$.fragment),qe=l(),ee=o("span"),Se=p("PNDM"),me=l(),g=o("h2"),w=o("a"),te=o("span"),Y(T.$$.fragment),Le=l(),ie=o("span"),Ce=p("Overview"),ge=l(),I=o("p"),x=o("a"),He=p("Pseudo Numerical methods for Diffusion Models on manifolds"),Oe=p(" (PNDM) by  Luping Liu, Yi Ren, Zhijie Lin and Zhou Zhao."),ve=l(),O=o("p"),Ue=p("The abstract of the paper is the following:"),_e=l(),U=o("p"),ze=p("Denoising Diffusion Probabilistic Models (DDPMs) can generate high-quality samples such as image and audio samples. However, DDPMs require hundreds to thousands of iterations to produce final samples. Several prior works have successfully accelerated DDPMs through adjusting the variance schedule (e.g., Improved Denoising Diffusion Probabilistic Models) or the denoising equation (e.g., Denoising Diffusion Implicit Models (DDIMs)). However, these acceleration methods cannot maintain the quality of samples and even introduce new noise at a high speedup rate, which limit their practicability. To accelerate the inference process while keeping the sample quality, we provide a fresh perspective that DDPMs should be treated as solving differential equations on manifolds. Under such a perspective, we propose pseudo numerical methods for diffusion models (PNDMs). Specifically, we figure out how to solve differential equations on manifolds and show that DDIMs are simple cases of pseudo numerical methods. We change several classical numerical methods to corresponding pseudo numerical methods and find that the pseudo linear multi-step method is the best in most situations. According to our experiments, by directly using pre-trained models on Cifar10, CelebA and LSUN, PNDMs can generate higher quality synthetic images with only 50 steps compared with 1000-step DDIMs (20x speedup), significantly outperform DDIMs with 250 steps (by around 0.4 in FID) and have good generalization on different variance schedules."),De=l(),y=o("p"),Ge=p("The original codebase can be found "),A=o("a"),Ze=p("here"),Re=p("."),Pe=l(),v=o("h2"),M=o("a"),oe=o("span"),Y(k.$$.fragment),je=l(),re=o("span"),We=p("Available Pipelines:"),be=l(),$=o("table"),ae=o("thead"),_=o("tr"),ne=o("th"),Be=p("Pipeline"),Ye=l(),se=o("th"),Fe=p("Tasks"),Ve=l(),z=o("th"),Je=p("Colab"),Ke=l(),le=o("tbody"),D=o("tr"),de=o("td"),q=o("a"),Qe=p("pipeline_pndm.py"),Xe=l(),pe=o("td"),ce=o("em"),et=p("Unconditional Image Generation"),tt=l(),G=o("td"),it=p("-"),we=l(),P=o("h2"),N=o("a"),he=o("span"),Y(S.$$.fragment),ot=l(),ue=o("span"),rt=p("PNDMPipeline"),ye=l(),u=o("div"),Y(L.$$.fragment),at=l(),C=o("p"),nt=p("This model inherits from "),Z=o("a"),st=p("DiffusionPipeline"),lt=p(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),dt=l(),R=o("div"),Y(H.$$.fragment),this.h()},l(e){const s=jt('[data-svelte="svelte-1phssyn"]',document.head);f=r(s,"META",{name:!0,content:!0}),s.forEach(t),fe=d(e),m=r(e,"H1",{class:!0});var $e=a(m);b=r($e,"A",{id:!0,class:!0,href:!0});var ht=a(b);X=r(ht,"SPAN",{});var ut=a(X);F(E.$$.fragment,ut),ut.forEach(t),ht.forEach(t),qe=d($e),ee=r($e,"SPAN",{});var ft=a(ee);Se=c(ft,"PNDM"),ft.forEach(t),$e.forEach(t),me=d(e),g=r(e,"H2",{class:!0});var Ne=a(g);w=r(Ne,"A",{id:!0,class:!0,href:!0});var mt=a(w);te=r(mt,"SPAN",{});var gt=a(te);F(T.$$.fragment,gt),gt.forEach(t),mt.forEach(t),Le=d(Ne),ie=r(Ne,"SPAN",{});var vt=a(ie);Ce=c(vt,"Overview"),vt.forEach(t),Ne.forEach(t),ge=d(e),I=r(e,"P",{});var pt=a(I);x=r(pt,"A",{href:!0,rel:!0});var _t=a(x);He=c(_t,"Pseudo Numerical methods for Diffusion Models on manifolds"),_t.forEach(t),Oe=c(pt," (PNDM) by  Luping Liu, Yi Ren, Zhijie Lin and Zhou Zhao."),pt.forEach(t),ve=d(e),O=r(e,"P",{});var Dt=a(O);Ue=c(Dt,"The abstract of the paper is the following:"),Dt.forEach(t),_e=d(e),U=r(e,"P",{});var Pt=a(U);ze=c(Pt,"Denoising Diffusion Probabilistic Models (DDPMs) can generate high-quality samples such as image and audio samples. However, DDPMs require hundreds to thousands of iterations to produce final samples. Several prior works have successfully accelerated DDPMs through adjusting the variance schedule (e.g., Improved Denoising Diffusion Probabilistic Models) or the denoising equation (e.g., Denoising Diffusion Implicit Models (DDIMs)). However, these acceleration methods cannot maintain the quality of samples and even introduce new noise at a high speedup rate, which limit their practicability. To accelerate the inference process while keeping the sample quality, we provide a fresh perspective that DDPMs should be treated as solving differential equations on manifolds. Under such a perspective, we propose pseudo numerical methods for diffusion models (PNDMs). Specifically, we figure out how to solve differential equations on manifolds and show that DDIMs are simple cases of pseudo numerical methods. We change several classical numerical methods to corresponding pseudo numerical methods and find that the pseudo linear multi-step method is the best in most situations. According to our experiments, by directly using pre-trained models on Cifar10, CelebA and LSUN, PNDMs can generate higher quality synthetic images with only 50 steps compared with 1000-step DDIMs (20x speedup), significantly outperform DDIMs with 250 steps (by around 0.4 in FID) and have good generalization on different variance schedules."),Pt.forEach(t),De=d(e),y=r(e,"P",{});var Ee=a(y);Ge=c(Ee,"The original codebase can be found "),A=r(Ee,"A",{href:!0,rel:!0});var bt=a(A);Ze=c(bt,"here"),bt.forEach(t),Re=c(Ee,"."),Ee.forEach(t),Pe=d(e),v=r(e,"H2",{class:!0});var Te=a(v);M=r(Te,"A",{id:!0,class:!0,href:!0});var wt=a(M);oe=r(wt,"SPAN",{});var yt=a(oe);F(k.$$.fragment,yt),yt.forEach(t),wt.forEach(t),je=d(Te),re=r(Te,"SPAN",{});var Mt=a(re);We=c(Mt,"Available Pipelines:"),Mt.forEach(t),Te.forEach(t),be=d(e),$=r(e,"TABLE",{});var Ie=a($);ae=r(Ie,"THEAD",{});var $t=a(ae);_=r($t,"TR",{});var j=a(_);ne=r(j,"TH",{});var Nt=a(ne);Be=c(Nt,"Pipeline"),Nt.forEach(t),Ye=d(j),se=r(j,"TH",{});var Et=a(se);Fe=c(Et,"Tasks"),Et.forEach(t),Ve=d(j),z=r(j,"TH",{align:!0});var Tt=a(z);Je=c(Tt,"Colab"),Tt.forEach(t),j.forEach(t),$t.forEach(t),Ke=d(Ie),le=r(Ie,"TBODY",{});var It=a(le);D=r(It,"TR",{});var W=a(D);de=r(W,"TD",{});var xt=a(de);q=r(xt,"A",{href:!0,rel:!0});var At=a(q);Qe=c(At,"pipeline_pndm.py"),At.forEach(t),xt.forEach(t),Xe=d(W),pe=r(W,"TD",{});var kt=a(pe);ce=r(kt,"EM",{});var qt=a(ce);et=c(qt,"Unconditional Image Generation"),qt.forEach(t),kt.forEach(t),tt=d(W),G=r(W,"TD",{align:!0});var St=a(G);it=c(St,"-"),St.forEach(t),W.forEach(t),It.forEach(t),Ie.forEach(t),we=d(e),P=r(e,"H2",{class:!0});var xe=a(P);N=r(xe,"A",{id:!0,class:!0,href:!0});var Lt=a(N);he=r(Lt,"SPAN",{});var Ct=a(he);F(S.$$.fragment,Ct),Ct.forEach(t),Lt.forEach(t),ot=d(xe),ue=r(xe,"SPAN",{});var Ht=a(ue);rt=c(Ht,"PNDMPipeline"),Ht.forEach(t),xe.forEach(t),ye=d(e),u=r(e,"DIV",{class:!0});var B=a(u);F(L.$$.fragment,B),at=d(B),C=r(B,"P",{});var Ae=a(C);nt=c(Ae,"This model inherits from "),Z=r(Ae,"A",{href:!0});var Ot=a(Z);st=c(Ot,"DiffusionPipeline"),Ot.forEach(t),lt=c(Ae,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),Ae.forEach(t),dt=d(B),R=r(B,"DIV",{class:!0});var Ut=a(R);F(H.$$.fragment,Ut),Ut.forEach(t),B.forEach(t),this.h()},h(){n(f,"name","hf:doc:metadata"),n(f,"content",JSON.stringify(Ft)),n(b,"id","pndm"),n(b,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(b,"href","#pndm"),n(m,"class","relative group"),n(w,"id","overview"),n(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(w,"href","#overview"),n(g,"class","relative group"),n(x,"href","https://arxiv.org/abs/2202.09778"),n(x,"rel","nofollow"),n(A,"href","https://github.com/luping-liu/PNDM"),n(A,"rel","nofollow"),n(M,"id","available-pipelines"),n(M,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(M,"href","#available-pipelines"),n(v,"class","relative group"),n(z,"align","center"),n(q,"href","https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pndm/pipeline_pndm.py"),n(q,"rel","nofollow"),n(G,"align","center"),n(N,"id","diffusers.PNDMPipeline"),n(N,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(N,"href","#diffusers.PNDMPipeline"),n(P,"class","relative group"),n(Z,"href","/docs/diffusers/pr_1170/en/using-diffusers/loading#diffusers.DiffusionPipeline"),n(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),n(u,"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,s){i(document.head,f),h(e,fe,s),h(e,m,s),i(m,b),i(b,X),V(E,X,null),i(m,qe),i(m,ee),i(ee,Se),h(e,me,s),h(e,g,s),i(g,w),i(w,te),V(T,te,null),i(g,Le),i(g,ie),i(ie,Ce),h(e,ge,s),h(e,I,s),i(I,x),i(x,He),i(I,Oe),h(e,ve,s),h(e,O,s),i(O,Ue),h(e,_e,s),h(e,U,s),i(U,ze),h(e,De,s),h(e,y,s),i(y,Ge),i(y,A),i(A,Ze),i(y,Re),h(e,Pe,s),h(e,v,s),i(v,M),i(M,oe),V(k,oe,null),i(v,je),i(v,re),i(re,We),h(e,be,s),h(e,$,s),i($,ae),i(ae,_),i(_,ne),i(ne,Be),i(_,Ye),i(_,se),i(se,Fe),i(_,Ve),i(_,z),i(z,Je),i($,Ke),i($,le),i(le,D),i(D,de),i(de,q),i(q,Qe),i(D,Xe),i(D,pe),i(pe,ce),i(ce,et),i(D,tt),i(D,G),i(G,it),h(e,we,s),h(e,P,s),i(P,N),i(N,he),V(S,he,null),i(P,ot),i(P,ue),i(ue,rt),h(e,ye,s),h(e,u,s),V(L,u,null),i(u,at),i(u,C),i(C,nt),i(C,Z),i(Z,st),i(C,lt),i(u,dt),i(u,R),V(H,R,null),Me=!0},p:Wt,i(e){Me||(J(E.$$.fragment,e),J(T.$$.fragment,e),J(k.$$.fragment,e),J(S.$$.fragment,e),J(L.$$.fragment,e),J(H.$$.fragment,e),Me=!0)},o(e){K(E.$$.fragment,e),K(T.$$.fragment,e),K(k.$$.fragment,e),K(S.$$.fragment,e),K(L.$$.fragment,e),K(H.$$.fragment,e),Me=!1},d(e){t(f),e&&t(fe),e&&t(m),Q(E),e&&t(me),e&&t(g),Q(T),e&&t(ge),e&&t(I),e&&t(ve),e&&t(O),e&&t(_e),e&&t(U),e&&t(De),e&&t(y),e&&t(Pe),e&&t(v),Q(k),e&&t(be),e&&t($),e&&t(we),e&&t(P),Q(S),e&&t(ye),e&&t(u),Q(L),Q(H)}}}const Ft={local:"pndm",sections:[{local:"overview",title:"Overview"},{local:"available-pipelines",title:"Available Pipelines:"},{local:"diffusers.PNDMPipeline",title:"PNDMPipeline"}],title:"PNDM"};function Vt(ct){return Bt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xt extends Gt{constructor(f){super();Zt(this,f,Vt,Yt,Rt,{})}}export{Xt as default,Ft as metadata};
