Buckets:
hf-doc-build/doc / diffusers /v0.7.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 m,w as M,t as a,M as Xe,c as r,d as t,m as d,a as l,x as N,h as o,b as u,G as n,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 nt(Se){let h,J,g,y,Y,P,fe,C,ue,R,v,pe,q,ce,me,F,p,de,x,he,ge,T,ye,ve,D,we,_e,U,$e,Pe,b,De,be,K,k,Q,w,ke,G,Ee,je,V,E,W,_,Ae,L,Ie,qe,X,j,Z,$,xe,A,Te,Ue,ee,S,Ge,te,I,ne;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(){h=s("meta"),J=m(),g=s("h1"),y=s("a"),Y=s("span"),M(P.$$.fragment),fe=m(),C=s("span"),ue=a("Unconditional Image Generation"),R=m(),v=s("p"),pe=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(),p=s("p"),de=a("Start by creating an instance of "),x=s("a"),he=a("DiffusionPipeline"),ge=a(` and specify which pipeline checkpoint you would like to download. | |
| You can use the `),T=s("a"),ye=a("DiffusionPipeline"),ve=a(" for any "),D=s("a"),we=a("Diffusers\u2019 checkpoint"),_e=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(),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=m(),M(E.$$.fragment),W=m(),_=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 i=Xe('[data-svelte="svelte-1phssyn"]',document.head);h=r(i,"META",{name:!0,content:!0}),i.forEach(t),J=d(e),g=r(e,"H1",{class:!0});var ie=l(g);y=r(ie,"A",{id:!0,class:!0,href:!0});var Ye=l(y);Y=r(Ye,"SPAN",{});var Ce=l(Y);N(P.$$.fragment,Ce),Ce.forEach(t),Ye.forEach(t),fe=d(ie),C=r(ie,"SPAN",{});var Le=l(C);ue=o(Le,"Unconditional Image Generation"),Le.forEach(t),ie.forEach(t),R=d(e),v=r(e,"P",{});var ae=l(v);pe=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=d(e),p=r(e,"P",{});var c=l(p);de=o(c,"Start by creating an instance of "),x=r(c,"A",{href:!0});var Ne=l(x);he=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);ye=o(Be,"DiffusionPipeline"),Be.forEach(t),ve=o(c," for any "),D=r(c,"A",{href:!0,rel:!0});var ze=l(D);we=o(ze,"Diffusers\u2019 checkpoint"),ze.forEach(t),_e=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=d(e),N(k.$$.fragment,e),Q=d(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=d(e),N(E.$$.fragment,e),W=d(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=d(e),N(j.$$.fragment,e),Z=d(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=d(e),S=r(e,"P",{});var Ke=l(S);Ge=o(Ke,"You can save the image by simply calling:"),Ke.forEach(t),te=d(e),N(I.$$.fragment,e),this.h()},h(){u(h,"name","hf:doc:metadata"),u(h,"content",JSON.stringify(it)),u(y,"id","unconditional-image-generation"),u(y,"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(y,"href","#unconditional-image-generation"),u(g,"class","relative group"),u(q,"href","/docs/diffusers/v0.7.0/en/using-diffusers/loading#diffusers.DiffusionPipeline"),u(x,"href","/docs/diffusers/v0.7.0/en/using-diffusers/loading#diffusers.DiffusionPipeline"),u(T,"href","/docs/diffusers/v0.7.0/en/using-diffusers/loading#diffusers.DiffusionPipeline"),u(D,"href","https://huggingface.co/models?library=diffusers&sort=downloads"),u(D,"rel","nofollow"),u(U,"href","/docs/diffusers/v0.7.0/en/using-diffusers/loading#diffusers.DiffusionPipeline"),u(b,"href","https://arxiv.org/abs/2006.11239"),u(b,"rel","nofollow"),u(G,"href","/docs/diffusers/v0.7.0/en/using-diffusers/loading#diffusers.DiffusionPipeline"),u(A,"href","https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class"),u(A,"rel","nofollow")},m(e,i){n(document.head,h),f(e,J,i),f(e,g,i),n(g,y),n(y,Y),B(P,Y,null),n(g,fe),n(g,C),n(C,ue),f(e,R,i),f(e,v,i),n(v,pe),n(v,q),n(q,ce),n(v,me),f(e,F,i),f(e,p,i),n(p,de),n(p,x),n(x,he),n(p,ge),n(p,T),n(T,ye),n(p,ve),n(p,D),n(D,we),n(p,_e),n(p,U),n(U,$e),n(p,Pe),n(p,b),n(b,De),n(p,be),f(e,K,i),B(k,e,i),f(e,Q,i),f(e,w,i),n(w,ke),n(w,G),n(G,Ee),n(w,je),f(e,V,i),B(E,e,i),f(e,W,i),f(e,_,i),n(_,Ae),n(_,L),n(L,Ie),n(_,qe),f(e,X,i),B(j,e,i),f(e,Z,i),f(e,$,i),n($,xe),n($,A),n(A,Te),n($,Ue),f(e,ee,i),f(e,S,i),n(S,Ge),f(e,te,i),B(I,e,i),ne=!0},p:Ze,i(e){ne||(z(P.$$.fragment,e),z(k.$$.fragment,e),z(E.$$.fragment,e),z(j.$$.fragment,e),z(I.$$.fragment,e),ne=!0)},o(e){O(P.$$.fragment,e),O(k.$$.fragment,e),O(E.$$.fragment,e),O(j.$$.fragment,e),O(I.$$.fragment,e),ne=!1},d(e){t(h),e&&t(J),e&&t(g),H(P),e&&t(R),e&&t(v),e&&t(F),e&&t(p),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($),e&&t(ee),e&&t(S),e&&t(te),H(I,e)}}}const it={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(h){super();Ve(this,h,at,nt,We,{})}}export{lt as default,it as metadata}; | |
Xet Storage Details
- Size:
- 7.65 kB
- Xet hash:
- d4fa0643f8082f41ae9c6b9cd16164480ecca2b1b403fa380dcab730be8c74f5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.