import{s as Ml,o as yl,n as il}from"../chunks/scheduler.8c3d61f6.js";import{S as ol,i as ml,g as b,s as y,r as G,A as Jl,h as d,f as a,c as o,j as el,u as f,x as C,k as tl,y as cl,a as e,v as g,d as B,t as I,w as W}from"../chunks/index.da70eac4.js";import{C as X}from"../chunks/CodeBlock.a9c4becf.js";import{H as nl,E as Ul}from"../chunks/getInferenceSnippets.33773fa8.js";import{H as rl,a as pl}from"../chunks/HfOption.6ab18950.js";function hl(Q){let p,j="For text-to-image, pass a list of prompts to the pipeline.",J,m,t,M,u="To generate multiple variations of one prompt, use the <code>num_images_per_prompt</code> argument.",Z,c,w,r,k="Combine both approaches to generate different variations of different prompts.",h,U,T;return m=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcHJvbXB0cyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMmNpbmVtYXRpYyUyMHBob3RvJTIwb2YlMjBBJTIwYmVhdXRpZnVsJTIwc3Vuc2V0JTIwb3ZlciUyMG1vdW50YWlucyUyQyUyMDM1bW0lMjBwaG90b2dyYXBoJTJDJTIwZmlsbSUyQyUyMHByb2Zlc3Npb25hbCUyQyUyMDRrJTJDJTIwaGlnaGx5JTIwZGV0YWlsZWQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJjaW5lbWF0aWMlMjBmaWxtJTIwc3RpbGwlMjBvZiUyMGElMjBjYXQlMjBiYXNraW5nJTIwaW4lMjB0aGUlMjBzdW4lMjBvbiUyMGElMjByb29mJTIwaW4lMjBUdXJrZXklMkMlMjBoaWdobHklMjBkZXRhaWxlZCUyQyUyMGhpZ2glMjBidWRnZXQlMjBob2xseXdvb2QlMjBtb3ZpZSUyQyUyMGNpbmVtYXNjb3BlJTJDJTIwbW9vZHklMkMlMjBlcGljJTJDJTIwZ29yZ2VvdXMlMkMlMjBmaWxtJTIwZ3JhaW4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJwaXhlbC1hcnQlMjBhJTIwY296eSUyMGNvZmZlZSUyMHNob3AlMjBpbnRlcmlvciUyQyUyMGxvdy1yZXMlMkMlMjBibG9ja3klMkMlMjBwaXhlbCUyMGFydCUyMHN0eWxlJTJDJTIwOC1iaXQlMjBncmFwaGljcyUyMiUwQSU1RCUwQSUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRHByb21wdHMlMkMlMEEpLmltYWdlcyUwQSUwQWZpZyUyQyUyMGF4ZXMlMjAlM0QlMjBwbHQuc3VicGxvdHMoMiUyQyUyMDIlMkMlMjBmaWdzaXplJTNEKDEyJTJDJTIwMTIpKSUwQWF4ZXMlMjAlM0QlMjBheGVzLmZsYXR0ZW4oKSUwQSUwQWZvciUyMGklMkMlMjBpbWFnZSUyMGluJTIwZW51bWVyYXRlKGltYWdlcyklM0ElMEElMjAlMjAlMjAlMjBheGVzJTVCaSU1RC5pbXNob3coaW1hZ2UpJTBBJTIwJTIwJTIwJTIwYXhlcyU1QmklNUQuc2V0X3RpdGxlKGYlMjJJbWFnZSUyMCU3QmklMkIxJTdEJTIyKSUwQSUyMCUyMCUyMCUyMGF4ZXMlNUJpJTVELmF4aXMoJ29mZicpJTBBJTBBcGx0LnRpZ2h0X2xheW91dCgpJTBBcGx0LnNob3coKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompts = [
    <span class="hljs-string">&quot;cinematic photo of A beautiful sunset over mountains, 35mm photograph, film, professional, 4k, highly detailed&quot;</span>,
    <span class="hljs-string">&quot;cinematic film still of a cat basking in the sun on a roof in Turkey, highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain&quot;</span>,
    <span class="hljs-string">&quot;pixel-art a cozy coffee shop interior, low-res, blocky, pixel art style, 8-bit graphics&quot;</span>
]

images = pipeline(
    prompt=prompts,
).images

fig, axes = plt.subplots(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>, figsize=(<span class="hljs-number">12</span>, <span class="hljs-number">12</span>))
axes = axes.flatten()

<span class="hljs-keyword">for</span> i, image <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(images):
    axes[i].imshow(image)
    axes[i].set_title(<span class="hljs-string">f&quot;Image <span class="hljs-subst">{i+<span class="hljs-number">1</span>}</span>&quot;</span>)
    axes[i].axis(<span class="hljs-string">&#x27;off&#x27;</span>)

plt.tight_layout()
plt.show()`,wrap:!1}}),c=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBtYXRwbG90bGliLnB5cGxvdCUyMGFzJTIwcGx0JTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCUyMnBpeGVsLWFydCUyMGElMjBjb3p5JTIwY29mZmVlJTIwc2hvcCUyMGludGVyaW9yJTJDJTIwbG93LXJlcyUyQyUyMGJsb2NreSUyQyUyMHBpeGVsJTIwYXJ0JTIwc3R5bGUlMkMlMjA4LWJpdCUyMGdyYXBoaWNzJTIyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2ltYWdlc19wZXJfcHJvbXB0JTNENCUwQSkuaW1hZ2VzJTBBJTBBZmlnJTJDJTIwYXhlcyUyMCUzRCUyMHBsdC5zdWJwbG90cygyJTJDJTIwMiUyQyUyMGZpZ3NpemUlM0QoMTIlMkMlMjAxMikpJTBBYXhlcyUyMCUzRCUyMGF4ZXMuZmxhdHRlbigpJTBBJTBBZm9yJTIwaSUyQyUyMGltYWdlJTIwaW4lMjBlbnVtZXJhdGUoaW1hZ2VzKSUzQSUwQSUyMCUyMCUyMCUyMGF4ZXMlNUJpJTVELmltc2hvdyhpbWFnZSklMEElMjAlMjAlMjAlMjBheGVzJTVCaSU1RC5zZXRfdGl0bGUoZiUyMkltYWdlJTIwJTdCaSUyQjElN0QlMjIpJTBBJTIwJTIwJTIwJTIwYXhlcyU1QmklNUQuYXhpcygnb2ZmJyklMEElMEFwbHQudGlnaHRfbGF5b3V0KCklMEFwbHQuc2hvdygp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

images = pipeline(
    prompt=<span class="hljs-string">&quot;pixel-art a cozy coffee shop interior, low-res, blocky, pixel art style, 8-bit graphics&quot;</span>,
    num_images_per_prompt=<span class="hljs-number">4</span>
).images

fig, axes = plt.subplots(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>, figsize=(<span class="hljs-number">12</span>, <span class="hljs-number">12</span>))
axes = axes.flatten()

<span class="hljs-keyword">for</span> i, image <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(images):
    axes[i].imshow(image)
    axes[i].set_title(<span class="hljs-string">f&quot;Image <span class="hljs-subst">{i+<span class="hljs-number">1</span>}</span>&quot;</span>)
    axes[i].axis(<span class="hljs-string">&#x27;off&#x27;</span>)

plt.tight_layout()
plt.show()`,wrap:!1}}),U=new X({props:{code:"aW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0cyUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbWFnZXNfcGVyX3Byb21wdCUzRDIlMkMlMEEpLmltYWdlcyUwQSUwQWZpZyUyQyUyMGF4ZXMlMjAlM0QlMjBwbHQuc3VicGxvdHMoMiUyQyUyMDIlMkMlMjBmaWdzaXplJTNEKDEyJTJDJTIwMTIpKSUwQWF4ZXMlMjAlM0QlMjBheGVzLmZsYXR0ZW4oKSUwQSUwQWZvciUyMGklMkMlMjBpbWFnZSUyMGluJTIwZW51bWVyYXRlKGltYWdlcyklM0ElMEElMjAlMjAlMjAlMjBheGVzJTVCaSU1RC5pbXNob3coaW1hZ2UpJTBBJTIwJTIwJTIwJTIwYXhlcyU1QmklNUQuc2V0X3RpdGxlKGYlMjJJbWFnZSUyMCU3QmklMkIxJTdEJTIyKSUwQSUyMCUyMCUyMCUyMGF4ZXMlNUJpJTVELmF4aXMoJ29mZicpJTBBJTBBcGx0LnRpZ2h0X2xheW91dCgpJTBBcGx0LnNob3coKQ==",highlighted:`images = pipeline(
    prompt=prompts,
    num_images_per_prompt=<span class="hljs-number">2</span>,
).images

fig, axes = plt.subplots(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>, figsize=(<span class="hljs-number">12</span>, <span class="hljs-number">12</span>))
axes = axes.flatten()

<span class="hljs-keyword">for</span> i, image <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(images):
    axes[i].imshow(image)
    axes[i].set_title(<span class="hljs-string">f&quot;Image <span class="hljs-subst">{i+<span class="hljs-number">1</span>}</span>&quot;</span>)
    axes[i].axis(<span class="hljs-string">&#x27;off&#x27;</span>)

plt.tight_layout()
plt.show()`,wrap:!1}}),{c(){p=b("p"),p.textContent=j,J=y(),G(m.$$.fragment),t=y(),M=b("p"),M.innerHTML=u,Z=y(),G(c.$$.fragment),w=y(),r=b("p"),r.textContent=k,h=y(),G(U.$$.fragment)},l(s){p=d(s,"P",{"data-svelte-h":!0}),C(p)!=="svelte-1u13a2m"&&(p.textContent=j),J=o(s),f(m.$$.fragment,s),t=o(s),M=d(s,"P",{"data-svelte-h":!0}),C(M)!=="svelte-1wlqa91"&&(M.innerHTML=u),Z=o(s),f(c.$$.fragment,s),w=o(s),r=d(s,"P",{"data-svelte-h":!0}),C(r)!=="svelte-1tfp3na"&&(r.textContent=k),h=o(s),f(U.$$.fragment,s)},m(s,i){e(s,p,i),e(s,J,i),g(m,s,i),e(s,t,i),e(s,M,i),e(s,Z,i),g(c,s,i),e(s,w,i),e(s,r,i),e(s,h,i),g(U,s,i),T=!0},p:il,i(s){T||(B(m.$$.fragment,s),B(c.$$.fragment,s),B(U.$$.fragment,s),T=!0)},o(s){I(m.$$.fragment,s),I(c.$$.fragment,s),I(U.$$.fragment,s),T=!1},d(s){s&&(a(p),a(J),a(t),a(M),a(Z),a(w),a(r),a(h)),W(m,s),W(c,s),W(U,s)}}}function wl(Q){let p,j="For image-to-image, pass a list of input images and prompts to the pipeline.",J,m,t,M,u="To generate multiple variations of one prompt, use the <code>num_images_per_prompt</code> argument.",Z,c,w,r,k="Combine both approaches to generate different variations of different prompts.",h,U,T;return m=new X({props:{code:"aW1wb3J0JTIwd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FmaWclMkMlMjBheGVzJTIwJTNEJTIwcGx0LnN1YnBsb3RzKDIlMkMlMjAyJTJDJTIwZmlnc2l6ZSUzRCgxMiUyQyUyMDEyKSklMEFheGVzJTIwJTNEJTIwYXhlcy5mbGF0dGVuKCklMEElMEFmb3IlMjBpJTJDJTIwaW1hZ2UlMjBpbiUyMGVudW1lcmF0ZShpbWFnZXMpJTNBJTBBJTIwJTIwJTIwJTIwYXhlcyU1QmklNUQuaW1zaG93KGltYWdlKSUwQSUyMCUyMCUyMCUyMGF4ZXMlNUJpJTVELnNldF90aXRsZShmJTIySW1hZ2UlMjAlN0JpJTJCMSU3RCUyMiklMEElMjAlMjAlMjAlMjBheGVzJTVCaSU1RC5heGlzKCdvZmYnKSUwQSUwQXBsdC50aWdodF9sYXlvdXQoKSUwQXBsdC5zaG93KCk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

input_images = [
    load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/inpaint.png&quot;</span>),
    load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png&quot;</span>),
    load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/detail-prompt.png&quot;</span>)
]

prompts = [
    <span class="hljs-string">&quot;cinematic photo of a beautiful sunset over mountains, 35mm photograph, film, professional, 4k, highly detailed&quot;</span>,
    <span class="hljs-string">&quot;cinematic film still of a cat basking in the sun on a roof in Turkey, highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain&quot;</span>,
    <span class="hljs-string">&quot;pixel-art a cozy coffee shop interior, low-res, blocky, pixel art style, 8-bit graphics&quot;</span>
]

images = pipeline(
    prompt=prompts,
    image=input_images,
    guidance_scale=<span class="hljs-number">8.0</span>,
    strength=<span class="hljs-number">0.5</span>
).images

fig, axes = plt.subplots(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>, figsize=(<span class="hljs-number">12</span>, <span class="hljs-number">12</span>))
axes = axes.flatten()

<span class="hljs-keyword">for</span> i, image <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(images):
    axes[i].imshow(image)
    axes[i].set_title(<span class="hljs-string">f&quot;Image <span class="hljs-subst">{i+<span class="hljs-number">1</span>}</span>&quot;</span>)
    axes[i].axis(<span class="hljs-string">&#x27;off&#x27;</span>)

plt.tight_layout()
plt.show()`,wrap:!1}}),c=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBtYXRwbG90bGliLnB5cGxvdCUyMGFzJTIwcGx0JTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW5wdXRfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmRldGFpbC1wcm9tcHQucG5nJTIyKSUwQSUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCUyMnBpeGVsLWFydCUyMGElMjBjb3p5JTIwY29mZmVlJTIwc2hvcCUyMGludGVyaW9yJTJDJTIwbG93LXJlcyUyQyUyMGJsb2NreSUyQyUyMHBpeGVsJTIwYXJ0JTIwc3R5bGUlMkMlMjA4LWJpdCUyMGdyYXBoaWNzJTIyJTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0RpbnB1dF9pbWFnZSUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbWFnZXNfcGVyX3Byb21wdCUzRDQlMEEpLmltYWdlcyUwQSUwQWZpZyUyQyUyMGF4ZXMlMjAlM0QlMjBwbHQuc3VicGxvdHMoMiUyQyUyMDIlMkMlMjBmaWdzaXplJTNEKDEyJTJDJTIwMTIpKSUwQWF4ZXMlMjAlM0QlMjBheGVzLmZsYXR0ZW4oKSUwQSUwQWZvciUyMGklMkMlMjBpbWFnZSUyMGluJTIwZW51bWVyYXRlKGltYWdlcyklM0ElMEElMjAlMjAlMjAlMjBheGVzJTVCaSU1RC5pbXNob3coaW1hZ2UpJTBBJTIwJTIwJTIwJTIwYXhlcyU1QmklNUQuc2V0X3RpdGxlKGYlMjJJbWFnZSUyMCU3QmklMkIxJTdEJTIyKSUwQSUyMCUyMCUyMCUyMGF4ZXMlNUJpJTVELmF4aXMoJ29mZicpJTBBJTBBcGx0LnRpZ2h0X2xheW91dCgpJTBBcGx0LnNob3coKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

input_image = load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/detail-prompt.png&quot;</span>)

images = pipeline(
    prompt=<span class="hljs-string">&quot;pixel-art a cozy coffee shop interior, low-res, blocky, pixel art style, 8-bit graphics&quot;</span>,
    image=input_image,
    num_images_per_prompt=<span class="hljs-number">4</span>
).images

fig, axes = plt.subplots(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>, figsize=(<span class="hljs-number">12</span>, <span class="hljs-number">12</span>))
axes = axes.flatten()

<span class="hljs-keyword">for</span> i, image <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(images):
    axes[i].imshow(image)
    axes[i].set_title(<span class="hljs-string">f&quot;Image <span class="hljs-subst">{i+<span class="hljs-number">1</span>}</span>&quot;</span>)
    axes[i].axis(<span class="hljs-string">&#x27;off&#x27;</span>)

plt.tight_layout()
plt.show()`,wrap:!1}}),U=new X({props:{code:"aW5wdXRfaW1hZ2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwbG9hZF9pbWFnZSglMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZjYXQucG5nJTIyKSUyQyUwQSUyMCUyMCUyMCUyMGxvYWRfaW1hZ2UoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGZGV0YWlsLXByb21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ltc2hvdyhpbWFnZSklMEElMjAlMjAlMjAlMjBheGVzJTVCaSU1RC5zZXRfdGl0bGUoZiUyMkltYWdlJTIwJTdCaSUyQjElN0QlMjIpJTBBJTIwJTIwJTIwJTIwYXhlcyU1QmklNUQuYXhpcygnb2ZmJyklMEElMEFwbHQudGlnaHRfbGF5b3V0KCklMEFwbHQuc2hvdygp",highlighted:`input_images = [
    load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png&quot;</span>),
    load_image(<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/detail-prompt.png&quot;</span>)
]

prompts = [
    <span class="hljs-string">&quot;cinematic film still of a cat basking in the sun on a roof in Turkey, highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain&quot;</span>,
    <span class="hljs-string">&quot;pixel-art a cozy coffee shop interior, low-res, blocky, pixel art style, 8-bit graphics&quot;</span>
]

images = pipeline(
    prompt=prompts,
    image=input_images,
    num_images_per_prompt=<span class="hljs-number">2</span>,
).images

fig, axes = plt.subplots(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>, figsize=(<span class="hljs-number">12</span>, <span class="hljs-number">12</span>))
axes = axes.flatten()

<span class="hljs-keyword">for</span> i, image <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(images):
    axes[i].imshow(image)
    axes[i].set_title(<span class="hljs-string">f&quot;Image <span class="hljs-subst">{i+<span class="hljs-number">1</span>}</span>&quot;</span>)
    axes[i].axis(<span class="hljs-string">&#x27;off&#x27;</span>)

plt.tight_layout()
plt.show()`,wrap:!1}}),{c(){p=b("p"),p.textContent=j,J=y(),G(m.$$.fragment),t=y(),M=b("p"),M.innerHTML=u,Z=y(),G(c.$$.fragment),w=y(),r=b("p"),r.textContent=k,h=y(),G(U.$$.fragment)},l(s){p=d(s,"P",{"data-svelte-h":!0}),C(p)!=="svelte-s3yhbz"&&(p.textContent=j),J=o(s),f(m.$$.fragment,s),t=o(s),M=d(s,"P",{"data-svelte-h":!0}),C(M)!=="svelte-1wlqa91"&&(M.innerHTML=u),Z=o(s),f(c.$$.fragment,s),w=o(s),r=d(s,"P",{"data-svelte-h":!0}),C(r)!=="svelte-1tfp3na"&&(r.textContent=k),h=o(s),f(U.$$.fragment,s)},m(s,i){e(s,p,i),e(s,J,i),g(m,s,i),e(s,t,i),e(s,M,i),e(s,Z,i),g(c,s,i),e(s,w,i),e(s,r,i),e(s,h,i),g(U,s,i),T=!0},p:il,i(s){T||(B(m.$$.fragment,s),B(c.$$.fragment,s),B(U.$$.fragment,s),T=!0)},o(s){I(m.$$.fragment,s),I(c.$$.fragment,s),I(U.$$.fragment,s),T=!1},d(s){s&&(a(p),a(J),a(t),a(M),a(Z),a(w),a(r),a(h)),W(m,s),W(c,s),W(U,s)}}}function Tl(Q){let p,j,J,m;return p=new pl({props:{id:"usage",option:"text-to-image",$$slots:{default:[hl]},$$scope:{ctx:Q}}}),J=new pl({props:{id:"usage",option:"image-to-image",$$slots:{default:[wl]},$$scope:{ctx:Q}}}),{c(){G(p.$$.fragment),j=y(),G(J.$$.fragment)},l(t){f(p.$$.fragment,t),j=o(t),f(J.$$.fragment,t)},m(t,M){g(p,t,M),e(t,j,M),g(J,t,M),m=!0},p(t,M){const u={};M&2&&(u.$$scope={dirty:M,ctx:t}),p.$set(u);const Z={};M&2&&(Z.$$scope={dirty:M,ctx:t}),J.$set(Z)},i(t){m||(B(p.$$.fragment,t),B(J.$$.fragment,t),m=!0)},o(t){I(p.$$.fragment,t),I(J.$$.fragment,t),m=!1},d(t){t&&a(j),W(p,t),W(J,t)}}}function ul(Q){let p,j,J,m,t,M,u,Z="Batch inference processes multiple prompts at a time to increase throughput. It is more efficient because processing multiple prompts at once maximizes GPU usage versus processing a single prompt and underutilizing the GPU.",c,w,r="The downside is increased latency because you must wait for the entire batch to complete, and more GPU memory is required for large batches.",k,h,U,T,s,i,K='Enable reproducible batch generation by passing a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">Generator’s</a> to the pipeline and tie each <code>Generator</code> to a seed to reuse it.',F,x,P="Use a list comprehension to iterate over the batch size specified in <code>range()</code> to create a unique <code>Generator</code> object for each image in the batch.",$,R,O="Don’t multiply the <code>Generator</code> by the batch size because that only creates one <code>Generator</code> object that is used sequentially for each image in the batch.",N,E,H,Y,ll="Pass the <code>generator</code> to the pipeline.",_,V,A,S,sl="You can use this to iteratively select an image associated with a seed and then improve on it by crafting a more detailed prompt.",q,v,L,z,D;return t=new nl({props:{title:"Batch inference",local:"batch-inference",headingTag:"h1"}}),h=new rl({props:{id:"usage",options:["text-to-image","image-to-image"],$$slots:{default:[Tl]},$$scope:{ctx:Q}}}),T=new nl({props:{title:"Deterministic generation",local:"deterministic-generation",headingTag:"h2"}}),E=new X({props:{code:"Z2VuZXJhdG9yJTIwJTNEJTIwJTVCdG9yY2guR2VuZXJhdG9yKGRldmljZSUzRCUyMmN1ZGElMjIpLm1hbnVhbF9zZWVkKDApJTVEJTIwKiUyMDM=",highlighted:'generator = [torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)] * <span class="hljs-number">3</span>',wrap:!1}}),V=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwJTVCdG9yY2guR2VuZXJhdG9yKGRldmljZ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UyMHBsdC5zdWJwbG90cygyJTJDJTIwMiUyQyUyMGZpZ3NpemUlM0QoMTIlMkMlMjAxMikpJTBBYXhlcyUyMCUzRCUyMGF4ZXMuZmxhdHRlbigpJTBBJTBBZm9yJTIwaSUyQyUyMGltYWdlJTIwaW4lMjBlbnVtZXJhdGUoaW1hZ2VzKSUzQSUwQSUyMCUyMCUyMCUyMGF4ZXMlNUJpJTVELmltc2hvdyhpbWFnZSklMEElMjAlMjAlMjAlMjBheGVzJTVCaSU1RC5zZXRfdGl0bGUoZiUyMkltYWdlJTIwJTdCaSUyQjElN0QlMjIpJTBBJTIwJTIwJTIwJTIwYXhlcyU1QmklNUQuYXhpcygnb2ZmJyklMEElMEFwbHQudGlnaHRfbGF5b3V0KCklMEFwbHQuc2hvdygp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)

