import{S as Qa,i as ei,s as ti,e as a,k as f,w as I,t as n,M as oi,c as i,d as t,m,a as r,x as $,h as s,b as g,G as e,g as j,y as D,q as P,o as k,B as S,v as ni,L as gt}from"../../../../chunks/vendor-hf-doc-builder.js";import{T as So}from"../../../../chunks/Tip-hf-doc-builder.js";import{D as N}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as ht}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Za}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as ut}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function si(T){let d,_,c,p,b;return p=new ht({props:{code:`import requests
import torch
from PIL import Image
from io import BytesIO

from diffusers import StableDiffusionImg2ImgPipeline

device = "cuda"
model_id_or_path = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
pipe = pipe.to(device)

url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"

response = requests.get(url)
init_image = Image.open(BytesIO(response.content)).convert("RGB")
init_image = init_image.resize((768, 512))

prompt = "A fantasy landscape, trending on artstation"

images = pipe(prompt=prompt, image=init_image, strength=0.75, guidance_scale=7.5).images
images[0].save("fantasy_landscape.png")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionImg2ImgPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&quot;cuda&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_id_or_path = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>response = requests.get(url)
<span class="hljs-meta">&gt;&gt;&gt; </span>init_image = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>init_image = init_image.resize((<span class="hljs-number">768</span>, <span class="hljs-number">512</span>))

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A fantasy landscape, trending on artstation&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>images = pipe(prompt=prompt, image=init_image, strength=<span class="hljs-number">0.75</span>, guidance_scale=<span class="hljs-number">7.5</span>).images
<span class="hljs-meta">&gt;&gt;&gt; </span>images[<span class="hljs-number">0</span>].save(<span class="hljs-string">&quot;fantasy_landscape.png&quot;</span>)`}}),{c(){d=a("p"),_=n("Examples:"),c=f(),I(p.$$.fragment)},l(l){d=i(l,"P",{});var u=r(d);_=s(u,"Examples:"),u.forEach(t),c=m(l),$(p.$$.fragment,l)},m(l,u){j(l,d,u),e(d,_),j(l,c,u),D(p,l,u),b=!0},p:gt,i(l){b||(P(p.$$.fragment,l),b=!0)},o(l){k(p.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(c),S(p,l)}}}function ai(T){let d,_,c,p,b;return p=new ht({props:{code:`import torch
from diffusers import DiffusionPipeline
from xformers.ops import MemoryEfficientAttentionFlashAttentionOp

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16)
pipe = pipe.to("cuda")
pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
# Workaround for not accepting attention shape using VAE for Flash Attention
pipe.vae.enable_xformers_memory_efficient_attention(attention_op=None)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> xformers.ops <span class="hljs-keyword">import</span> MemoryEfficientAttentionFlashAttentionOp

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Workaround for not accepting attention shape using VAE for Flash Attention</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.vae.enable_xformers_memory_efficient_attention(attention_op=<span class="hljs-literal">None</span>)`}}),{c(){d=a("p"),_=n("Examples:"),c=f(),I(p.$$.fragment)},l(l){d=i(l,"P",{});var u=r(d);_=s(u,"Examples:"),u.forEach(t),c=m(l),$(p.$$.fragment,l)},m(l,u){j(l,d,u),e(d,_),j(l,c,u),D(p,l,u),b=!0},p:gt,i(l){b||(P(p.$$.fragment,l),b=!0)},o(l){k(p.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(c),S(p,l)}}}function ii(T){let d,_;return{c(){d=a("p"),_=n("This function is experimental and might change in the future.")},l(c){d=i(c,"P",{});var p=r(d);_=s(p,"This function is experimental and might change in the future."),p.forEach(t)},m(c,p){j(c,d,p),e(d,_)},d(c){c&&t(d)}}}function ri(T){let d,_,c,p,b,l,u,E;return{c(){d=a("p"),_=n("It is required to be logged in ("),c=a("code"),p=n("huggingface-cli login"),b=n(") when you want to use private or "),l=a("a"),u=n(`gated
models`),E=n("."),this.h()},l(h){d=i(h,"P",{});var y=r(d);_=s(y,"It is required to be logged in ("),c=i(y,"CODE",{});var q=r(c);p=s(q,"huggingface-cli login"),q.forEach(t),b=s(y,") when you want to use private or "),l=i(y,"A",{href:!0,rel:!0});var F=r(l);u=s(F,`gated
models`),F.forEach(t),E=s(y,"."),y.forEach(t),this.h()},h(){g(l,"href","https://huggingface.co/docs/hub/models-gated#gated-models"),g(l,"rel","nofollow")},m(h,y){j(h,d,y),e(d,_),e(d,c),e(c,p),e(d,b),e(d,l),e(l,u),e(d,E)},d(h){h&&t(d)}}}function li(T){let d,_,c,p,b,l,u,E;return u=new ht({props:{code:`from diffusers import StableDiffusionPipeline
import torch

model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")

pipe.load_textual_inversion("sd-concepts-library/cat-toy")

prompt = "A <cat-toy> backpack"

image = pipe(prompt, num_inference_steps=50).images[0]
image.save("cat-backpack.png")`,highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

model_id = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipe.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/cat-toy&quot;</span>)

prompt = <span class="hljs-string">&quot;A &lt;cat-toy&gt; backpack&quot;</span>

image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;cat-backpack.png&quot;</span>)`}}),{c(){d=a("p"),_=n("To load a textual inversion embedding vector in "),c=a("code"),p=n("diffusers"),b=n(" format:"),l=f(),I(u.$$.fragment)},l(h){d=i(h,"P",{});var y=r(d);_=s(y,"To load a textual inversion embedding vector in "),c=i(y,"CODE",{});var q=r(c);p=s(q,"diffusers"),q.forEach(t),b=s(y," format:"),y.forEach(t),l=m(h),$(u.$$.fragment,h)},m(h,y){j(h,d,y),e(d,_),e(d,c),e(c,p),e(d,b),j(h,l,y),D(u,h,y),E=!0},p:gt,i(h){E||(P(u.$$.fragment,h),E=!0)},o(h){k(u.$$.fragment,h),E=!1},d(h){h&&t(d),h&&t(l),S(u,h)}}}function di(T){let d,_,c,p,b,l,u,E;return u=new ht({props:{code:`from diffusers import StableDiffusionPipeline
import torch

model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")

pipe.load_textual_inversion("./charturnerv2.pt", token="charturnerv2")

prompt = "charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details."

image = pipe(prompt, num_inference_steps=50).images[0]
image.save("character.png")`,highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

model_id = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipe.load_textual_inversion(<span class="hljs-string">&quot;./charturnerv2.pt&quot;</span>, token=<span class="hljs-string">&quot;charturnerv2&quot;</span>)

prompt = <span class="hljs-string">&quot;charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details.&quot;</span>

image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;character.png&quot;</span>)`}}),{c(){d=a("p"),_=n("e.g. from "),c=a("a"),p=n("civitAI"),b=n(" and then load the vector locally:"),l=f(),I(u.$$.fragment),this.h()},l(h){d=i(h,"P",{});var y=r(d);_=s(y,"e.g. from "),c=i(y,"A",{href:!0,rel:!0});var q=r(c);p=s(q,"civitAI"),q.forEach(t),b=s(y," and then load the vector locally:"),y.forEach(t),l=m(h),$(u.$$.fragment,h),this.h()},h(){g(c,"href","https://civitai.com/models/3036?modelVersionId=9857"),g(c,"rel","nofollow")},m(h,y){j(h,d,y),e(d,_),e(d,c),e(c,p),e(d,b),j(h,l,y),D(u,h,y),E=!0},p:gt,i(h){E||(P(u.$$.fragment,h),E=!0)},o(h){k(u.$$.fragment,h),E=!1},d(h){h&&t(d),h&&t(l),S(u,h)}}}function ci(T){let d,_,c,p,b;return p=new ht({props:{code:`from diffusers import StableDiffusionPipeline

# Download pipeline from huggingface.co and cache.
pipeline = StableDiffusionPipeline.from_ckpt(
    "https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors"
)

# Download pipeline from local file
# file is downloaded under ./v1-5-pruned-emaonly.ckpt
pipeline = StableDiffusionPipeline.from_ckpt("./v1-5-pruned-emaonly")

# Enable float16 and move to GPU
pipeline = StableDiffusionPipeline.from_ckpt(
    "https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.ckpt",
    torch_dtype=torch.float16,
)
pipeline.to("cuda")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Download pipeline from huggingface.co and cache.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipeline.from_ckpt(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;https://huggingface.co/WarriorMama777/OrangeMixs/blob/main/Models/AbyssOrangeMix/AbyssOrangeMix.safetensors&quot;</span>
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Download pipeline from local file</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># file is downloaded under ./v1-5-pruned-emaonly.ckpt</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipeline.from_ckpt(<span class="hljs-string">&quot;./v1-5-pruned-emaonly&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Enable float16 and move to GPU</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipeline.from_ckpt(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.ckpt&quot;</span>,
<span class="hljs-meta">... </span>    torch_dtype=torch.float16,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)`}}),{c(){d=a("p"),_=n("Examples:"),c=f(),I(p.$$.fragment)},l(l){d=i(l,"P",{});var u=r(d);_=s(u,"Examples:"),u.forEach(t),c=m(l),$(p.$$.fragment,l)},m(l,u){j(l,d,u),e(d,_),j(l,c,u),D(p,l,u),b=!0},p:gt,i(l){b||(P(p.$$.fragment,l),b=!0)},o(l){k(p.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(c),S(p,l)}}}function pi(T){let d,_;return{c(){d=a("p"),_=n("This function is experimental and might change in the future.")},l(c){d=i(c,"P",{});var p=r(d);_=s(p,"This function is experimental and might change in the future."),p.forEach(t)},m(c,p){j(c,d,p),e(d,_)},d(c){c&&t(d)}}}function fi(T){let d,_,c,p,b,l,u,E;return{c(){d=a("p"),_=n("It is required to be logged in ("),c=a("code"),p=n("huggingface-cli login"),b=n(") when you want to use private or "),l=a("a"),u=n(`gated
models`),E=n("."),this.h()},l(h){d=i(h,"P",{});var y=r(d);_=s(y,"It is required to be logged in ("),c=i(y,"CODE",{});var q=r(c);p=s(q,"huggingface-cli login"),q.forEach(t),b=s(y,") when you want to use private or "),l=i(y,"A",{href:!0,rel:!0});var F=r(l);u=s(F,`gated
models`),F.forEach(t),E=s(y,"."),y.forEach(t),this.h()},h(){g(l,"href","https://huggingface.co/docs/hub/models-gated#gated-models"),g(l,"rel","nofollow")},m(h,y){j(h,d,y),e(d,_),e(d,c),e(c,p),e(d,b),e(d,l),e(l,u),e(d,E)},d(h){h&&t(d)}}}function mi(T){let d,_,c,p,b;return p=new ht({props:{code:`import jax
import numpy as np
import jax.numpy as jnp
from flax.jax_utils import replicate
from flax.training.common_utils import shard
import requests
from io import BytesIO
from PIL import Image
from diffusers import FlaxStableDiffusionImg2ImgPipeline


def create_key(seed=0):
    return jax.random.PRNGKey(seed)


rng = create_key(0)

url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
response = requests.get(url)
init_img = Image.open(BytesIO(response.content)).convert("RGB")
init_img = init_img.resize((768, 512))

prompts = "A fantasy landscape, trending on artstation"

pipeline, params = FlaxStableDiffusionImg2ImgPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    revision="flax",
    dtype=jnp.bfloat16,
)

num_samples = jax.device_count()
rng = jax.random.split(rng, jax.device_count())
prompt_ids, processed_image = pipeline.prepare_inputs(
    prompt=[prompts] * num_samples, image=[init_img] * num_samples
)
p_params = replicate(params)
prompt_ids = shard(prompt_ids)
processed_image = shard(processed_image)

output = pipeline(
    prompt_ids=prompt_ids,
    image=processed_image,
    params=p_params,
    prng_seed=rng,
    strength=0.75,
    num_inference_steps=50,
    jit=True,
    height=512,
    width=768,
).images

output_images = pipeline.numpy_to_pil(np.asarray(output.reshape((num_samples,) + output.shape[-3:])))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> jax
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> jax.numpy <span class="hljs-keyword">as</span> jnp
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> flax.jax_utils <span class="hljs-keyword">import</span> replicate
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> flax.training.common_utils <span class="hljs-keyword">import</span> shard
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FlaxStableDiffusionImg2ImgPipeline


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">create_key</span>(<span class="hljs-params">seed=<span class="hljs-number">0</span></span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> jax.random.PRNGKey(seed)


<span class="hljs-meta">&gt;&gt;&gt; </span>rng = create_key(<span class="hljs-number">0</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>response = requests.get(url)
<span class="hljs-meta">&gt;&gt;&gt; </span>init_img = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>init_img = init_img.resize((<span class="hljs-number">768</span>, <span class="hljs-number">512</span>))

<span class="hljs-meta">&gt;&gt;&gt; </span>prompts = <span class="hljs-string">&quot;A fantasy landscape, trending on artstation&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline, params = FlaxStableDiffusionImg2ImgPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>,
<span class="hljs-meta">... </span>    revision=<span class="hljs-string">&quot;flax&quot;</span>,
<span class="hljs-meta">... </span>    dtype=jnp.bfloat16,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>num_samples = jax.device_count()
<span class="hljs-meta">&gt;&gt;&gt; </span>rng = jax.random.split(rng, jax.device_count())
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt_ids, processed_image = pipeline.prepare_inputs(
<span class="hljs-meta">... </span>    prompt=[prompts] * num_samples, image=[init_img] * num_samples
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>p_params = replicate(params)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt_ids = shard(prompt_ids)
<span class="hljs-meta">&gt;&gt;&gt; </span>processed_image = shard(processed_image)

<span class="hljs-meta">&gt;&gt;&gt; </span>output = pipeline(
<span class="hljs-meta">... </span>    prompt_ids=prompt_ids,
<span class="hljs-meta">... </span>    image=processed_image,
<span class="hljs-meta">... </span>    params=p_params,
<span class="hljs-meta">... </span>    prng_seed=rng,
<span class="hljs-meta">... </span>    strength=<span class="hljs-number">0.75</span>,
<span class="hljs-meta">... </span>    num_inference_steps=<span class="hljs-number">50</span>,
<span class="hljs-meta">... </span>    jit=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    height=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span>    width=<span class="hljs-number">768</span>,
<span class="hljs-meta">... </span>).images

<span class="hljs-meta">&gt;&gt;&gt; </span>output_images = pipeline.numpy_to_pil(np.asarray(output.reshape((num_samples,) + output.shape[-<span class="hljs-number">3</span>:])))`}}),{c(){d=a("p"),_=n("Examples:"),c=f(),I(p.$$.fragment)},l(l){d=i(l,"P",{});var u=r(d);_=s(u,"Examples:"),u.forEach(t),c=m(l),$(p.$$.fragment,l)},m(l,u){j(l,d,u),e(d,_),j(l,c,u),D(p,l,u),b=!0},p:gt,i(l){b||(P(p.$$.fragment,l),b=!0)},o(l){k(p.$$.fragment,l),b=!1},d(l){l&&t(d),l&&t(c),S(p,l)}}}function ui(T){let d,_,c,p,b,l,u,E,h,y,q,F,_t,ve,jo,bt,Eo,ao,A,To,ye,qo,Co,we,Ao,Lo,xe,Mo,Fo,Ie,Oo,No,Ze,Uo,zo,io,$e,Wo,De,Vo,ro,Q,Qe,Go,Bo,et,Ro,lo,ee,Ko,Pe,Ho,Jo,co,v,ke,Yo,vt,Xo,Zo,Se,Qo,tt,en,tn,on,yt,nn,sn,J,je,wt,an,rn,ot,ln,dn,Ee,xt,cn,pn,nt,fn,mn,Te,It,un,gn,st,hn,_n,$t,bn,vn,Dt,qe,Pt,yn,wn,at,xn,In,G,Ce,$n,kt,Dn,Pn,te,kn,B,Ae,Sn,St,jn,En,jt,Tn,qn,oe,Le,Cn,Me,An,Et,Ln,Mn,Fn,O,Fe,On,Tt,Nn,Un,qt,zn,Wn,Ct,Vn,Gn,ne,Bn,se,Oe,Rn,At,Kn,Hn,C,Ne,Jn,Y,Yn,Lt,Xn,Zn,Mt,Qn,es,ts,ae,os,ie,ns,Ft,ss,as,re,is,Ot,rs,ls,le,ds,W,Ue,cs,Nt,ps,fs,ze,ms,Ut,us,gs,hs,de,_s,V,We,bs,X,vs,it,ys,ws,Ve,zt,xs,Is,$s,ce,Ds,pe,Ps,fe,Ge,ks,Wt,Ss,js,me,Be,Es,U,Ts,Vt,qs,Cs,Gt,As,Ls,Bt,Ms,Fs,Rt,Os,Ns,Us,ue,Re,zs,Z,Ws,Kt,Vs,Gs,Ht,Bs,Rs,po,z,Ke,Ks,Jt,Hs,Js,He,Ys,Yt,Xs,Zs,Qs,R,Je,ea,Xt,ta,oa,ge,fo;return l=new Za({}),ve=new Za({}),ke=new N({props:{name:"class diffusers.StableDiffusionImg2ImgPipeline",anchor:"diffusers.StableDiffusionImg2ImgPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"safety_checker",val:": StableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPImageProcessor"},{name:"requires_safety_checker",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.StableDiffusionImg2ImgPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.16.0/en/api/models#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder. Stable Diffusion uses the text portion of
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIP</a>, specifically
the <a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a> variant.`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/v0.16.0/en/api/models#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.16.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/v0.16.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.16.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.16.0/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.safety_checker",description:`<strong>safety_checker</strong> (<code>StableDiffusionSafetyChecker</code>) &#x2014;
Classification module that estimates whether generated images could be considered offensive or harmful.
Please, refer to the <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">model card</a> for details.`,name:"safety_checker"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
Model that extracts features from generated images to be used as inputs for the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L95"}}),Ce=new N({props:{name:"__call__",anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image] = None"},{name:"strength",val:": float = 0.8"},{name:"num_inference_steps",val:": typing.Optional[int] = 50"},{name:"guidance_scale",val:": typing.Optional[float] = 7.5"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": typing.Optional[float] = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": int = 1"},{name:"cross_attention_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,name:"prompt"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> or <code>PIL.Image.Image</code>) &#x2014;
<code>Image</code>, or tensor representing an image batch, that will be used as the starting point for the
process.`,name:"image"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.strength",description:`<strong>strength</strong> (<code>float</code>, <em>optional</em>, defaults to 0.8) &#x2014;
Conceptually, indicates how much to transform the reference <code>image</code>. Must be between 0 and 1. <code>image</code>
will be used as a starting point, adding more noise to it the larger the <code>strength</code>. The number of
denoising steps depends on the amount of noise initially added. When <code>strength</code> is 1, added noise will
be maximum and the denoising process will run for the full number of iterations specified in
<code>num_inference_steps</code>. A value of 1, therefore, essentially ignores <code>image</code>.`,name:"strength"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference. This parameter will be modulated by <code>strength</code>.`,name:"num_inference_steps"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion Guidance</a>.
<code>guidance_scale</code> is defined as <code>w</code> of equation 2. of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen
Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to the text <code>prompt</code>,
usually at the expense of lower image quality.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code>. instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code>
is less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) in the DDIM paper: <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">https://arxiv.org/abs/2010.02502</a>. Only applies to
<a href="/docs/diffusers/v0.16.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,name:"eta"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</a>
to make generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that will be called every <code>callback_steps</code> steps during inference. The function will be
called with the following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function will be called. If not specified, the callback will be
called at every step.`,name:"callback_steps"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/cross_attention.py" rel="nofollow">diffusers.cross_attention</a>.`,name:"cross_attention_kwargs"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L578",returnDescription:`
<p><a
  href="/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> if <code>return_dict</code> is True, otherwise a <code>tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of </code>bool<code>s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the </code>safety_checker\`.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),te=new ut({props:{anchor:"diffusers.StableDiffusionImg2ImgPipeline.__call__.example",$$slots:{default:[si]},$$scope:{ctx:T}}}),Ae=new N({props:{name:"enable_attention_slicing",anchor:"diffusers.StableDiffusionImg2ImgPipeline.enable_attention_slicing",parameters:[{name:"slice_size",val:": typing.Union[str, int, NoneType] = 'auto'"}],parametersDescription:[{anchor:"diffusers.StableDiffusionImg2ImgPipeline.enable_attention_slicing.slice_size",description:`<strong>slice_size</strong> (<code>str</code> or <code>int</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
When <code>&quot;auto&quot;</code>, halves the input to the attention heads, so attention will be computed in two steps. If
<code>&quot;max&quot;</code>, maximum amount of memory will be saved by running only one slice at a time. If a number is
provided, uses as many slices as <code>attention_head_dim // slice_size</code>. In this case, <code>attention_head_dim</code>
must be a multiple of <code>slice_size</code>.`,name:"slice_size"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/pipeline_utils.py#L1476"}}),Le=new N({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionImg2ImgPipeline.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/pipeline_utils.py#L1492"}}),Fe=new N({props:{name:"enable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionImg2ImgPipeline.enable_xformers_memory_efficient_attention",parameters:[{name:"attention_op",val:": typing.Optional[typing.Callable] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionImg2ImgPipeline.enable_xformers_memory_efficient_attention.attention_op",description:`<strong>attention_op</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
Override the default <code>None</code> operator for use as <code>op</code> argument to the
<a href="https://facebookresearch.github.io/xformers/components/ops.html#xformers.ops.memory_efficient_attention" rel="nofollow"><code>memory_efficient_attention()</code></a>
function of xFormers.`,name:"attention_op"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/pipeline_utils.py#L1418"}}),ne=new ut({props:{anchor:"diffusers.StableDiffusionImg2ImgPipeline.enable_xformers_memory_efficient_attention.example",$$slots:{default:[ai]},$$scope:{ctx:T}}}),Oe=new N({props:{name:"disable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionImg2ImgPipeline.disable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/pipeline_utils.py#L1450"}}),Ne=new N({props:{name:"load_textual_inversion",anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, typing.Dict[str, torch.Tensor]]"},{name:"token",val:": typing.Optional[str] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids should have an organization name, like
<code>&quot;sd-concepts-library/low-poly-hd-logos-icons&quot;</code>.</li>
<li>A path to a <em>directory</em> containing textual inversion weights, e.g.
<code>./my_text_inversion_directory/</code>.</li>
</ul>`,name:"pretrained_model_name_or_path"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.weight_name",description:`<strong>weight_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Name of a custom weight file. This should be used in two cases:</p>
<ul>
<li>The saved textual inversion file is in <code>diffusers</code> format, but was saved under a specific weight
name, such as <code>text_inv.bin</code>.</li>
<li>The saved textual inversion file is in the &#x201C;Automatic1111&#x201D; form.</li>
</ul>`,name:"weight_name"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.cache_dir",description:`<strong>cache_dir</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Path to a directory in which a downloaded pretrained model configuration should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to delete incompletely received files. Will attempt to resume the download if such a
file exists.`,name:"resume_download"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, e.g., <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}</code>. The proxies are used on each request.`,name:"proxies"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.local_files_only(bool,",description:`<strong>local_files_only(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to only look at local files (i.e., do not try to download the model).`,name:"local_files_only(bool,"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.use_auth_token",description:`<strong>use_auth_token</strong> (<code>str</code> or <em>bool</em>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>diffusers-cli login</code> (stored in <code>~/.huggingface</code>).`,name:"use_auth_token"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so <code>revision</code> can be any
identifier allowed by git.`,name:"revision"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.subfolder",description:`<strong>subfolder</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
In case the relevant files are located inside a subfolder of the model repo (either remote in
huggingface.co or downloaded locally), you can specify the folder name here.`,name:"subfolder"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.mirror",description:`<strong>mirror</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Mirror source to accelerate downloads in China. If you are from China and have an accessibility
problem, you can set this option to resolve it. Note that we do not guarantee the timeliness or safety.
Please refer to the mirror site for more information.`,name:"mirror"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/loaders.py#L420"}}),ae=new So({props:{warning:!0,$$slots:{default:[ii]},$$scope:{ctx:T}}}),ie=new So({props:{$$slots:{default:[ri]},$$scope:{ctx:T}}}),re=new ut({props:{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.example",$$slots:{default:[li]},$$scope:{ctx:T}}}),le=new ut({props:{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion.example-2",$$slots:{default:[di]},$$scope:{ctx:T}}}),Ue=new N({props:{name:"from_ckpt",anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt",parameters:[{name:"pretrained_model_link_or_path",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.pretrained_model_link_or_path",description:`<strong>pretrained_model_link_or_path</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) &#x2014;
Can be either:<ul>
<li>A link to the .ckpt file on the Hub. Should be in the format
<code>&quot;https://huggingface.co/&lt;repo_id&gt;/blob/main/&lt;path_to_file&gt;&quot;</code></li>
<li>A path to a <em>file</em> containing all pipeline weights.</li>
</ul>`,name:"pretrained_model_link_or_path"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.torch_dtype",description:`<strong>torch_dtype</strong> (<code>str</code> or <code>torch.dtype</code>, <em>optional</em>) &#x2014;
Override the default <code>torch.dtype</code> and load the model under this dtype. If <code>&quot;auto&quot;</code> is passed the dtype
will be automatically derived from the model&#x2019;s weights.`,name:"torch_dtype"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.cache_dir",description:`<strong>cache_dir</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Path to a directory in which a downloaded pretrained model configuration should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to delete incompletely received files. Will attempt to resume the download if such a
file exists.`,name:"resume_download"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, e.g., <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}</code>. The proxies are used on each request.`,name:"proxies"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.local_files_only",description:`<strong>local_files_only</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to only look at local files (i.e., do not try to download the model).`,name:"local_files_only"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.use_auth_token",description:`<strong>use_auth_token</strong> (<code>str</code> or <em>bool</em>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>huggingface-cli login</code> (stored in <code>~/.huggingface</code>).`,name:"use_auth_token"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so <code>revision</code> can be any
identifier allowed by git.`,name:"revision"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.use_safetensors",description:`<strong>use_safetensors</strong> (<code>bool</code>, <em>optional</em> ) &#x2014;
If set to <code>True</code>, the pipeline will be loaded from <code>safetensors</code> weights. If set to <code>None</code> (the
default). The pipeline will load using <code>safetensors</code> if the safetensors weights are available <em>and</em> if
<code>safetensors</code> is installed. If the to <code>False</code> the pipeline will <em>not</em> use <code>safetensors</code>.`,name:"use_safetensors"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.extract_ema",description:`<strong>extract_ema</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014; Only relevant for
checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights or not. Defaults
to <code>False</code>. Pass <code>True</code> to extract the EMA weights. EMA weights usually yield higher quality images for
inference. Non-EMA weights are usually better to continue fine-tuning.`,name:"extract_ema"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.upcast_attention",description:`<strong>upcast_attention</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Whether the attention computation should always be upcasted. This is necessary when running stable`,name:"upcast_attention"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The image size that the model was trained on. Use 512 for Stable Diffusion v1.X and Stable Diffusion v2
Base. Use 768 for Stable Diffusion v2.`,name:"image_size"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The prediction type that the model was trained on. Use <code>&apos;epsilon&apos;</code> for Stable Diffusion v1.X and Stable
Diffusion v2 Base. Use <code>&apos;v_prediction&apos;</code> for Stable Diffusion v2.`,name:"prediction_type"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.num_in_channels",description:`<strong>num_in_channels</strong> (<code>int</code>, <em>optional</em>, defaults to None) &#x2014;
The number of input channels. If <code>None</code>, it will be automatically inferred.`,name:"num_in_channels"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.scheduler_type",description:`<strong>scheduler_type</strong> (<code>str</code>, <em>optional</em>, defaults to &#x2018;pndm&#x2019;) &#x2014;
Type of scheduler to use. Should be one of <code>[&quot;pndm&quot;, &quot;lms&quot;, &quot;heun&quot;, &quot;euler&quot;, &quot;euler-ancestral&quot;, &quot;dpm&quot;, &quot;ddim&quot;]</code>.`,name:"scheduler_type"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.load_safety_checker",description:`<strong>load_safety_checker</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to load the safety checker or not. Defaults to <code>True</code>.`,name:"load_safety_checker"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.kwargs",description:`<strong>kwargs</strong> (remaining dictionary of keyword arguments, <em>optional</em>) &#x2014;
Can be used to overwrite load - and saveable variables - <em>i.e.</em> the pipeline components - of the
specific pipeline class. The overwritten components are then directly passed to the pipelines
<code>__init__</code> method. See example below for more information.`,name:"kwargs"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/loaders.py#L1116"}}),de=new ut({props:{anchor:"diffusers.StableDiffusionImg2ImgPipeline.from_ckpt.example",$$slots:{default:[ci]},$$scope:{ctx:T}}}),We=new N({props:{name:"load_lora_weights",anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights",parameters:[{name:"pretrained_model_name_or_path_or_dict",val:": typing.Union[str, typing.Dict[str, torch.Tensor]]"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.pretrained_model_name_or_path_or_dict",description:`<strong>pretrained_model_name_or_path_or_dict</strong> (<code>str</code> or <code>os.PathLike</code> or <code>dict</code>) &#x2014;
Can be either:</p>
<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids should have an organization name, like <code>google/ddpm-celebahq-256</code>.</li>
<li>A path to a <em>directory</em> containing model weights saved using <code>~ModelMixin.save_config</code>, e.g.,
<code>./my_model_directory/</code>.</li>
<li>A <a href="https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict" rel="nofollow">torch state
dict</a>.</li>
</ul>`,name:"pretrained_model_name_or_path_or_dict"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.cache_dir",description:`<strong>cache_dir</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Path to a directory in which a downloaded pretrained model configuration should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to delete incompletely received files. Will attempt to resume the download if such a
file exists.`,name:"resume_download"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, e.g., <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}</code>. The proxies are used on each request.`,name:"proxies"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.local_files_only(bool,",description:`<strong>local_files_only(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to only look at local files (i.e., do not try to download the model).`,name:"local_files_only(bool,"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.use_auth_token",description:`<strong>use_auth_token</strong> (<code>str</code> or <em>bool</em>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>diffusers-cli login</code> (stored in <code>~/.huggingface</code>).`,name:"use_auth_token"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so <code>revision</code> can be any
identifier allowed by git.`,name:"revision"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.subfolder",description:`<strong>subfolder</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
In case the relevant files are located inside a subfolder of the model repo (either remote in
huggingface.co or downloaded locally), you can specify the folder name here.`,name:"subfolder"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights.mirror",description:`<strong>mirror</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Mirror source to accelerate downloads in China. If you are from China and have an accessibility
problem, you can set this option to resolve it. Note that we do not guarantee the timeliness or safety.
Please refer to the mirror site for more information.`,name:"mirror"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/loaders.py#L678"}}),ce=new So({props:{warning:!0,$$slots:{default:[pi]},$$scope:{ctx:T}}}),pe=new So({props:{$$slots:{default:[fi]},$$scope:{ctx:T}}}),Ge=new N({props:{name:"save_lora_weights",anchor:"diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights",parameters:[{name:"save_directory",val:": typing.Union[str, os.PathLike]"},{name:"unet_lora_layers",val:": typing.Dict[str, torch.nn.modules.module.Module] = None"},{name:"text_encoder_lora_layers",val:": typing.Dict[str, torch.nn.modules.module.Module] = None"},{name:"is_main_process",val:": bool = True"},{name:"weight_name",val:": str = None"},{name:"save_function",val:": typing.Callable = None"},{name:"safe_serialization",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory to which to save. Will be created if it doesn&#x2019;t exist.`,name:"save_directory"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights.unet_lora_layers",description:`<strong>unet_lora_layers</strong> (<code>Dict[str, torch.nn.Module</code>]) &#x2014;
State dict of the LoRA layers corresponding to the UNet. Specifying this helps to make the
serialization process easier and cleaner.`,name:"unet_lora_layers"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights.text_encoder_lora_layers",description:`<strong>text_encoder_lora_layers</strong> (<code>Dict[str, torch.nn.Module</code>]) &#x2014;
State dict of the LoRA layers corresponding to the <code>text_encoder</code>. Since the <code>text_encoder</code> comes from
<code>transformers</code>, we cannot rejig it. That is why we have to explicitly pass the text encoder LoRA state
dict.`,name:"text_encoder_lora_layers"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights.is_main_process",description:`<strong>is_main_process</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether the process calling this is the main process or not. Useful when in distributed training like
TPUs and need to call this function on all processes. In this case, set <code>is_main_process=True</code> only on
the main process to avoid race conditions.`,name:"is_main_process"},{anchor:"diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights.save_function",description:`<strong>save_function</strong> (<code>Callable</code>) &#x2014;
The function to use to save the state dictionary. Useful on distributed training like TPUs when one
need to replace <code>torch.save</code> by another method. Can be configured with the environment variable
<code>DIFFUSERS_SAVE_MODE</code>.`,name:"save_function"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/loaders.py#L1038"}}),Be=new N({props:{name:"enable_model_cpu_offload",anchor:"diffusers.StableDiffusionImg2ImgPipeline.enable_model_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L251"}}),Re=new N({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionImg2ImgPipeline.enable_sequential_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L225"}}),Ke=new N({props:{name:"class diffusers.FlaxStableDiffusionImg2ImgPipeline",anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline",parameters:[{name:"vae",val:": FlaxAutoencoderKL"},{name:"text_encoder",val:": FlaxCLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": FlaxUNet2DConditionModel"},{name:"scheduler",val:": typing.Union[diffusers.schedulers.scheduling_ddim_flax.FlaxDDIMScheduler, diffusers.schedulers.scheduling_pndm_flax.FlaxPNDMScheduler, diffusers.schedulers.scheduling_lms_discrete_flax.FlaxLMSDiscreteScheduler, diffusers.schedulers.scheduling_dpmsolver_multistep_flax.FlaxDPMSolverMultistepScheduler]"},{name:"safety_checker",val:": FlaxStableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPImageProcessor"},{name:"dtype",val:": dtype = <class 'jax.numpy.float32'>"}],parametersDescription:[{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.16.0/en/api/models#diffusers.FlaxAutoencoderKL">FlaxAutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>FlaxCLIPTextModel</code>) &#x2014;
Frozen text-encoder. Stable Diffusion uses the text portion of
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.FlaxCLIPTextModel" rel="nofollow">CLIP</a>,
specifically the <a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a> variant.`,name:"text_encoder"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/v0.16.0/en/api/models#diffusers.FlaxUNet2DConditionModel">FlaxUNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.16.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<code>FlaxDDIMScheduler</code>, <code>FlaxLMSDiscreteScheduler</code>, <code>FlaxPNDMScheduler</code>, or
<code>FlaxDPMSolverMultistepScheduler</code>.`,name:"scheduler"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.safety_checker",description:`<strong>safety_checker</strong> (<code>FlaxStableDiffusionSafetyChecker</code>) &#x2014;
Classification module that estimates whether generated images could be considered offensive or harmful.
Please, refer to the <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">model card</a> for details.`,name:"safety_checker"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
Model that extracts features from generated images to be used as inputs for the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_img2img.py#L105"}}),Je=new N({props:{name:"__call__",anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__",parameters:[{name:"prompt_ids",val:": array"},{name:"image",val:": array"},{name:"params",val:": typing.Union[typing.Dict, flax.core.frozen_dict.FrozenDict]"},{name:"prng_seed",val:": PRNGKeyArray"},{name:"strength",val:": float = 0.8"},{name:"num_inference_steps",val:": int = 50"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"guidance_scale",val:": typing.Union[float, array] = 7.5"},{name:"noise",val:": array = None"},{name:"neg_prompt_ids",val:": array = None"},{name:"return_dict",val:": bool = True"},{name:"jit",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.prompt_ids",description:`<strong>prompt_ids</strong> (<code>jnp.array</code>) &#x2014;
The prompt or prompts to guide the image generation.`,name:"prompt_ids"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.image",description:`<strong>image</strong> (<code>jnp.array</code>) &#x2014;
Array representing an image batch, that will be used as the starting point for the process.`,name:"image"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.params",description:"<strong>params</strong> (<code>Dict</code> or <code>FrozenDict</code>) &#x2014; Dictionary containing the model parameters/weights",name:"params"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.prng_seed",description:"<strong>prng_seed</strong> (<code>jax.random.KeyArray</code> or <code>jax.Array</code>) &#x2014; Array containing random number generator key",name:"prng_seed"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.strength",description:`<strong>strength</strong> (<code>float</code>, <em>optional</em>, defaults to 0.8) &#x2014;
Conceptually, indicates how much to transform the reference <code>image</code>. Must be between 0 and 1. <code>image</code>
will be used as a starting point, adding more noise to it the larger the <code>strength</code>. The number of
denoising steps depends on the amount of noise initially added. When <code>strength</code> is 1, added noise will
be maximum and the denoising process will run for the full number of iterations specified in`,name:"strength"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion Guidance</a>.
<code>guidance_scale</code> is defined as <code>w</code> of equation 2. of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen
Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to the text <code>prompt</code>,
usually at the expense of lower image quality.`,name:"guidance_scale"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.noise",description:`<strong>noise</strong> (<code>jnp.array</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. tensor will ge generated
by sampling using the supplied random <code>generator</code>.`,name:"noise"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>FlaxStableDiffusionPipelineOutput</code> instead of
a plain tuple.`,name:"return_dict"},{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.jit",description:`<strong>jit</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to run <code>pmap</code> versions of the generation and safety scoring functions. NOTE: This argument
exists because <code>__call__</code> is not yet end-to-end pmap-able. It will be removed in a future release.`,name:"jit"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion_img2img.py#L338",returnDescription:`
<p><code>FlaxStableDiffusionPipelineOutput</code> if <code>return_dict</code> is True, otherwise a
<code>tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of </code>bool<code>s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the </code>safety_checker\`.</p>
`,returnType:`
<p><code>FlaxStableDiffusionPipelineOutput</code> or <code>tuple</code></p>
`}}),ge=new ut({props:{anchor:"diffusers.FlaxStableDiffusionImg2ImgPipeline.__call__.example",$$slots:{default:[mi]},$$scope:{ctx:T}}}),{c(){d=a("meta"),_=f(),c=a("h1"),p=a("a"),b=a("span"),I(l.$$.fragment),u=f(),E=a("span"),h=n("Image-to-Image Generation"),y=f(),q=a("h2"),F=a("a"),_t=a("span"),I(ve.$$.fragment),jo=f(),bt=a("span"),Eo=n("StableDiffusionImg2ImgPipeline"),ao=f(),A=a("p"),To=n("The Stable Diffusion model was created by the researchers and engineers from "),ye=a("a"),qo=n("CompVis"),Co=n(", "),we=a("a"),Ao=n("Stability AI"),Lo=n(", "),xe=a("a"),Mo=n("runway"),Fo=n(", and "),Ie=a("a"),Oo=n("LAION"),No=n(". The "),Ze=a("a"),Uo=n("StableDiffusionImg2ImgPipeline"),zo=n(" lets you pass a text prompt and an initial image to condition the generation of new images using Stable Diffusion."),io=f(),$e=a("p"),Wo=n("The original codebase can be found here: "),De=a("a"),Vo=n("CampVis/stable-diffusion"),ro=f(),Q=a("p"),Qe=a("a"),Go=n("StableDiffusionImg2ImgPipeline"),Bo=n(" is compatible with all Stable Diffusion checkpoints for "),et=a("a"),Ro=n("Text-to-Image"),lo=f(),ee=a("p"),Ko=n("The pipeline uses the diffusion-denoising mechanism proposed by SDEdit ("),Pe=a("a"),Ho=n("SDEdit: Guided Image Synthesis and Editing with Stochastic Differential Equations"),Jo=n(`
proposed by Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, Stefano Ermon).`),co=f(),v=a("div"),I(ke.$$.fragment),Yo=f(),vt=a("p"),Xo=n("Pipeline for text-guided image to image generation using Stable Diffusion."),Zo=f(),Se=a("p"),Qo=n("This model inherits from "),tt=a("a"),en=n("DiffusionPipeline"),tn=n(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),on=f(),yt=a("p"),nn=n("In addition the pipeline inherits the following loading methods:"),sn=f(),J=a("ul"),je=a("li"),wt=a("em"),an=n("Textual-Inversion"),rn=n(": "),ot=a("a"),ln=n("loaders.TextualInversionLoaderMixin.load_textual_inversion()"),dn=f(),Ee=a("li"),xt=a("em"),cn=n("LoRA"),pn=n(": "),nt=a("a"),fn=n("loaders.LoraLoaderMixin.load_lora_weights()"),mn=f(),Te=a("li"),It=a("em"),un=n("Ckpt"),gn=n(": "),st=a("a"),hn=n("loaders.FromCkptMixin.from_ckpt()"),_n=f(),$t=a("p"),bn=n("as well as the following saving methods:"),vn=f(),Dt=a("ul"),qe=a("li"),Pt=a("em"),yn=n("LoRA"),wn=n(": "),at=a("a"),xn=n("loaders.LoraLoaderMixin.save_lora_weights()"),In=f(),G=a("div"),I(Ce.$$.fragment),$n=f(),kt=a("p"),Dn=n("Function invoked when calling the pipeline for generation."),Pn=f(),I(te.$$.fragment),kn=f(),B=a("div"),I(Ae.$$.fragment),Sn=f(),St=a("p"),jn=n("Enable sliced attention computation."),En=f(),jt=a("p"),Tn=n(`When this option is enabled, the attention module will split the input tensor in slices, to compute attention
in several steps. This is useful to save some memory in exchange for a small speed decrease.`),qn=f(),oe=a("div"),I(Le.$$.fragment),Cn=f(),Me=a("p"),An=n("Disable sliced attention computation. If "),Et=a("code"),Ln=n("enable_attention_slicing"),Mn=n(` was previously invoked, this method will go
back to computing attention in one step.`),Fn=f(),O=a("div"),I(Fe.$$.fragment),On=f(),Tt=a("p"),Nn=n("Enable memory efficient attention as implemented in xformers."),Un=f(),qt=a("p"),zn=n(`When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.`),Wn=f(),Ct=a("p"),Vn=n(`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Gn=f(),I(ne.$$.fragment),Bn=f(),se=a("div"),I(Oe.$$.fragment),Rn=f(),At=a("p"),Kn=n("Disable memory efficient attention as implemented in xformers."),Hn=f(),C=a("div"),I(Ne.$$.fragment),Jn=f(),Y=a("p"),Yn=n("Load textual inversion embeddings into the text encoder of stable diffusion pipelines. Both "),Lt=a("code"),Xn=n("diffusers"),Zn=n(` and
`),Mt=a("code"),Qn=n("Automatic1111"),es=n(" formats are supported (see example below)."),ts=f(),I(ae.$$.fragment),os=f(),I(ie.$$.fragment),ns=f(),Ft=a("p"),ss=n("Example:"),as=f(),I(re.$$.fragment),is=f(),Ot=a("p"),rs=n("To load a textual inversion embedding vector in Automatic1111 format, make sure to first download the vector,"),ls=f(),I(le.$$.fragment),ds=f(),W=a("div"),I(Ue.$$.fragment),cs=f(),Nt=a("p"),ps=n("Instantiate a PyTorch diffusion pipeline from pre-trained pipeline weights saved in the original .ckpt format."),fs=f(),ze=a("p"),ms=n("The pipeline is set in evaluation mode by default using "),Ut=a("code"),us=n("model.eval()"),gs=n(" (Dropout modules are deactivated)."),hs=f(),I(de.$$.fragment),_s=f(),V=a("div"),I(We.$$.fragment),bs=f(),X=a("p"),vs=n("Load pretrained attention processor layers (such as LoRA) into "),it=a("a"),ys=n("UNet2DConditionModel"),ws=n(` and
`),Ve=a("a"),zt=a("code"),xs=n("CLIPTextModel"),Is=n(")."),$s=f(),I(ce.$$.fragment),Ds=f(),I(pe.$$.fragment),Ps=f(),fe=a("div"),I(Ge.$$.fragment),ks=f(),Wt=a("p"),Ss=n("Save the LoRA parameters corresponding to the UNet and the text encoder."),js=f(),me=a("div"),I(Be.$$.fragment),Es=f(),U=a("p"),Ts=n(`Offloads all models to CPU using accelerate, reducing memory usage with a low impact on performance. Compared
to `),Vt=a("code"),qs=n("enable_sequential_cpu_offload"),Cs=n(", this method moves one whole model at a time to the GPU when its "),Gt=a("code"),As=n("forward"),Ls=n(`
method is called, and the model remains in GPU until the next model runs. Memory savings are lower than with
`),Bt=a("code"),Ms=n("enable_sequential_cpu_offload"),Fs=n(", but performance is much better due to the iterative execution of the "),Rt=a("code"),Os=n("unet"),Ns=n("."),Us=f(),ue=a("div"),I(Re.$$.fragment),zs=f(),Z=a("p"),Ws=n(`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Kt=a("code"),Vs=n("torch.device('meta') and loaded to GPU only when their specific submodule has its "),Gs=n("forward"),Ht=a("code"),Bs=n("method called. Note that offloading happens on a submodule basis. Memory savings are higher than with"),Rs=n("enable_model_cpu_offload`, but performance is lower."),po=f(),z=a("div"),I(Ke.$$.fragment),Ks=f(),Jt=a("p"),Hs=n("Pipeline for image-to-image generation using Stable Diffusion."),Js=f(),He=a("p"),Ys=n("This model inherits from "),Yt=a("code"),Xs=n("FlaxDiffusionPipeline"),Zs=n(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),Qs=f(),R=a("div"),I(Je.$$.fragment),ea=f(),Xt=a("p"),ta=n("Function invoked when calling the pipeline for generation."),oa=f(),I(ge.$$.fragment),this.h()},l(o){const w=oi('[data-svelte="svelte-1phssyn"]',document.head);d=i(w,"META",{name:!0,content:!0}),w.forEach(t),_=m(o),c=i(o,"H1",{class:!0});var Ye=r(c);p=i(Ye,"A",{id:!0,class:!0,href:!0});var Zt=r(p);b=i(Zt,"SPAN",{});var Qt=r(b);$(l.$$.fragment,Qt),Qt.forEach(t),Zt.forEach(t),u=m(Ye),E=i(Ye,"SPAN",{});var eo=r(E);h=s(eo,"Image-to-Image Generation"),eo.forEach(t),Ye.forEach(t),y=m(o),q=i(o,"H2",{class:!0});var Xe=r(q);F=i(Xe,"A",{id:!0,class:!0,href:!0});var to=r(F);_t=i(to,"SPAN",{});var oo=r(_t);$(ve.$$.fragment,oo),oo.forEach(t),to.forEach(t),jo=m(Xe),bt=i(Xe,"SPAN",{});var no=r(bt);Eo=s(no,"StableDiffusionImg2ImgPipeline"),no.forEach(t),Xe.forEach(t),ao=m(o),A=i(o,"P",{});var M=r(A);To=s(M,"The Stable Diffusion model was created by the researchers and engineers from "),ye=i(M,"A",{href:!0,rel:!0});var so=r(ye);qo=s(so,"CompVis"),so.forEach(t),Co=s(M,", "),we=i(M,"A",{href:!0,rel:!0});var sa=r(we);Ao=s(sa,"Stability AI"),sa.forEach(t),Lo=s(M,", "),xe=i(M,"A",{href:!0,rel:!0});var aa=r(xe);Mo=s(aa,"runway"),aa.forEach(t),Fo=s(M,", and "),Ie=i(M,"A",{href:!0,rel:!0});var ia=r(Ie);Oo=s(ia,"LAION"),ia.forEach(t),No=s(M,". The "),Ze=i(M,"A",{href:!0});var ra=r(Ze);Uo=s(ra,"StableDiffusionImg2ImgPipeline"),ra.forEach(t),zo=s(M," lets you pass a text prompt and an initial image to condition the generation of new images using Stable Diffusion."),M.forEach(t),io=m(o),$e=i(o,"P",{});var na=r($e);Wo=s(na,"The original codebase can be found here: "),De=i(na,"A",{href:!0,rel:!0});var la=r(De);Vo=s(la,"CampVis/stable-diffusion"),la.forEach(t),na.forEach(t),ro=m(o),Q=i(o,"P",{});var mo=r(Q);Qe=i(mo,"A",{href:!0});var da=r(Qe);Go=s(da,"StableDiffusionImg2ImgPipeline"),da.forEach(t),Bo=s(mo," is compatible with all Stable Diffusion checkpoints for "),et=i(mo,"A",{href:!0});var ca=r(et);Ro=s(ca,"Text-to-Image"),ca.forEach(t),mo.forEach(t),lo=m(o),ee=i(o,"P",{});var uo=r(ee);Ko=s(uo,"The pipeline uses the diffusion-denoising mechanism proposed by SDEdit ("),Pe=i(uo,"A",{href:!0,rel:!0});var pa=r(Pe);Ho=s(pa,"SDEdit: Guided Image Synthesis and Editing with Stochastic Differential Equations"),pa.forEach(t),Jo=s(uo,`
proposed by Chenlin Meng, Yutong He, Yang Song, Jiaming Song, Jiajun Wu, Jun-Yan Zhu, Stefano Ermon).`),uo.forEach(t),co=m(o),v=i(o,"DIV",{class:!0});var x=r(v);$(ke.$$.fragment,x),Yo=m(x),vt=i(x,"P",{});var fa=r(vt);Xo=s(fa,"Pipeline for text-guided image to image generation using Stable Diffusion."),fa.forEach(t),Zo=m(x),Se=i(x,"P",{});var go=r(Se);Qo=s(go,"This model inherits from "),tt=i(go,"A",{href:!0});var ma=r(tt);en=s(ma,"DiffusionPipeline"),ma.forEach(t),tn=s(go,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),go.forEach(t),on=m(x),yt=i(x,"P",{});var ua=r(yt);nn=s(ua,"In addition the pipeline inherits the following loading methods:"),ua.forEach(t),sn=m(x),J=i(x,"UL",{});var rt=r(J);je=i(rt,"LI",{});var ho=r(je);wt=i(ho,"EM",{});var ga=r(wt);an=s(ga,"Textual-Inversion"),ga.forEach(t),rn=s(ho,": "),ot=i(ho,"A",{href:!0});var ha=r(ot);ln=s(ha,"loaders.TextualInversionLoaderMixin.load_textual_inversion()"),ha.forEach(t),ho.forEach(t),dn=m(rt),Ee=i(rt,"LI",{});var _o=r(Ee);xt=i(_o,"EM",{});var _a=r(xt);cn=s(_a,"LoRA"),_a.forEach(t),pn=s(_o,": "),nt=i(_o,"A",{href:!0});var ba=r(nt);fn=s(ba,"loaders.LoraLoaderMixin.load_lora_weights()"),ba.forEach(t),_o.forEach(t),mn=m(rt),Te=i(rt,"LI",{});var bo=r(Te);It=i(bo,"EM",{});var va=r(It);un=s(va,"Ckpt"),va.forEach(t),gn=s(bo,": "),st=i(bo,"A",{href:!0});var ya=r(st);hn=s(ya,"loaders.FromCkptMixin.from_ckpt()"),ya.forEach(t),bo.forEach(t),rt.forEach(t),_n=m(x),$t=i(x,"P",{});var wa=r($t);bn=s(wa,"as well as the following saving methods:"),wa.forEach(t),vn=m(x),Dt=i(x,"UL",{});var xa=r(Dt);qe=i(xa,"LI",{});var vo=r(qe);Pt=i(vo,"EM",{});var Ia=r(Pt);yn=s(Ia,"LoRA"),Ia.forEach(t),wn=s(vo,": "),at=i(vo,"A",{href:!0});var $a=r(at);xn=s($a,"loaders.LoraLoaderMixin.save_lora_weights()"),$a.forEach(t),vo.forEach(t),xa.forEach(t),In=m(x),G=i(x,"DIV",{class:!0});var lt=r(G);$(Ce.$$.fragment,lt),$n=m(lt),kt=i(lt,"P",{});var Da=r(kt);Dn=s(Da,"Function invoked when calling the pipeline for generation."),Da.forEach(t),Pn=m(lt),$(te.$$.fragment,lt),lt.forEach(t),kn=m(x),B=i(x,"DIV",{class:!0});var dt=r(B);$(Ae.$$.fragment,dt),Sn=m(dt),St=i(dt,"P",{});var Pa=r(St);jn=s(Pa,"Enable sliced attention computation."),Pa.forEach(t),En=m(dt),jt=i(dt,"P",{});var ka=r(jt);Tn=s(ka,`When this option is enabled, the attention module will split the input tensor in slices, to compute attention
in several steps. This is useful to save some memory in exchange for a small speed decrease.`),ka.forEach(t),dt.forEach(t),qn=m(x),oe=i(x,"DIV",{class:!0});var yo=r(oe);$(Le.$$.fragment,yo),Cn=m(yo),Me=i(yo,"P",{});var wo=r(Me);An=s(wo,"Disable sliced attention computation. If "),Et=i(wo,"CODE",{});var Sa=r(Et);Ln=s(Sa,"enable_attention_slicing"),Sa.forEach(t),Mn=s(wo,` was previously invoked, this method will go
back to computing attention in one step.`),wo.forEach(t),yo.forEach(t),Fn=m(x),O=i(x,"DIV",{class:!0});var K=r(O);$(Fe.$$.fragment,K),On=m(K),Tt=i(K,"P",{});var ja=r(Tt);Nn=s(ja,"Enable memory efficient attention as implemented in xformers."),ja.forEach(t),Un=m(K),qt=i(K,"P",{});var Ea=r(qt);zn=s(Ea,`When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.`),Ea.forEach(t),Wn=m(K),Ct=i(K,"P",{});var Ta=r(Ct);Vn=s(Ta,`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Ta.forEach(t),Gn=m(K),$(ne.$$.fragment,K),K.forEach(t),Bn=m(x),se=i(x,"DIV",{class:!0});var xo=r(se);$(Oe.$$.fragment,xo),Rn=m(xo),At=i(xo,"P",{});var qa=r(At);Kn=s(qa,"Disable memory efficient attention as implemented in xformers."),qa.forEach(t),xo.forEach(t),Hn=m(x),C=i(x,"DIV",{class:!0});var L=r(C);$(Ne.$$.fragment,L),Jn=m(L),Y=i(L,"P",{});var ct=r(Y);Yn=s(ct,"Load textual inversion embeddings into the text encoder of stable diffusion pipelines. Both "),Lt=i(ct,"CODE",{});var Ca=r(Lt);Xn=s(Ca,"diffusers"),Ca.forEach(t),Zn=s(ct,` and
`),Mt=i(ct,"CODE",{});var Aa=r(Mt);Qn=s(Aa,"Automatic1111"),Aa.forEach(t),es=s(ct," formats are supported (see example below)."),ct.forEach(t),ts=m(L),$(ae.$$.fragment,L),os=m(L),$(ie.$$.fragment,L),ns=m(L),Ft=i(L,"P",{});var La=r(Ft);ss=s(La,"Example:"),La.forEach(t),as=m(L),$(re.$$.fragment,L),is=m(L),Ot=i(L,"P",{});var Ma=r(Ot);rs=s(Ma,"To load a textual inversion embedding vector in Automatic1111 format, make sure to first download the vector,"),Ma.forEach(t),ls=m(L),$(le.$$.fragment,L),L.forEach(t),ds=m(x),W=i(x,"DIV",{class:!0});var he=r(W);$(Ue.$$.fragment,he),cs=m(he),Nt=i(he,"P",{});var Fa=r(Nt);ps=s(Fa,"Instantiate a PyTorch diffusion pipeline from pre-trained pipeline weights saved in the original .ckpt format."),Fa.forEach(t),fs=m(he),ze=i(he,"P",{});var Io=r(ze);ms=s(Io,"The pipeline is set in evaluation mode by default using "),Ut=i(Io,"CODE",{});var Oa=r(Ut);us=s(Oa,"model.eval()"),Oa.forEach(t),gs=s(Io," (Dropout modules are deactivated)."),Io.forEach(t),hs=m(he),$(de.$$.fragment,he),he.forEach(t),_s=m(x),V=i(x,"DIV",{class:!0});var _e=r(V);$(We.$$.fragment,_e),bs=m(_e),X=i(_e,"P",{});var pt=r(X);vs=s(pt,"Load pretrained attention processor layers (such as LoRA) into "),it=i(pt,"A",{href:!0});var Na=r(it);ys=s(Na,"UNet2DConditionModel"),Na.forEach(t),ws=s(pt,` and
`),Ve=i(pt,"A",{href:!0,rel:!0});var Ua=r(Ve);zt=i(Ua,"CODE",{});var za=r(zt);xs=s(za,"CLIPTextModel"),za.forEach(t),Ua.forEach(t),Is=s(pt,")."),pt.forEach(t),$s=m(_e),$(ce.$$.fragment,_e),Ds=m(_e),$(pe.$$.fragment,_e),_e.forEach(t),Ps=m(x),fe=i(x,"DIV",{class:!0});var $o=r(fe);$(Ge.$$.fragment,$o),ks=m($o),Wt=i($o,"P",{});var Wa=r(Wt);Ss=s(Wa,"Save the LoRA parameters corresponding to the UNet and the text encoder."),Wa.forEach(t),$o.forEach(t),js=m(x),me=i(x,"DIV",{class:!0});var Do=r(me);$(Be.$$.fragment,Do),Es=m(Do),U=i(Do,"P",{});var H=r(U);Ts=s(H,`Offloads all models to CPU using accelerate, reducing memory usage with a low impact on performance. Compared
to `),Vt=i(H,"CODE",{});var Va=r(Vt);qs=s(Va,"enable_sequential_cpu_offload"),Va.forEach(t),Cs=s(H,", this method moves one whole model at a time to the GPU when its "),Gt=i(H,"CODE",{});var Ga=r(Gt);As=s(Ga,"forward"),Ga.forEach(t),Ls=s(H,`
method is called, and the model remains in GPU until the next model runs. Memory savings are lower than with
`),Bt=i(H,"CODE",{});var Ba=r(Bt);Ms=s(Ba,"enable_sequential_cpu_offload"),Ba.forEach(t),Fs=s(H,", but performance is much better due to the iterative execution of the "),Rt=i(H,"CODE",{});var Ra=r(Rt);Os=s(Ra,"unet"),Ra.forEach(t),Ns=s(H,"."),H.forEach(t),Do.forEach(t),Us=m(x),ue=i(x,"DIV",{class:!0});var Po=r(ue);$(Re.$$.fragment,Po),zs=m(Po),Z=i(Po,"P",{});var ft=r(Z);Ws=s(ft,`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Kt=i(ft,"CODE",{});var Ka=r(Kt);Vs=s(Ka,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),Ka.forEach(t),Gs=s(ft,"forward"),Ht=i(ft,"CODE",{});var Ha=r(Ht);Bs=s(Ha,"method called. Note that offloading happens on a submodule basis. Memory savings are higher than with"),Ha.forEach(t),Rs=s(ft,"enable_model_cpu_offload`, but performance is lower."),ft.forEach(t),Po.forEach(t),x.forEach(t),po=m(o),z=i(o,"DIV",{class:!0});var be=r(z);$(Ke.$$.fragment,be),Ks=m(be),Jt=i(be,"P",{});var Ja=r(Jt);Hs=s(Ja,"Pipeline for image-to-image generation using Stable Diffusion."),Ja.forEach(t),Js=m(be),He=i(be,"P",{});var ko=r(He);Ys=s(ko,"This model inherits from "),Yt=i(ko,"CODE",{});var Ya=r(Yt);Xs=s(Ya,"FlaxDiffusionPipeline"),Ya.forEach(t),Zs=s(ko,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),ko.forEach(t),Qs=m(be),R=i(be,"DIV",{class:!0});var mt=r(R);$(Je.$$.fragment,mt),ea=m(mt),Xt=i(mt,"P",{});var Xa=r(Xt);ta=s(Xa,"Function invoked when calling the pipeline for generation."),Xa.forEach(t),oa=m(mt),$(ge.$$.fragment,mt),mt.forEach(t),be.forEach(t),this.h()},h(){g(d,"name","hf:doc:metadata"),g(d,"content",JSON.stringify(gi)),g(p,"id","imagetoimage-generation"),g(p,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),g(p,"href","#imagetoimage-generation"),g(c,"class","relative group"),g(F,"id","diffusers.StableDiffusionImg2ImgPipeline"),g(F,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),g(F,"href","#diffusers.StableDiffusionImg2ImgPipeline"),g(q,"class","relative group"),g(ye,"href","https://github.com/CompVis"),g(ye,"rel","nofollow"),g(we,"href","https://stability.ai/"),g(we,"rel","nofollow"),g(xe,"href","https://github.com/runwayml"),g(xe,"rel","nofollow"),g(Ie,"href","https://laion.ai/"),g(Ie,"rel","nofollow"),g(Ze,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline"),g(De,"href","https://github.com/CompVis/stable-diffusion/blob/main/scripts/img2img.py"),g(De,"rel","nofollow"),g(Qe,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline"),g(et,"href","./text2img"),g(Pe,"href","https://arxiv.org/abs/2108.01073"),g(Pe,"rel","nofollow"),g(tt,"href","/docs/diffusers/v0.16.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),g(ot,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline.load_textual_inversion"),g(nt,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline.load_lora_weights"),g(st,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline.from_ckpt"),g(at,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline.save_lora_weights"),g(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(it,"href","/docs/diffusers/v0.16.0/en/api/models#diffusers.UNet2DConditionModel"),g(Ve,"href","https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel"),g(Ve,"rel","nofollow"),g(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),g(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,w){e(document.head,d),j(o,_,w),j(o,c,w),e(c,p),e(p,b),D(l,b,null),e(c,u),e(c,E),e(E,h),j(o,y,w),j(o,q,w),e(q,F),e(F,_t),D(ve,_t,null),e(q,jo),e(q,bt),e(bt,Eo),j(o,ao,w),j(o,A,w),e(A,To),e(A,ye),e(ye,qo),e(A,Co),e(A,we),e(we,Ao),e(A,Lo),e(A,xe),e(xe,Mo),e(A,Fo),e(A,Ie),e(Ie,Oo),e(A,No),e(A,Ze),e(Ze,Uo),e(A,zo),j(o,io,w),j(o,$e,w),e($e,Wo),e($e,De),e(De,Vo),j(o,ro,w),j(o,Q,w),e(Q,Qe),e(Qe,Go),e(Q,Bo),e(Q,et),e(et,Ro),j(o,lo,w),j(o,ee,w),e(ee,Ko),e(ee,Pe),e(Pe,Ho),e(ee,Jo),j(o,co,w),j(o,v,w),D(ke,v,null),e(v,Yo),e(v,vt),e(vt,Xo),e(v,Zo),e(v,Se),e(Se,Qo),e(Se,tt),e(tt,en),e(Se,tn),e(v,on),e(v,yt),e(yt,nn),e(v,sn),e(v,J),e(J,je),e(je,wt),e(wt,an),e(je,rn),e(je,ot),e(ot,ln),e(J,dn),e(J,Ee),e(Ee,xt),e(xt,cn),e(Ee,pn),e(Ee,nt),e(nt,fn),e(J,mn),e(J,Te),e(Te,It),e(It,un),e(Te,gn),e(Te,st),e(st,hn),e(v,_n),e(v,$t),e($t,bn),e(v,vn),e(v,Dt),e(Dt,qe),e(qe,Pt),e(Pt,yn),e(qe,wn),e(qe,at),e(at,xn),e(v,In),e(v,G),D(Ce,G,null),e(G,$n),e(G,kt),e(kt,Dn),e(G,Pn),D(te,G,null),e(v,kn),e(v,B),D(Ae,B,null),e(B,Sn),e(B,St),e(St,jn),e(B,En),e(B,jt),e(jt,Tn),e(v,qn),e(v,oe),D(Le,oe,null),e(oe,Cn),e(oe,Me),e(Me,An),e(Me,Et),e(Et,Ln),e(Me,Mn),e(v,Fn),e(v,O),D(Fe,O,null),e(O,On),e(O,Tt),e(Tt,Nn),e(O,Un),e(O,qt),e(qt,zn),e(O,Wn),e(O,Ct),e(Ct,Vn),e(O,Gn),D(ne,O,null),e(v,Bn),e(v,se),D(Oe,se,null),e(se,Rn),e(se,At),e(At,Kn),e(v,Hn),e(v,C),D(Ne,C,null),e(C,Jn),e(C,Y),e(Y,Yn),e(Y,Lt),e(Lt,Xn),e(Y,Zn),e(Y,Mt),e(Mt,Qn),e(Y,es),e(C,ts),D(ae,C,null),e(C,os),D(ie,C,null),e(C,ns),e(C,Ft),e(Ft,ss),e(C,as),D(re,C,null),e(C,is),e(C,Ot),e(Ot,rs),e(C,ls),D(le,C,null),e(v,ds),e(v,W),D(Ue,W,null),e(W,cs),e(W,Nt),e(Nt,ps),e(W,fs),e(W,ze),e(ze,ms),e(ze,Ut),e(Ut,us),e(ze,gs),e(W,hs),D(de,W,null),e(v,_s),e(v,V),D(We,V,null),e(V,bs),e(V,X),e(X,vs),e(X,it),e(it,ys),e(X,ws),e(X,Ve),e(Ve,zt),e(zt,xs),e(X,Is),e(V,$s),D(ce,V,null),e(V,Ds),D(pe,V,null),e(v,Ps),e(v,fe),D(Ge,fe,null),e(fe,ks),e(fe,Wt),e(Wt,Ss),e(v,js),e(v,me),D(Be,me,null),e(me,Es),e(me,U),e(U,Ts),e(U,Vt),e(Vt,qs),e(U,Cs),e(U,Gt),e(Gt,As),e(U,Ls),e(U,Bt),e(Bt,Ms),e(U,Fs),e(U,Rt),e(Rt,Os),e(U,Ns),e(v,Us),e(v,ue),D(Re,ue,null),e(ue,zs),e(ue,Z),e(Z,Ws),e(Z,Kt),e(Kt,Vs),e(Z,Gs),e(Z,Ht),e(Ht,Bs),e(Z,Rs),j(o,po,w),j(o,z,w),D(Ke,z,null),e(z,Ks),e(z,Jt),e(Jt,Hs),e(z,Js),e(z,He),e(He,Ys),e(He,Yt),e(Yt,Xs),e(He,Zs),e(z,Qs),e(z,R),D(Je,R,null),e(R,ea),e(R,Xt),e(Xt,ta),e(R,oa),D(ge,R,null),fo=!0},p(o,[w]){const Ye={};w&2&&(Ye.$$scope={dirty:w,ctx:o}),te.$set(Ye);const Zt={};w&2&&(Zt.$$scope={dirty:w,ctx:o}),ne.$set(Zt);const Qt={};w&2&&(Qt.$$scope={dirty:w,ctx:o}),ae.$set(Qt);const eo={};w&2&&(eo.$$scope={dirty:w,ctx:o}),ie.$set(eo);const Xe={};w&2&&(Xe.$$scope={dirty:w,ctx:o}),re.$set(Xe);const to={};w&2&&(to.$$scope={dirty:w,ctx:o}),le.$set(to);const oo={};w&2&&(oo.$$scope={dirty:w,ctx:o}),de.$set(oo);const no={};w&2&&(no.$$scope={dirty:w,ctx:o}),ce.$set(no);const M={};w&2&&(M.$$scope={dirty:w,ctx:o}),pe.$set(M);const so={};w&2&&(so.$$scope={dirty:w,ctx:o}),ge.$set(so)},i(o){fo||(P(l.$$.fragment,o),P(ve.$$.fragment,o),P(ke.$$.fragment,o),P(Ce.$$.fragment,o),P(te.$$.fragment,o),P(Ae.$$.fragment,o),P(Le.$$.fragment,o),P(Fe.$$.fragment,o),P(ne.$$.fragment,o),P(Oe.$$.fragment,o),P(Ne.$$.fragment,o),P(ae.$$.fragment,o),P(ie.$$.fragment,o),P(re.$$.fragment,o),P(le.$$.fragment,o),P(Ue.$$.fragment,o),P(de.$$.fragment,o),P(We.$$.fragment,o),P(ce.$$.fragment,o),P(pe.$$.fragment,o),P(Ge.$$.fragment,o),P(Be.$$.fragment,o),P(Re.$$.fragment,o),P(Ke.$$.fragment,o),P(Je.$$.fragment,o),P(ge.$$.fragment,o),fo=!0)},o(o){k(l.$$.fragment,o),k(ve.$$.fragment,o),k(ke.$$.fragment,o),k(Ce.$$.fragment,o),k(te.$$.fragment,o),k(Ae.$$.fragment,o),k(Le.$$.fragment,o),k(Fe.$$.fragment,o),k(ne.$$.fragment,o),k(Oe.$$.fragment,o),k(Ne.$$.fragment,o),k(ae.$$.fragment,o),k(ie.$$.fragment,o),k(re.$$.fragment,o),k(le.$$.fragment,o),k(Ue.$$.fragment,o),k(de.$$.fragment,o),k(We.$$.fragment,o),k(ce.$$.fragment,o),k(pe.$$.fragment,o),k(Ge.$$.fragment,o),k(Be.$$.fragment,o),k(Re.$$.fragment,o),k(Ke.$$.fragment,o),k(Je.$$.fragment,o),k(ge.$$.fragment,o),fo=!1},d(o){t(d),o&&t(_),o&&t(c),S(l),o&&t(y),o&&t(q),S(ve),o&&t(ao),o&&t(A),o&&t(io),o&&t($e),o&&t(ro),o&&t(Q),o&&t(lo),o&&t(ee),o&&t(co),o&&t(v),S(ke),S(Ce),S(te),S(Ae),S(Le),S(Fe),S(ne),S(Oe),S(Ne),S(ae),S(ie),S(re),S(le),S(Ue),S(de),S(We),S(ce),S(pe),S(Ge),S(Be),S(Re),o&&t(po),o&&t(z),S(Ke),S(Je),S(ge)}}}const gi={local:"imagetoimage-generation",sections:[{local:"diffusers.StableDiffusionImg2ImgPipeline",title:"StableDiffusionImg2ImgPipeline"}],title:"Image-to-Image Generation"};function hi(T){return ni(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ii extends Qa{constructor(d){super();ei(this,d,hi,ui,ti,{})}}export{Ii as default,gi as metadata};
