import{s as Ue,n as Je,o as Ze}from"../chunks/scheduler.53228c21.js";import{S as Se,i as Be,e as a,s as n,c as o,h as Ge,a as p,d as l,b as s,f as We,g as m,j as f,k as re,l as _e,m as i,n as u,t as r,o as b,p as d}from"../chunks/index.100fac89.js";import{C as Xe}from"../chunks/CopyLLMTxtMenu.9360b11d.js";import{C}from"../chunks/CodeBlock.d30a6509.js";import{H as be,E as Ne}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.c9001d7a.js";function Re(de){let c,Q,k,I,w,E,$,P,T,ce='🤗 <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:',Y,y,F,x,Me="This guide will show you how to use the Stable Diffusion and Stable Diffusion XL (SDXL) pipelines with ONNX Runtime.",V,g,O,v,he="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>:",q,j,D,M,we="<p>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.</p>",z,W,$e=`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:`,A,U,K,J,Te="Then to perform inference (you don’t have to specify <code>export=True</code> again):",ee,Z,te,h,ye='<img src="https://huggingface.co/datasets/optimum/documentation-images/resolve/main/onnxruntime/stable_diffusion_v1_5_ort_sail_boat.png"/>',le,S,xe='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.',ie,B,ne,G,ge="To load and run inference with SDXL, use the <code>ORTStableDiffusionXLPipeline</code>:",se,_,ae,X,ve='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:',pe,N,oe,R,je="SDXL in the ONNX format is supported for text-to-image and image-to-image.",me,L,fe,H,ue;return w=new Xe({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new be({props:{title:"ONNX Runtime",local:"onnx-runtime",headingTag:"h1"}}),y=new C({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1xJTIwb3B0aW11bSU1QiUyMm9ubnhydW50aW1lJTIyJTVE",highlighted:'pip install -q optimum[<span class="hljs-string">&quot;onnxruntime&quot;</span>]',wrap:!1}}),g=new be({props:{title:"Stable Diffusion",local:"stable-diffusion",headingTag:"h2"}}),j=new C({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}}),U=new C({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 C({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 be({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),_=new C({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 C({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 Ne({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/onnx.md"}}),{c(){c=a("meta"),Q=n(),k=a("p"),I=n(),o(w.$$.fragment),E=n(),o($.$$.fragment),P=n(),T=a("p"),T.innerHTML=ce,Y=n(),o(y.$$.fragment),F=n(),x=a("p"),x.textContent=Me,V=n(),o(g.$$.fragment),O=n(),v=a("p"),v.innerHTML=he,q=n(),o(j.$$.fragment),D=n(),M=a("blockquote"),M.innerHTML=we,z=n(),W=a("p"),W.innerHTML=$e,A=n(),o(U.$$.fragment),K=n(),J=a("p"),J.innerHTML=Te,ee=n(),o(Z.$$.fragment),te=n(),h=a("div"),h.innerHTML=ye,le=n(),S=a("p"),S.innerHTML=xe,ie=n(),o(B.$$.fragment),ne=n(),G=a("p"),G.innerHTML=ge,se=n(),o(_.$$.fragment),ae=n(),X=a("p"),X.innerHTML=ve,pe=n(),o(N.$$.fragment),oe=n(),R=a("p"),R.textContent=je,me=n(),o(L.$$.fragment),fe=n(),H=a("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);c=p(t,"META",{name:!0,content:!0}),t.forEach(l),Q=s(e),k=p(e,"P",{}),We(k).forEach(l),I=s(e),m(w.$$.fragment,e),E=s(e),m($.$$.fragment,e),P=s(e),T=p(e,"P",{"data-svelte-h":!0}),f(T)!=="svelte-y6glu5"&&(T.innerHTML=ce),Y=s(e),m(y.$$.fragment,e),F=s(e),x=p(e,"P",{"data-svelte-h":!0}),f(x)!=="svelte-a0u2"&&(x.textContent=Me),V=s(e),m(g.$$.fragment,e),O=s(e),v=p(e,"P",{"data-svelte-h":!0}),f(v)!=="svelte-1hyrtw6"&&(v.innerHTML=he),q=s(e),m(j.$$.fragment,e),D=s(e),M=p(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),f(M)!=="svelte-1dqostb"&&(M.innerHTML=we),z=s(e),W=p(e,"P",{"data-svelte-h":!0}),f(W)!=="svelte-1jrf34f"&&(W.innerHTML=$e),A=s(e),m(U.$$.fragment,e),K=s(e),J=p(e,"P",{"data-svelte-h":!0}),f(J)!=="svelte-uler64"&&(J.innerHTML=Te),ee=s(e),m(Z.$$.fragment,e),te=s(e),h=p(e,"DIV",{class:!0,"data-svelte-h":!0}),f(h)!=="svelte-1pusq1s"&&(h.innerHTML=ye),le=s(e),S=p(e,"P",{"data-svelte-h":!0}),f(S)!=="svelte-prwd9a"&&(S.innerHTML=xe),ie=s(e),m(B.$$.fragment,e),ne=s(e),G=p(e,"P",{"data-svelte-h":!0}),f(G)!=="svelte-1drvfsn"&&(G.innerHTML=ge),se=s(e),m(_.$$.fragment,e),ae=s(e),X=p(e,"P",{"data-svelte-h":!0}),f(X)!=="svelte-jm4k2m"&&(X.innerHTML=ve),pe=s(e),m(N.$$.fragment,e),oe=s(e),R=p(e,"P",{"data-svelte-h":!0}),f(R)!=="svelte-5zcwcl"&&(R.textContent=je),me=s(e),m(L.$$.fragment,e),fe=s(e),H=p(e,"P",{}),We(H).forEach(l),this.h()},h(){re(c,"name","hf:doc:metadata"),re(c,"content",Le),re(M,"class","warning"),re(h,"class","flex justify-center")},m(e,t){_e(document.head,c),i(e,Q,t),i(e,k,t),i(e,I,t),u(w,e,t),i(e,E,t),u($,e,t),i(e,P,t),i(e,T,t),i(e,Y,t),u(y,e,t),i(e,F,t),i(e,x,t),i(e,V,t),u(g,e,t),i(e,O,t),i(e,v,t),i(e,q,t),u(j,e,t),i(e,D,t),i(e,M,t),i(e,z,t),i(e,W,t),i(e,A,t),u(U,e,t),i(e,K,t),i(e,J,t),i(e,ee,t),u(Z,e,t),i(e,te,t),i(e,h,t),i(e,le,t),i(e,S,t),i(e,ie,t),u(B,e,t),i(e,ne,t),i(e,G,t),i(e,se,t),u(_,e,t),i(e,ae,t),i(e,X,t),i(e,pe,t),u(N,e,t),i(e,oe,t),i(e,R,t),i(e,me,t),u(L,e,t),i(e,fe,t),i(e,H,t),ue=!0},p:Je,i(e){ue||(r(w.$$.fragment,e),r($.$$.fragment,e),r(y.$$.fragment,e),r(g.$$.fragment,e),r(j.$$.fragment,e),r(U.$$.fragment,e),r(Z.$$.fragment,e),r(B.$$.fragment,e),r(_.$$.fragment,e),r(N.$$.fragment,e),r(L.$$.fragment,e),ue=!0)},o(e){b(w.$$.fragment,e),b($.$$.fragment,e),b(y.$$.fragment,e),b(g.$$.fragment,e),b(j.$$.fragment,e),b(U.$$.fragment,e),b(Z.$$.fragment,e),b(B.$$.fragment,e),b(_.$$.fragment,e),b(N.$$.fragment,e),b(L.$$.fragment,e),ue=!1},d(e){e&&(l(Q),l(k),l(I),l(E),l(P),l(T),l(Y),l(F),l(x),l(V),l(O),l(v),l(q),l(D),l(M),l(z),l(W),l(A),l(K),l(J),l(ee),l(te),l(h),l(le),l(S),l(ie),l(ne),l(G),l(se),l(ae),l(X),l(pe),l(oe),l(R),l(me),l(fe),l(H)),l(c),d(w,e),d($,e),d(y,e),d(g,e),d(j,e),d(U,e),d(Z,e),d(B,e),d(_,e),d(N,e),d(L,e)}}}const Le='{"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(de){return Ze(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pe extends Se{constructor(c){super(),Be(this,c,Ce,Re,Ue,{})}}export{Pe as component};
