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