import{s as Me,n as Te,o as Je}from"../chunks/scheduler.8c3d61f6.js";import{S as ye,i as ge,g as a,s as i,r as u,A as Ue,h as p,f as l,c as s,j as we,u as r,x as o,k as ie,y as ve,a as n,v as d,d as c,t as h,w as b}from"../chunks/index.da70eac4.js";import{C as ne}from"../chunks/CodeBlock.a9c4becf.js";import{H as se,E as Ge}from"../chunks/getInferenceSnippets.725ed3d4.js";function We(ae){let m,S,x,X,w,L,M,pe='🤗 <a href="https://github.com/huggingface/optimum-intel" rel="nofollow">Optimum</a> provides Stable Diffusion pipelines compatible with OpenVINO to perform inference on a variety of Intel processors (see the <a href="https://docs.openvino.ai/latest/openvino_docs_OV_UG_supported_plugins_Supported_Devices.html" rel="nofollow">full list</a> of supported devices).',H,T,oe='You’ll need to install 🤗 Optimum Intel with the <code>--upgrade-strategy eager</code> option to ensure <a href="https://github.com/huggingface/optimum-intel" rel="nofollow"><code>optimum-intel</code></a> is using the latest version:',E,J,k,y,me="This guide will show you how to use the Stable Diffusion and Stable Diffusion XL (SDXL) pipelines with OpenVINO.",D,g,R,U,fe="To load and run inference, use the <code>OVStableDiffusionPipeline</code>. If you want to load a PyTorch model and convert it to the OpenVINO format on-the-fly, set <code>export=True</code>:",F,v,z,G,ue="To further speed-up inference, statically reshape the model. If you change any parameters such as the outputs height or width, you’ll need to statically reshape your model again.",N,W,Y,f,re='<img src="https://huggingface.co/datasets/optimum/documentation-images/resolve/main/intel/openvino/stable_diffusion_v1_5_sail_boat_rembrandt.png"/>',Q,Z,de='You can find more examples in the 🤗 Optimum <a href="https://huggingface.co/docs/optimum/intel/inference#stable-diffusion" rel="nofollow">documentation</a>, and Stable Diffusion is supported for text-to-image, image-to-image, and inpainting.',O,$,P,I,ce="To load and run inference with SDXL, use the <code>OVStableDiffusionXLPipeline</code>:",q,j,A,_,he='To further speed-up inference, <a href="#stable-diffusion">statically reshape</a> the model as shown in the Stable Diffusion section.',K,V,be='You can find more examples in the 🤗 Optimum <a href="https://huggingface.co/docs/optimum/intel/inference#stable-diffusion-xl" rel="nofollow">documentation</a>, and running SDXL in OpenVINO is supported for text-to-image and image-to-image.',ee,B,te,C,le;return w=new se({props:{title:"OpenVINO",local:"openvino",headingTag:"h1"}}),J=new ne({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"}}),v=new ne({props:{code:"ZnJvbSUyMG9wdGltdW0uaW50ZWwlMjBpbXBvcnQlMjBPVlN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEFwaXBlbGluZSUyMCUzRCUyME9WU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwZXhwb3J0JTNEVHJ1ZSklMEFwcm9tcHQlMjAlM0QlMjAlMjJzYWlsaW5nJTIwc2hpcCUyMGluJTIwc3Rvcm0lMjBieSUyMFJlbWJyYW5kdCUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0KS5pbWFnZXMlNUIwJTVEJTBBJTBBJTIzJTIwRG9uJ3QlMjBmb3JnZXQlMjB0byUyMHNhdmUlMjB0aGUlMjBleHBvcnRlZCUyMG1vZGVsJTBBcGlwZWxpbmUuc2F2ZV9wcmV0cmFpbmVkKCUyMm9wZW52aW5vLXNkLXYxLTUlMjIp",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"># Don&#x27;t forget to save the exported model</span>
pipeline.save_pretrained(<span class="hljs-string">&quot;openvino-sd-v1-5&quot;</span>)`,wrap:!1}}),W=new ne({props:{code:"JTIzJTIwRGVmaW5lJTIwdGhlJTIwc2hhcGVzJTIwcmVsYXRlZCUyMHRvJTIwdGhlJTIwaW5wdXRzJTIwYW5kJTIwZGVzaXJlZCUyMG91dHB1dHMlMEFiYXRjaF9zaXplJTJDJTIwbnVtX2ltYWdlcyUyQyUyMGhlaWdodCUyQyUyMHdpZHRoJTIwJTNEJTIwMSUyQyUyMDElMkMlMjA1MTIlMkMlMjA1MTIlMEElMEElMjMlMjBTdGF0aWNhbGx5JTIwcmVzaGFwZSUyMHRoZSUyMG1vZGVsJTBBcGlwZWxpbmUucmVzaGFwZShiYXRjaF9zaXplJTJDJTIwaGVpZ2h0JTJDJTIwd2lkdGglMkMlMjBudW1faW1hZ2VzKSUwQSUyMyUyMENvbXBpbGUlMjB0aGUlMjBtb2RlbCUyMGJlZm9yZSUyMGluZmVyZW5jZSUwQXBpcGVsaW5lLmNvbXBpbGUoKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwaGVpZ2h0JTNEaGVpZ2h0JTJDJTBBJTIwJTIwJTIwJTIwd2lkdGglM0R3aWR0aCUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbWFnZXNfcGVyX3Byb21wdCUzRG51bV9pbWFnZXMlMkMlMEEpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-comment"># Define the shapes related to the inputs and desired outputs</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"># Statically reshape the model</span>
pipeline.reshape(batch_size, height, width, num_images)
<span class="hljs-comment"># Compile the model before inference</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}}),$=new se({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),j=new ne({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}}),B=new Ge({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/optimization/open_vino.md"}}),{c(){m=a("meta"),S=i(),x=a("p"),X=i(),u(w.$$.fragment),L=i(),M=a("p"),M.innerHTML=pe,H=i(),T=a("p"),T.innerHTML=oe,E=i(),u(J.$$.fragment),k=i(),y=a("p"),y.textContent=me,D=i(),u(g.$$.fragment),R=i(),U=a("p"),U.innerHTML=fe,F=i(),u(v.$$.fragment),z=i(),G=a("p"),G.textContent=ue,N=i(),u(W.$$.fragment),Y=i(),f=a("div"),f.innerHTML=re,Q=i(),Z=a("p"),Z.innerHTML=de,O=i(),u($.$$.fragment),P=i(),I=a("p"),I.innerHTML=ce,q=i(),u(j.$$.fragment),A=i(),_=a("p"),_.innerHTML=he,K=i(),V=a("p"),V.innerHTML=be,ee=i(),u(B.$$.fragment),te=i(),C=a("p"),this.h()},l(e){const t=Ue("svelte-u9bgzb",document.head);m=p(t,"META",{name:!0,content:!0}),t.forEach(l),S=s(e),x=p(e,"P",{}),we(x).forEach(l),X=s(e),r(w.$$.fragment,e),L=s(e),M=p(e,"P",{"data-svelte-h":!0}),o(M)!=="svelte-8v4mnh"&&(M.innerHTML=pe),H=s(e),T=p(e,"P",{"data-svelte-h":!0}),o(T)!=="svelte-1yjuyfl"&&(T.innerHTML=oe),E=s(e),r(J.$$.fragment,e),k=s(e),y=p(e,"P",{"data-svelte-h":!0}),o(y)!=="svelte-rxdhyz"&&(y.textContent=me),D=s(e),r(g.$$.fragment,e),R=s(e),U=p(e,"P",{"data-svelte-h":!0}),o(U)!=="svelte-1150q8r"&&(U.innerHTML=fe),F=s(e),r(v.$$.fragment,e),z=s(e),G=p(e,"P",{"data-svelte-h":!0}),o(G)!=="svelte-1pgwlbo"&&(G.textContent=ue),N=s(e),r(W.$$.fragment,e),Y=s(e),f=p(e,"DIV",{class:!0,"data-svelte-h":!0}),o(f)!=="svelte-1bbei4i"&&(f.innerHTML=re),Q=s(e),Z=p(e,"P",{"data-svelte-h":!0}),o(Z)!=="svelte-al50pl"&&(Z.innerHTML=de),O=s(e),r($.$$.fragment,e),P=s(e),I=p(e,"P",{"data-svelte-h":!0}),o(I)!=="svelte-1a3vd4r"&&(I.innerHTML=ce),q=s(e),r(j.$$.fragment,e),A=s(e),_=p(e,"P",{"data-svelte-h":!0}),o(_)!=="svelte-1ku614i"&&(_.innerHTML=he),K=s(e),V=p(e,"P",{"data-svelte-h":!0}),o(V)!=="svelte-ar6dc6"&&(V.innerHTML=be),ee=s(e),r(B.$$.fragment,e),te=s(e),C=p(e,"P",{}),we(C).forEach(l),this.h()},h(){ie(m,"name","hf:doc:metadata"),ie(m,"content",Ze),ie(f,"class","flex justify-center")},m(e,t){ve(document.head,m),n(e,S,t),n(e,x,t),n(e,X,t),d(w,e,t),n(e,L,t),n(e,M,t),n(e,H,t),n(e,T,t),n(e,E,t),d(J,e,t),n(e,k,t),n(e,y,t),n(e,D,t),d(g,e,t),n(e,R,t),n(e,U,t),n(e,F,t),d(v,e,t),n(e,z,t),n(e,G,t),n(e,N,t),d(W,e,t),n(e,Y,t),n(e,f,t),n(e,Q,t),n(e,Z,t),n(e,O,t),d($,e,t),n(e,P,t),n(e,I,t),n(e,q,t),d(j,e,t),n(e,A,t),n(e,_,t),n(e,K,t),n(e,V,t),n(e,ee,t),d(B,e,t),n(e,te,t),n(e,C,t),le=!0},p:Te,i(e){le||(c(w.$$.fragment,e),c(J.$$.fragment,e),c(g.$$.fragment,e),c(v.$$.fragment,e),c(W.$$.fragment,e),c($.$$.fragment,e),c(j.$$.fragment,e),c(B.$$.fragment,e),le=!0)},o(e){h(w.$$.fragment,e),h(J.$$.fragment,e),h(g.$$.fragment,e),h(v.$$.fragment,e),h(W.$$.fragment,e),h($.$$.fragment,e),h(j.$$.fragment,e),h(B.$$.fragment,e),le=!1},d(e){e&&(l(S),l(x),l(X),l(L),l(M),l(H),l(T),l(E),l(k),l(y),l(D),l(R),l(U),l(F),l(z),l(G),l(N),l(Y),l(f),l(Q),l(Z),l(O),l(P),l(I),l(q),l(A),l(_),l(K),l(V),l(ee),l(te),l(C)),l(m),b(w,e),b(J,e),b(g,e),b(v,e),b(W,e),b($,e),b(j,e),b(B,e)}}}const Ze='{"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 $e(ae){return Je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Be extends ye{constructor(m){super(),ge(this,m,$e,We,Me,{})}}export{Be as component};
