import{s as we,n as he,o as Me}from"../chunks/scheduler.5c93273d.js";import{S as de,i as ge,g as a,s as n,r as o,A as $e,h as p,f as l,c as s,j as be,u as f,x as J,k as ne,y as ye,a as i,v as T,d as u,t as r,w as c}from"../chunks/index.e43dd92b.js";import{C as ie}from"../chunks/CodeBlock.6896320e.js";import{H as se,E as We}from"../chunks/getInferenceSnippets.d410b42d.js";function ve(ae){let m,x,j,F,b,E,w,pe='🤗 <a href="https://github.com/huggingface/optimum-intel" rel="nofollow">Optimum</a> 提供与 OpenVINO 兼容的 Stable Diffusion 管道，可在各种 Intel 处理器上执行推理（请参阅支持的设备<a href="https://docs.openvino.ai/latest/openvino_docs_OV_UG_supported_plugins_Supported_Devices.html" rel="nofollow">完整列表</a>）。',L,h,Je='您需要安装 🤗 Optimum Intel，并使用 <code>--upgrade-strategy eager</code> 选项以确保 <a href="https://github.com/huggingface/optimum-intel" rel="nofollow"><code>optimum-intel</code></a> 使用最新版本：',k,M,X,d,me="本指南将展示如何使用 Stable Diffusion 和 Stable Diffusion XL (SDXL) 管道与 OpenVINO。",N,g,D,$,Ue="要加载并运行推理，请使用 <code>OVStableDiffusionPipeline</code>。如果您想加载 PyTorch 模型并即时转换为 OpenVINO 格式，请设置 <code>export=True</code>：",O,y,H,W,oe="为了进一步加速推理，静态重塑模型。如果您更改任何参数，例如输出高度或宽度，您需要再次静态重塑模型。",z,v,Q,U,fe='<img src="https://huggingface.co/datasets/optimum/documentation-images/resolve/main/intel/openvino/stable_diffusion_v1_5_sail_boat_rembrandt.png"/>',R,V,Te='您可以在 🤗 Optimum <a href="https://huggingface.co/docs/optimum/intel/inference#stable-diffusion" rel="nofollow">文档</a> 中找到更多示例，Stable Diffusion 支持文本到图像、图像到图像和修复。',P,B,Y,I,ue="要加载并运行 SDXL 推理，请使用 <code>OVStableDiffusionXLPipeline</code>：",q,_,A,C,re='为了进一步加速推理，可以如Stable Diffusion部分所示<a href="#stable-diffusion">静态重塑</a>模型。',K,Z,ce='您可以在🤗 Optimum<a href="https://huggingface.co/docs/optimum/intel/inference#stable-diffusion-xl" rel="nofollow">文档</a>中找到更多示例，并且在OpenVINO中运行SDXL支持文本到图像和图像到图像。',ee,G,te,S,le;return b=new se({props:{title:"OpenVINO",local:"openvino",headingTag:"h1"}}),M=new ie({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZS1zdHJhdGVneSUyMGVhZ2VyJTIwb3B0aW11bSU1QiUyMm9wZW52aW5vJTIyJTVE",highlighted:'pip install --upgrade-strategy eager optimum[<span class="hljs-string">&quot;openvino&quot;</span>]',wrap:!1}}),g=new se({props:{title:"Stable Diffusion",local:"stable-diffusion",headingTag:"h2"}}),y=new ie({props:{code:"ZnJvbSUyMG9wdGltdW0uaW50ZWwlMjBpbXBvcnQlMjBPVlN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEFwaXBlbGluZSUyMCUzRCUyME9WU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwZXhwb3J0JTNEVHJ1ZSklMEFwcm9tcHQlMjAlM0QlMjAlMjJzYWlsaW5nJTIwc2hpcCUyMGluJTIwc3Rvcm0lMjBieSUyMFJlbWJyYW5kdCUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0KS5pbWFnZXMlNUIwJTVEJTBBJTBBJTIzJTIwJUU1JTg4JUFCJUU1JUJGJTk4JUU0JUJBJTg2JUU0JUJGJTlEJUU1JUFEJTk4JUU1JUFGJUJDJUU1JTg3JUJBJUU3JTlBJTg0JUU2JUE4JUExJUU1JTlFJThCJTBBcGlwZWxpbmUuc2F2ZV9wcmV0cmFpbmVkKCUyMm9wZW52aW5vLXNkLXYxLTUlMjIp",highlighted:`<span class="hljs-keyword">from</span> optimum.intel <span class="hljs-keyword">import</span> OVStableDiffusionPipeline

model_id = <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
pipeline = OVStableDiffusionPipeline.from_pretrained(model_id, export=<span class="hljs-literal">True</span>)
prompt = <span class="hljs-string">&quot;sailing ship in storm by Rembrandt&quot;</span>
image = pipeline(prompt).images[<span class="hljs-number">0</span>]

<span class="hljs-comment"># 别忘了保存导出的模型</span>
pipeline.save_pretrained(<span class="hljs-string">&quot;openvino-sd-v1-5&quot;</span>)`,wrap:!1}}),v=new ie({props:{code:"JTIzJTIwJUU1JUFFJTlBJUU0JUI5JTg5JUU0JUI4JThFJUU4JUJFJTkzJUU1JTg1JUE1JUU1JTkyJThDJUU2JTlDJTlGJUU2JTlDJTlCJUU4JUJFJTkzJUU1JTg3JUJBJUU3JTlCJUI4JUU1JTg1JUIzJUU3JTlBJTg0JUU1JUJEJUEyJUU3JThBJUI2JTBBYmF0Y2hfc2l6ZSUyQyUyMG51bV9pbWFnZXMlMkMlMjBoZWlnaHQlMkMlMjB3aWR0aCUyMCUzRCUyMDElMkMlMjAxJTJDJTIwNTEyJTJDJTIwNTEyJTBBJTBBJTIzJTIwJUU5JTlEJTk5JUU2JTgwJTgxJUU5JTg3JThEJUU1JUExJTkxJUU2JUE4JUExJUU1JTlFJThCJTBBcGlwZWxpbmUucmVzaGFwZShiYXRjaF9zaXplJTJDJTIwaGVpZ2h0JTJDJTIwd2lkdGglMkMlMjBudW1faW1hZ2VzKSUwQSUyMyUyMCVFNSU5QyVBOCVFNiU4RSVBOCVFNyU5MCU4NiVFNSU4OSU4RCVFNyVCQyU5NiVFOCVBRiU5MSVFNiVBOCVBMSVFNSU5RSU4QiUwQXBpcGVsaW5lLmNvbXBpbGUoKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwaGVpZ2h0JTNEaGVpZ2h0JTJDJTBBJTIwJTIwJTIwJTIwd2lkdGglM0R3aWR0aCUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbWFnZXNfcGVyX3Byb21wdCUzRG51bV9pbWFnZXMlMkMlMEEpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-comment"># 定义与输入和期望输出相关的形状</span>
batch_size, num_images, height, width = <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">512</span>, <span class="hljs-number">512</span>

<span class="hljs-comment"># 静态重塑模型</span>
pipeline.reshape(batch_size, height, width, num_images)
<span class="hljs-comment"># 在推理前编译模型</span>
pipeline.<span class="hljs-built_in">compile</span>()

image = pipeline(
    prompt,
    height=height,
    width=width,
    num_images_per_prompt=num_images,
).images[<span class="hljs-number">0</span>]`,wrap:!1}}),B=new se({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),_=new ie({props:{code:"ZnJvbSUyMG9wdGltdW0uaW50ZWwlMjBpbXBvcnQlMjBPVlN0YWJsZURpZmZ1c2lvblhMUGlwZWxpbmUlMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUwQXBpcGVsaW5lJTIwJTNEJTIwT1ZTdGFibGVEaWZmdXNpb25YTFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFwcm9tcHQlMjAlM0QlMjAlMjJzYWlsaW5nJTIwc2hpcCUyMGluJTIwc3Rvcm0lMjBieSUyMFJlbWJyYW5kdCUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0KS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">from</span> optimum.intel <span class="hljs-keyword">import</span> OVStableDiffusionXLPipeline

model_id = <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>
pipeline = OVStableDiffusionXLPipeline.from_pretrained(model_id)
prompt = <span class="hljs-string">&quot;sailing ship in storm by Rembrandt&quot;</span>
image = pipeline(prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),G=new We({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/optimization/open_vino.md"}}),{c(){m=a("meta"),x=n(),j=a("p"),F=n(),o(b.$$.fragment),E=n(),w=a("p"),w.innerHTML=pe,L=n(),h=a("p"),h.innerHTML=Je,k=n(),o(M.$$.fragment),X=n(),d=a("p"),d.textContent=me,N=n(),o(g.$$.fragment),D=n(),$=a("p"),$.innerHTML=Ue,O=n(),o(y.$$.fragment),H=n(),W=a("p"),W.textContent=oe,z=n(),o(v.$$.fragment),Q=n(),U=a("div"),U.innerHTML=fe,R=n(),V=a("p"),V.innerHTML=Te,P=n(),o(B.$$.fragment),Y=n(),I=a("p"),I.innerHTML=ue,q=n(),o(_.$$.fragment),A=n(),C=a("p"),C.innerHTML=re,K=n(),Z=a("p"),Z.innerHTML=ce,ee=n(),o(G.$$.fragment),te=n(),S=a("p"),this.h()},l(e){const t=$e("svelte-u9bgzb",document.head);m=p(t,"META",{name:!0,content:!0}),t.forEach(l),x=s(e),j=p(e,"P",{}),be(j).forEach(l),F=s(e),f(b.$$.fragment,e),E=s(e),w=p(e,"P",{"data-svelte-h":!0}),J(w)!=="svelte-1mlnscv"&&(w.innerHTML=pe),L=s(e),h=p(e,"P",{"data-svelte-h":!0}),J(h)!=="svelte-1n4m4a7"&&(h.innerHTML=Je),k=s(e),f(M.$$.fragment,e),X=s(e),d=p(e,"P",{"data-svelte-h":!0}),J(d)!=="svelte-j7ofnn"&&(d.textContent=me),N=s(e),f(g.$$.fragment,e),D=s(e),$=p(e,"P",{"data-svelte-h":!0}),J($)!=="svelte-1yy7m16"&&($.innerHTML=Ue),O=s(e),f(y.$$.fragment,e),H=s(e),W=p(e,"P",{"data-svelte-h":!0}),J(W)!=="svelte-1pv8wg6"&&(W.textContent=oe),z=s(e),f(v.$$.fragment,e),Q=s(e),U=p(e,"DIV",{class:!0,"data-svelte-h":!0}),J(U)!=="svelte-1bbei4i"&&(U.innerHTML=fe),R=s(e),V=p(e,"P",{"data-svelte-h":!0}),J(V)!=="svelte-180xwbj"&&(V.innerHTML=Te),P=s(e),f(B.$$.fragment,e),Y=s(e),I=p(e,"P",{"data-svelte-h":!0}),J(I)!=="svelte-1xia1vt"&&(I.innerHTML=ue),q=s(e),f(_.$$.fragment,e),A=s(e),C=p(e,"P",{"data-svelte-h":!0}),J(C)!=="svelte-2ooruq"&&(C.innerHTML=re),K=s(e),Z=p(e,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-1psuxlw"&&(Z.innerHTML=ce),ee=s(e),f(G.$$.fragment,e),te=s(e),S=p(e,"P",{}),be(S).forEach(l),this.h()},h(){ne(m,"name","hf:doc:metadata"),ne(m,"content",Ve),ne(U,"class","flex justify-center")},m(e,t){ye(document.head,m),i(e,x,t),i(e,j,t),i(e,F,t),T(b,e,t),i(e,E,t),i(e,w,t),i(e,L,t),i(e,h,t),i(e,k,t),T(M,e,t),i(e,X,t),i(e,d,t),i(e,N,t),T(g,e,t),i(e,D,t),i(e,$,t),i(e,O,t),T(y,e,t),i(e,H,t),i(e,W,t),i(e,z,t),T(v,e,t),i(e,Q,t),i(e,U,t),i(e,R,t),i(e,V,t),i(e,P,t),T(B,e,t),i(e,Y,t),i(e,I,t),i(e,q,t),T(_,e,t),i(e,A,t),i(e,C,t),i(e,K,t),i(e,Z,t),i(e,ee,t),T(G,e,t),i(e,te,t),i(e,S,t),le=!0},p:he,i(e){le||(u(b.$$.fragment,e),u(M.$$.fragment,e),u(g.$$.fragment,e),u(y.$$.fragment,e),u(v.$$.fragment,e),u(B.$$.fragment,e),u(_.$$.fragment,e),u(G.$$.fragment,e),le=!0)},o(e){r(b.$$.fragment,e),r(M.$$.fragment,e),r(g.$$.fragment,e),r(y.$$.fragment,e),r(v.$$.fragment,e),r(B.$$.fragment,e),r(_.$$.fragment,e),r(G.$$.fragment,e),le=!1},d(e){e&&(l(x),l(j),l(F),l(E),l(w),l(L),l(h),l(k),l(X),l(d),l(N),l(D),l($),l(O),l(H),l(W),l(z),l(Q),l(U),l(R),l(V),l(P),l(Y),l(I),l(q),l(A),l(C),l(K),l(Z),l(ee),l(te),l(S)),l(m),c(b,e),c(M,e),c(g,e),c(y,e),c(v,e),c(B,e),c(_,e),c(G,e)}}}const Ve='{"title":"OpenVINO","local":"openvino","sections":[{"title":"Stable Diffusion","local":"stable-diffusion","sections":[],"depth":2},{"title":"Stable Diffusion XL","local":"stable-diffusion-xl","sections":[],"depth":2}],"depth":1}';function Be(ae){return Me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ge extends de{constructor(m){super(),ge(this,m,Be,ve,we,{})}}export{Ge as component};
