import{S as Qe,i as Ve,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 W,L as tt,q as J,o as z,B as F,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,Q,d,b,I,k,pe,q,ce,V,D,me,Z,v,y,C,x,de,T,ve,ee,O,X,we,te,w,$,j,N,_e,H,be,oe,c,ye,L,$e,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(
    "runwayml/stable-diffusion-v1-5",
    revision="onnx",
    provider="CUDAExecutionProvider",
)

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;runwayml/stable-diffusion-v1-5&quot;</span>,
    revision=<span class="hljs-string">&quot;onnx&quot;</span>,
    provider=<span class="hljs-string">&quot;CUDAExecutionProvider&quot;</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"),Q=h(),d=n("h1"),b=n("a"),I=n("span"),M(k.$$.fragment),pe=h(),q=n("span"),ce=f("How to use the ONNX Runtime for inference"),V=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"),y=n("a"),C=n("span"),M(x.$$.fragment),de=h(),T=n("span"),ve=f("Installation"),ee=h(),O=n("ul"),X=n("li"),we=f("TODO"),te=h(),w=n("h2"),$=n("a"),j=n("span"),M(N.$$.fragment),_e=h(),H=n("span"),be=f("Stable Diffusion Inference"),oe=h(),c=n("p"),ye=f("The snippet below demonstrates how to use the ONNX runtime. You need to use "),L=n("code"),$e=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),Q=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);I=a(Ae,"SPAN",{});var Ie=s(I);B(k.$$.fragment,Ie),Ie.forEach(t),Ae.forEach(t),pe=p(re),q=a(re,"SPAN",{});var qe=s(q);ce=u(qe,"How to use the ONNX Runtime for inference"),qe.forEach(t),re.forEach(t),V=p(e),D=a(e,"P",{});var Ce=s(D);me=u(Ce,"\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."),Ce.forEach(t),Z=p(e),v=a(e,"H2",{class:!0});var le=s(v);y=a(le,"A",{id:!0,class:!0,href:!0});var Te=s(y);C=a(Te,"SPAN",{});var Xe=s(C);B(x.$$.fragment,Xe),Xe.forEach(t),Te.forEach(t),de=p(le),T=a(le,"SPAN",{});var je=s(T);ve=u(je,"Installation"),je.forEach(t),le.forEach(t),ee=p(e),O=a(e,"UL",{});var He=s(O);X=a(He,"LI",{});var Le=s(X);we=u(Le,"TODO"),Le.forEach(t),He.forEach(t),te=p(e),w=a(e,"H2",{class:!0});var fe=s(w);$=a(fe,"A",{id:!0,class:!0,href:!0});var Ue=s($);j=a(Ue,"SPAN",{});var Re=s(j);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);ye=u(E,"The snippet below demonstrates how to use the ONNX runtime. You need to use "),L=a(E,"CODE",{});var Ge=s(L);$e=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 We=s(Y);B(S.$$.fragment,We),We.forEach(t),Be.forEach(t),Pe=p(ue),G=a(ue,"SPAN",{});var Je=s(G);Se=u(Je,"Known Issues"),Je.forEach(t),ue.forEach(t),se=p(e),A=a(e,"UL",{});var ze=s(A);K=a(ze,"LI",{});var Fe=s(K);De=u(Fe,"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."),Fe.forEach(t),ze.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(y,"id","installation"),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","#installation"),r(v,"class","relative group"),r($,"id","stable-diffusion-inference"),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","#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,Q,i),l(e,d,i),o(d,b),o(b,I),W(k,I,null),o(d,pe),o(d,q),o(q,ce),l(e,V,i),l(e,D,i),o(D,me),l(e,Z,i),l(e,v,i),o(v,y),o(y,C),W(x,C,null),o(v,de),o(v,T),o(T,ve),l(e,ee,i),l(e,O,i),o(O,X),o(X,we),l(e,te,i),l(e,w,i),o(w,$),o($,j),W(N,j,null),o(w,_e),o(w,H),o(H,be),l(e,oe,i),l(e,c,i),o(c,ye),o(c,L),o(L,$e),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),W(P,e,i),l(e,ae,i),l(e,_,i),o(_,g),o(g,Y),W(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||(J(k.$$.fragment,e),J(x.$$.fragment,e),J(N.$$.fragment,e),J(P.$$.fragment,e),J(S.$$.fragment,e),ie=!0)},o(e){z(k.$$.fragment,e),z(x.$$.fragment,e),z(N.$$.fragment,e),z(P.$$.fragment,e),z(S.$$.fragment,e),ie=!1},d(e){t(m),e&&t(Q),e&&t(d),F(k),e&&t(V),e&&t(D),e&&t(Z),e&&t(v),F(x),e&&t(ee),e&&t(O),e&&t(te),e&&t(w),F(N),e&&t(oe),e&&t(c),e&&t(ne),F(P,e),e&&t(ae),e&&t(_),F(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 Qe{constructor(m){super();Ve(this,m,it,at,Ze,{})}}export{ut as default,st as metadata};
