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