import{s as Ue,o as ve,n as je}from"../chunks/scheduler.8c3d61f6.js";import{S as We,i as Ge,g as p,s as i,r as f,A as Ze,h as o,f as l,c as s,j as Je,u,x as h,k as ue,y as _e,a as n,v as r,d,t as b,w as c}from"../chunks/index.da70eac4.js";import{T as Se}from"../chunks/Tip.1d9b8c37.js";import{C as k}from"../chunks/CodeBlock.00a903b3.js";import{H as re,E as Be}from"../chunks/EditOnGithub.1e64e623.js";function Ce(V){let a,M="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.";return{c(){a=p("p"),a.textContent=M},l(m){a=o(m,"P",{"data-svelte-h":!0}),h(a)!=="svelte-15fyw3p"&&(a.textContent=M)},m(m,N){n(m,a,N)},p:je,d(m){m&&l(a)}}}function Xe(V){let a,M,m,N,T,F,g,de='🤗 <a href="https://github.com/huggingface/optimum" rel="nofollow">Optimum</a> provides a Stable Diffusion pipeline compatible with ONNX Runtime. You’ll need to install 🤗 Optimum with the following command for ONNX Runtime support:',E,y,P,x,be="This guide will show you how to use the Stable Diffusion and Stable Diffusion XL (SDXL) pipelines with ONNX Runtime.",Q,J,Y,U,ce="To load and run inference, use the <code>ORTStableDiffusionPipeline</code>. If you want to load a PyTorch model and convert it to the ONNX format on-the-fly, set <code>export=True</code>:",z,v,O,$,D,j,he=`To export the pipeline in the ONNX format offline and use it later for inference,
use the <a href="https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/export_a_model#exporting-a-model-to-onnx-using-the-cli" rel="nofollow"><code>optimum-cli export</code></a> command:`,q,W,A,G,$e="Then to perform inference (you don’t have to specify <code>export=True</code> again):",K,Z,ee,w,we='<img src="https://huggingface.co/datasets/optimum/documentation-images/resolve/main/onnxruntime/stable_diffusion_v1_5_ort_sail_boat.png"/>',te,_,Me='You can find more examples in 🤗 Optimum <a href="https://huggingface.co/docs/optimum/" rel="nofollow">documentation</a>, and Stable Diffusion is supported for text-to-image, image-to-image, and inpainting.',le,S,ne,B,Te="To load and run inference with SDXL, use the <code>ORTStableDiffusionXLPipeline</code>:",ie,C,se,X,ge='To export the pipeline in the ONNX format and use it later for inference, use the <a href="https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/export_a_model#exporting-a-model-to-onnx-using-the-cli" rel="nofollow"><code>optimum-cli export</code></a> command:',ae,R,pe,L,ye="SDXL in the ONNX format is supported for text-to-image and image-to-image.",oe,H,me,I,fe;return T=new re({props:{title:"ONNX Runtime",local:"onnx-runtime",headingTag:"h1"}}),y=new k({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1xJTIwb3B0aW11bSU1QiUyMm9ubnhydW50aW1lJTIyJTVE",highlighted:'pip install -q optimum[<span class="hljs-string">&quot;onnxruntime&quot;</span>]',wrap:!1}}),J=new re({props:{title:"Stable Diffusion",local:"stable-diffusion",headingTag:"h2"}}),v=new k({props:{code:"ZnJvbSUyMG9wdGltdW0ub25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBPUlRTdGFibGVEaWZmdXNpb25QaXBlbGluZSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEFwaXBlbGluZSUyMCUzRCUyME9SVFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMGV4cG9ydCUzRFRydWUpJTBBcHJvbXB0JTIwJTNEJTIwJTIyc2FpbGluZyUyMHNoaXAlMjBpbiUyMHN0b3JtJTIwYnklMjBMZW9uYXJkbyUyMGRhJTIwVmluY2klMjIlMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCkuaW1hZ2VzJTVCMCU1RCUwQXBpcGVsaW5lLnNhdmVfcHJldHJhaW5lZCglMjIuJTJGb25ueC1zdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIp",highlighted:`<span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTStableDiffusionPipeline

model_id = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
pipeline = ORTStableDiffusionPipeline.from_pretrained(model_id, export=<span class="hljs-literal">True</span>)
prompt = <span class="hljs-string">&quot;sailing ship in storm by Leonardo da Vinci&quot;</span>
image = pipeline(prompt).images[<span class="hljs-number">0</span>]
pipeline.save_pretrained(<span class="hljs-string">&quot;./onnx-stable-diffusion-v1-5&quot;</span>)`,wrap:!1}}),$=new Se({props:{warning:!0,$$slots:{default:[Ce]},$$scope:{ctx:V}}}),W=new k({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMHJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIwc2RfdjE1X29ubnglMkY=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model runwayml/stable-diffusion-v1-5 sd_v15_onnx/',wrap:!1}}),Z=new k({props:{code:"ZnJvbSUyMG9wdGltdW0ub25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBPUlRTdGFibGVEaWZmdXNpb25QaXBlbGluZSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyc2RfdjE1X29ubnglMjIlMEFwaXBlbGluZSUyMCUzRCUyME9SVFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFwcm9tcHQlMjAlM0QlMjAlMjJzYWlsaW5nJTIwc2hpcCUyMGluJTIwc3Rvcm0lMjBieSUyMExlb25hcmRvJTIwZGElMjBWaW5jaSUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0KS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTStableDiffusionPipeline

model_id = <span class="hljs-string">&quot;sd_v15_onnx&quot;</span>
pipeline = ORTStableDiffusionPipeline.from_pretrained(model_id)
prompt = <span class="hljs-string">&quot;sailing ship in storm by Leonardo da Vinci&quot;</span>
image = pipeline(prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),S=new re({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),C=new k({props:{code:"ZnJvbSUyMG9wdGltdW0ub25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBPUlRTdGFibGVEaWZmdXNpb25YTFBpcGVsaW5lJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMEFwaXBlbGluZSUyMCUzRCUyME9SVFN0YWJsZURpZmZ1c2lvblhMUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKSUwQXByb21wdCUyMCUzRCUyMCUyMnNhaWxpbmclMjBzaGlwJTIwaW4lMjBzdG9ybSUyMGJ5JTIwTGVvbmFyZG8lMjBkYSUyMFZpbmNpJTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTStableDiffusionXLPipeline

model_id = <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>
pipeline = ORTStableDiffusionXLPipeline.from_pretrained(model_id)
prompt = <span class="hljs-string">&quot;sailing ship in storm by Leonardo da Vinci&quot;</span>
image = pipeline(prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),R=new k({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMHN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMC0tdGFzayUyMHN0YWJsZS1kaWZmdXNpb24teGwlMjBzZF94bF9vbm54JTJG",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model stabilityai/stable-diffusion-xl-base-1.0 --task stable-diffusion-xl sd_xl_onnx/',wrap:!1}}),H=new Be({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/onnx.md"}}),{c(){a=p("meta"),M=i(),m=p("p"),N=i(),f(T.$$.fragment),F=i(),g=p("p"),g.innerHTML=de,E=i(),f(y.$$.fragment),P=i(),x=p("p"),x.textContent=be,Q=i(),f(J.$$.fragment),Y=i(),U=p("p"),U.innerHTML=ce,z=i(),f(v.$$.fragment),O=i(),f($.$$.fragment),D=i(),j=p("p"),j.innerHTML=he,q=i(),f(W.$$.fragment),A=i(),G=p("p"),G.innerHTML=$e,K=i(),f(Z.$$.fragment),ee=i(),w=p("div"),w.innerHTML=we,te=i(),_=p("p"),_.innerHTML=Me,le=i(),f(S.$$.fragment),ne=i(),B=p("p"),B.innerHTML=Te,ie=i(),f(C.$$.fragment),se=i(),X=p("p"),X.innerHTML=ge,ae=i(),f(R.$$.fragment),pe=i(),L=p("p"),L.textContent=ye,oe=i(),f(H.$$.fragment),me=i(),I=p("p"),this.h()},l(e){const t=Ze("svelte-u9bgzb",document.head);a=o(t,"META",{name:!0,content:!0}),t.forEach(l),M=s(e),m=o(e,"P",{}),Je(m).forEach(l),N=s(e),u(T.$$.fragment,e),F=s(e),g=o(e,"P",{"data-svelte-h":!0}),h(g)!=="svelte-y6glu5"&&(g.innerHTML=de),E=s(e),u(y.$$.fragment,e),P=s(e),x=o(e,"P",{"data-svelte-h":!0}),h(x)!=="svelte-a0u2"&&(x.textContent=be),Q=s(e),u(J.$$.fragment,e),Y=s(e),U=o(e,"P",{"data-svelte-h":!0}),h(U)!=="svelte-1hyrtw6"&&(U.innerHTML=ce),z=s(e),u(v.$$.fragment,e),O=s(e),u($.$$.fragment,e),D=s(e),j=o(e,"P",{"data-svelte-h":!0}),h(j)!=="svelte-1jrf34f"&&(j.innerHTML=he),q=s(e),u(W.$$.fragment,e),A=s(e),G=o(e,"P",{"data-svelte-h":!0}),h(G)!=="svelte-uler64"&&(G.innerHTML=$e),K=s(e),u(Z.$$.fragment,e),ee=s(e),w=o(e,"DIV",{class:!0,"data-svelte-h":!0}),h(w)!=="svelte-1pusq1s"&&(w.innerHTML=we),te=s(e),_=o(e,"P",{"data-svelte-h":!0}),h(_)!=="svelte-prwd9a"&&(_.innerHTML=Me),le=s(e),u(S.$$.fragment,e),ne=s(e),B=o(e,"P",{"data-svelte-h":!0}),h(B)!=="svelte-1drvfsn"&&(B.innerHTML=Te),ie=s(e),u(C.$$.fragment,e),se=s(e),X=o(e,"P",{"data-svelte-h":!0}),h(X)!=="svelte-jm4k2m"&&(X.innerHTML=ge),ae=s(e),u(R.$$.fragment,e),pe=s(e),L=o(e,"P",{"data-svelte-h":!0}),h(L)!=="svelte-5zcwcl"&&(L.textContent=ye),oe=s(e),u(H.$$.fragment,e),me=s(e),I=o(e,"P",{}),Je(I).forEach(l),this.h()},h(){ue(a,"name","hf:doc:metadata"),ue(a,"content",Re),ue(w,"class","flex justify-center")},m(e,t){_e(document.head,a),n(e,M,t),n(e,m,t),n(e,N,t),r(T,e,t),n(e,F,t),n(e,g,t),n(e,E,t),r(y,e,t),n(e,P,t),n(e,x,t),n(e,Q,t),r(J,e,t),n(e,Y,t),n(e,U,t),n(e,z,t),r(v,e,t),n(e,O,t),r($,e,t),n(e,D,t),n(e,j,t),n(e,q,t),r(W,e,t),n(e,A,t),n(e,G,t),n(e,K,t),r(Z,e,t),n(e,ee,t),n(e,w,t),n(e,te,t),n(e,_,t),n(e,le,t),r(S,e,t),n(e,ne,t),n(e,B,t),n(e,ie,t),r(C,e,t),n(e,se,t),n(e,X,t),n(e,ae,t),r(R,e,t),n(e,pe,t),n(e,L,t),n(e,oe,t),r(H,e,t),n(e,me,t),n(e,I,t),fe=!0},p(e,[t]){const xe={};t&2&&(xe.$$scope={dirty:t,ctx:e}),$.$set(xe)},i(e){fe||(d(T.$$.fragment,e),d(y.$$.fragment,e),d(J.$$.fragment,e),d(v.$$.fragment,e),d($.$$.fragment,e),d(W.$$.fragment,e),d(Z.$$.fragment,e),d(S.$$.fragment,e),d(C.$$.fragment,e),d(R.$$.fragment,e),d(H.$$.fragment,e),fe=!0)},o(e){b(T.$$.fragment,e),b(y.$$.fragment,e),b(J.$$.fragment,e),b(v.$$.fragment,e),b($.$$.fragment,e),b(W.$$.fragment,e),b(Z.$$.fragment,e),b(S.$$.fragment,e),b(C.$$.fragment,e),b(R.$$.fragment,e),b(H.$$.fragment,e),fe=!1},d(e){e&&(l(M),l(m),l(N),l(F),l(g),l(E),l(P),l(x),l(Q),l(Y),l(U),l(z),l(O),l(D),l(j),l(q),l(A),l(G),l(K),l(ee),l(w),l(te),l(_),l(le),l(ne),l(B),l(ie),l(se),l(X),l(ae),l(pe),l(L),l(oe),l(me),l(I)),l(a),c(T,e),c(y,e),c(J,e),c(v,e),c($,e),c(W,e),c(Z,e),c(S,e),c(C,e),c(R,e),c(H,e)}}}const Re='{"title":"ONNX Runtime","local":"onnx-runtime","sections":[{"title":"Stable Diffusion","local":"stable-diffusion","sections":[],"depth":2},{"title":"Stable Diffusion XL","local":"stable-diffusion-xl","sections":[],"depth":2}],"depth":1}';function Le(V){return ve(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Fe extends We{constructor(a){super(),Ge(this,a,Le,Xe,Ue,{})}}export{Fe as component};
