Buckets:

hf-doc-build/doc / diffusers /v0.4.0 /en /_app /pages /using-diffusers /unconditional_image_generation.mdx-hf-doc-builder.js
rtrm's picture
download
raw
7.65 kB
import{S as Qe,i as Ve,s as We,e as s,k as m,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,P,fe,C,pe,R,y,ue,q,ce,me,F,u,he,x,de,ge,T,_e,ye,D,ve,we,U,$e,Pe,b,De,be,K,k,Q,v,ke,G,Ee,je,V,E,W,w,Ae,L,Ie,qe,X,j,Z,$,xe,A,Te,Ue,ee,S,Ge,te,I,ie;return P=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=m(),g=s("h1"),_=s("a"),Y=s("span"),M(P.$$.fragment),fe=m(),C=s("span"),pe=a("Unconditional Image Generation"),R=m(),y=s("p"),ue=a("The "),q=s("a"),ce=a("DiffusionPipeline"),me=a(" is the easiest way to use a pre-trained diffusion system for inference"),F=m(),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"),ve=a("Diffusers\u2019 checkpoint"),we=a(`.
In this guide though, you\u2019ll use `),U=s("a"),$e=a("DiffusionPipeline"),Pe=a(" for unconditional image generation with "),b=s("a"),De=a("DDPM"),be=a(":"),K=m(),M(k.$$.fragment),Q=m(),v=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=m(),M(E.$$.fragment),W=m(),w=s("p"),Ae=a("Now you can use the "),L=s("code"),Ie=a("generator"),qe=a(" on your text prompt:"),X=m(),M(j.$$.fragment),Z=m(),$=s("p"),xe=a("The output is by default wrapped into a "),A=s("a"),Te=a("PIL Image object"),Ue=a("."),ee=m(),S=s("p"),Ge=a("You can save the image by simply calling:"),te=m(),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(P.$$.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);ce=o(Me,"DiffusionPipeline"),Me.forEach(t),me=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 c=l(u);he=o(c,"Start by creating an instance of "),x=r(c,"A",{href:!0});var Ne=l(x);de=o(Ne,"DiffusionPipeline"),Ne.forEach(t),ge=o(c,` and specify which pipeline checkpoint you would like to download.
You can use the `),T=r(c,"A",{href:!0});var Be=l(T);_e=o(Be,"DiffusionPipeline"),Be.forEach(t),ye=o(c," for any "),D=r(c,"A",{href:!0,rel:!0});var ze=l(D);ve=o(ze,"Diffusers\u2019 checkpoint"),ze.forEach(t),we=o(c,`.
In this guide though, you\u2019ll use `),U=r(c,"A",{href:!0});var Oe=l(U);$e=o(Oe,"DiffusionPipeline"),Oe.forEach(t),Pe=o(c," for unconditional image generation with "),b=r(c,"A",{href:!0,rel:!0});var He=l(b);De=o(He,"DDPM"),He.forEach(t),be=o(c,":"),c.forEach(t),K=h(e),N(k.$$.fragment,e),Q=h(e),v=r(e,"P",{});var oe=l(v);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),w=r(e,"P",{});var se=l(w);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),$=r(e,"P",{});var re=l($);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/v0.4.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(x,"href","/docs/diffusers/v0.4.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(T,"href","/docs/diffusers/v0.4.0/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/v0.4.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(b,"href","https://arxiv.org/abs/2006.11239"),p(b,"rel","nofollow"),p(G,"href","/docs/diffusers/v0.4.0/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(P,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,ce),i(y,me),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,ve),i(u,we),i(u,U),i(U,$e),i(u,Pe),i(u,b),i(b,De),i(u,be),f(e,K,n),B(k,e,n),f(e,Q,n),f(e,v,n),i(v,ke),i(v,G),i(G,Ee),i(v,je),f(e,V,n),B(E,e,n),f(e,W,n),f(e,w,n),i(w,Ae),i(w,L),i(L,Ie),i(w,qe),f(e,X,n),B(j,e,n),f(e,Z,n),f(e,$,n),i($,xe),i($,A),i(A,Te),i($,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(P.$$.fragment,e),z(k.$$.fragment,e),z(E.$$.fragment,e),z(j.$$.fragment,e),z(I.$$.fragment,e),ie=!0)},o(e){O(P.$$.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(P),e&&t(R),e&&t(y),e&&t(F),e&&t(u),e&&t(K),H(k,e),e&&t(Q),e&&t(v),e&&t(V),H(E,e),e&&t(W),e&&t(w),e&&t(X),H(j,e),e&&t(Z),e&&t($),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};

Xet Storage Details

Size:
7.65 kB
·
Xet hash:
a6553e83b30ca849f9af32bf83f2466a5d708e58e38f3649ae3d774c0405ce30

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.