import{s as he,z as be,o as we,n as $e}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 s,j as ae,u as j,x as u,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 Pe}from"../chunks/DocNotebookDropdown.d9060979.js";import{H as ke}from"../chunks/Heading.16916d63.js";function xe(V){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}),u(o)!=="svelte-vx68wx"&&(o.innerHTML=g)},m(f,W){i(f,o,W)},p:$e,d(f){f&&n(o)}}}function Ze(V){let o,g,f,W,c,q,d,z,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.",E,b,oe='The <a href="/docs/diffusers/v0.22.0/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/v0.22.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).`,F,m,R,$,re='In this guide, you’ll use <a href="/docs/diffusers/v0.22.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>:',B,y,S,v,fe=`The <a href="/docs/diffusers/v0.22.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,M,Y,P,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,k,me="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,J,ne;return c=new ke({props:{title:"Unconditional image generation",local:"unconditional-image-generation",headingTag:"h1"}}),d=new Pe({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 Me({props:{$$slots:{default:[xe]},$$scope:{ctx:V}}}),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}}),_=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),q=a(),C(d.$$.fragment),z=a(),h=l("p"),h.textContent=se,E=a(),b=l("p"),b.innerHTML=oe,I=a(),w=l("p"),w.innerHTML=le,F=a(),C(m.$$.fragment),R=a(),$=l("p"),$.innerHTML=re,B=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(M.$$.fragment),Y=a(),P=l("p"),P.innerHTML=ue,Q=a(),k=l("p"),k.textContent=me,X=a(),C(x.$$.fragment),O=a(),Z=l("p"),Z.textContent=ge,ee=a(),p=l("iframe"),te=a(),J=l("p"),this.h()},l(e){const t=_e("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),q=s(e),j(d.$$.fragment,e),z=s(e),h=r(e,"P",{"data-svelte-h":!0}),u(h)!=="svelte-1s4jzli"&&(h.textContent=se),E=s(e),b=r(e,"P",{"data-svelte-h":!0}),u(b)!=="svelte-1oir390"&&(b.innerHTML=oe),I=s(e),w=r(e,"P",{"data-svelte-h":!0}),u(w)!=="svelte-y42193"&&(w.innerHTML=le),F=s(e),j(m.$$.fragment,e),R=s(e),$=r(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-1aadam5"&&($.innerHTML=re),B=s(e),j(y.$$.fragment,e),S=s(e),v=r(e,"P",{"data-svelte-h":!0}),u(v)!=="svelte-qwz3qu"&&(v.innerHTML=fe),N=s(e),j(_.$$.fragment,e),A=s(e),T=r(e,"P",{"data-svelte-h":!0}),u(T)!=="svelte-fr79tl"&&(T.innerHTML=pe),K=s(e),j(M.$$.fragment,e),Y=s(e),P=r(e,"P",{"data-svelte-h":!0}),u(P)!=="svelte-1n0jmoo"&&(P.innerHTML=ue),Q=s(e),k=r(e,"P",{"data-svelte-h":!0}),u(k)!=="svelte-1v6wxor"&&(k.textContent=me),X=s(e),j(x.$$.fragment,e),O=s(e),Z=r(e,"P",{"data-svelte-h":!0}),u(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),J=r(e,"P",{}),ae(J).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,q,t),U(d,e,t),i(e,z,t),i(e,h,t),i(e,E,t),i(e,b,t),i(e,I,t),i(e,w,t),i(e,F,t),U(m,e,t),i(e,R,t),i(e,$,t),i(e,B,t),U(y,e,t),i(e,S,t),i(e,v,t),i(e,N,t),U(_,e,t),i(e,A,t),i(e,T,t),i(e,K,t),U(M,e,t),i(e,Y,t),i(e,P,t),i(e,Q,t),i(e,k,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,J,t),ne=!0},p(e,[t]){const de={};t&2&&(de.$$scope={dirty:t,ctx:e}),m.$set(de)},i(e){ne||(H(c.$$.fragment,e),H(d.$$.fragment,e),H(m.$$.fragment,e),H(y.$$.fragment,e),H(_.$$.fragment,e),H(M.$$.fragment,e),H(x.$$.fragment,e),ne=!0)},o(e){L(c.$$.fragment,e),L(d.$$.fragment,e),L(m.$$.fragment,e),L(y.$$.fragment,e),L(_.$$.fragment,e),L(M.$$.fragment,e),L(x.$$.fragment,e),ne=!1},d(e){e&&(n(g),n(f),n(W),n(q),n(z),n(h),n(E),n(b),n(I),n(w),n(F),n(R),n($),n(B),n(S),n(v),n(N),n(A),n(T),n(K),n(Y),n(P),n(Q),n(k),n(X),n(O),n(Z),n(ee),n(p),n(te),n(J)),n(o),D(c,e),D(d,e),D(m,e),D(y,e),D(_,e),D(M,e),D(x,e)}}}const Ce='{"title":"Unconditional image generation","local":"unconditional-image-generation","sections":[],"depth":1}';function je(V){return we(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends ye{constructor(o){super(),ve(this,o,je,Ze,he,{})}}export{Je as component};