generator = [torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(i) <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">3</span>)]
prompts = [
    <span class="hljs-string">&quot;cinematic photo of A beautiful sunset over mountains, 35mm photograph, film, professional, 4k, highly detailed&quot;</span>,
    <span class="hljs-string">&quot;cinematic film still of a cat basking in the sun on a roof in Turkey, highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain&quot;</span>,
    <span class="hljs-string">&quot;pixel-art a cozy coffee shop interior, low-res, blocky, pixel art style, 8-bit graphics&quot;</span>
]

images = pipeline(
    prompt=prompts,
    generator=generator
).images

fig, axes = plt.subplots(<span class="hljs-number">2</span>, <span class="hljs-number">2</span>, figsize=(<span class="hljs-number">12</span>, <span class="hljs-number">12</span>))
axes = axes.flatten()

<span class="hljs-keyword">for</span> i, image <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(images):
    axes[i].imshow(image)
    axes[i].set_title(<span class="hljs-string">f&quot;Image <span class="hljs-subst">{i+<span class="hljs-number">1</span>}</span>&quot;</span>)
    axes[i].axis(<span class="hljs-string">&#x27;off&#x27;</span>)

plt.tight_layout()
plt.show()`,wrap:!1}}),v=new Ul({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/batched_inference.md"}}),{c(){p=b("meta"),j=y(),J=b("p"),m=y(),G(t.$$.fragment),M=y(),u=b("p"),u.textContent=Z,c=y(),w=b("p"),w.textContent=r,k=y(),G(h.$$.fragment),U=y(),G(T.$$.fragment),s=y(),i=b("p"),i.innerHTML=K,F=y(),x=b("p"),x.innerHTML=P,$=y(),R=b("p"),R.innerHTML=O,N=y(),G(E.$$.fragment),H=y(),Y=b("p"),Y.innerHTML=ll,_=y(),G(V.$$.fragment),A=y(),S=b("p"),S.textContent=sl,q=y(),G(v.$$.fragment),L=y(),z=b("p"),this.h()},l(l){const n=Jl("svelte-u9bgzb",document.head);p=d(n,"META",{name:!0,content:!0}),n.forEach(a),j=o(l),J=d(l,"P",{}),el(J).forEach(a),m=o(l),f(t.$$.fragment,l),M=o(l),u=d(l,"P",{"data-svelte-h":!0}),C(u)!=="svelte-1gcbm5z"&&(u.textContent=Z),c=o(l),w=d(l,"P",{"data-svelte-h":!0}),C(w)!=="svelte-19m5zxe"&&(w.textContent=r),k=o(l),f(h.$$.fragment,l),U=o(l),f(T.$$.fragment,l),s=o(l),i=d(l,"P",{"data-svelte-h":!0}),C(i)!=="svelte-agd9mv"&&(i.innerHTML=K),F=o(l),x=d(l,"P",{"data-svelte-h":!0}),C(x)!=="svelte-1j6y6ag"&&(x.innerHTML=P),$=o(l),R=d(l,"P",{"data-svelte-h":!0}),C(R)!=="svelte-vrwtho"&&(R.innerHTML=O),N=o(l),f(E.$$.fragment,l),H=o(l),Y=d(l,"P",{"data-svelte-h":!0}),C(Y)!=="svelte-c466x0"&&(Y.innerHTML=ll),_=o(l),f(V.$$.fragment,l),A=o(l),S=d(l,"P",{"data-svelte-h":!0}),C(S)!=="svelte-1njy55c"&&(S.textContent=sl),q=o(l),f(v.$$.fragment,l),L=o(l),z=d(l,"P",{}),el(z).forEach(a),this.h()},h(){tl(p,"name","hf:doc:metadata"),tl(p,"content",bl)},m(l,n){cl(document.head,p),e(l,j,n),e(l,J,n),e(l,m,n),g(t,l,n),e(l,M,n),e(l,u,n),e(l,c,n),e(l,w,n),e(l,k,n),g(h,l,n),e(l,U,n),g(T,l,n),e(l,s,n),e(l,i,n),e(l,F,n),e(l,x,n),e(l,$,n),e(l,R,n),e(l,N,n),g(E,l,n),e(l,H,n),e(l,Y,n),e(l,_,n),g(V,l,n),e(l,A,n),e(l,S,n),e(l,q,n),g(v,l,n),e(l,L,n),e(l,z,n),D=!0},p(l,[n]){const al={};n&2&&(al.$$scope={dirty:n,ctx:l}),h.$set(al)},i(l){D||(B(t.$$.fragment,l),B(h.$$.fragment,l),B(T.$$.fragment,l),B(E.$$.fragment,l),B(V.$$.fragment,l),B(v.$$.fragment,l),D=!0)},o(l){I(t.$$.fragment,l),I(h.$$.fragment,l),I(T.$$.fragment,l),I(E.$$.fragment,l),I(V.$$.fragment,l),I(v.$$.fragment,l),D=!1},d(l){l&&(a(j),a(J),a(m),a(M),a(u),a(c),a(w),a(k),a(U),a(s),a(i),a(F),a(x),a($),a(R),a(N),a(H),a(Y),a(_),a(A),a(S),a(q),a(L),a(z)),a(p),W(t,l),W(h,l),W(T,l),W(E,l),W(V,l),W(v,l)}}}const bl='{"title":"Batch inference","local":"batch-inference","sections":[{"title":"Deterministic generation","local":"deterministic-generation","sections":[],"depth":2}],"depth":1}';function dl(Q){return yl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Bl extends ol{constructor(p){super(),ml(this,p,dl,ul,Ml,{})}}export{Bl as component};
