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 s,j as ae,u as j,x as m,k as G,y as Te,a as i,v as U,d as H,t as L,w as D}from"../chunks/index.abf12888.js";import{T as Me}from"../chunks/Tip.230e2334.js";import{C as ie}from"../chunks/CodeBlock.57fe6e13.js";import{D as ke}from"../chunks/DocNotebookDropdown.d9060979.js";import{H as Pe}from"../chunks/Heading.16916d63.js";function xe(J){let o,g='💡 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(){o=l("p"),o.innerHTML=g},l(f){o=r(f,"P",{"data-svelte-h":!0}),m(o)!=="svelte-vx68wx"&&(o.innerHTML=g)},m(f,W){i(f,o,W)},p:$e,d(f){f&&n(o)}}}function Ze(J){let o,g,f,W,c,V,d,E,h,se="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,oe='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.',z,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).`,F,u,R,$,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>:',B,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,me='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,ue="You can save the image by calling:",X,x,O,Z,ge="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,ce,te,q,ne;return c=new Pe({props:{title:"Unconditional image generation",local:"unconditional-image-generation",headingTag:"h1"}}),d=new ke({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"}]}}),u=new Me({props:{$$slots:{default:[xe]},$$scope:{ctx:J}}}),y=new ie({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmFudG9uLWwlMkZkZHBtLWJ1dHRlcmZsaWVzLTEyOCUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

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