Buckets:

rtrm's picture
download
raw
8.29 kB
import{s as he,z as be,o as $e,n as we}from"../chunks/scheduler.182ea377.js";import{S as ye,i as ve,g as l,s as a,r as C,A as _e,h as r,f as n,c as o,j as ae,u as U,x as u,k as G,y as Te,a as i,v as H,d as L,t as j,w as W}from"../chunks/index.abf12888.js";import{T as Me}from"../chunks/Tip.230e2334.js";import{C as ie}from"../chunks/CodeBlock.57fe6e13.js";import{D as Pe}from"../chunks/DocNotebookDropdown.d9060979.js";import{H as ke}from"../chunks/Heading.16916d63.js";function xe(V){let s,c='💡 Want to train your own unconditional image generation model? Take a look at the training <a href="../training/unconditional_training">guide</a> to learn how to generate your own images.';return{c(){s=l("p"),s.innerHTML=c},l(f){s=r(f,"P",{"data-svelte-h":!0}),u(s)!=="svelte-1sst9pc"&&(s.innerHTML=c)},m(f,D){i(f,s,D)},p:we,d(f){f&&n(s)}}}function Ze(V){let s,c,f,D,g,z,d,B,h,oe="Unconditional image generation is a relatively straightforward task. The model only generates images - without any additional context like text or an image - resembling the training data it was trained on.",E,b,se='The <a href="/docs/diffusers/v0.23.1/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> is the easiest way to use a pre-trained diffusion system for inference.',I,$,le=`Start by creating an instance of <a href="/docs/diffusers/v0.23.1/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> and specify which pipeline checkpoint you would like to download.
You can use any of the 🧨 Diffusers <a href="https://huggingface.co/models?library=diffusers&amp;sort=downloads" rel="nofollow">checkpoints</a> from the Hub (the checkpoint you’ll use generates images of butterflies).`,q,m,F,w,re='In this guide, you’ll use <a href="/docs/diffusers/v0.23.1/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> for unconditional image generation with <a href="https://arxiv.org/abs/2006.11239" rel="nofollow">DDPM</a>:',R,y,S,v,fe=`The <a href="/docs/diffusers/v0.23.1/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</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 a GPU.
You can move the generator object to a GPU, just like you would in PyTorch:`,N,_,A,T,pe="Now you can use the <code>generator</code> to generate an image:",K,M,Y,P,ue='The output is by default wrapped into a <a href="https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class" rel="nofollow"><code>PIL.Image</code></a> object.',Q,k,me="You can save the image by calling:",X,x,O,Z,ce="Try out the Spaces below, and feel free to play around with the inference steps parameter to see how it affects the image quality!",ee,p,ge,te,J,ne;return g=new ke({props:{title:"Unconditional image generation",local:"unconditional-image-generation",headingTag:"h1"}}),d=new Pe({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/unconditional_image_generation.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/unconditional_image_generation.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/unconditional_image_generation.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/unconditional_image_generation.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/unconditional_image_generation.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/unconditional_image_generation.ipynb"}]}}),m=new Me({props:{$$slots:{default:[xe]},$$scope:{ctx:V}}}),y=new ie({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmFudG9uLWwlMkZkZHBtLWJ1dHRlcmZsaWVzLTEyOCUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
generator = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;anton-l/ddpm-butterflies-128&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>)`,wrap:!1}}),_=new ie({props:{code:"Z2VuZXJhdG9yLnRvKCUyMmN1ZGElMjIp",highlighted:'generator.to(<span class="hljs-string">&quot;cuda&quot;</span>)',wrap:!1}}),M=new ie({props:{code:"aW1hZ2UlMjAlM0QlMjBnZW5lcmF0b3IoKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2U=",highlighted:`image = generator().images[<span class="hljs-number">0</span>]
image`,wrap:!1}}),x=new ie({props:{code:"aW1hZ2Uuc2F2ZSglMjJnZW5lcmF0ZWRfaW1hZ2UucG5nJTIyKQ==",highlighted:'image.save(<span class="hljs-string">&quot;generated_image.png&quot;</span>)',wrap:!1}}),{c(){s=l("meta"),c=a(),f=l("p"),D=a(),C(g.$$.fragment),z=a(),C(d.$$.fragment),B=a(),h=l("p"),h.textContent=oe,E=a(),b=l("p"),b.innerHTML=se,I=a(),$=l("p"),$.innerHTML=le,q=a(),C(m.$$.fragment),F=a(),w=l("p"),w.innerHTML=re,R=a(),C(y.$$.fragment),S=a(),v=l("p"),v.innerHTML=fe,N=a(),C(_.$$.fragment),A=a(),T=l("p"),T.innerHTML=pe,K=a(),C(M.$$.fragment),Y=a(),P=l("p"),P.innerHTML=ue,Q=a(),k=l("p"),k.textContent=me,X=a(),C(x.$$.fragment),O=a(),Z=l("p"),Z.textContent=ce,ee=a(),p=l("iframe"),te=a(),J=l("p"),this.h()},l(e){const t=_e("svelte-u9bgzb",document.head);s=r(t,"META",{name:!0,content:!0}),t.forEach(n),c=o(e),f=r(e,"P",{}),ae(f).forEach(n),D=o(e),U(g.$$.fragment,e),z=o(e),U(d.$$.fragment,e),B=o(e),h=r(e,"P",{"data-svelte-h":!0}),u(h)!=="svelte-1s4jzli"&&(h.textContent=oe),E=o(e),b=r(e,"P",{"data-svelte-h":!0}),u(b)!=="svelte-g098o"&&(b.innerHTML=se),I=o(e),$=r(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-1eyazs3"&&($.innerHTML=le),q=o(e),U(m.$$.fragment,e),F=o(e),w=r(e,"P",{"data-svelte-h":!0}),u(w)!=="svelte-teijo9"&&(w.innerHTML=re),R=o(e),U(y.$$.fragment,e),S=o(e),v=r(e,"P",{"data-svelte-h":!0}),u(v)!=="svelte-zj76ru"&&(v.innerHTML=fe),N=o(e),U(_.$$.fragment,e),A=o(e),T=r(e,"P",{"data-svelte-h":!0}),u(T)!=="svelte-fr79tl"&&(T.innerHTML=pe),K=o(e),U(M.$$.fragment,e),Y=o(e),P=r(e,"P",{"data-svelte-h":!0}),u(P)!=="svelte-1n0jmoo"&&(P.innerHTML=ue),Q=o(e),k=r(e,"P",{"data-svelte-h":!0}),u(k)!=="svelte-1v6wxor"&&(k.textContent=me),X=o(e),U(x.$$.fragment,e),O=o(e),Z=r(e,"P",{"data-svelte-h":!0}),u(Z)!=="svelte-qb1yds"&&(Z.textContent=ce),ee=o(e),p=r(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),ae(p).forEach(n),te=o(e),J=r(e,"P",{}),ae(J).forEach(n),this.h()},h(){G(s,"name","hf:doc:metadata"),G(s,"content",Ce),be(p.src,ge="https://stevhliu-ddpm-butterflies-128.hf.space")||G(p,"src",ge),G(p,"frameborder","0"),G(p,"width","850"),G(p,"height","500")},m(e,t){Te(document.head,s),i(e,c,t),i(e,f,t),i(e,D,t),H(g,e,t),i(e,z,t),H(d,e,t),i(e,B,t),i(e,h,t),i(e,E,t),i(e,b,t),i(e,I,t),i(e,$,t),i(e,q,t),H(m,e,t),i(e,F,t),i(e,w,t),i(e,R,t),H(y,e,t),i(e,S,t),i(e,v,t),i(e,N,t),H(_,e,t),i(e,A,t),i(e,T,t),i(e,K,t),H(M,e,t),i(e,Y,t),i(e,P,t),i(e,Q,t),i(e,k,t),i(e,X,t),H(x,e,t),i(e,O,t),i(e,Z,t),i(e,ee,t),i(e,p,t),i(e,te,t),i(e,J,t),ne=!0},p(e,[t]){const de={};t&2&&(de.$$scope={dirty:t,ctx:e}),m.$set(de)},i(e){ne||(L(g.$$.fragment,e),L(d.$$.fragment,e),L(m.$$.fragment,e),L(y.$$.fragment,e),L(_.$$.fragment,e),L(M.$$.fragment,e),L(x.$$.fragment,e),ne=!0)},o(e){j(g.$$.fragment,e),j(d.$$.fragment,e),j(m.$$.fragment,e),j(y.$$.fragment,e),j(_.$$.fragment,e),j(M.$$.fragment,e),j(x.$$.fragment,e),ne=!1},d(e){e&&(n(c),n(f),n(D),n(z),n(B),n(h),n(E),n(b),n(I),n($),n(q),n(F),n(w),n(R),n(S),n(v),n(N),n(A),n(T),n(K),n(Y),n(P),n(Q),n(k),n(X),n(O),n(Z),n(ee),n(p),n(te),n(J)),n(s),W(g,e),W(d,e),W(m,e),W(y,e),W(_,e),W(M,e),W(x,e)}}}const Ce='{"title":"Unconditional image generation","local":"unconditional-image-generation","sections":[],"depth":1}';function Ue(V){return $e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends ye{constructor(s){super(),ve(this,s,Ue,Ze,he,{})}}export{Je as component};

Xet Storage Details

Size:
8.29 kB
·
Xet hash:
349ebccd9c3ccf49d082a1f7e8077c3ecbf471c603c5cb9b067380712b47c84e

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