import{s as ct,n as yt,o as Mt}from"../chunks/scheduler.23542ac5.js";import{S as wt,i as Tt,e as a,s as i,c as m,h as ht,a as p,d as l,b as s,f as dt,g as o,j as $,k as $t,l as Ut,m as n,n as f,t as u,o as r,p as b}from"../chunks/index.9b1f405b.js";import{C as gt,H as nt,E as vt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.a0107385.js";import{C as it}from"../chunks/CodeBlock.a47c827a.js";function xt(st){let d,W,R,X,c,H,y,I,M,at="🤗 Diffusers는 ONNX Runtime과 호환되는 Stable Diffusion 파이프라인을 제공합니다. 이를 통해 ONNX(CPU 포함)를 지원하고 PyTorch의 가속 버전을 사용할 수 없는 모든 하드웨어에서 Stable Diffusion을 실행할 수 있습니다.",P,w,E,T,pt="다음 명령어로 ONNX Runtime를 지원하는 🤗 Optimum를 설치합니다:",k,h,L,U,V,g,mt=`아래 코드는 ONNX 런타임을 사용하는 방법을 보여줍니다. <code>StableDiffusionPipeline</code> 대신 <code>OnnxStableDiffusionPipeline</code>을 사용해야 합니다.
PyTorch 모델을 불러오고 즉시 ONNX 형식으로 변환하려는 경우 <code>export=True</code>로 설정합니다.`,O,v,Q,x,ot=`파이프라인을 ONNX 형식으로 오프라인으로 내보내고 나중에 추론에 사용하려는 경우,
<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> 명령어를 사용할 수 있습니다:`,q,J,z,Z,ft="그 다음 추론을 수행합니다:",F,G,Y,_,ut="Notice that we didn’t have to specify <code>export=True</code> above.",D,j,rt='<a href="https://huggingface.co/docs/optimum/" rel="nofollow">Optimum 문서</a>에서 더 많은 예시를 찾을 수 있습니다.',K,B,A,C,bt="<li>여러 프롬프트를 배치로 생성하면 너무 많은 메모리가 사용되는 것 같습니다. 이를 조사하는 동안, 배치 대신 반복 방법이 필요할 수도 있습니다.</li>",tt,S,et,N,lt;return c=new gt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),y=new nt({props:{title:"추론을 위해 ONNX 런타임을 사용하는 방법",local:"추론을-위해-onnx-런타임을-사용하는-방법",headingTag:"h1"}}),w=new nt({props:{title:"설치",local:"설치",headingTag:"h2"}}),h=new it({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUIlMjJvbm54cnVudGltZSUyMiU1RA==",highlighted:'pip install optimum[<span class="hljs-string">&quot;onnxruntime&quot;</span>]',wrap:!1}}),U=new nt({props:{title:"Stable Diffusion 추론",local:"stable-diffusion-추론",headingTag:"h2"}}),v=new it({props:{code:"ZnJvbSUyMG9wdGltdW0ub25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBPUlRTdGFibGVEaWZmdXNpb25QaXBlbGluZSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBcGlwZSUyMCUzRCUyME9SVFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMGV4cG9ydCUzRFRydWUpJTBBcHJvbXB0JTIwJTNEJTIwJTIyYSUyMHBob3RvJTIwb2YlMjBhbiUyMGFzdHJvbmF1dCUyMHJpZGluZyUyMGElMjBob3JzZSUyMG9uJTIwbWFycyUyMiUwQWltYWdlcyUyMCUzRCUyMHBpcGUocHJvbXB0KS5pbWFnZXMlNUIwJTVEJTBBcGlwZS5zYXZlX3ByZXRyYWluZWQoJTIyLiUyRm9ubngtc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyKQ==",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>
pipe = ORTStableDiffusionPipeline.from_pretrained(model_id, export=<span class="hljs-literal">True</span>)
prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>
images = pipe(prompt).images[<span class="hljs-number">0</span>]
pipe.save_pretrained(<span class="hljs-string">&quot;./onnx-stable-diffusion-v1-5&quot;</span>)`,wrap:!1}}),J=new it({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}}),G=new it({props:{code:"ZnJvbSUyMG9wdGltdW0ub25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBPUlRTdGFibGVEaWZmdXNpb25QaXBlbGluZSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyc2RfdjE1X29ubnglMjIlMEFwaXBlJTIwJTNEJTIwT1JUU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKSUwQXByb21wdCUyMCUzRCUyMCUyMmElMjBwaG90byUyMG9mJTIwYW4lMjBhc3Ryb25hdXQlMjByaWRpbmclMjBhJTIwaG9yc2UlMjBvbiUyMG1hcnMlMjIlMEFpbWFnZXMlMjAlM0QlMjBwaXBlKHByb21wdCkuaW1hZ2VzJTVCMCU1RA==",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>
pipe = ORTStableDiffusionPipeline.from_pretrained(model_id)
prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>
images = pipe(prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),B=new nt({props:{title:"알려진 이슈들",local:"알려진-이슈들",headingTag:"h2"}}),S=new vt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/ko/optimization/onnx.md"}}),{c(){d=a("meta"),W=i(),R=a("p"),X=i(),m(c.$$.fragment),H=i(),m(y.$$.fragment),I=i(),M=a("p"),M.textContent=at,P=i(),m(w.$$.fragment),E=i(),T=a("p"),T.textContent=pt,k=i(),m(h.$$.fragment),L=i(),m(U.$$.fragment),V=i(),g=a("p"),g.innerHTML=mt,O=i(),m(v.$$.fragment),Q=i(),x=a("p"),x.innerHTML=ot,q=i(),m(J.$$.fragment),z=i(),Z=a("p"),Z.textContent=ft,F=i(),m(G.$$.fragment),Y=i(),_=a("p"),_.innerHTML=ut,D=i(),j=a("p"),j.innerHTML=rt,K=i(),m(B.$$.fragment),A=i(),C=a("ul"),C.innerHTML=bt,tt=i(),m(S.$$.fragment),et=i(),N=a("p"),this.h()},l(t){const e=ht("svelte-u9bgzb",document.head);d=p(e,"META",{name:!0,content:!0}),e.forEach(l),W=s(t),R=p(t,"P",{}),dt(R).forEach(l),X=s(t),o(c.$$.fragment,t),H=s(t),o(y.$$.fragment,t),I=s(t),M=p(t,"P",{"data-svelte-h":!0}),$(M)!=="svelte-h692mz"&&(M.textContent=at),P=s(t),o(w.$$.fragment,t),E=s(t),T=p(t,"P",{"data-svelte-h":!0}),$(T)!=="svelte-nll8dy"&&(T.textContent=pt),k=s(t),o(h.$$.fragment,t),L=s(t),o(U.$$.fragment,t),V=s(t),g=p(t,"P",{"data-svelte-h":!0}),$(g)!=="svelte-1tmm7xi"&&(g.innerHTML=mt),O=s(t),o(v.$$.fragment,t),Q=s(t),x=p(t,"P",{"data-svelte-h":!0}),$(x)!=="svelte-1o6hlyg"&&(x.innerHTML=ot),q=s(t),o(J.$$.fragment,t),z=s(t),Z=p(t,"P",{"data-svelte-h":!0}),$(Z)!=="svelte-sng2sw"&&(Z.textContent=ft),F=s(t),o(G.$$.fragment,t),Y=s(t),_=p(t,"P",{"data-svelte-h":!0}),$(_)!=="svelte-1n2qv5o"&&(_.innerHTML=ut),D=s(t),j=p(t,"P",{"data-svelte-h":!0}),$(j)!=="svelte-ayqywd"&&(j.innerHTML=rt),K=s(t),o(B.$$.fragment,t),A=s(t),C=p(t,"UL",{"data-svelte-h":!0}),$(C)!=="svelte-g2ahj8"&&(C.innerHTML=bt),tt=s(t),o(S.$$.fragment,t),et=s(t),N=p(t,"P",{}),dt(N).forEach(l),this.h()},h(){$t(d,"name","hf:doc:metadata"),$t(d,"content",Jt)},m(t,e){Ut(document.head,d),n(t,W,e),n(t,R,e),n(t,X,e),f(c,t,e),n(t,H,e),f(y,t,e),n(t,I,e),n(t,M,e),n(t,P,e),f(w,t,e),n(t,E,e),n(t,T,e),n(t,k,e),f(h,t,e),n(t,L,e),f(U,t,e),n(t,V,e),n(t,g,e),n(t,O,e),f(v,t,e),n(t,Q,e),n(t,x,e),n(t,q,e),f(J,t,e),n(t,z,e),n(t,Z,e),n(t,F,e),f(G,t,e),n(t,Y,e),n(t,_,e),n(t,D,e),n(t,j,e),n(t,K,e),f(B,t,e),n(t,A,e),n(t,C,e),n(t,tt,e),f(S,t,e),n(t,et,e),n(t,N,e),lt=!0},p:yt,i(t){lt||(u(c.$$.fragment,t),u(y.$$.fragment,t),u(w.$$.fragment,t),u(h.$$.fragment,t),u(U.$$.fragment,t),u(v.$$.fragment,t),u(J.$$.fragment,t),u(G.$$.fragment,t),u(B.$$.fragment,t),u(S.$$.fragment,t),lt=!0)},o(t){r(c.$$.fragment,t),r(y.$$.fragment,t),r(w.$$.fragment,t),r(h.$$.fragment,t),r(U.$$.fragment,t),r(v.$$.fragment,t),r(J.$$.fragment,t),r(G.$$.fragment,t),r(B.$$.fragment,t),r(S.$$.fragment,t),lt=!1},d(t){t&&(l(W),l(R),l(X),l(H),l(I),l(M),l(P),l(E),l(T),l(k),l(L),l(V),l(g),l(O),l(Q),l(x),l(q),l(z),l(Z),l(F),l(Y),l(_),l(D),l(j),l(K),l(A),l(C),l(tt),l(et),l(N)),l(d),b(c,t),b(y,t),b(w,t),b(h,t),b(U,t),b(v,t),b(J,t),b(G,t),b(B,t),b(S,t)}}}const Jt='{"title":"추론을 위해 ONNX 런타임을 사용하는 방법","local":"추론을-위해-onnx-런타임을-사용하는-방법","sections":[{"title":"설치","local":"설치","sections":[],"depth":2},{"title":"Stable Diffusion 추론","local":"stable-diffusion-추론","sections":[],"depth":2},{"title":"알려진 이슈들","local":"알려진-이슈들","sections":[],"depth":2}],"depth":1}';function Zt(st){return Mt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ct extends wt{constructor(d){super(),Tt(this,d,Zt,xt,ct,{})}}export{Ct as component};
