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