import{S as mt,i as ct,s as ht,e as l,k as m,w as S,t as n,M as gt,c as r,d as t,m as c,a as f,x as q,h as s,b as u,N as dt,G as a,g as o,y as B,q as N,o as C,B as V,v as bt}from"../../chunks/vendor-hf-doc-builder.js";import{T as wt}from"../../chunks/Tip-hf-doc-builder.js";import{I as yt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as ke}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as _t}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function vt(te){let p,$,h,d,v;return{c(){p=l("p"),$=n("\u{1F4A1} Want to train your own unconditional image generation model? Take a look at the training "),h=l("a"),d=n("guide"),v=n(" to learn how to generate your own images."),this.h()},l(g){p=r(g,"P",{});var b=f(p);$=s(b,"\u{1F4A1} Want to train your own unconditional image generation model? Take a look at the training "),h=r(b,"A",{href:!0});var k=f(h);d=s(k,"guide"),k.forEach(t),v=s(b," to learn how to generate your own images."),b.forEach(t),this.h()},h(){u(h,"href","training/unconditional_training")},m(g,b){o(g,p,b),a(p,$),a(p,h),a(h,d),a(p,v)},d(g){g&&t(p)}}}function $t(te){let p,$,h,d,v,g,b,k,Pe,ae,U,ie,F,Ee,oe,P,Te,L,De,Ze,ne,w,Ue,R,je,Me,j,Ge,Ie,se,E,le,y,xe,Y,We,Ae,M,Je,Se,re,G,fe,T,qe,z,Be,Ne,ue,I,pe,D,Ce,Q,Ve,Fe,me,x,ce,Z,Le,W,ee,Re,Ye,he,H,ze,ge,A,de,K,He,be,_,Ke,we;return g=new yt({}),U=new _t({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"}]}}),E=new wt({props:{$$slots:{default:[vt]},$$scope:{ctx:te}}}),G=new ke({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmFudG9uLWwlMkZkZHBtLWJ1dHRlcmZsaWVzLTEyOCUyMik=",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>)`}}),I=new ke({props:{code:"Z2VuZXJhdG9yLnRvKCUyMmN1ZGElMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>generator.to(<span class="hljs-string">&quot;cuda&quot;</span>)'}}),x=new ke({props:{code:"aW1hZ2UlMjAlM0QlMjBnZW5lcmF0b3IoKS5pbWFnZXMlNUIwJTVE",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>image = generator().images[<span class="hljs-number">0</span>]'}}),A=new ke({props:{code:"aW1hZ2Uuc2F2ZSglMjJnZW5lcmF0ZWRfaW1hZ2UucG5nJTIyKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;generated_image.png&quot;</span>)'}}),{c(){p=l("meta"),$=m(),h=l("h1"),d=l("a"),v=l("span"),S(g.$$.fragment),b=m(),k=l("span"),Pe=n("Unconditional image generation"),ae=m(),S(U.$$.fragment),ie=m(),F=l("p"),Ee=n("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."),oe=m(),P=l("p"),Te=n("The "),L=l("a"),De=n("DiffusionPipeline"),Ze=n(" is the easiest way to use a pre-trained diffusion system for inference."),ne=m(),w=l("p"),Ue=n("Start by creating an instance of "),R=l("a"),je=n("DiffusionPipeline"),Me=n(` and specify which pipeline checkpoint you would like to download.
You can use any of the \u{1F9E8} Diffusers `),j=l("a"),Ge=n("checkpoints"),Ie=n(" from the Hub (the checkpoint you\u2019ll use generates images of butterflies)."),se=m(),S(E.$$.fragment),le=m(),y=l("p"),xe=n("In this guide, you\u2019ll use "),Y=l("a"),We=n("DiffusionPipeline"),Ae=n(" for unconditional image generation with "),M=l("a"),Je=n("DDPM"),Se=n(":"),re=m(),S(G.$$.fragment),fe=m(),T=l("p"),qe=n("The "),z=l("a"),Be=n("DiffusionPipeline"),Ne=n(` 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:`),ue=m(),S(I.$$.fragment),pe=m(),D=l("p"),Ce=n("Now you can use the "),Q=l("code"),Ve=n("generator"),Fe=n(" to generate an image:"),me=m(),S(x.$$.fragment),ce=m(),Z=l("p"),Le=n("The output is by default wrapped into a "),W=l("a"),ee=l("code"),Re=n("PIL.Image"),Ye=n(" object."),he=m(),H=l("p"),ze=n("You can save the image by calling:"),ge=m(),S(A.$$.fragment),de=m(),K=l("p"),He=n("Try out the Spaces below, and feel free to play around with the inference steps parameter to see how it affects the image quality!"),be=m(),_=l("iframe"),this.h()},l(e){const i=gt('[data-svelte="svelte-1phssyn"]',document.head);p=r(i,"META",{name:!0,content:!0}),i.forEach(t),$=c(e),h=r(e,"H1",{class:!0});var J=f(h);d=r(J,"A",{id:!0,class:!0,href:!0});var Oe=f(d);v=r(Oe,"SPAN",{});var Xe=f(v);q(g.$$.fragment,Xe),Xe.forEach(t),Oe.forEach(t),b=c(J),k=r(J,"SPAN",{});var Qe=f(k);Pe=s(Qe,"Unconditional image generation"),Qe.forEach(t),J.forEach(t),ae=c(e),q(U.$$.fragment,e),ie=c(e),F=r(e,"P",{});var et=f(F);Ee=s(et,"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."),et.forEach(t),oe=c(e),P=r(e,"P",{});var ye=f(P);Te=s(ye,"The "),L=r(ye,"A",{href:!0});var tt=f(L);De=s(tt,"DiffusionPipeline"),tt.forEach(t),Ze=s(ye," is the easiest way to use a pre-trained diffusion system for inference."),ye.forEach(t),ne=c(e),w=r(e,"P",{});var O=f(w);Ue=s(O,"Start by creating an instance of "),R=r(O,"A",{href:!0});var at=f(R);je=s(at,"DiffusionPipeline"),at.forEach(t),Me=s(O,` and specify which pipeline checkpoint you would like to download.
You can use any of the \u{1F9E8} Diffusers `),j=r(O,"A",{href:!0,rel:!0});var it=f(j);Ge=s(it,"checkpoints"),it.forEach(t),Ie=s(O," from the Hub (the checkpoint you\u2019ll use generates images of butterflies)."),O.forEach(t),se=c(e),q(E.$$.fragment,e),le=c(e),y=r(e,"P",{});var X=f(y);xe=s(X,"In this guide, you\u2019ll use "),Y=r(X,"A",{href:!0});var ot=f(Y);We=s(ot,"DiffusionPipeline"),ot.forEach(t),Ae=s(X," for unconditional image generation with "),M=r(X,"A",{href:!0,rel:!0});var nt=f(M);Je=s(nt,"DDPM"),nt.forEach(t),Se=s(X,":"),X.forEach(t),re=c(e),q(G.$$.fragment,e),fe=c(e),T=r(e,"P",{});var _e=f(T);qe=s(_e,"The "),z=r(_e,"A",{href:!0});var st=f(z);Be=s(st,"DiffusionPipeline"),st.forEach(t),Ne=s(_e,` 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:`),_e.forEach(t),ue=c(e),q(I.$$.fragment,e),pe=c(e),D=r(e,"P",{});var ve=f(D);Ce=s(ve,"Now you can use the "),Q=r(ve,"CODE",{});var lt=f(Q);Ve=s(lt,"generator"),lt.forEach(t),Fe=s(ve," to generate an image:"),ve.forEach(t),me=c(e),q(x.$$.fragment,e),ce=c(e),Z=r(e,"P",{});var $e=f(Z);Le=s($e,"The output is by default wrapped into a "),W=r($e,"A",{href:!0,rel:!0});var rt=f(W);ee=r(rt,"CODE",{});var ft=f(ee);Re=s(ft,"PIL.Image"),ft.forEach(t),rt.forEach(t),Ye=s($e," object."),$e.forEach(t),he=c(e),H=r(e,"P",{});var ut=f(H);ze=s(ut,"You can save the image by calling:"),ut.forEach(t),ge=c(e),q(A.$$.fragment,e),de=c(e),K=r(e,"P",{});var pt=f(K);He=s(pt,"Try out the Spaces below, and feel free to play around with the inference steps parameter to see how it affects the image quality!"),pt.forEach(t),be=c(e),_=r(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),f(_).forEach(t),this.h()},h(){u(p,"name","hf:doc:metadata"),u(p,"content",JSON.stringify(kt)),u(d,"id","unconditional-image-generation"),u(d,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(d,"href","#unconditional-image-generation"),u(h,"class","relative group"),u(L,"href","/docs/diffusers/v0.19.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(R,"href","/docs/diffusers/v0.19.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(j,"href","https://huggingface.co/models?library=diffusers&sort=downloads"),u(j,"rel","nofollow"),u(Y,"href","/docs/diffusers/v0.19.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(M,"href","https://arxiv.org/abs/2006.11239"),u(M,"rel","nofollow"),u(z,"href","/docs/diffusers/v0.19.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(W,"href","https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class"),u(W,"rel","nofollow"),dt(_.src,Ke="https://stevhliu-ddpm-butterflies-128.hf.space")||u(_,"src",Ke),u(_,"frameborder","0"),u(_,"width","850"),u(_,"height","500")},m(e,i){a(document.head,p),o(e,$,i),o(e,h,i),a(h,d),a(d,v),B(g,v,null),a(h,b),a(h,k),a(k,Pe),o(e,ae,i),B(U,e,i),o(e,ie,i),o(e,F,i),a(F,Ee),o(e,oe,i),o(e,P,i),a(P,Te),a(P,L),a(L,De),a(P,Ze),o(e,ne,i),o(e,w,i),a(w,Ue),a(w,R),a(R,je),a(w,Me),a(w,j),a(j,Ge),a(w,Ie),o(e,se,i),B(E,e,i),o(e,le,i),o(e,y,i),a(y,xe),a(y,Y),a(Y,We),a(y,Ae),a(y,M),a(M,Je),a(y,Se),o(e,re,i),B(G,e,i),o(e,fe,i),o(e,T,i),a(T,qe),a(T,z),a(z,Be),a(T,Ne),o(e,ue,i),B(I,e,i),o(e,pe,i),o(e,D,i),a(D,Ce),a(D,Q),a(Q,Ve),a(D,Fe),o(e,me,i),B(x,e,i),o(e,ce,i),o(e,Z,i),a(Z,Le),a(Z,W),a(W,ee),a(ee,Re),a(Z,Ye),o(e,he,i),o(e,H,i),a(H,ze),o(e,ge,i),B(A,e,i),o(e,de,i),o(e,K,i),a(K,He),o(e,be,i),o(e,_,i),we=!0},p(e,[i]){const J={};i&2&&(J.$$scope={dirty:i,ctx:e}),E.$set(J)},i(e){we||(N(g.$$.fragment,e),N(U.$$.fragment,e),N(E.$$.fragment,e),N(G.$$.fragment,e),N(I.$$.fragment,e),N(x.$$.fragment,e),N(A.$$.fragment,e),we=!0)},o(e){C(g.$$.fragment,e),C(U.$$.fragment,e),C(E.$$.fragment,e),C(G.$$.fragment,e),C(I.$$.fragment,e),C(x.$$.fragment,e),C(A.$$.fragment,e),we=!1},d(e){t(p),e&&t($),e&&t(h),V(g),e&&t(ae),V(U,e),e&&t(ie),e&&t(F),e&&t(oe),e&&t(P),e&&t(ne),e&&t(w),e&&t(se),V(E,e),e&&t(le),e&&t(y),e&&t(re),V(G,e),e&&t(fe),e&&t(T),e&&t(ue),V(I,e),e&&t(pe),e&&t(D),e&&t(me),V(x,e),e&&t(ce),e&&t(Z),e&&t(he),e&&t(H),e&&t(ge),V(A,e),e&&t(de),e&&t(K),e&&t(be),e&&t(_)}}}const kt={local:"unconditional-image-generation",title:"Unconditional image generation"};function Pt(te){return bt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends mt{constructor(p){super();ct(this,p,Pt,$t,ht,{})}}export{jt as default,kt as metadata};
