Buckets:

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

Xet Storage Details

Size:
7.83 kB
·
Xet hash:
fe5f4b674c456e9f71014b57b67a4cb2f3b6ce0cf58fc49447a66c20f603e7b3

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