import{s as je,o as We,n as Je}from"../chunks/scheduler.8c3d61f6.js";import{S as Se,i as Ue,g as p,s as i,r as f,A as Ze,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.00a903b3.js";import{H as re,E as Ge}from"../chunks/EditOnGithub.1e64e623.js";function Xe(P){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 Re(P){let a,w,m,k,g,I,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:',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 <a href="https://huggingface.co/docs/optimum/main/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>:',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,S,A,U,Me="Then to perform inference (you don’t have to specify <code>export=True</code> again):",K,Z,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,ge='To load and run inference with SDXL, use the <a href="https://huggingface.co/docs/optimum/main/en/onnxruntime/package_reference/modeling_ort#optimum.onnxruntime.ORTStableDiffusionXLPipeline" rel="nofollow">ORTStableDiffusionXLPipeline</a>:',ie,X,se,R,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,N,pe,C,xe="SDXL in the ONNX format is supported for text-to-image and image-to-image.",oe,L,me,Q,fe;return g=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:P}}}),S=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}}),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}}),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}}),N=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(g.$$.fragment),I=i(),T=p("p"),T.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(S.$$.fragment),A=i(),U=p("p"),U.innerHTML=Me,K=i(),f(Z.$$.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=ge,ie=i(),f(X.$$.fragment),se=i(),R=p("p"),R.innerHTML=Te,ae=i(),f(N.$$.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=Ze("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(g.$$.fragment,e),I=s(e),T=o(e,"P",{"data-svelte-h":!0}),h(T)!=="svelte-y6glu5"&&(T.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-nycch4"&&(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(S.$$.fragment,e),A=s(e),U=o(e,"P",{"data-svelte-h":!0}),h(U)!=="svelte-uler64"&&(U.innerHTML=Me),K=s(e),u(Z.$$.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-ua8g2l"&&(G.innerHTML=ge),ie=s(e),u(X.$$.fragment,e),se=s(e),R=o(e,"P",{"data-svelte-h":!0}),h(R)!=="svelte-jm4k2m"&&(R.innerHTML=Te),ae=s(e),u(N.$$.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",Ne),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(g,e,t),n(e,I,t),n(e,T,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(S,e,t),n(e,A,t),n(e,U,t),n(e,K,t),r(Z,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,R,t),n(e,ae,t),r(N,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(g.$$.fragment,e),b(x.$$.fragment,e),b(v.$$.fragment,e),b(W.$$.fragment,e),b(M.$$.fragment,e),b(S.$$.fragment,e),b(Z.$$.fragment,e),b(B.$$.fragment,e),b(X.$$.fragment,e),b(N.$$.fragment,e),b(L.$$.fragment,e),fe=!0)},o(e){d(g.$$.fragment,e),d(x.$$.fragment,e),d(v.$$.fragment,e),d(W.$$.fragment,e),d(M.$$.fragment,e),d(S.$$.fragment,e),d(Z.$$.fragment,e),d(B.$$.fragment,e),d(X.$$.fragment,e),d(N.$$.fragment,e),d(L.$$.fragment,e),fe=!1},d(e){e&&(l(w),l(m),l(k),l(I),l(T),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(U),l(K),l(ee),l($),l(te),l(_),l(le),l(ne),l(G),l(ie),l(se),l(R),l(ae),l(pe),l(C),l(oe),l(me),l(Q)),l(a),c(g,e),c(x,e),c(v,e),c(W,e),c(M,e),c(S,e),c(Z,e),c(B,e),c(X,e),c(N,e),c(L,e)}}}const Ne='{"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(P){return We(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ie extends Se{constructor(a){super(),Ue(this,a,Ce,Re,je,{})}}export{Ie as component};
