import{s as Ue,o as ve,n as je}from"../chunks/scheduler.8c3d61f6.js";import{S as _e,i as We,g as p,s as i,r as f,A as Ge,h as o,f as n,c as s,j as Je,u,x as h,k as ue,y as Ze,a as l,v as r,d as b,t as d,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){l(m,a,N)},p:je,d(m){m&&n(a)}}}function Xe(V){let a,M,m,N,g,F,T,be='🤗 <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:',P,x,E,y,de="This guide will show you how to use the Stable Diffusion and Stable Diffusion XL (SDXL) pipelines with ONNX Runtime.",Q,J,O,U,ce='To load and run inference, use the <a href="https://huggingface.co/docs/optimum/v1.21.4/en/onnxruntime/package_reference/modeling_ort#optimum.onnxruntime.ORTStableDiffusionPipeline" rel="nofollow">ORTStableDiffusionPipeline</a>. If you want to load a PyTorch model and convert it to the ONNX format on-the-fly, set <code>export=True</code>:',Y,v,z,w,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,_,A,W,we="Then to perform inference (you don’t have to specify <code>export=True</code> again):",K,G,ee,$,$e='<img src="https://huggingface.co/datasets/optimum/documentation-images/resolve/main/onnxruntime/stable_diffusion_v1_5_ort_sail_boat.png"/>',te,Z,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.',ne,S,le,B,ge='To load and run inference with SDXL, use the <a href="https://huggingface.co/docs/optimum/v1.21.4/en/onnxruntime/package_reference/modeling_ort#optimum.onnxruntime.ORTStableDiffusionXLPipeline" rel="nofollow">ORTStableDiffusionXLPipeline</a>:',ie,C,se,X,Te='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,xe="SDXL in the ONNX format is supported for text-to-image and image-to-image.",oe,H,me,I,fe;return g=new re({props:{title:"ONNX Runtime",local:"onnx-runtime",headingTag:"h1"}}),x=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}}),w=new Se({props:{warning:!0,$$slots:{default:[Ce]},$$scope:{ctx:V}}}),_=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}}),G=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(g.$$.fragment),F=i(),T=p("p"),T.innerHTML=be,P=i(),f(x.$$.fragment),E=i(),y=p("p"),y.textContent=de,Q=i(),f(J.$$.fragment),O=i(),U=p("p"),U.innerHTML=ce,Y=i(),f(v.$$.fragment),z=i(),f(w.$$.fragment),D=i(),j=p("p"),j.innerHTML=he,q=i(),f(_.$$.fragment),A=i(),W=p("p"),W.innerHTML=we,K=i(),f(G.$$.fragment),ee=i(),$=p("div"),$.innerHTML=$e,te=i(),Z=p("p"),Z.innerHTML=Me,ne=i(),f(S.$$.fragment),le=i(),B=p("p"),B.innerHTML=ge,ie=i(),f(C.$$.fragment),se=i(),X=p("p"),X.innerHTML=Te,ae=i(),f(R.$$.fragment),pe=i(),L=p("p"),L.textContent=xe,oe=i(),f(H.$$.fragment),me=i(),I=p("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);a=o(t,"META",{name:!0,content:!0}),t.forEach(n),M=s(e),m=o(e,"P",{}),Je(m).forEach(n),N=s(e),u(g.$$.fragment,e),F=s(e),T=o(e,"P",{"data-svelte-h":!0}),h(T)!=="svelte-y6glu5"&&(T.innerHTML=be),P=s(e),u(x.$$.fragment,e),E=s(e),y=o(e,"P",{"data-svelte-h":!0}),h(y)!=="svelte-a0u2"&&(y.textContent=de),Q=s(e),u(J.$$.fragment,e),O=s(e),U=o(e,"P",{"data-svelte-h":!0}),h(U)!=="svelte-1mxcdy1"&&(U.innerHTML=ce),Y=s(e),u(v.$$.fragment,e),z=s(e),u(w.$$.fragment,e),D=s(e),j=o(e,"P",{"data-svelte-h":!0}),h(j)!=="svelte-1jrf34f"&&(j.innerHTML=he),q=s(e),u(_.$$.fragment,e),A=s(e),W=o(e,"P",{"data-svelte-h":!0}),h(W)!=="svelte-uler64"&&(W.innerHTML=we),K=s(e),u(G.$$.fragment,e),ee=s(e),$=o(e,"DIV",{class:!0,"data-svelte-h":!0}),h($)!=="svelte-1pusq1s"&&($.innerHTML=$e),te=s(e),Z=o(e,"P",{"data-svelte-h":!0}),h(Z)!=="svelte-prwd9a"&&(Z.innerHTML=Me),ne=s(e),u(S.$$.fragment,e),le=s(e),B=o(e,"P",{"data-svelte-h":!0}),h(B)!=="svelte-113ab3g"&&(B.innerHTML=ge),ie=s(e),u(C.$$.fragment,e),se=s(e),X=o(e,"P",{"data-svelte-h":!0}),h(X)!=="svelte-jm4k2m"&&(X.innerHTML=Te),ae=s(e),u(R.$$.fragment,e),pe=s(e),L=o(e,"P",{"data-svelte-h":!0}),h(L)!=="svelte-5zcwcl"&&(L.textContent=xe),oe=s(e),u(H.$$.fragment,e),me=s(e),I=o(e,"P",{}),Je(I).forEach(n),this.h()},h(){ue(a,"name","hf:doc:metadata"),ue(a,"content",Re),ue($,"class","flex justify-center")},m(e,t){Ze(document.head,a),l(e,M,t),l(e,m,t),l(e,N,t),r(g,e,t),l(e,F,t),l(e,T,t),l(e,P,t),r(x,e,t),l(e,E,t),l(e,y,t),l(e,Q,t),r(J,e,t),l(e,O,t),l(e,U,t),l(e,Y,t),r(v,e,t),l(e,z,t),r(w,e,t),l(e,D,t),l(e,j,t),l(e,q,t),r(_,e,t),l(e,A,t),l(e,W,t),l(e,K,t),r(G,e,t),l(e,ee,t),l(e,$,t),l(e,te,t),l(e,Z,t),l(e,ne,t),r(S,e,t),l(e,le,t),l(e,B,t),l(e,ie,t),r(C,e,t),l(e,se,t),l(e,X,t),l(e,ae,t),r(R,e,t),l(e,pe,t),l(e,L,t),l(e,oe,t),r(H,e,t),l(e,me,t),l(e,I,t),fe=!0},p(e,[t]){const ye={};t&2&&(ye.$$scope={dirty:t,ctx:e}),w.$set(ye)},i(e){fe||(b(g.$$.fragment,e),b(x.$$.fragment,e),b(J.$$.fragment,e),b(v.$$.fragment,e),b(w.$$.fragment,e),b(_.$$.fragment,e),b(G.$$.fragment,e),b(S.$$.fragment,e),b(C.$$.fragment,e),b(R.$$.fragment,e),b(H.$$.fragment,e),fe=!0)},o(e){d(g.$$.fragment,e),d(x.$$.fragment,e),d(J.$$.fragment,e),d(v.$$.fragment,e),d(w.$$.fragment,e),d(_.$$.fragment,e),d(G.$$.fragment,e),d(S.$$.fragment,e),d(C.$$.fragment,e),d(R.$$.fragment,e),d(H.$$.fragment,e),fe=!1},d(e){e&&(n(M),n(m),n(N),n(F),n(T),n(P),n(E),n(y),n(Q),n(O),n(U),n(Y),n(z),n(D),n(j),n(q),n(A),n(W),n(K),n(ee),n($),n(te),n(Z),n(ne),n(le),n(B),n(ie),n(se),n(X),n(ae),n(pe),n(L),n(oe),n(me),n(I)),n(a),c(g,e),c(x,e),c(J,e),c(v,e),c(w,e),c(_,e),c(G,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 _e{constructor(a){super(),We(this,a,Le,Xe,Ue,{})}}export{Fe as component};
