Buckets:
| import{s as Se,f as ke,o as Ye,n as Fe}from"../chunks/scheduler.85c25b89.js";import{S as Qe,i as qe,g as s,s as i,r as p,A as Re,h as o,f as n,c as a,j as Ue,u as m,x as d,k as w,y as _e,a as l,v as u,d as h,t as c,w as f}from"../chunks/index.c9bcf812.js";import{T as ze}from"../chunks/Tip.d8f753fa.js";import{D as Ze}from"../chunks/Docstring.af42ec0f.js";import{C as Je}from"../chunks/CodeBlock.c004bd26.js";import{H as Q}from"../chunks/index.9790a2b6.js";function De(D){let r,$="We recommend using a <code>inf2.8xlarge</code> or a larger instance for the model compilation. You will also be able to compile the model with the Optimum CLI on a CPU-only instance (needs ~35 GB memory), and then run the pre-compiled model on <code>inf2.xlarge</code> to reduce the expenses. In this case, don’t forget to disable validation of inference by adding the <code>--disable-validation</code> argument.";return{c(){r=s("p"),r.innerHTML=$},l(g){r=o(g,"P",{"data-svelte-h":!0}),d(r)!=="svelte-1evfral"&&(r.innerHTML=$)},m(g,q){l(g,r,q)},p:Fe,d(g){g&&n(r)}}}function Oe(D){let r,$,g,q,x,O,T,K,U,Ce='<a href="https://huggingface.co/papers/2310.00426" rel="nofollow">PixArt-α: Fast Training of Diffusion Transformer for Photorealistic Text-to-Image Synthesis</a> is Junsong Chen, Jincheng Yu, Chongjian Ge, Lewei Yao, Enze Xie, Yue Wu, Zhongdao Wang, James Kwok, Ping Luo, Huchuan Lu, and Zhenguo Li.',ee,v,je="Some notes about this pipeline:",te,_,Pe='<li>It uses a Transformer backbone (instead of a UNet) for denoising. As such it has a similar architecture as <a href="./dit">DiT</a>.</li> <li>It was trained using text conditions computed from T5. This aspect makes the pipeline better at following complex text prompts with intricate details.</li> <li>It is good at producing high-resolution images at different aspect ratios. To get the best results, the authors recommend some size brackets which can be found <a href="https://github.com/PixArt-alpha/PixArt-alpha/blob/08fbbd281ec96866109bdd2cdb75f2f58fb17610/diffusion/data/datasets/utils.py" rel="nofollow">here</a>.</li> <li>It rivals the quality of state-of-the-art text-to-image generation systems (as of this writing) such as Stable Diffusion XL, Imagen, and DALL-E 2, while being more efficient than them.</li>',ne,J,Ae='You can find the original codebase at <a href="https://github.com/PixArt-alpha/PixArt-alpha" rel="nofollow">PixArt-alpha/PixArt-alpha</a> and all the available checkpoints at <a href="https://huggingface.co/PixArt-alpha" rel="nofollow">PixArt-alpha</a>.',le,C,Ge="🤗 <code>Optimum</code> extends <code>Diffusers</code> to support inference on the second generation of Neuron devices(powering Trainium and Inferentia 2). It aims at inheriting the ease of Diffusers on Neuron.",ie,j,ae,P,Ve="To deploy models in the PixArt-α pipeline, you will need to compile them to TorchScript optimized for AWS Neuron. There are four components which need to be exported to the <code>.neuron</code> format to boost the performance:",se,A,Ie="<li>Text encoder</li> <li>Transformer</li> <li>VAE encoder</li> <li>VAE decoder</li>",oe,G,Be="You can either compile and export a PixArt-α Checkpoint via CLI or <code>NeuronPixArtAlphaPipeline</code> class.",re,V,pe,I,me,b,ue,B,he,L,ce,H,fe,X,Le="<code>NeuronPixArtAlphaPipeline</code> class allows you to generate images from a text prompt on neuron devices similar to the experience with <code>Diffusers</code>.",de,E,He="With pre-compiled PixArt-α models, now generate an image with a prompt on Neuron:",ge,N,ye,y,Xe,Me,W,be,Z,Ee="Pipeline for text-to-image generation using PixArt-α.",we,M,S,ve,R,k,$e,Y,Ne='Are there any other diffusion features that you want us to support in 🤗<code>Optimum-neuron</code>? Please file an issue to <a href="https://github.com/huggingface/optimum-neuron" rel="nofollow"><code>Optimum-neuron</code> Github repo</a> or discuss with us on <a href="https://discuss.huggingface.co/c/optimum/" rel="nofollow">HuggingFace’s community forum</a>, cheers 🤗 !',xe,z,Te;return x=new Q({props:{title:"PixArt-α",local:"pixart-α",headingTag:"h1"}}),T=new Q({props:{title:"Overview",local:"overview",headingTag:"h2"}}),j=new Q({props:{title:"Export to Neuron",local:"export-to-neuron",headingTag:"h2"}}),V=new Q({props:{title:"Option 1: CLI",local:"option-1-cli",headingTag:"h3"}}),I=new Je({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBuZXVyb24lMjAtLW1vZGVsJTIwUGl4QXJ0LWFscGhhJTJGUGl4QXJ0LVhMLTItNTEyeDUxMiUyMC0tYmF0Y2hfc2l6ZSUyMDElMjAtLWhlaWdodCUyMDUxMiUyMC0td2lkdGglMjA1MTIlMjAtLW51bV9pbWFnZXNfcGVyX3Byb21wdCUyMDElMjAtLXRvcmNoX2R0eXBlJTIwYmZsb2F0MTYlMjAtLXNlcXVlbmNlX2xlbmd0aCUyMDEyMCUyMHBpeGFydF9hbHBoYV9uZXVyb25fNTEyJTJG",highlighted:'optimum-cli <span class="hljs-built_in">export</span> neuron --model PixArt-alpha/PixArt-XL-2-512x512 --batch_size 1 --height 512 --width 512 --num_images_per_prompt 1 --torch_dtype bfloat16 --sequence_length 120 pixart_alpha_neuron_512/',wrap:!1}}),b=new ze({props:{warning:!1,$$slots:{default:[De]},$$scope:{ctx:D}}}),B=new Q({props:{title:"Option 2: Python API",local:"option-2-python-api",headingTag:"h3"}}),L=new Je({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwb3B0aW11bS5uZXVyb24lMjBpbXBvcnQlMjBOZXVyb25QaXhBcnRBbHBoYVBpcGVsaW5lJTBBJTBBJTIzJTIwQ29tcGlsZSUwQWNvbXBpbGVyX2FyZ3MlMjAlM0QlMjAlN0IlMjJhdXRvX2Nhc3QlMjIlM0ElMjAlMjJub25lJTIyJTdEJTBBaW5wdXRfc2hhcGVzJTIwJTNEJTIwJTdCJTIyYmF0Y2hfc2l6ZSUyMiUzQSUyMDElMkMlMjAlMjJoZWlnaHQlMjIlM0ElMjA1MTIlMkMlMjAlMjJ3aWR0aCUyMiUzQSUyMDUxMiUyQyUyMCUyMnNlcXVlbmNlX2xlbmd0aCUyMiUzQSUyMDEyMCU3RCUwQSUwQW5ldXJvbl9tb2RlbCUyMCUzRCUyME5ldXJvblBpeEFydEFscGhhUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMlBpeEFydC1hbHBoYSUyRlBpeEFydC1YTC0yLTUxMng1MTIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTJDJTIwZXhwb3J0JTNEVHJ1ZSUyQyUyMGRpc2FibGVfbmV1cm9uX2NhY2hlJTNEVHJ1ZSUyQyUyMCoqY29tcGlsZXJfYXJncyUyQyUyMCoqaW5wdXRfc2hhcGVzKSUwQSUwQSUyMyUyMFNhdmUlMjBsb2NhbGx5JTBBbmV1cm9uX21vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJwaXhhcnRfYWxwaGFfbmV1cm9uXzUxMiUyRiUyMiklMEElMEElMjMlMjBVcGxvYWQlMjB0byUyMHRoZSUyMEh1Z2dpbmdGYWNlJTIwSHViJTBBbmV1cm9uX21vZGVsLnB1c2hfdG9faHViKCUwQSUyMCUyMCUyMCUyMCUyMnBpeGFydF9hbHBoYV9uZXVyb25fNTEyJTJGJTIyJTJDJTIwcmVwb3NpdG9yeV9pZCUzRCUyMkppbmd5YSUyRlBpeEFydC1YTC0yLTUxMng1MTItbmV1cm9ueCUyMiUyMCUyMCUyMyUyMFJlcGxhY2UlMjB3aXRoJTIweW91ciUyMEhGJTIwSHViJTIwcmVwbyUyMGlkJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> optimum.neuron <span class="hljs-keyword">import</span> NeuronPixArtAlphaPipeline | |
| <span class="hljs-comment"># Compile</span> | |
| compiler_args = {<span class="hljs-string">"auto_cast"</span>: <span class="hljs-string">"none"</span>} | |
| input_shapes = {<span class="hljs-string">"batch_size"</span>: <span class="hljs-number">1</span>, <span class="hljs-string">"height"</span>: <span class="hljs-number">512</span>, <span class="hljs-string">"width"</span>: <span class="hljs-number">512</span>, <span class="hljs-string">"sequence_length"</span>: <span class="hljs-number">120</span>} | |
| neuron_model = NeuronPixArtAlphaPipeline.from_pretrained(<span class="hljs-string">"PixArt-alpha/PixArt-XL-2-512x512"</span>, torch_dtype=torch.bfloat16, export=<span class="hljs-literal">True</span>, disable_neuron_cache=<span class="hljs-literal">True</span>, **compiler_args, **input_shapes) | |
| <span class="hljs-comment"># Save locally</span> | |
| neuron_model.save_pretrained(<span class="hljs-string">"pixart_alpha_neuron_512/"</span>) | |
| <span class="hljs-comment"># Upload to the HuggingFace Hub</span> | |
| neuron_model.push_to_hub( | |
| <span class="hljs-string">"pixart_alpha_neuron_512/"</span>, repository_id=<span class="hljs-string">"Jingya/PixArt-XL-2-512x512-neuronx"</span> <span class="hljs-comment"># Replace with your HF Hub repo id</span> | |
| )`,wrap:!1}}),H=new Q({props:{title:"Text-to-Image",local:"text-to-image",headingTag:"h2"}}),N=new Je({props:{code:"ZnJvbSUyMG9wdGltdW0ubmV1cm9uJTIwaW1wb3J0JTIwTmV1cm9uUGl4QXJ0QWxwaGFQaXBlbGluZSUwQSUwQW5ldXJvbl9tb2RlbCUyMCUzRCUyME5ldXJvblBpeEFydEFscGhhUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnBpeGFydF9hbHBoYV9uZXVyb25fNTEyJTJGJTIyKSUwQXByb21wdCUyMCUzRCUyMCUyMk9wcGVuaGVpbWVyJTIwc2l0cyUyMG9uJTIwdGhlJTIwYmVhY2glMjBvbiUyMGElMjBjaGFpciUyQyUyMHdhdGNoaW5nJTIwYSUyMG51Y2xlYXIlMjBleHBvc2l0aW9uJTIwd2l0aCUyMGElMjBodWdlJTIwbXVzaHJvb20lMjBjbG91ZCUyQyUyMDEyMG1tLiUyMiUwQWltYWdlJTIwJTNEJTIwbmV1cm9uX21vZGVsKHByb21wdCUzRHByb21wdCkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">from</span> optimum.neuron <span class="hljs-keyword">import</span> NeuronPixArtAlphaPipeline | |
| neuron_model = NeuronPixArtAlphaPipeline.from_pretrained(<span class="hljs-string">"pixart_alpha_neuron_512/"</span>) | |
| prompt = <span class="hljs-string">"Oppenheimer sits on the beach on a chair, watching a nuclear exposition with a huge mushroom cloud, 120mm."</span> | |
| image = neuron_model(prompt=prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),W=new Q({props:{title:"NeuronPixArtAlphaPipeline",local:"optimum.neuron.NeuronPixArtAlphaPipeline",headingTag:"h2"}}),S=new Ze({props:{name:"class optimum.neuron.NeuronPixArtAlphaPipeline",anchor:"optimum.neuron.NeuronPixArtAlphaPipeline",parameters:[{name:"**kwargs",val:""}],source:"https://github.com/huggingface/optimum-neuron/blob/v0.2.0.dev4/optimum/neuron/modeling_diffusion.py#L1601"}}),k=new Ze({props:{name:"__call__",anchor:"optimum.neuron.NeuronPixArtAlphaPipeline.__call__",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/optimum-neuron/blob/v0.2.0.dev4/optimum/neuron/modeling_diffusion.py#L1165"}}),{c(){r=s("meta"),$=i(),g=s("p"),q=i(),p(x.$$.fragment),O=i(),p(T.$$.fragment),K=i(),U=s("p"),U.innerHTML=Ce,ee=i(),v=s("p"),v.textContent=je,te=i(),_=s("ul"),_.innerHTML=Pe,ne=i(),J=s("p"),J.innerHTML=Ae,le=i(),C=s("p"),C.innerHTML=Ge,ie=i(),p(j.$$.fragment),ae=i(),P=s("p"),P.innerHTML=Ve,se=i(),A=s("ul"),A.innerHTML=Ie,oe=i(),G=s("p"),G.innerHTML=Be,re=i(),p(V.$$.fragment),pe=i(),p(I.$$.fragment),me=i(),p(b.$$.fragment),ue=i(),p(B.$$.fragment),he=i(),p(L.$$.fragment),ce=i(),p(H.$$.fragment),fe=i(),X=s("p"),X.innerHTML=Le,de=i(),E=s("p"),E.textContent=He,ge=i(),p(N.$$.fragment),ye=i(),y=s("img"),Me=i(),p(W.$$.fragment),be=i(),Z=s("p"),Z.textContent=Ee,we=i(),M=s("div"),p(S.$$.fragment),ve=i(),R=s("div"),p(k.$$.fragment),$e=i(),Y=s("p"),Y.innerHTML=Ne,xe=i(),z=s("p"),this.h()},l(e){const t=Re("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(n),$=a(e),g=o(e,"P",{}),Ue(g).forEach(n),q=a(e),m(x.$$.fragment,e),O=a(e),m(T.$$.fragment,e),K=a(e),U=o(e,"P",{"data-svelte-h":!0}),d(U)!=="svelte-9ej743"&&(U.innerHTML=Ce),ee=a(e),v=o(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-v1sn1g"&&(v.textContent=je),te=a(e),_=o(e,"UL",{"data-svelte-h":!0}),d(_)!=="svelte-1o0jwg8"&&(_.innerHTML=Pe),ne=a(e),J=o(e,"P",{"data-svelte-h":!0}),d(J)!=="svelte-1c7kadv"&&(J.innerHTML=Ae),le=a(e),C=o(e,"P",{"data-svelte-h":!0}),d(C)!=="svelte-1g87d8z"&&(C.innerHTML=Ge),ie=a(e),m(j.$$.fragment,e),ae=a(e),P=o(e,"P",{"data-svelte-h":!0}),d(P)!=="svelte-1eugdyd"&&(P.innerHTML=Ve),se=a(e),A=o(e,"UL",{"data-svelte-h":!0}),d(A)!=="svelte-bwcnjm"&&(A.innerHTML=Ie),oe=a(e),G=o(e,"P",{"data-svelte-h":!0}),d(G)!=="svelte-wkhkz6"&&(G.innerHTML=Be),re=a(e),m(V.$$.fragment,e),pe=a(e),m(I.$$.fragment,e),me=a(e),m(b.$$.fragment,e),ue=a(e),m(B.$$.fragment,e),he=a(e),m(L.$$.fragment,e),ce=a(e),m(H.$$.fragment,e),fe=a(e),X=o(e,"P",{"data-svelte-h":!0}),d(X)!=="svelte-16eqm35"&&(X.innerHTML=Le),de=a(e),E=o(e,"P",{"data-svelte-h":!0}),d(E)!=="svelte-9cwmyz"&&(E.textContent=He),ge=a(e),m(N.$$.fragment,e),ye=a(e),y=o(e,"IMG",{src:!0,width:!0,height:!0,alt:!0}),Me=a(e),m(W.$$.fragment,e),be=a(e),Z=o(e,"P",{"data-svelte-h":!0}),d(Z)!=="svelte-be4wby"&&(Z.textContent=Ee),we=a(e),M=o(e,"DIV",{class:!0});var F=Ue(M);m(S.$$.fragment,F),ve=a(F),R=o(F,"DIV",{class:!0});var We=Ue(R);m(k.$$.fragment,We),We.forEach(n),F.forEach(n),$e=a(e),Y=o(e,"P",{"data-svelte-h":!0}),d(Y)!=="svelte-1wos5lv"&&(Y.innerHTML=Ne),xe=a(e),z=o(e,"P",{}),Ue(z).forEach(n),this.h()},h(){w(r,"name","hf:doc:metadata"),w(r,"content",Ke),ke(y.src,Xe="https://huggingface.co/datasets/Jingya/document_images/resolve/main/optimum/neuron/pixart-alpha-oppenheimer.png")||w(y,"src",Xe),w(y,"width","256"),w(y,"height","256"),w(y,"alt","PixArt-α generated image."),w(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){_e(document.head,r),l(e,$,t),l(e,g,t),l(e,q,t),u(x,e,t),l(e,O,t),u(T,e,t),l(e,K,t),l(e,U,t),l(e,ee,t),l(e,v,t),l(e,te,t),l(e,_,t),l(e,ne,t),l(e,J,t),l(e,le,t),l(e,C,t),l(e,ie,t),u(j,e,t),l(e,ae,t),l(e,P,t),l(e,se,t),l(e,A,t),l(e,oe,t),l(e,G,t),l(e,re,t),u(V,e,t),l(e,pe,t),u(I,e,t),l(e,me,t),u(b,e,t),l(e,ue,t),u(B,e,t),l(e,he,t),u(L,e,t),l(e,ce,t),u(H,e,t),l(e,fe,t),l(e,X,t),l(e,de,t),l(e,E,t),l(e,ge,t),u(N,e,t),l(e,ye,t),l(e,y,t),l(e,Me,t),u(W,e,t),l(e,be,t),l(e,Z,t),l(e,we,t),l(e,M,t),u(S,M,null),_e(M,ve),_e(M,R),u(k,R,null),l(e,$e,t),l(e,Y,t),l(e,xe,t),l(e,z,t),Te=!0},p(e,[t]){const F={};t&2&&(F.$$scope={dirty:t,ctx:e}),b.$set(F)},i(e){Te||(h(x.$$.fragment,e),h(T.$$.fragment,e),h(j.$$.fragment,e),h(V.$$.fragment,e),h(I.$$.fragment,e),h(b.$$.fragment,e),h(B.$$.fragment,e),h(L.$$.fragment,e),h(H.$$.fragment,e),h(N.$$.fragment,e),h(W.$$.fragment,e),h(S.$$.fragment,e),h(k.$$.fragment,e),Te=!0)},o(e){c(x.$$.fragment,e),c(T.$$.fragment,e),c(j.$$.fragment,e),c(V.$$.fragment,e),c(I.$$.fragment,e),c(b.$$.fragment,e),c(B.$$.fragment,e),c(L.$$.fragment,e),c(H.$$.fragment,e),c(N.$$.fragment,e),c(W.$$.fragment,e),c(S.$$.fragment,e),c(k.$$.fragment,e),Te=!1},d(e){e&&(n($),n(g),n(q),n(O),n(K),n(U),n(ee),n(v),n(te),n(_),n(ne),n(J),n(le),n(C),n(ie),n(ae),n(P),n(se),n(A),n(oe),n(G),n(re),n(pe),n(me),n(ue),n(he),n(ce),n(fe),n(X),n(de),n(E),n(ge),n(ye),n(y),n(Me),n(be),n(Z),n(we),n(M),n($e),n(Y),n(xe),n(z)),n(r),f(x,e),f(T,e),f(j,e),f(V,e),f(I,e),f(b,e),f(B,e),f(L,e),f(H,e),f(N,e),f(W,e),f(S),f(k)}}}const Ke='{"title":"PixArt-α","local":"pixart-α","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Export to Neuron","local":"export-to-neuron","sections":[{"title":"Option 1: CLI","local":"option-1-cli","sections":[],"depth":3},{"title":"Option 2: Python API","local":"option-2-python-api","sections":[],"depth":3}],"depth":2},{"title":"Text-to-Image","local":"text-to-image","sections":[],"depth":2},{"title":"NeuronPixArtAlphaPipeline","local":"optimum.neuron.NeuronPixArtAlphaPipeline","sections":[],"depth":2}],"depth":1}';function et(D){return Ye(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ot extends Qe{constructor(r){super(),qe(this,r,et,Oe,Se,{})}}export{ot as component}; | |
Xet Storage Details
- Size:
- 14.8 kB
- Xet hash:
- 95811bef8336f2de8364f646bbe2a3d8856adec91aa3e29a7b73752d74c06d22
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.