Buckets:
hf-doc-build/doc / diffusers /v0.3.0 /en /_app /pages /using-diffusers /unconditional_image_generation.mdx-hf-doc-builder.js
| 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,P,fe,C,pe,R,y,ue,q,me,ce,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">>>> </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline | |
| <span class="hljs-meta">>>> </span>generator = DiffusionPipeline.from_pretrained(<span class="hljs-string">"google/ddpm-celebahq-256"</span>)`}}),E=new le({props:{code:'generator.to("cuda")',highlighted:'<span class="hljs-meta">>>> </span>generator.to(<span class="hljs-string">"cuda"</span>)'}}),j=new le({props:{code:"image = generator().images[0]",highlighted:'<span class="hljs-meta">>>> </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">>>> </span>image.save(<span class="hljs-string">"generated_image.png"</span>)'}}),{c(){d=s("meta"),J=c(),g=s("h1"),_=s("a"),Y=s("span"),M(P.$$.fragment),fe=c(),C=s("span"),pe=a("Unonditional 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"),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=c(),M(k.$$.fragment),Q=c(),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=c(),M(E.$$.fragment),W=c(),w=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(),$=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(P.$$.fragment,Ce),Ce.forEach(t),Ye.forEach(t),fe=h(ne),C=r(ne,"SPAN",{});var Le=l(C);pe=o(Le,"Unonditional 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);ve=o(ze,"Diffusers\u2019 checkpoint"),ze.forEach(t),we=o(m,`. | |
| In this guide though, you\u2019ll use `),U=r(m,"A",{href:!0});var Oe=l(U);$e=o(Oe,"DiffusionPipeline"),Oe.forEach(t),Pe=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),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","unonditional-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","#unonditional-image-generation"),p(g,"class","relative group"),p(q,"href","/docs/diffusers/v0.3.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(x,"href","/docs/diffusers/v0.3.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(T,"href","/docs/diffusers/v0.3.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.3.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.3.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,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,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:"unonditional-image-generation",title:"Unonditional 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.64 kB
- Xet hash:
- 11f13659c1adc5503960c6530020a3dc45465cec39398ecd7209504c49b35a28
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.