import{s as xe,o as Je,n as Ue}from"../chunks/scheduler.182ea377.js";import{S as ve,i as je,g as p,s as i,r as u,A as Ge,h as o,f as l,c as s,j as ye,u as r,x as f,k as me,y as We,a as n,v as d,d as b,t as c,w as h}from"../chunks/index.abf12888.js";import{T as Ze}from"../chunks/Tip.230e2334.js";import{C as H}from"../chunks/CodeBlock.57fe6e13.js";import{H as fe}from"../chunks/Heading.16916d63.js";function _e(I){let a,$="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=$},l(m){a=o(m,"P",{"data-svelte-h":!0}),f(a)!=="svelte-15fyw3p"&&(a.textContent=$)},m(m,N){n(m,a,N)},p:Ue,d(m){m&&l(a)}}}function Se(I){let a,$,m,N,T,V,g,ue='🤗 <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:',F,y,P,x,re="This guide will show you how to use the Stable Diffusion and Stable Diffusion XL (SDXL) pipelines with ONNX Runtime.",E,J,Q,U,de="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>:",Y,v,z,M,D,j,be=`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:`,O,G,q,W,ce="Then to perform inference (you don’t have to specify <code>export=True</code> again):",A,Z,K,w,he='<img src="https://huggingface.co/datasets/optimum/documentation-images/resolve/main/onnxruntime/stable_diffusion_v1_5_ort_sail_boat.png"/>',ee,_,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.',te,S,le,B,we="To load and run inference with SDXL, use the <code>ORTStableDiffusionXLPipeline</code>:",ne,C,ie,X,$e='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:',se,R,ae,L,Te="SDXL in the ONNX format is supported for text-to-image and image-to-image.",pe,k,oe;return T=new fe({props:{title:"ONNX Runtime",local:"onnx-runtime",headingTag:"h1"}}),y=new H({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUIlMjJvbm54cnVudGltZSUyMiU1RA==",highlighted:'pip install optimum[<span class="hljs-string">&quot;onnxruntime&quot;</span>]',wrap:!1}}),J=new fe({props:{title:"Stable Diffusion",local:"stable-diffusion",headingTag:"h2"}}),v=new H({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}}),M=new Ze({props:{warning:!0,$$slots:{default:[_e]},$$scope:{ctx:I}}}),G=new H({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 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}}),S=new fe({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),C=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}}),{c(){a=p("meta"),$=i(),m=p("p"),N=i(),u(T.$$.fragment),V=i(),g=p("p"),g.innerHTML=ue,F=i(),u(y.$$.fragment),P=i(),x=p("p"),x.textContent=re,E=i(),u(J.$$.fragment),Q=i(),U=p("p"),U.innerHTML=de,Y=i(),u(v.$$.fragment),z=i(),u(M.$$.fragment),D=i(),j=p("p"),j.innerHTML=be,O=i(),u(G.$$.fragment),q=i(),W=p("p"),W.innerHTML=ce,A=i(),u(Z.$$.fragment),K=i(),w=p("div"),w.innerHTML=he,ee=i(),_=p("p"),_.innerHTML=Me,te=i(),u(S.$$.fragment),le=i(),B=p("p"),B.innerHTML=we,ne=i(),u(C.$$.fragment),ie=i(),X=p("p"),X.innerHTML=$e,se=i(),u(R.$$.fragment),ae=i(),L=p("p"),L.textContent=Te,pe=i(),k=p("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);a=o(t,"META",{name:!0,content:!0}),t.forEach(l),$=s(e),m=o(e,"P",{}),ye(m).forEach(l),N=s(e),r(T.$$.fragment,e),V=s(e),g=o(e,"P",{"data-svelte-h":!0}),f(g)!=="svelte-y6glu5"&&(g.innerHTML=ue),F=s(e),r(y.$$.fragment,e),P=s(e),x=o(e,"P",{"data-svelte-h":!0}),f(x)!=="svelte-a0u2"&&(x.textContent=re),E=s(e),r(J.$$.fragment,e),Q=s(e),U=o(e,"P",{"data-svelte-h":!0}),f(U)!=="svelte-1hyrtw6"&&(U.innerHTML=de),Y=s(e),r(v.$$.fragment,e),z=s(e),r(M.$$.fragment,e),D=s(e),j=o(e,"P",{"data-svelte-h":!0}),f(j)!=="svelte-1jrf34f"&&(j.innerHTML=be),O=s(e),r(G.$$.fragment,e),q=s(e),W=o(e,"P",{"data-svelte-h":!0}),f(W)!=="svelte-uler64"&&(W.innerHTML=ce),A=s(e),r(Z.$$.fragment,e),K=s(e),w=o(e,"DIV",{class:!0,"data-svelte-h":!0}),f(w)!=="svelte-1pusq1s"&&(w.innerHTML=he),ee=s(e),_=o(e,"P",{"data-svelte-h":!0}),f(_)!=="svelte-prwd9a"&&(_.innerHTML=Me),te=s(e),r(S.$$.fragment,e),le=s(e),B=o(e,"P",{"data-svelte-h":!0}),f(B)!=="svelte-1drvfsn"&&(B.innerHTML=we),ne=s(e),r(C.$$.fragment,e),ie=s(e),X=o(e,"P",{"data-svelte-h":!0}),f(X)!=="svelte-jm4k2m"&&(X.innerHTML=$e),se=s(e),r(R.$$.fragment,e),ae=s(e),L=o(e,"P",{"data-svelte-h":!0}),f(L)!=="svelte-5zcwcl"&&(L.textContent=Te),pe=s(e),k=o(e,"P",{}),ye(k).forEach(l),this.h()},h(){me(a,"name","hf:doc:metadata"),me(a,"content",Be),me(w,"class","flex justify-center")},m(e,t){We(document.head,a),n(e,$,t),n(e,m,t),n(e,N,t),d(T,e,t),n(e,V,t),n(e,g,t),n(e,F,t),d(y,e,t),n(e,P,t),n(e,x,t),n(e,E,t),d(J,e,t),n(e,Q,t),n(e,U,t),n(e,Y,t),d(v,e,t),n(e,z,t),d(M,e,t),n(e,D,t),n(e,j,t),n(e,O,t),d(G,e,t),n(e,q,t),n(e,W,t),n(e,A,t),d(Z,e,t),n(e,K,t),n(e,w,t),n(e,ee,t),n(e,_,t),n(e,te,t),d(S,e,t),n(e,le,t),n(e,B,t),n(e,ne,t),d(C,e,t),n(e,ie,t),n(e,X,t),n(e,se,t),d(R,e,t),n(e,ae,t),n(e,L,t),n(e,pe,t),n(e,k,t),oe=!0},p(e,[t]){const ge={};t&2&&(ge.$$scope={dirty:t,ctx:e}),M.$set(ge)},i(e){oe||(b(T.$$.fragment,e),b(y.$$.fragment,e),b(J.$$.fragment,e),b(v.$$.fragment,e),b(M.$$.fragment,e),b(G.$$.fragment,e),b(Z.$$.fragment,e),b(S.$$.fragment,e),b(C.$$.fragment,e),b(R.$$.fragment,e),oe=!0)},o(e){c(T.$$.fragment,e),c(y.$$.fragment,e),c(J.$$.fragment,e),c(v.$$.fragment,e),c(M.$$.fragment,e),c(G.$$.fragment,e),c(Z.$$.fragment,e),c(S.$$.fragment,e),c(C.$$.fragment,e),c(R.$$.fragment,e),oe=!1},d(e){e&&(l($),l(m),l(N),l(V),l(g),l(F),l(P),l(x),l(E),l(Q),l(U),l(Y),l(z),l(D),l(j),l(O),l(q),l(W),l(A),l(K),l(w),l(ee),l(_),l(te),l(le),l(B),l(ne),l(ie),l(X),l(se),l(ae),l(L),l(pe),l(k)),l(a),h(T,e),h(y,e),h(J,e),h(v,e),h(M,e),h(G,e),h(Z,e),h(S,e),h(C,e),h(R,e)}}}const Be='{"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 Je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends ve{constructor(a){super(),je(this,a,Ce,Se,xe,{})}}export{ke as component};
