import{s as he,z as be,o as we,n as $e}from"../chunks/scheduler.182ea377.js";import{S as ye,i as _e,g as l,s as a,r as C,A as ve,h as r,f as n,c as o,j as ae,u as U,x as u,k as G,y as Te,a as i,v as H,d as L,t as j,w as D}from"../chunks/index.1ea56653.js";import{H as Me,g as ke}from"../chunks/Heading.71ac6e9f.js";import{T as Pe}from"../chunks/Tip.67abc998.js";import{C as ie}from"../chunks/CodeBlock.82c2494b.js";import{D as xe}from"../chunks/DocNotebookDropdown.b1496a40.js";function Ze(q){let s,c='💡 Want to train your own unconditional image generation model? Take a look at the training <a href="../training/unconditional_training">guide</a> to learn how to generate your own images.';return{c(){s=l("p"),s.innerHTML=c},l(f){s=r(f,"P",{"data-svelte-h":!0}),u(s)!=="svelte-1sst9pc"&&(s.innerHTML=c)},m(f,W){i(f,s,W)},p:$e,d(f){f&&n(s)}}}function Ce(q){let s,c,f,W,g,V,d,B,h,oe="Unconditional image generation is a relatively straightforward task. The model only generates images - without any additional context like text or an image - resembling the training data it was trained on.",E,b,se='The <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> is the easiest way to use a pre-trained diffusion system for inference.',I,w,le=`Start by creating an instance of <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> and specify which pipeline checkpoint you would like to download.
You can use any of the 🧨 Diffusers <a href="https://huggingface.co/models?library=diffusers&amp;sort=downloads" rel="nofollow">checkpoints</a> from the Hub (the checkpoint you’ll use generates images of butterflies).`,z,m,F,$,re='In this guide, you’ll use <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> for unconditional image generation with <a href="https://arxiv.org/abs/2006.11239" rel="nofollow">DDPM</a>:',R,y,S,_,fe=`The <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> downloads and caches all modeling, tokenization, and scheduling components.
Because the model consists of roughly 1.4 billion parameters, we strongly recommend running it on a GPU.
You can move the generator object to a GPU, just like you would in PyTorch:`,N,v,A,T,pe="Now you can use the <code>generator</code> to generate an image:",K,M,Y,k,ue='The output is by default wrapped into a <a href="https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class" rel="nofollow"><code>PIL.Image</code></a> object.',Q,P,me="You can save the image by calling:",X,x,O,Z,ce="Try out the Spaces below, and feel free to play around with the inference steps parameter to see how it affects the image quality!",ee,p,ge,te,J,ne;return g=new Me({props:{title:"Unconditional image generation",local:"unconditional-image-generation",headingTag:"h1"}}),d=new xe({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/unconditional_image_generation.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/unconditional_image_generation.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/unconditional_image_generation.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/unconditional_image_generation.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/unconditional_image_generation.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/unconditional_image_generation.ipynb"}]}}),m=new Pe({props:{$$slots:{default:[Ze]},$$scope:{ctx:q}}}),y=new ie({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmFudG9uLWwlMkZkZHBtLWJ1dHRlcmZsaWVzLTEyOCUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

generator = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;anton-l/ddpm-butterflies-128&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>)`,wrap:!1}}),v=new ie({props:{code:"Z2VuZXJhdG9yLnRvKCUyMmN1ZGElMjIp",highlighted:'generator.to(<span class="hljs-string">&quot;cuda&quot;</span>)',wrap:!1}}),M=new ie({props:{code:"aW1hZ2UlMjAlM0QlMjBnZW5lcmF0b3IoKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2U=",highlighted:`image = generator().images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),x=new ie({props:{code:"aW1hZ2Uuc2F2ZSglMjJnZW5lcmF0ZWRfaW1hZ2UucG5nJTIyKQ==",highlighted:'image.save(<span class="hljs-string">&quot;generated_image.png&quot;</span>)',wrap:!1}}),{c(){s=l("meta"),c=a(),f=l("p"),W=a(),C(g.$$.fragment),V=a(),C(d.$$.fragment),B=a(),h=l("p"),h.textContent=oe,E=a(),b=l("p"),b.innerHTML=se,I=a(),w=l("p"),w.innerHTML=le,z=a(),C(m.$$.fragment),F=a(),$=l("p"),$.innerHTML=re,R=a(),C(y.$$.fragment),S=a(),_=l("p"),_.innerHTML=fe,N=a(),C(v.$$.fragment),A=a(),T=l("p"),T.innerHTML=pe,K=a(),C(M.$$.fragment),Y=a(),k=l("p"),k.innerHTML=ue,Q=a(),P=l("p"),P.textContent=me,X=a(),C(x.$$.fragment),O=a(),Z=l("p"),Z.textContent=ce,ee=a(),p=l("iframe"),te=a(),J=l("p"),this.h()},l(e){const t=ve("svelte-u9bgzb",document.head);s=r(t,"META",{name:!0,content:!0}),t.forEach(n),c=o(e),f=r(e,"P",{}),ae(f).forEach(n),W=o(e),U(g.$$.fragment,e),V=o(e),U(d.$$.fragment,e),B=o(e),h=r(e,"P",{"data-svelte-h":!0}),u(h)!=="svelte-1s4jzli"&&(h.textContent=oe),E=o(e),b=r(e,"P",{"data-svelte-h":!0}),u(b)!=="svelte-13s4k5x"&&(b.innerHTML=se),I=o(e),w=r(e,"P",{"data-svelte-h":!0}),u(w)!=="svelte-ofq2yy"&&(w.innerHTML=le),z=o(e),U(m.$$.fragment,e),F=o(e),$=r(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-1q3mqv8"&&($.innerHTML=re),R=o(e),U(y.$$.fragment,e),S=o(e),_=r(e,"P",{"data-svelte-h":!0}),u(_)!=="svelte-1y9fnbf"&&(_.innerHTML=fe),N=o(e),U(v.$$.fragment,e),A=o(e),T=r(e,"P",{"data-svelte-h":!0}),u(T)!=="svelte-fr79tl"&&(T.innerHTML=pe),K=o(e),U(M.$$.fragment,e),Y=o(e),k=r(e,"P",{"data-svelte-h":!0}),u(k)!=="svelte-1n0jmoo"&&(k.innerHTML=ue),Q=o(e),P=r(e,"P",{"data-svelte-h":!0}),u(P)!=="svelte-1v6wxor"&&(P.textContent=me),X=o(e),U(x.$$.fragment,e),O=o(e),Z=r(e,"P",{"data-svelte-h":!0}),u(Z)!=="svelte-qb1yds"&&(Z.textContent=ce),ee=o(e),p=r(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),ae(p).forEach(n),te=o(e),J=r(e,"P",{}),ae(J).forEach(n),this.h()},h(){G(s,"name","hf:doc:metadata"),G(s,"content",Ue),be(p.src,ge="https://stevhliu-ddpm-butterflies-128.hf.space")||G(p,"src",ge),G(p,"frameborder","0"),G(p,"width","850"),G(p,"height","500")},m(e,t){Te(document.head,s),i(e,c,t),i(e,f,t),i(e,W,t),H(g,e,t),i(e,V,t),H(d,e,t),i(e,B,t),i(e,h,t),i(e,E,t),i(e,b,t),i(e,I,t),i(e,w,t),i(e,z,t),H(m,e,t),i(e,F,t),i(e,$,t),i(e,R,t),H(y,e,t),i(e,S,t),i(e,_,t),i(e,N,t),H(v,e,t),i(e,A,t),i(e,T,t),i(e,K,t),H(M,e,t),i(e,Y,t),i(e,k,t),i(e,Q,t),i(e,P,t),i(e,X,t),H(x,e,t),i(e,O,t),i(e,Z,t),i(e,ee,t),i(e,p,t),i(e,te,t),i(e,J,t),ne=!0},p(e,[t]){const de={};t&2&&(de.$$scope={dirty:t,ctx:e}),m.$set(de)},i(e){ne||(L(g.$$.fragment,e),L(d.$$.fragment,e),L(m.$$.fragment,e),L(y.$$.fragment,e),L(v.$$.fragment,e),L(M.$$.fragment,e),L(x.$$.fragment,e),ne=!0)},o(e){j(g.$$.fragment,e),j(d.$$.fragment,e),j(m.$$.fragment,e),j(y.$$.fragment,e),j(v.$$.fragment,e),j(M.$$.fragment,e),j(x.$$.fragment,e),ne=!1},d(e){e&&(n(c),n(f),n(W),n(V),n(B),n(h),n(E),n(b),n(I),n(w),n(z),n(F),n($),n(R),n(S),n(_),n(N),n(A),n(T),n(K),n(Y),n(k),n(Q),n(P),n(X),n(O),n(Z),n(ee),n(p),n(te),n(J)),n(s),D(g,e),D(d,e),D(m,e),D(y,e),D(v,e),D(M,e),D(x,e)}}}const Ue='{"title":"Unconditional image generation","local":"unconditional-image-generation","sections":[],"depth":1}';function He(q){return we(()=>{new URLSearchParams(window.location.search).get("fw"),window.hfDocGoto=ke}),[]}class qe extends ye{constructor(s){super(),_e(this,s,He,Ce,he,{})}}export{qe as component};
