import{S as Fe,i as Qe,s as Ze,e as n,k as h,w as M,t as f,M as et,c as a,d as t,m as p,a as s,x as B,h as u,b as r,G as o,g as l,y as V,L as tt,q as W,o as J,B as z,v as ot}from"../../chunks/vendor-hf-doc-builder.js";import{I as he}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as nt}from"../../chunks/CodeBlock-hf-doc-builder.js";function at(Oe){let m,F,d,b,C,k,pe,I,ce,Q,D,me,Z,v,$,q,x,de,T,ve,ee,O,j,we,te,w,y,X,N,_e,H,be,oe,c,$e,L,ye,ge,U,Ee,ke,R,xe,Ne,ne,P,ae,_,g,Y,S,Pe,G,Se,se,A,K,De,ie;return k=new he({}),x=new he({}),N=new he({}),P=new nt({props:{code:`# make sure you're logged in with \`huggingface-cli login\`
from diffusers import StableDiffusionOnnxPipeline

pipe = StableDiffusionOnnxPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    revision="onnx",
    provider="CUDAExecutionProvider",
    use_auth_token=True,
)

prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]`,highlighted:`<span class="hljs-comment"># make sure you&#x27;re logged in with \`huggingface-cli login\`</span>
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionOnnxPipeline

pipe = StableDiffusionOnnxPipeline.from_pretrained(
    <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>,
    revision=<span class="hljs-string">&quot;onnx&quot;</span>,
    provider=<span class="hljs-string">&quot;CUDAExecutionProvider&quot;</span>,
    use_auth_token=<span class="hljs-literal">True</span>,
)

prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>
image = pipe(prompt).images[<span class="hljs-number">0</span>]`}}),S=new he({}),{c(){m=n("meta"),F=h(),d=n("h1"),b=n("a"),C=n("span"),M(k.$$.fragment),pe=h(),I=n("span"),ce=f("How to use the ONNX Runtime for inference"),Q=h(),D=n("p"),me=f("\u{1F917} Diffusers provides a Stable Diffusion pipeline compatible with the ONNX Runtime. This allows you to run Stable Diffusion on any hardware that supports ONNX (including CPUs), and where an accelerated version of PyTorch is not available."),Z=h(),v=n("h2"),$=n("a"),q=n("span"),M(x.$$.fragment),de=h(),T=n("span"),ve=f("Installation"),ee=h(),O=n("ul"),j=n("li"),we=f("TODO"),te=h(),w=n("h2"),y=n("a"),X=n("span"),M(N.$$.fragment),_e=h(),H=n("span"),be=f("Stable Diffusion Inference"),oe=h(),c=n("p"),$e=f("The snippet below demonstrates how to use the ONNX runtime. You need to use "),L=n("code"),ye=f("StableDiffusionOnnxPipeline"),ge=f(" instead of "),U=n("code"),Ee=f("StableDiffusionPipeline"),ke=f(". You also need to download the weights from the "),R=n("code"),xe=f("onnx"),Ne=f(" branch of the repository, and indicate the runtime provider you want to use."),ne=h(),M(P.$$.fragment),ae=h(),_=n("h2"),g=n("a"),Y=n("span"),M(S.$$.fragment),Pe=h(),G=n("span"),Se=f("Known Issues"),se=h(),A=n("ul"),K=n("li"),De=f("Generating multiple prompts in a batch seems to take too much memory. While we look into it, you may need to iterate instead of batching."),this.h()},l(e){const i=et('[data-svelte="svelte-1phssyn"]',document.head);m=a(i,"META",{name:!0,content:!0}),i.forEach(t),F=p(e),d=a(e,"H1",{class:!0});var re=s(d);b=a(re,"A",{id:!0,class:!0,href:!0});var Ae=s(b);C=a(Ae,"SPAN",{});var Ce=s(C);B(k.$$.fragment,Ce),Ce.forEach(t),Ae.forEach(t),pe=p(re),I=a(re,"SPAN",{});var Ie=s(I);ce=u(Ie,"How to use the ONNX Runtime for inference"),Ie.forEach(t),re.forEach(t),Q=p(e),D=a(e,"P",{});var qe=s(D);me=u(qe,"\u{1F917} Diffusers provides a Stable Diffusion pipeline compatible with the ONNX Runtime. This allows you to run Stable Diffusion on any hardware that supports ONNX (including CPUs), and where an accelerated version of PyTorch is not available."),qe.forEach(t),Z=p(e),v=a(e,"H2",{class:!0});var le=s(v);$=a(le,"A",{id:!0,class:!0,href:!0});var Te=s($);q=a(Te,"SPAN",{});var je=s(q);B(x.$$.fragment,je),je.forEach(t),Te.forEach(t),de=p(le),T=a(le,"SPAN",{});var Xe=s(T);ve=u(Xe,"Installation"),Xe.forEach(t),le.forEach(t),ee=p(e),O=a(e,"UL",{});var He=s(O);j=a(He,"LI",{});var Le=s(j);we=u(Le,"TODO"),Le.forEach(t),He.forEach(t),te=p(e),w=a(e,"H2",{class:!0});var fe=s(w);y=a(fe,"A",{id:!0,class:!0,href:!0});var Ue=s(y);X=a(Ue,"SPAN",{});var Re=s(X);B(N.$$.fragment,Re),Re.forEach(t),Ue.forEach(t),_e=p(fe),H=a(fe,"SPAN",{});var Ye=s(H);be=u(Ye,"Stable Diffusion Inference"),Ye.forEach(t),fe.forEach(t),oe=p(e),c=a(e,"P",{});var E=s(c);$e=u(E,"The snippet below demonstrates how to use the ONNX runtime. You need to use "),L=a(E,"CODE",{});var Ge=s(L);ye=u(Ge,"StableDiffusionOnnxPipeline"),Ge.forEach(t),ge=u(E," instead of "),U=a(E,"CODE",{});var Ke=s(U);Ee=u(Ke,"StableDiffusionPipeline"),Ke.forEach(t),ke=u(E,". You also need to download the weights from the "),R=a(E,"CODE",{});var Me=s(R);xe=u(Me,"onnx"),Me.forEach(t),Ne=u(E," branch of the repository, and indicate the runtime provider you want to use."),E.forEach(t),ne=p(e),B(P.$$.fragment,e),ae=p(e),_=a(e,"H2",{class:!0});var ue=s(_);g=a(ue,"A",{id:!0,class:!0,href:!0});var Be=s(g);Y=a(Be,"SPAN",{});var Ve=s(Y);B(S.$$.fragment,Ve),Ve.forEach(t),Be.forEach(t),Pe=p(ue),G=a(ue,"SPAN",{});var We=s(G);Se=u(We,"Known Issues"),We.forEach(t),ue.forEach(t),se=p(e),A=a(e,"UL",{});var Je=s(A);K=a(Je,"LI",{});var ze=s(K);De=u(ze,"Generating multiple prompts in a batch seems to take too much memory. While we look into it, you may need to iterate instead of batching."),ze.forEach(t),Je.forEach(t),this.h()},h(){r(m,"name","hf:doc:metadata"),r(m,"content",JSON.stringify(st)),r(b,"id","how-to-use-the-onnx-runtime-for-inference"),r(b,"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"),r(b,"href","#how-to-use-the-onnx-runtime-for-inference"),r(d,"class","relative group"),r($,"id","installation"),r($,"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"),r($,"href","#installation"),r(v,"class","relative group"),r(y,"id","stable-diffusion-inference"),r(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"),r(y,"href","#stable-diffusion-inference"),r(w,"class","relative group"),r(g,"id","known-issues"),r(g,"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"),r(g,"href","#known-issues"),r(_,"class","relative group")},m(e,i){o(document.head,m),l(e,F,i),l(e,d,i),o(d,b),o(b,C),V(k,C,null),o(d,pe),o(d,I),o(I,ce),l(e,Q,i),l(e,D,i),o(D,me),l(e,Z,i),l(e,v,i),o(v,$),o($,q),V(x,q,null),o(v,de),o(v,T),o(T,ve),l(e,ee,i),l(e,O,i),o(O,j),o(j,we),l(e,te,i),l(e,w,i),o(w,y),o(y,X),V(N,X,null),o(w,_e),o(w,H),o(H,be),l(e,oe,i),l(e,c,i),o(c,$e),o(c,L),o(L,ye),o(c,ge),o(c,U),o(U,Ee),o(c,ke),o(c,R),o(R,xe),o(c,Ne),l(e,ne,i),V(P,e,i),l(e,ae,i),l(e,_,i),o(_,g),o(g,Y),V(S,Y,null),o(_,Pe),o(_,G),o(G,Se),l(e,se,i),l(e,A,i),o(A,K),o(K,De),ie=!0},p:tt,i(e){ie||(W(k.$$.fragment,e),W(x.$$.fragment,e),W(N.$$.fragment,e),W(P.$$.fragment,e),W(S.$$.fragment,e),ie=!0)},o(e){J(k.$$.fragment,e),J(x.$$.fragment,e),J(N.$$.fragment,e),J(P.$$.fragment,e),J(S.$$.fragment,e),ie=!1},d(e){t(m),e&&t(F),e&&t(d),z(k),e&&t(Q),e&&t(D),e&&t(Z),e&&t(v),z(x),e&&t(ee),e&&t(O),e&&t(te),e&&t(w),z(N),e&&t(oe),e&&t(c),e&&t(ne),z(P,e),e&&t(ae),e&&t(_),z(S),e&&t(se),e&&t(A)}}}const st={local:"how-to-use-the-onnx-runtime-for-inference",sections:[{local:"installation",title:"Installation"},{local:"stable-diffusion-inference",title:"Stable Diffusion Inference"},{local:"known-issues",title:"Known Issues"}],title:"How to use the ONNX Runtime for inference"};function it(Oe){return ot(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ut extends Fe{constructor(m){super();Qe(this,m,it,at,Ze,{})}}export{ut as default,st as metadata};
