Buckets:

rtrm's picture
download
raw
13.1 kB
import{s as De,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 b,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 v,p as D}from"../chunks/index.100fac89.js";import{C as Ue}from"../chunks/CopyLLMTxtMenu.133e28e0.js";import{D as ue}from"../chunks/Docstring.f8721f67.js";import{C as je}from"../chunks/CodeBlock.d30a6509.js";import{E as Le}from"../chunks/ExampleCodeBlock.24511344.js";import{H as fe,E as Se}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d8195636.js";function ke(R){let o,I="Example:",h,c,m;return c=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(),b(c.$$.fragment)},l(r){o=p(r,"P",{"data-svelte-h":!0}),M(o)!=="svelte-11lpom8"&&(o.textContent=I),h=a(r),$(c.$$.fragment,r)},m(r,f){s(r,o,f),s(r,h,f),P(c,r,f),m=!0},p:we,i(r){m||(y(c.$$.fragment,r),m=!0)},o(r){v(c.$$.fragment,r),m=!1},d(r){r&&(n(o),n(h)),D(c,r)}}}function Ee(R){let o,I,h,c,m,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,_e="<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,be='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/pr_12249/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,_,E,de,q,ye="The call function to the pipeline for generation.",ce,C,te,G,ne,x,Z,me,J,ve="Output class for image pipelines.",se,B,ie,W,ae;return m=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/pr_12249/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_12249/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_12249/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>, or <a href="/docs/diffusers/pr_12249/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/vr_12249/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/pr_12249/en/api/pipelines/stable_unclip#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_12249/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/pr_12249/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/pr_12249/en/api/pipelines/stable_unclip#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/vr_12249/src/diffusers/pipelines/pipeline_utils.py#L120"}}),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"),c=i(),b(m.$$.fragment),r=i(),b(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=_e,Q=i(),L=l("p"),L.innerHTML=be,Y=i(),w=l("blockquote"),w.innerHTML=$e,K=i(),b(S.$$.fragment),ee=i(),d=l("div"),b(k.$$.fragment),oe=i(),O=l("p"),O.textContent=Me,le=i(),H=l("p"),H.innerHTML=Pe,pe=i(),_=l("div"),b(E.$$.fragment),de=i(),q=l("p"),q.textContent=ye,ce=i(),b(C.$$.fragment),te=i(),b(G.$$.fragment),ne=i(),x=l("div"),b(Z.$$.fragment),me=i(),J=l("p"),J.textContent=ve,se=i(),b(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),c=a(e),$(m.$$.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=_e),Q=a(e),L=p(e,"P",{"data-svelte-h":!0}),M(L)!=="svelte-si8dkt"&&(L.innerHTML=be),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-1m9a5y4"&&(H.innerHTML=Pe),pe=a(g),_=p(g,"DIV",{class:!0});var N=z(_);$(E.$$.fragment,N),de=a(N),q=p(N,"P",{"data-svelte-h":!0}),M(q)!=="svelte-50j04k"&&(q.textContent=ye),ce=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),me=a(re),J=p(re,"P",{"data-svelte-h":!0}),M(J)!=="svelte-19wetgi"&&(J.textContent=ve),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(_,"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,c,t),P(m,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,_),P(E,_,null),u(_,de),u(_,q),u(_,ce),P(C,_,null),s(e,te,t),P(G,e,t),s(e,ne,t),s(e,x,t),P(Z,x,null),u(x,me),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(m.$$.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){v(m.$$.fragment,e),v(f.$$.fragment,e),v(S.$$.fragment,e),v(k.$$.fragment,e),v(E.$$.fragment,e),v(C.$$.fragment,e),v(G.$$.fragment,e),v(Z.$$.fragment,e),v(B.$$.fragment,e),ae=!1},d(e){e&&(n(I),n(h),n(c),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),D(m,e),D(f,e),D(S,e),D(k),D(E),D(C),D(G,e),D(Z),D(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,De,{})}}export{We as component};

Xet Storage Details

Size:
13.1 kB
·
Xet hash:
34a197bfa5efa9a60d8be801f0bdcccb3e6b84e4e747e4c1dce19d61012da42b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.