import{s as he,z as be,o as $e,n as we}from"../chunks/scheduler.182ea377.js";import{S as ye,i as ve,g as l,s as a,r as C,A as _e,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 j,d as H,t as L,w as W}from"../chunks/index.abf12888.js";import{T as ke}from"../chunks/Tip.230e2334.js";import{C as ie}from"../chunks/CodeBlock.57fe6e13.js";import{D as Me}from"../chunks/DocNotebookDropdown.d9060979.js";import{H as Pe}from"../chunks/Heading.16916d63.js";function xe(V){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,D){i(f,s,D)},p:we,d(f){f&&n(s)}}}function Ze(V){let s,c,f,D,g,B,d,E,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.",I,b,se='The <a href="/docs/diffusers/v0.23.0/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> is the easiest way to use a pre-trained diffusion system for inference.',q,$,le=`Start by creating an instance of <a href="/docs/diffusers/v0.23.0/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,w,re='In this guide, you’ll use <a href="/docs/diffusers/v0.23.0/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,v,fe=`The <a href="/docs/diffusers/v0.23.0/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,_,A,T,pe="Now you can use the <code>generator</code> to generate an image:",K,k,Y,M,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 Pe({props:{title:"Unconditional image generation",local:"unconditional-image-generation",headingTag:"h1"}}),d=new Me({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 ke({props:{$$slots:{default:[xe]},$$scope:{ctx:V}}}),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}}),_=new ie({props:{code:"Z2VuZXJhdG9yLnRvKCUyMmN1ZGElMjIp",highlighted:'generator.to(<span class="hljs-string">&quot;cuda&quot;</span>)',wrap:!1}}),k=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"),D=a(),C(g.$$.fragment),B=a(),C(d.$$.fragment),E=a(),h=l("p"),h.textContent=oe,I=a(),b=l("p"),b.innerHTML=se,q=a(),$=l("p"),$.innerHTML=le,z=a(),C(m.$$.fragment),F=a(),w=l("p"),w.innerHTML=re,R=a(),C(y.$$.fragment),S=a(),v=l("p"),v.innerHTML=fe,N=a(),C(_.$$.fragment),A=a(),T=l("p"),T.innerHTML=pe,K=a(),C(k.$$.fragment),Y=a(),M=l("p"),M.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=_e("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),D=o(e),U(g.$$.fragment,e),B=o(e),U(d.$$.fragment,e),E=o(e),h=r(e,"P",{"data-svelte-h":!0}),u(h)!=="svelte-1s4jzli"&&(h.textContent=oe),I=o(e),b=r(e,"P",{"data-svelte-h":!0}),u(b)!=="svelte-1m8v38p"&&(b.innerHTML=se),q=o(e),$=r(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-1j0ckj8"&&($.innerHTML=le),z=o(e),U(m.$$.fragment,e),F=o(e),w=r(e,"P",{"data-svelte-h":!0}),u(w)!=="svelte-mjejek"&&(w.innerHTML=re),R=o(e),U(y.$$.fragment,e),S=o(e),v=r(e,"P",{"data-svelte-h":!0}),u(v)!=="svelte-1bdevib"&&(v.innerHTML=fe),N=o(e),U(_.$$.fragment,e),A=o(e),T=r(e,"P",{"data-svelte-h":!0}),u(T)!=="svelte-fr79tl"&&(T.innerHTML=pe),K=o(e),U(k.$$.fragment,e),Y=o(e),M=r(e,"P",{"data-svelte-h":!0}),u(M)!=="svelte-1n0jmoo"&&(M.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",Ce),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,D,t),j(g,e,t),i(e,B,t),j(d,e,t),i(e,E,t),i(e,h,t),i(e,I,t),i(e,b,t),i(e,q,t),i(e,$,t),i(e,z,t),j(m,e,t),i(e,F,t),i(e,w,t),i(e,R,t),j(y,e,t),i(e,S,t),i(e,v,t),i(e,N,t),j(_,e,t),i(e,A,t),i(e,T,t),i(e,K,t),j(k,e,t),i(e,Y,t),i(e,M,t),i(e,Q,t),i(e,P,t),i(e,X,t),j(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||(H(g.$$.fragment,e),H(d.$$.fragment,e),H(m.$$.fragment,e),H(y.$$.fragment,e),H(_.$$.fragment,e),H(k.$$.fragment,e),H(x.$$.fragment,e),ne=!0)},o(e){L(g.$$.fragment,e),L(d.$$.fragment,e),L(m.$$.fragment,e),L(y.$$.fragment,e),L(_.$$.fragment,e),L(k.$$.fragment,e),L(x.$$.fragment,e),ne=!1},d(e){e&&(n(c),n(f),n(D),n(B),n(E),n(h),n(I),n(b),n(q),n($),n(z),n(F),n(w),n(R),n(S),n(v),n(N),n(A),n(T),n(K),n(Y),n(M),n(Q),n(P),n(X),n(O),n(Z),n(ee),n(p),n(te),n(J)),n(s),W(g,e),W(d,e),W(m,e),W(y,e),W(_,e),W(k,e),W(x,e)}}}const Ce='{"title":"Unconditional image generation","local":"unconditional-image-generation","sections":[],"depth":1}';function Ue(V){return $e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends ye{constructor(s){super(),ve(this,s,Ue,Ze,he,{})}}export{Je as component};
