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 V,h as s,b as u,N as dt,G as a,g as o,y as q,q as B,o as N,B as C,v as yt}from"../../chunks/vendor-hf-doc-builder.js";import{T as bt}from"../../chunks/Tip-hf-doc-builder.js";import{I as wt}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 $t(te){let p,v,h,d,$;return{c(){p=l("p"),v=n("\u{1F4A1} Want to train your own unconditional image generation model? Take a look at the training "),h=l("a"),d=n("guide"),$=n(" to learn how to generate your own images."),this.h()},l(g){p=r(g,"P",{});var y=f(p);v=s(y,"\u{1F4A1} Want to train your own unconditional image generation model? Take a look at the training "),h=r(y,"A",{href:!0});var k=f(h);d=s(k,"guide"),k.forEach(t),$=s(y," to learn how to generate your own images."),y.forEach(t),this.h()},h(){u(h,"href","training/unconditional_training")},m(g,y){o(g,p,y),a(p,v),a(p,h),a(h,d),a(p,$)},d(g){g&&t(p)}}}function vt(te){let p,v,h,d,$,g,y,k,Pe,ae,D,ie,F,Ee,oe,P,Te,R,Ue,Ze,ne,b,De,z,je,Me,j,Ge,We,se,E,le,w,Ie,L,xe,Ae,M,Je,Se,re,G,fe,T,Ve,Y,qe,Be,ue,W,pe,U,Ne,X,Ce,Fe,me,I,ce,Z,Re,x,ee,ze,Le,he,H,Ye,ge,A,de,K,He,ye,_,Ke,be;return g=new wt({}),D=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 bt({props:{$$slots:{default:[$t]},$$scope:{ctx:te}}}),G=new ke({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>)`}}),W=new ke({props:{code:"Z2VuZXJhdG9yLnRvKCUyMmN1ZGElMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>generator.to(<span class="hljs-string">&quot;cuda&quot;</span>)'}}),I=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"),v=m(),h=l("h1"),d=l("a"),$=l("span"),S(g.$$.fragment),y=m(),k=l("span"),Pe=n("Unconditional image generation"),ae=m(),S(D.$$.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 "),R=l("a"),Ue=n("DiffusionPipeline"),Ze=n(" is the easiest way to use a pre-trained diffusion system for inference."),ne=m(),b=l("p"),De=n("Start by creating an instance of "),z=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"),We=n(" from the Hub (the checkpoint you\u2019ll use generates images of butterflies)."),se=m(),S(E.$$.fragment),le=m(),w=l("p"),Ie=n("In this guide, you\u2019ll use "),L=l("a"),xe=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"),Ve=n("The "),Y=l("a"),qe=n("DiffusionPipeline"),Be=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(W.$$.fragment),pe=m(),U=l("p"),Ne=n("Now you can use the "),X=l("code"),Ce=n("generator"),Fe=n(" to generate an image:"),me=m(),S(I.$$.fragment),ce=m(),Z=l("p"),Re=n("The output is by default wrapped into a "),x=l("a"),ee=l("code"),ze=n("PIL.Image"),Le=n(" object."),he=m(),H=l("p"),Ye=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!"),ye=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),v=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);$=r(Oe,"SPAN",{});var Qe=f($);V(g.$$.fragment,Qe),Qe.forEach(t),Oe.forEach(t),y=c(J),k=r(J,"SPAN",{});var Xe=f(k);Pe=s(Xe,"Unconditional image generation"),Xe.forEach(t),J.forEach(t),ae=c(e),V(D.$$.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 we=f(P);Te=s(we,"The "),R=r(we,"A",{href:!0});var tt=f(R);Ue=s(tt,"DiffusionPipeline"),tt.forEach(t),Ze=s(we," is the easiest way to use a pre-trained diffusion system for inference."),we.forEach(t),ne=c(e),b=r(e,"P",{});var O=f(b);De=s(O,"Start by creating an instance of "),z=r(O,"A",{href:!0});var at=f(z);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),We=s(O," from the Hub (the checkpoint you\u2019ll use generates images of butterflies)."),O.forEach(t),se=c(e),V(E.$$.fragment,e),le=c(e),w=r(e,"P",{});var Q=f(w);Ie=s(Q,"In this guide, you\u2019ll use "),L=r(Q,"A",{href:!0});var ot=f(L);xe=s(ot,"DiffusionPipeline"),ot.forEach(t),Ae=s(Q," for unconditional image generation with "),M=r(Q,"A",{href:!0,rel:!0});var nt=f(M);Je=s(nt,"DDPM"),nt.forEach(t),Se=s(Q,":"),Q.forEach(t),re=c(e),V(G.$$.fragment,e),fe=c(e),T=r(e,"P",{});var _e=f(T);Ve=s(_e,"The "),Y=r(_e,"A",{href:!0});var st=f(Y);qe=s(st,"DiffusionPipeline"),st.forEach(t),Be=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),V(W.$$.fragment,e),pe=c(e),U=r(e,"P",{});var $e=f(U);Ne=s($e,"Now you can use the "),X=r($e,"CODE",{});var lt=f(X);Ce=s(lt,"generator"),lt.forEach(t),Fe=s($e," to generate an image:"),$e.forEach(t),me=c(e),V(I.$$.fragment,e),ce=c(e),Z=r(e,"P",{});var ve=f(Z);Re=s(ve,"The output is by default wrapped into a "),x=r(ve,"A",{href:!0,rel:!0});var rt=f(x);ee=r(rt,"CODE",{});var ft=f(ee);ze=s(ft,"PIL.Image"),ft.forEach(t),rt.forEach(t),Le=s(ve," object."),ve.forEach(t),he=c(e),H=r(e,"P",{});var ut=f(H);Ye=s(ut,"You can save the image by calling:"),ut.forEach(t),ge=c(e),V(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),ye=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(R,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(z,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(j,"href","https://huggingface.co/models?library=diffusers&sort=downloads"),u(j,"rel","nofollow"),u(L,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(M,"href","https://arxiv.org/abs/2006.11239"),u(M,"rel","nofollow"),u(Y,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),u(x,"href","https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class"),u(x,"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,v,i),o(e,h,i),a(h,d),a(d,$),q(g,$,null),a(h,y),a(h,k),a(k,Pe),o(e,ae,i),q(D,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,R),a(R,Ue),a(P,Ze),o(e,ne,i),o(e,b,i),a(b,De),a(b,z),a(z,je),a(b,Me),a(b,j),a(j,Ge),a(b,We),o(e,se,i),q(E,e,i),o(e,le,i),o(e,w,i),a(w,Ie),a(w,L),a(L,xe),a(w,Ae),a(w,M),a(M,Je),a(w,Se),o(e,re,i),q(G,e,i),o(e,fe,i),o(e,T,i),a(T,Ve),a(T,Y),a(Y,qe),a(T,Be),o(e,ue,i),q(W,e,i),o(e,pe,i),o(e,U,i),a(U,Ne),a(U,X),a(X,Ce),a(U,Fe),o(e,me,i),q(I,e,i),o(e,ce,i),o(e,Z,i),a(Z,Re),a(Z,x),a(x,ee),a(ee,ze),a(Z,Le),o(e,he,i),o(e,H,i),a(H,Ye),o(e,ge,i),q(A,e,i),o(e,de,i),o(e,K,i),a(K,He),o(e,ye,i),o(e,_,i),be=!0},p(e,[i]){const J={};i&2&&(J.$$scope={dirty:i,ctx:e}),E.$set(J)},i(e){be||(B(g.$$.fragment,e),B(D.$$.fragment,e),B(E.$$.fragment,e),B(G.$$.fragment,e),B(W.$$.fragment,e),B(I.$$.fragment,e),B(A.$$.fragment,e),be=!0)},o(e){N(g.$$.fragment,e),N(D.$$.fragment,e),N(E.$$.fragment,e),N(G.$$.fragment,e),N(W.$$.fragment,e),N(I.$$.fragment,e),N(A.$$.fragment,e),be=!1},d(e){t(p),e&&t(v),e&&t(h),C(g),e&&t(ae),C(D,e),e&&t(ie),e&&t(F),e&&t(oe),e&&t(P),e&&t(ne),e&&t(b),e&&t(se),C(E,e),e&&t(le),e&&t(w),e&&t(re),C(G,e),e&&t(fe),e&&t(T),e&&t(ue),C(W,e),e&&t(pe),e&&t(U),e&&t(me),C(I,e),e&&t(ce),e&&t(Z),e&&t(he),e&&t(H),e&&t(ge),C(A,e),e&&t(de),e&&t(K),e&&t(ye),e&&t(_)}}}const kt={local:"unconditional-image-generation",title:"Unconditional image generation"};function Pt(te){return yt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends mt{constructor(p){super();ct(this,p,Pt,vt,ht,{})}}export{jt as default,kt as metadata};
