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