Buckets:
| import"../chunks/DsnmJJEf.js";import{i as T,h as j,C as S,H as t,D as o,E as G,s as Z,a as B}from"../chunks/BtE7mKSK.js";import{p as k,o as J,s as e,f as y,a as r,b as N,c as d,d as p,r as l,n as D}from"../chunks/jDjavuwI.js";import{E as O}from"../chunks/SrSJA0zO.js";const E='{"title":"DDPM","local":"ddpm","sections":[],"depth":1}';var L=p('<meta name="hf:doc:metadata"/>'),C=p("<p>Example:</p> <!>",1),q=p(`<p></p> <!> <!> <p><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.</p> <p>The abstract from the paper is:</p> <p><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></p> <p>The original codebase can be found at <a href="https://github.com/hojonathanho/diffusion" rel="nofollow">hohonathanho/diffusion</a>.</p> <blockquote class="tip"><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></blockquote> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Pipeline for image generation.</p> <p>This model inherits from <a href="/docs/diffusers/pr_14257/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.).</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The call function to the pipeline for generation.</p> <!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Output class for image pipelines.</p></div> <!> <p></p>`,1);function X(P,v){k(v,!1),J(()=>{new URLSearchParams(window.location.search).get("fw")}),T();var c=q();j("1k4mrnf",s=>{var i=L();Z(i,"content",E),r(s,i)});var u=e(y(c),2);S(u,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var m=e(u,2);t(m,{title:"DDPM",local:"ddpm",headingTag:"h1"});var f=e(m,12);t(f,{title:"DDPMPipeline",local:"diffusers.DDPMPipeline",headingTag:"h1"});var n=e(f,2),h=d(n);o(h,{name:"class diffusers.DDPMPipeline",anchor:"diffusers.DDPMPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14257/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L33",parameters:[{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": DDPMScheduler"}],parametersDescription:[{anchor:"diffusers.DDPMPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/pr_14257/en/api/models/unet2d#diffusers.UNet2DModel">UNet2DModel</a>) — | |
| 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_14257/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) — | |
| 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_14257/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>, or <a href="/docs/diffusers/pr_14257/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>.`,name:"scheduler"}]});var g=e(h,6),_=d(g);o(_,{name:"__call__",anchor:"diffusers.DDPMPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14257/src/diffusers/pipelines/ddpm/pipeline_ddpm.py#L54",parameters:[{name:"batch_size",val:": int = 1"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"num_inference_steps",val:": int = 1000"},{name:"output_type",val:": str | None = '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) — | |
| 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>) — | |
| 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) — | |
| 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>"pil"</code>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/diffusers/pr_14257/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If <code>return_dict</code> is <code>True</code>, <a | |
| href="/docs/diffusers/pr_14257/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/pr_14257/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput" | |
| >ImagePipelineOutput</a> or <code>tuple</code></p> | |
| `});var w=e(_,4);O(w,{anchor:"diffusers.DDPMPipeline.__call__.example",children:(s,i)=>{var M=C(),x=e(y(M),2);B(x,{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEREUE1QaXBlbGluZSUwQSUwQSUyMyUyMGxvYWQlMjBtb2RlbCUyMGFuZCUyMHNjaGVkdWxlciUwQXBpcGUlMjAlM0QlMjBERFBNUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRmRkcG0tY2F0LTI1NiUyMiklMEElMEElMjMlMjBydW4lMjBwaXBlbGluZSUyMGluJTIwaW5mZXJlbmNlJTIwKHNhbXBsZSUyMHJhbmRvbSUyMG5vaXNlJTIwYW5kJTIwZGVub2lzZSklMEFpbWFnZSUyMCUzRCUyMHBpcGUoKS5pbWFnZXMlNUIwJTVEJTBBJTBBJTIzJTIwc2F2ZSUyMGltYWdlJTBBaW1hZ2Uuc2F2ZSglMjJkZHBtX2dlbmVyYXRlZF9pbWFnZS5wbmclMjIp",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDPMPipeline | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># load model and scheduler</span> | |
| <span class="hljs-meta">>>> </span>pipe = DDPMPipeline.from_pretrained(<span class="hljs-string">"google/ddpm-cat-256"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># run pipeline in inference (sample random noise and denoise)</span> | |
| <span class="hljs-meta">>>> </span>image = pipe().images[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># save image</span> | |
| <span class="hljs-meta">>>> </span>image.save(<span class="hljs-string">"ddpm_generated_image.png"</span>)`,lang:"py",wrap:!1}),r(s,M)},$$slots:{default:!0}}),l(g),l(n);var b=e(n,2);t(b,{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"});var a=e(b,2),I=d(a);o(I,{name:"class diffusers.ImagePipelineOutput",anchor:"diffusers.ImagePipelineOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14257/src/diffusers/pipelines/pipeline_utils.py#L135",parameters:[{name:"images",val:": 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>) — | |
| 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"}]}),D(2),l(a);var U=e(a,2);G(U,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/ddpm.md"}),D(2),r(P,c),N()}export{X as component}; | |
Xet Storage Details
- Size:
- 9.53 kB
- Xet hash:
- 1c5dcf149f0307faa43fe4bbf7437584179ad2d812cce33fbdedb50bcfc25232
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.