import{S as Qe,i as Ve,s as We,e as s,k as c,w as M,t as a,M as Xe,c as r,d as t,m as h,a as l,x as N,h as o,b as p,G as i,g as f,y as B,L as Ze,q as z,o as O,B as H,v as et}from"../../chunks/vendor-hf-doc-builder.js";import{I as tt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as le}from"../../chunks/CodeBlock-hf-doc-builder.js";function it(Se){let d,J,g,_,Y,v,fe,C,pe,R,y,ue,q,me,ce,F,u,he,x,de,ge,T,_e,ye,D,we,$e,U,Pe,ve,b,De,be,K,k,Q,w,ke,G,Ee,je,V,E,W,$,Ae,L,Ie,qe,X,j,Z,P,xe,A,Te,Ue,ee,S,Ge,te,I,ie;return v=new tt({}),k=new le({props:{code:`from diffusers import DiffusionPipeline

generator = DiffusionPipeline.from_pretrained("google/ddpm-celebahq-256")`,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;google/ddpm-celebahq-256&quot;</span>)`}}),E=new le({props:{code:'generator.to("cuda")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>generator.to(<span class="hljs-string">&quot;cuda&quot;</span>)'}}),j=new le({props:{code:"image = generator().images[0]",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>image = generator().images[<span class="hljs-number">0</span>]'}}),I=new le({props:{code:'image.save("generated_image.png")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;generated_image.png&quot;</span>)'}}),{c(){d=s("meta"),J=c(),g=s("h1"),_=s("a"),Y=s("span"),M(v.$$.fragment),fe=c(),C=s("span"),pe=a("Unconditional Image Generation"),R=c(),y=s("p"),ue=a("The "),q=s("a"),me=a("DiffusionPipeline"),ce=a(" is the easiest way to use a pre-trained diffusion system for inference"),F=c(),u=s("p"),he=a("Start by creating an instance of "),x=s("a"),de=a("DiffusionPipeline"),ge=a(` and specify which pipeline checkpoint you would like to download.
You can use the `),T=s("a"),_e=a("DiffusionPipeline"),ye=a(" for any "),D=s("a"),we=a("Diffusers\u2019 checkpoint"),$e=a(`.
In this guide though, you\u2019ll use `),U=s("a"),Pe=a("DiffusionPipeline"),ve=a(" for unconditional image generation with "),b=s("a"),De=a("DDPM"),be=a(":"),K=c(),M(k.$$.fragment),Q=c(),w=s("p"),ke=a("The "),G=s("a"),Ee=a("DiffusionPipeline"),je=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 GPU.
You can move the generator object to GPU, just like you would in PyTorch.`),V=c(),M(E.$$.fragment),W=c(),$=s("p"),Ae=a("Now you can use the "),L=s("code"),Ie=a("generator"),qe=a(" on your text prompt:"),X=c(),M(j.$$.fragment),Z=c(),P=s("p"),xe=a("The output is by default wrapped into a "),A=s("a"),Te=a("PIL Image object"),Ue=a("."),ee=c(),S=s("p"),Ge=a("You can save the image by simply calling:"),te=c(),M(I.$$.fragment),this.h()},l(e){const n=Xe('[data-svelte="svelte-1phssyn"]',document.head);d=r(n,"META",{name:!0,content:!0}),n.forEach(t),J=h(e),g=r(e,"H1",{class:!0});var ne=l(g);_=r(ne,"A",{id:!0,class:!0,href:!0});var Ye=l(_);Y=r(Ye,"SPAN",{});var Ce=l(Y);N(v.$$.fragment,Ce),Ce.forEach(t),Ye.forEach(t),fe=h(ne),C=r(ne,"SPAN",{});var Le=l(C);pe=o(Le,"Unconditional Image Generation"),Le.forEach(t),ne.forEach(t),R=h(e),y=r(e,"P",{});var ae=l(y);ue=o(ae,"The "),q=r(ae,"A",{href:!0});var Me=l(q);me=o(Me,"DiffusionPipeline"),Me.forEach(t),ce=o(ae," is the easiest way to use a pre-trained diffusion system for inference"),ae.forEach(t),F=h(e),u=r(e,"P",{});var m=l(u);he=o(m,"Start by creating an instance of "),x=r(m,"A",{href:!0});var Ne=l(x);de=o(Ne,"DiffusionPipeline"),Ne.forEach(t),ge=o(m,` and specify which pipeline checkpoint you would like to download.
You can use the `),T=r(m,"A",{href:!0});var Be=l(T);_e=o(Be,"DiffusionPipeline"),Be.forEach(t),ye=o(m," for any "),D=r(m,"A",{href:!0,rel:!0});var ze=l(D);we=o(ze,"Diffusers\u2019 checkpoint"),ze.forEach(t),$e=o(m,`.
In this guide though, you\u2019ll use `),U=r(m,"A",{href:!0});var Oe=l(U);Pe=o(Oe,"DiffusionPipeline"),Oe.forEach(t),ve=o(m," for unconditional image generation with "),b=r(m,"A",{href:!0,rel:!0});var He=l(b);De=o(He,"DDPM"),He.forEach(t),be=o(m,":"),m.forEach(t),K=h(e),N(k.$$.fragment,e),Q=h(e),w=r(e,"P",{});var oe=l(w);ke=o(oe,"The "),G=r(oe,"A",{href:!0});var Je=l(G);Ee=o(Je,"DiffusionPipeline"),Je.forEach(t),je=o(oe,` 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 GPU.
You can move the generator object to GPU, just like you would in PyTorch.`),oe.forEach(t),V=h(e),N(E.$$.fragment,e),W=h(e),$=r(e,"P",{});var se=l($);Ae=o(se,"Now you can use the "),L=r(se,"CODE",{});var Re=l(L);Ie=o(Re,"generator"),Re.forEach(t),qe=o(se," on your text prompt:"),se.forEach(t),X=h(e),N(j.$$.fragment,e),Z=h(e),P=r(e,"P",{});var re=l(P);xe=o(re,"The output is by default wrapped into a "),A=r(re,"A",{href:!0,rel:!0});var Fe=l(A);Te=o(Fe,"PIL Image object"),Fe.forEach(t),Ue=o(re,"."),re.forEach(t),ee=h(e),S=r(e,"P",{});var Ke=l(S);Ge=o(Ke,"You can save the image by simply calling:"),Ke.forEach(t),te=h(e),N(I.$$.fragment,e),this.h()},h(){p(d,"name","hf:doc:metadata"),p(d,"content",JSON.stringify(nt)),p(_,"id","unconditional-image-generation"),p(_,"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"),p(_,"href","#unconditional-image-generation"),p(g,"class","relative group"),p(q,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(x,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(T,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(D,"href","https://huggingface.co/models?library=diffusers&sort=downloads"),p(D,"rel","nofollow"),p(U,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(b,"href","https://arxiv.org/abs/2006.11239"),p(b,"rel","nofollow"),p(G,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(A,"href","https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class"),p(A,"rel","nofollow")},m(e,n){i(document.head,d),f(e,J,n),f(e,g,n),i(g,_),i(_,Y),B(v,Y,null),i(g,fe),i(g,C),i(C,pe),f(e,R,n),f(e,y,n),i(y,ue),i(y,q),i(q,me),i(y,ce),f(e,F,n),f(e,u,n),i(u,he),i(u,x),i(x,de),i(u,ge),i(u,T),i(T,_e),i(u,ye),i(u,D),i(D,we),i(u,$e),i(u,U),i(U,Pe),i(u,ve),i(u,b),i(b,De),i(u,be),f(e,K,n),B(k,e,n),f(e,Q,n),f(e,w,n),i(w,ke),i(w,G),i(G,Ee),i(w,je),f(e,V,n),B(E,e,n),f(e,W,n),f(e,$,n),i($,Ae),i($,L),i(L,Ie),i($,qe),f(e,X,n),B(j,e,n),f(e,Z,n),f(e,P,n),i(P,xe),i(P,A),i(A,Te),i(P,Ue),f(e,ee,n),f(e,S,n),i(S,Ge),f(e,te,n),B(I,e,n),ie=!0},p:Ze,i(e){ie||(z(v.$$.fragment,e),z(k.$$.fragment,e),z(E.$$.fragment,e),z(j.$$.fragment,e),z(I.$$.fragment,e),ie=!0)},o(e){O(v.$$.fragment,e),O(k.$$.fragment,e),O(E.$$.fragment,e),O(j.$$.fragment,e),O(I.$$.fragment,e),ie=!1},d(e){t(d),e&&t(J),e&&t(g),H(v),e&&t(R),e&&t(y),e&&t(F),e&&t(u),e&&t(K),H(k,e),e&&t(Q),e&&t(w),e&&t(V),H(E,e),e&&t(W),e&&t($),e&&t(X),H(j,e),e&&t(Z),e&&t(P),e&&t(ee),e&&t(S),e&&t(te),H(I,e)}}}const nt={local:"unconditional-image-generation",title:"Unconditional Image Generation"};function at(Se){return et(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class lt extends Qe{constructor(d){super();Ve(this,d,at,it,We,{})}}export{lt as default,nt as metadata};
