import{s as je,o as We,n as Je}from"../chunks/scheduler.8c3d61f6.js";import{S as Ue,i as Ze,g as p,s as i,r as f,A as Se,h as o,f as l,c as s,j as ve,u,x as h,k as ue,y as _e,a as n,v as r,d as b,t as d,w as c}from"../chunks/index.da70eac4.js";import{T as Be}from"../chunks/Tip.1d9b8c37.js";import{C as H}from"../chunks/CodeBlock.a9c4becf.js";import{H as re,E as Ge}from"../chunks/getInferenceSnippets.39110341.js";function Xe(I){let a,w="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=w},l(m){a=o(m,"P",{"data-svelte-h":!0}),h(a)!=="svelte-15fyw3p"&&(a.textContent=w)},m(m,k){n(m,a,k)},p:Je,d(m){m&&l(a)}}}function Ne(I){let a,w,m,k,T,P,g,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:',E,x,Y,y,de="This guide will show you how to use the Stable Diffusion and Stable Diffusion XL (SDXL) pipelines with ONNX Runtime.",F,v,V,j,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>:",O,W,D,M,q,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:`,z,U,A,Z,Me="Then to perform inference (you don’t have to specify <code>export=True</code> again):",K,S,ee,$,$e='<img src="https://huggingface.co/datasets/optimum/documentation-images/resolve/main/onnxruntime/stable_diffusion_v1_5_ort_sail_boat.png"/>',te,_,we='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,B,ne,G,Te="To load and run inference with SDXL, use the <code>ORTStableDiffusionXLPipeline</code>:",ie,X,se,N,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,C,xe="SDXL in the ONNX format is supported for text-to-image and image-to-image.",oe,L,me,Q,fe;return T=new re({props:{title:"ONNX Runtime",local:"onnx-runtime",headingTag:"h1"}}),x=new H({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1xJTIwb3B0aW11bSU1QiUyMm9ubnhydW50aW1lJTIyJTVE",highlighted:'pip install -q optimum[<span class="hljs-string">&quot;onnxruntime&quot;</span>]',wrap:!1}}),v=new re({props:{title:"Stable Diffusion",local:"stable-diffusion",headingTag:"h2"}}),W=new H({props:{code:"ZnJvbSUyMG9wdGltdW0ub25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBPUlRTdGFibGVEaWZmdXNpb25QaXBlbGluZSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBcGlwZWxpbmUlMjAlM0QlMjBPUlRTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjBleHBvcnQlM0RUcnVlKSUwQXByb21wdCUyMCUzRCUyMCUyMnNhaWxpbmclMjBzaGlwJTIwaW4lMjBzdG9ybSUyMGJ5JTIwTGVvbmFyZG8lMjBkYSUyMFZpbmNpJTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQpLmltYWdlcyU1QjAlNUQlMEFwaXBlbGluZS5zYXZlX3ByZXRyYWluZWQoJTIyLiUyRm9ubngtc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTStableDiffusionPipeline

model_id = <span class="hljs-string">&quot;stable-diffusion-v1-5/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}}),M=new Be({props:{warning:!0,$$slots:{default:[Xe]},$$scope:{ctx:I}}}),U=new H({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMHN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMHNkX3YxNV9vbm54JTJG",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model stable-diffusion-v1-5/stable-diffusion-v1-5 sd_v15_onnx/',wrap:!1}}),S=new H({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}}),B=new re({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),X=new H({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 H({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}}),L=new Ge({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/onnx.md"}}),{c(){a=p("meta"),w=i(),m=p("p"),k=i(),f(T.$$.fragment),P=i(),g=p("p"),g.innerHTML=be,E=i(),f(x.$$.fragment),Y=i(),y=p("p"),y.textContent=de,F=i(),f(v.$$.fragment),V=i(),j=p("p"),j.innerHTML=ce,O=i(),f(W.$$.fragment),D=i(),f(M.$$.fragment),q=i(),J=p("p"),J.innerHTML=he,z=i(),f(U.$$.fragment),A=i(),Z=p("p"),Z.innerHTML=Me,K=i(),f(S.$$.fragment),ee=i(),$=p("div"),$.innerHTML=$e,te=i(),_=p("p"),_.innerHTML=we,le=i(),f(B.$$.fragment),ne=i(),G=p("p"),G.innerHTML=Te,ie=i(),f(X.$$.fragment),se=i(),N=p("p"),N.innerHTML=ge,ae=i(),f(R.$$.fragment),pe=i(),C=p("p"),C.textContent=xe,oe=i(),f(L.$$.fragment),me=i(),Q=p("p"),this.h()},l(e){const t=Se("svelte-u9bgzb",document.head);a=o(t,"META",{name:!0,content:!0}),t.forEach(l),w=s(e),m=o(e,"P",{}),ve(m).forEach(l),k=s(e),u(T.$$.fragment,e),P=s(e),g=o(e,"P",{"data-svelte-h":!0}),h(g)!=="svelte-y6glu5"&&(g.innerHTML=be),E=s(e),u(x.$$.fragment,e),Y=s(e),y=o(e,"P",{"data-svelte-h":!0}),h(y)!=="svelte-a0u2"&&(y.textContent=de),F=s(e),u(v.$$.fragment,e),V=s(e),j=o(e,"P",{"data-svelte-h":!0}),h(j)!=="svelte-1hyrtw6"&&(j.innerHTML=ce),O=s(e),u(W.$$.fragment,e),D=s(e),u(M.$$.fragment,e),q=s(e),J=o(e,"P",{"data-svelte-h":!0}),h(J)!=="svelte-1jrf34f"&&(J.innerHTML=he),z=s(e),u(U.$$.fragment,e),A=s(e),Z=o(e,"P",{"data-svelte-h":!0}),h(Z)!=="svelte-uler64"&&(Z.innerHTML=Me),K=s(e),u(S.$$.fragment,e),ee=s(e),$=o(e,"DIV",{class:!0,"data-svelte-h":!0}),h($)!=="svelte-1pusq1s"&&($.innerHTML=$e),te=s(e),_=o(e,"P",{"data-svelte-h":!0}),h(_)!=="svelte-prwd9a"&&(_.innerHTML=we),le=s(e),u(B.$$.fragment,e),ne=s(e),G=o(e,"P",{"data-svelte-h":!0}),h(G)!=="svelte-1drvfsn"&&(G.innerHTML=Te),ie=s(e),u(X.$$.fragment,e),se=s(e),N=o(e,"P",{"data-svelte-h":!0}),h(N)!=="svelte-jm4k2m"&&(N.innerHTML=ge),ae=s(e),u(R.$$.fragment,e),pe=s(e),C=o(e,"P",{"data-svelte-h":!0}),h(C)!=="svelte-5zcwcl"&&(C.textContent=xe),oe=s(e),u(L.$$.fragment,e),me=s(e),Q=o(e,"P",{}),ve(Q).forEach(l),this.h()},h(){ue(a,"name","hf:doc:metadata"),ue(a,"content",Re),ue($,"class","flex justify-center")},m(e,t){_e(document.head,a),n(e,w,t),n(e,m,t),n(e,k,t),r(T,e,t),n(e,P,t),n(e,g,t),n(e,E,t),r(x,e,t),n(e,Y,t),n(e,y,t),n(e,F,t),r(v,e,t),n(e,V,t),n(e,j,t),n(e,O,t),r(W,e,t),n(e,D,t),r(M,e,t),n(e,q,t),n(e,J,t),n(e,z,t),r(U,e,t),n(e,A,t),n(e,Z,t),n(e,K,t),r(S,e,t),n(e,ee,t),n(e,$,t),n(e,te,t),n(e,_,t),n(e,le,t),r(B,e,t),n(e,ne,t),n(e,G,t),n(e,ie,t),r(X,e,t),n(e,se,t),n(e,N,t),n(e,ae,t),r(R,e,t),n(e,pe,t),n(e,C,t),n(e,oe,t),r(L,e,t),n(e,me,t),n(e,Q,t),fe=!0},p(e,[t]){const ye={};t&2&&(ye.$$scope={dirty:t,ctx:e}),M.$set(ye)},i(e){fe||(b(T.$$.fragment,e),b(x.$$.fragment,e),b(v.$$.fragment,e),b(W.$$.fragment,e),b(M.$$.fragment,e),b(U.$$.fragment,e),b(S.$$.fragment,e),b(B.$$.fragment,e),b(X.$$.fragment,e),b(R.$$.fragment,e),b(L.$$.fragment,e),fe=!0)},o(e){d(T.$$.fragment,e),d(x.$$.fragment,e),d(v.$$.fragment,e),d(W.$$.fragment,e),d(M.$$.fragment,e),d(U.$$.fragment,e),d(S.$$.fragment,e),d(B.$$.fragment,e),d(X.$$.fragment,e),d(R.$$.fragment,e),d(L.$$.fragment,e),fe=!1},d(e){e&&(l(w),l(m),l(k),l(P),l(g),l(E),l(Y),l(y),l(F),l(V),l(j),l(O),l(D),l(q),l(J),l(z),l(A),l(Z),l(K),l(ee),l($),l(te),l(_),l(le),l(ne),l(G),l(ie),l(se),l(N),l(ae),l(pe),l(C),l(oe),l(me),l(Q)),l(a),c(T,e),c(x,e),c(v,e),c(W,e),c(M,e),c(U,e),c(S,e),c(B,e),c(X,e),c(R,e),c(L,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 Ce(I){return We(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pe extends Ue{constructor(a){super(),Ze(this,a,Ce,Ne,je,{})}}export{Pe as component};
