import{S as dd,i as cd,s as md,e as a,k as p,w as g,t as o,M as fd,c as s,d as n,m as d,a as i,x as u,h as l,b as m,G as t,g as c,y as h,q as b,o as _,B as y,v as gd,L as Jr}from"../../../chunks/vendor-hf-doc-builder.js";import{T as ud}from"../../../chunks/Tip-hf-doc-builder.js";import{D as N}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as T}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Tt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Mr}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function hd(X){let w,v;return{c(){w=a("p"),v=o("This is an experimental feature!")},l(f){w=s(f,"P",{});var U=i(w);v=l(U,"This is an experimental feature!"),U.forEach(n)},m(f,U){c(f,w,U),t(w,v)},d(f){f&&n(w)}}}function bd(X){let w,v;return w=new T({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uRGlmZkVkaXRQaXBlbGluZSUwQSUwQSUwQWRlZiUyMGRvd25sb2FkX2ltYWdlKHVybCklM0ElMEElMjAlMjAlMjAlMjByZXNwb25zZSUyMCUzRCUyMHJlcXVlc3RzLmdldCh1cmwpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwUElMLkltYWdlLm9wZW4oQnl0ZXNJTyhyZXNwb25zZS5jb250ZW50KSkuY29udmVydCglMjJSR0IlMjIpJTBBJTBBJTBBaW1nX3VybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRlhpYW5nLWNkJTJGRGlmZkVkaXQtc3RhYmxlLWRpZmZ1c2lvbiUyRnJhdyUyRm1haW4lMkZhc3NldHMlMkZvcmlnaW4ucG5nJTIyJTBBJTBBaW5pdF9pbWFnZSUyMCUzRCUyMGRvd25sb2FkX2ltYWdlKGltZ191cmwpLnJlc2l6ZSgoNzY4JTJDJTIwNzY4KSklMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uRGlmZkVkaXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTItMSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMERESU1TY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEFwaXBlbGluZS5pbnZlcnNlX3NjaGVkdWxlciUyMCUzRCUyMERESU1JbnZlcnNlU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMEFtYXNrX3Byb21wdCUyMCUzRCUyMCUyMkElMjBib3dsJTIwb2YlMjBmcnVpdHMlMjIlMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwYm93bCUyMG9mJTIwcGVhcnMlMjIlMEElMEFtYXNrX2ltYWdlJTIwJTNEJTIwcGlwZS5nZW5lcmF0ZV9tYXNrKGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMHNvdXJjZV9wcm9tcHQlM0Rwcm9tcHQlMkMlMjB0YXJnZXRfcHJvbXB0JTNEbWFza19wcm9tcHQpJTBBaW1hZ2VfbGF0ZW50cyUyMCUzRCUyMHBpcGUuaW52ZXJ0KGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMHByb21wdCUzRG1hc2tfcHJvbXB0KS5sYXRlbnRzJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKHByb21wdCUzRHByb21wdCUyQyUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlJTJDJTIwaW1hZ2VfbGF0ZW50cyUzRGltYWdlX2xhdGVudHMpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> PIL
<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> 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> StableDiffusionDiffEditPipeline


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
<span class="hljs-meta">... </span>    response = requests.get(url)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> PIL.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>img_url = <span class="hljs-string">&quot;https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>init_image = download_image(img_url).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionDiffEditPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<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>pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.enable_model_cpu_offload()

<span class="hljs-meta">&gt;&gt;&gt; </span>mask_prompt = <span class="hljs-string">&quot;A bowl of fruits&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A bowl of pears&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>mask_image = pipe.generate_mask(image=init_image, source_prompt=prompt, target_prompt=mask_prompt)
<span class="hljs-meta">&gt;&gt;&gt; </span>image_latents = pipe.invert(image=init_image, prompt=mask_prompt).latents
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt=prompt, mask_image=mask_image, image_latents=image_latents).images[<span class="hljs-number">0</span>]`}}),{c(){g(w.$$.fragment)},l(f){u(w.$$.fragment,f)},m(f,U){h(w,f,U),v=!0},p:Jr,i(f){v||(b(w.$$.fragment,f),v=!0)},o(f){_(w.$$.fragment,f),v=!1},d(f){y(w,f)}}}function _d(X){let w,v;return w=new T({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uRGlmZkVkaXRQaXBlbGluZSUwQSUwQSUwQWRlZiUyMGRvd25sb2FkX2ltYWdlKHVybCklM0ElMEElMjAlMjAlMjAlMjByZXNwb25zZSUyMCUzRCUyMHJlcXVlc3RzLmdldCh1cmwpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwUElMLkltYWdlLm9wZW4oQnl0ZXNJTyhyZXNwb25zZS5jb250ZW50KSkuY29udmVydCglMjJSR0IlMjIpJTBBJTBBJTBBaW1nX3VybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRlhpYW5nLWNkJTJGRGlmZkVkaXQtc3RhYmxlLWRpZmZ1c2lvbiUyRnJhdyUyRm1haW4lMkZhc3NldHMlMkZvcmlnaW4ucG5nJTIyJTBBJTBBaW5pdF9pbWFnZSUyMCUzRCUyMGRvd25sb2FkX2ltYWdlKGltZ191cmwpLnJlc2l6ZSgoNzY4JTJDJTIwNzY4KSklMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uRGlmZkVkaXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTItMSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMERESU1TY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEFwaXBlbGluZS5pbnZlcnNlX3NjaGVkdWxlciUyMCUzRCUyMERESU1JbnZlcnNlU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwYm93bCUyMG9mJTIwZnJ1aXRzJTIyJTBBJTBBaW52ZXJ0ZWRfbGF0ZW50cyUyMCUzRCUyMHBpcGUuaW52ZXJ0KGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMHByb21wdCUzRHByb21wdCkubGF0ZW50cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> PIL
<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> 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> StableDiffusionDiffEditPipeline


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
<span class="hljs-meta">... </span>    response = requests.get(url)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> PIL.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>img_url = <span class="hljs-string">&quot;https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>init_image = download_image(img_url).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionDiffEditPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<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>pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.enable_model_cpu_offload()

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A bowl of fruits&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>inverted_latents = pipe.invert(image=init_image, prompt=prompt).latents`}}),{c(){g(w.$$.fragment)},l(f){u(w.$$.fragment,f)},m(f,U){h(w,f,U),v=!0},p:Jr,i(f){v||(b(w.$$.fragment,f),v=!0)},o(f){_(w.$$.fragment,f),v=!1},d(f){y(w,f)}}}function yd(X){let w,v;return w=new T({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uRGlmZkVkaXRQaXBlbGluZSUwQSUwQSUwQWRlZiUyMGRvd25sb2FkX2ltYWdlKHVybCklM0ElMEElMjAlMjAlMjAlMjByZXNwb25zZSUyMCUzRCUyMHJlcXVlc3RzLmdldCh1cmwpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwUElMLkltYWdlLm9wZW4oQnl0ZXNJTyhyZXNwb25zZS5jb250ZW50KSkuY29udmVydCglMjJSR0IlMjIpJTBBJTBBJTBBaW1nX3VybCUyMCUzRCUyMCUyMmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRlhpYW5nLWNkJTJGRGlmZkVkaXQtc3RhYmxlLWRpZmZ1c2lvbiUyRnJhdyUyRm1haW4lMkZhc3NldHMlMkZvcmlnaW4ucG5nJTIyJTBBJTBBaW5pdF9pbWFnZSUyMCUzRCUyMGRvd25sb2FkX2ltYWdlKGltZ191cmwpLnJlc2l6ZSgoNzY4JTJDJTIwNzY4KSklMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uRGlmZkVkaXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTItMSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMERESU1TY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEFwaXBlbGluZS5pbnZlcnNlX3NjaGVkdWxlciUyMCUzRCUyMERESU1JbnZlcnNlU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEElMEFtYXNrX3Byb21wdCUyMCUzRCUyMCUyMkElMjBib3dsJTIwb2YlMjBmcnVpdHMlMjIlMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwYm93bCUyMG9mJTIwcGVhcnMlMjIlMEElMEFtYXNrX2ltYWdlJTIwJTNEJTIwcGlwZS5nZW5lcmF0ZV9tYXNrKGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMHNvdXJjZV9wcm9tcHQlM0Rwcm9tcHQlMkMlMjB0YXJnZXRfcHJvbXB0JTNEbWFza19wcm9tcHQpJTBBaW1hZ2VfbGF0ZW50cyUyMCUzRCUyMHBpcGUuaW52ZXJ0KGltYWdlJTNEaW5pdF9pbWFnZSUyQyUyMHByb21wdCUzRG1hc2tfcHJvbXB0KS5sYXRlbnRzJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKHByb21wdCUzRHByb21wdCUyQyUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlJTJDJTIwaW1hZ2VfbGF0ZW50cyUzRGltYWdlX2xhdGVudHMpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> PIL
<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> 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> StableDiffusionDiffEditPipeline


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
<span class="hljs-meta">... </span>    response = requests.get(url)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> PIL.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>img_url = <span class="hljs-string">&quot;https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>init_image = download_image(img_url).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionDiffEditPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<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>pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.enable_model_cpu_offload()

<span class="hljs-meta">&gt;&gt;&gt; </span>mask_prompt = <span class="hljs-string">&quot;A bowl of fruits&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A bowl of pears&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>mask_image = pipe.generate_mask(image=init_image, source_prompt=prompt, target_prompt=mask_prompt)
<span class="hljs-meta">&gt;&gt;&gt; </span>image_latents = pipe.invert(image=init_image, prompt=mask_prompt).latents
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt=prompt, mask_image=mask_image, image_latents=image_latents).images[<span class="hljs-number">0</span>]`}}),{c(){g(w.$$.fragment)},l(f){u(w.$$.fragment,f)},m(f,U){h(w,f,U),v=!0},p:Jr,i(f){v||(b(w.$$.fragment,f),v=!0)},o(f){_(w.$$.fragment,f),v=!1},d(f){y(w,f)}}}function wd(X){let w,v,f,U,nn,Me,Vs,an,$s,fa,Je,ve,xs,Ns,ga,Ut,Fs,ua,Zt,sn,Ys,ha,D,Ps,Te,Hs,zs,Ue,Qs,As,ba,q,Ls,Ze,qs,Os,_a,F,O,on,Ee,Ks,ln,eo,ya,Z,rn,to,no,W,ao,pn,so,oo,dn,io,lo,cn,ro,po,co,E,mo,mn,fo,go,fn,uo,ho,gn,bo,_o,un,yo,wo,hn,Mo,Jo,vo,G,To,bn,Uo,Zo,_n,Eo,Io,Et,jo,ko,Wo,j,Go,yn,Bo,Ro,wn,Xo,Do,Mn,Co,So,Jn,Vo,$o,xo,It,No,Y,B,Fo,vn,Yo,Po,Tn,Ho,zo,Un,Qo,Ao,Lo,Ie,qo,Zn,Oo,Ko,ei,P,ti,En,ni,ai,In,si,oi,ii,je,li,jt,ri,pi,wa,H,K,jn,ke,di,kn,ci,Ma,z,ee,Wn,We,mi,Gn,fi,Ja,te,gi,Bn,ui,hi,va,kt,bi,Ta,Ge,Ua,Wt,_i,Za,Be,Ea,Gt,yi,Ia,Re,ja,Bt,wi,ka,Xe,Wa,Rt,Mi,Ga,De,Ba,Q,ne,Rn,Ce,Ji,Xn,vi,Ra,ae,Ti,Se,Ui,Zi,Xa,Xt,Ei,Da,Ve,Ca,Dt,Ii,Sa,$e,Va,Ct,ji,$a,xe,xa,St,ki,Na,Ne,Fa,Vt,Wi,Ya,Fe,Pa,A,se,Dn,Ye,Gi,Cn,Bi,Ha,oe,Ri,Pe,Xi,Di,za,He,Sn,Ci,Si,Qa,ze,Aa,Qe,Vn,Vi,$i,La,Ae,qa,$t,xi,Oa,Le,$n,Ni,Fi,Ka,xt,Yi,es,qe,ts,Nt,Pi,ns,Oe,as,C,Hi,xn,zi,Qi,Ke,Ai,Li,ss,et,Nn,qi,Oi,os,Ft,Ki,is,tt,ls,nt,Fn,el,tl,rs,at,ps,Yt,nl,ds,st,cs,L,ie,Yn,ot,al,Pn,sl,ms,M,it,ol,le,il,Hn,ll,rl,lt,pl,Pt,dl,cl,ml,zn,fl,gl,rt,pt,Qn,ul,hl,Ht,bl,_l,dt,An,yl,wl,zt,Ml,Jl,Ln,vl,Tl,qn,ct,On,Ul,Zl,Qt,El,Il,S,mt,jl,Kn,kl,Wl,re,Gl,V,ft,Bl,ea,Rl,Xl,pe,Dl,$,gt,Cl,ta,Sl,Vl,de,$l,ce,ut,xl,ht,Nl,na,Fl,Yl,Pl,me,bt,Hl,_t,zl,aa,Ql,Al,Ll,fe,yt,ql,R,Ol,sa,Kl,er,oa,tr,nr,ia,ar,sr,or,ge,wt,ir,la,lr,rr,ue,Mt,pr,ra,dr,cr,he,Jt,mr,pa,fr,fs;return Me=new Tt({}),Ee=new Tt({}),ke=new Tt({}),We=new Tt({}),Ge=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRERJTVNjaGVkdWxlciUyQyUyMERESU1JbnZlcnNlU2NoZWR1bGVyJTJDJTIwU3RhYmxlRGlmZnVzaW9uRGlmZkVkaXRQaXBlbGluZSUwQSUwQXNkX21vZGVsX2NrcHQlMjAlM0QlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24tMi0xJTIyJTBBcGlwZWxpbmUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25EaWZmRWRpdFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBzZF9tb2RlbF9ja3B0JTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBJTIwJTIwJTIwJTIwc2FmZXR5X2NoZWNrZXIlM0ROb25lJTJDJTBBKSUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMERESU1TY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEFwaXBlbGluZS5pbnZlcnNlX3NjaGVkdWxlciUyMCUzRCUyMERESU1JbnZlcnNlU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEFwaXBlbGluZS5lbmFibGVfdmFlX3NsaWNpbmcoKSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLm1hbnVhbF9zZWVkKDAp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMScheduler, DDIMInverseScheduler, StableDiffusionDiffEditPipeline

sd_model_ckpt = <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>
pipeline = StableDiffusionDiffEditPipeline.from_pretrained(
    sd_model_ckpt,
    torch_dtype=torch.float16,
    safety_checker=<span class="hljs-literal">None</span>,
)
pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
pipeline.enable_model_cpu_offload()
pipeline.enable_vae_slicing()
generator = torch.manual_seed(<span class="hljs-number">0</span>)`}}),Be=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEFpbWdfdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGWGlhbmctY2QlMkZEaWZmRWRpdC1zdGFibGUtZGlmZnVzaW9uJTJGcmF3JTJGbWFpbiUyRmFzc2V0cyUyRm9yaWdpbi5wbmclMjIlMEFyYXdfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKGltZ191cmwpLmNvbnZlcnQoJTIyUkdCJTIyKS5yZXNpemUoKDc2OCUyQyUyMDc2OCkp",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

img_url = <span class="hljs-string">&quot;https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png&quot;</span>
raw_image = load_image(img_url).convert(<span class="hljs-string">&quot;RGB&quot;</span>).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))`}}),Re=new T({props:{code:"JTIzJTIwU2VlJTIwdGhlJTIwJTIyR2VuZXJhdGluZyUyMHNvdXJjZSUyMGFuZCUyMHRhcmdldCUyMGVtYmVkZGluZ3MlMjIlMjBzZWN0aW9uJTIwYmVsb3clMjB0byUwQSUyMyUyMGF1dG9tYXRlJTIwdGhlJTIwZ2VuZXJhdGlvbiUyMG9mJTIwdGhlc2UlMjBjYXB0aW9ucyUyMHdpdGglMjBhJTIwcHJlLXRyYWluZWQlMjBtb2RlbCUyMGxpa2UlMjBGbGFuLVQ1JTIwYXMlMjBleHBsYWluZWQlMjBiZWxvdy4lMEElMEFzb3VyY2VfcHJvbXB0JTIwJTNEJTIwJTIyYSUyMGJvd2wlMjBvZiUyMGZydWl0cyUyMiUwQXRhcmdldF9wcm9tcHQlMjAlM0QlMjAlMjJhJTIwYmFza2V0JTIwb2YlMjBmcnVpdHMlMjIlMEFtYXNrX2ltYWdlJTIwJTNEJTIwcGlwZWxpbmUuZ2VuZXJhdGVfbWFzayglMEElMjAlMjAlMjAlMjBpbWFnZSUzRHJhd19pbWFnZSUyQyUwQSUyMCUyMCUyMCUyMHNvdXJjZV9wcm9tcHQlM0Rzb3VyY2VfcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwdGFyZ2V0X3Byb21wdCUzRHRhcmdldF9wcm9tcHQlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEEp",highlighted:`<span class="hljs-comment"># See the &quot;Generating source and target embeddings&quot; section below to</span>
<span class="hljs-comment"># automate the generation of these captions with a pre-trained model like Flan-T5 as explained below.</span>

source_prompt = <span class="hljs-string">&quot;a bowl of fruits&quot;</span>
target_prompt = <span class="hljs-string">&quot;a basket of fruits&quot;</span>
mask_image = pipeline.generate_mask(
    image=raw_image,
    source_prompt=source_prompt,
    target_prompt=target_prompt,
    generator=generator,
)`}}),Xe=new T({props:{code:"aW52X2xhdGVudHMlMjAlM0QlMjBwaXBlbGluZS5pbnZlcnQocHJvbXB0JTNEc291cmNlX3Byb21wdCUyQyUyMGltYWdlJTNEcmF3X2ltYWdlJTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yKS5sYXRlbnRz",highlighted:"inv_latents = pipeline.invert(prompt=source_prompt, image=raw_image, generator=generator).latents"}}),De=new T({props:{code:"aW1hZ2UlMjAlM0QlMjBwaXBlbGluZSglMEElMjAlMjAlMjAlMjBwcm9tcHQlM0R0YXJnZXRfcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjBpbWFnZV9sYXRlbnRzJTNEaW52X2xhdGVudHMlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEElMjAlMjAlMjAlMjBuZWdhdGl2ZV9wcm9tcHQlM0Rzb3VyY2VfcHJvbXB0JTJDJTBBKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJlZGl0ZWRfaW1hZ2UucG5nJTIyKQ==",highlighted:`image = pipeline(
    prompt=target_prompt,
    mask_image=mask_image,
    image_latents=inv_latents,
    generator=generator,
    negative_prompt=source_prompt,
).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;edited_image.png&quot;</span>)`}}),Ce=new Tt({}),Ve=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQmxpcEZvckNvbmRpdGlvbmFsR2VuZXJhdGlvbiUyQyUyMEJsaXBQcm9jZXNzb3IlMEElMEFjYXB0aW9uZXJfaWQlMjAlM0QlMjAlMjJTYWxlc2ZvcmNlJTJGYmxpcC1pbWFnZS1jYXB0aW9uaW5nLWJhc2UlMjIlMEFwcm9jZXNzb3IlMjAlM0QlMjBCbGlwUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZChjYXB0aW9uZXJfaWQpJTBBbW9kZWwlMjAlM0QlMjBCbGlwRm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZChjYXB0aW9uZXJfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjBsb3dfY3B1X21lbV91c2FnZSUzRFRydWUp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BlipForConditionalGeneration, BlipProcessor

captioner_id = <span class="hljs-string">&quot;Salesforce/blip-image-captioning-base&quot;</span>
processor = BlipProcessor.from_pretrained(captioner_id)
model = BlipForConditionalGeneration.from_pretrained(captioner_id, torch_dtype=torch.float16, low_cpu_mem_usage=<span class="hljs-literal">True</span>)`}}),$e=new T({props:{code:"JTQwdG9yY2gubm9fZ3JhZCgpJTBBZGVmJTIwZ2VuZXJhdGVfY2FwdGlvbihpbWFnZXMlMkMlMjBjYXB0aW9uX2dlbmVyYXRvciUyQyUyMGNhcHRpb25fcHJvY2Vzc29yKSUzQSUwQSUyMCUyMCUyMCUyMHRleHQlMjAlM0QlMjAlMjJhJTIwcGhvdG9ncmFwaCUyMG9mJTIyJTBBJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTIwJTNEJTIwY2FwdGlvbl9wcm9jZXNzb3IoaW1hZ2VzJTJDJTIwdGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLnRvKGRldmljZSUzRCUyMmN1ZGElMjIlMkMlMjBkdHlwZSUzRGNhcHRpb25fZ2VuZXJhdG9yLmR0eXBlKSUwQSUyMCUyMCUyMCUyMGNhcHRpb25fZ2VuZXJhdG9yLnRvKCUyMmN1ZGElMjIpJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMGNhcHRpb25fZ2VuZXJhdG9yLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMjgpJTBBJTBBJTIwJTIwJTIwJTIwJTIzJTIwb2ZmbG9hZCUyMGNhcHRpb24lMjBnZW5lcmF0b3IlMEElMjAlMjAlMjAlMjBjYXB0aW9uX2dlbmVyYXRvci50byglMjJjcHUlMjIpJTBBJTBBJTIwJTIwJTIwJTIwY2FwdGlvbiUyMCUzRCUyMGNhcHRpb25fcHJvY2Vzc29yLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTVCMCU1RCUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGNhcHRpb24=",highlighted:`<span class="hljs-meta">@torch.no_grad()</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">generate_caption</span>(<span class="hljs-params">images, caption_generator, caption_processor</span>):
    text = <span class="hljs-string">&quot;a photograph of&quot;</span>

    inputs = caption_processor(images, text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(device=<span class="hljs-string">&quot;cuda&quot;</span>, dtype=caption_generator.dtype)
    caption_generator.to(<span class="hljs-string">&quot;cuda&quot;</span>)
    outputs = caption_generator.generate(**inputs, max_new_tokens=<span class="hljs-number">128</span>)

    <span class="hljs-comment"># offload caption generator</span>
    caption_generator.to(<span class="hljs-string">&quot;cpu&quot;</span>)

    caption = caption_processor.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>]
    <span class="hljs-keyword">return</span> caption`}}),xe=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEFpbWdfdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGWGlhbmctY2QlMkZEaWZmRWRpdC1zdGFibGUtZGlmZnVzaW9uJTJGcmF3JTJGbWFpbiUyRmFzc2V0cyUyRm9yaWdpbi5wbmclMjIlMEFyYXdfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKGltZ191cmwpLmNvbnZlcnQoJTIyUkdCJTIyKS5yZXNpemUoKDc2OCUyQyUyMDc2OCkpJTBBY2FwdGlvbiUyMCUzRCUyMGdlbmVyYXRlX2NhcHRpb24ocmF3X2ltYWdlJTJDJTIwbW9kZWwlMkMlMjBwcm9jZXNzb3Ip",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

img_url = <span class="hljs-string">&quot;https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png&quot;</span>
raw_image = load_image(img_url).convert(<span class="hljs-string">&quot;RGB&quot;</span>).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))
caption = generate_caption(raw_image, model, processor)`}}),Ne=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERESU1JbnZlcnNlU2NoZWR1bGVyJTJDJTIwRERJTVNjaGVkdWxlciUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uRGlmZkVkaXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTItMSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFwaXBlbGluZSUyMCUzRCUyMHBpcGVsaW5lLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEFwaXBlbGluZS5lbmFibGVfdmFlX3NsaWNpbmcoKSUwQSUwQXBpcGVsaW5lLnNjaGVkdWxlciUyMCUzRCUyMERESU1TY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEFwaXBlbGluZS5pbnZlcnNlX3NjaGVkdWxlciUyMCUzRCUyMERESU1JbnZlcnNlU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWcpJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2gubWFudWFsX3NlZWQoMCklMEFpbnZfbGF0ZW50cyUyMCUzRCUyMHBpcGVsaW5lLmludmVydChwcm9tcHQlM0RjYXB0aW9uJTJDJTIwaW1hZ2UlM0RyYXdfaW1hZ2UlMkMlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IpLmxhdGVudHM=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMInverseScheduler, DDIMScheduler

pipeline = StableDiffusionDiffEditPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16
)
pipeline = pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_model_cpu_offload()
pipeline.enable_vae_slicing()

pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)

generator = torch.manual_seed(<span class="hljs-number">0</span>)
inv_latents = pipeline.invert(prompt=caption, image=raw_image, generator=generator).latents`}}),Fe=new T({props:{code:"c291cmNlX3Byb21wdCUyMCUzRCUyMCUyMmElMjBib3dsJTIwb2YlMjBmcnVpdHMlMjIlMEF0YXJnZXRfcHJvbXB0JTIwJTNEJTIwJTIyYSUyMGJhc2tldCUyMG9mJTIwZnJ1aXRzJTIyJTBBJTBBbWFza19pbWFnZSUyMCUzRCUyMHBpcGVsaW5lLmdlbmVyYXRlX21hc2soJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0RyYXdfaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjBzb3VyY2VfcHJvbXB0JTNEc291cmNlX3Byb21wdCUyQyUwQSUyMCUyMCUyMCUyMHRhcmdldF9wcm9tcHQlM0R0YXJnZXRfcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEdGFyZ2V0X3Byb21wdCUyQyUwQSUyMCUyMCUyMCUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlJTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2VfbGF0ZW50cyUzRGludl9sYXRlbnRzJTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEc291cmNlX3Byb21wdCUyQyUwQSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyZWRpdGVkX2ltYWdlLnBuZyUyMik=",highlighted:`source_prompt = <span class="hljs-string">&quot;a bowl of fruits&quot;</span>
target_prompt = <span class="hljs-string">&quot;a basket of fruits&quot;</span>

mask_image = pipeline.generate_mask(
    image=raw_image,
    source_prompt=source_prompt,
    target_prompt=target_prompt,
    generator=generator,
)

image = pipeline(
    prompt=target_prompt,
    mask_image=mask_image,
    image_latents=inv_latents,
    generator=generator,
    negative_prompt=source_prompt,
).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;edited_image.png&quot;</span>)`}}),Ye=new Tt({}),ze=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFQ1Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGZmxhbi10NS14bCUyMiklMEFtb2RlbCUyMCUzRCUyMFQ1Rm9yQ29uZGl0aW9uYWxHZW5lcmF0aW9uLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZmbGFuLXQ1LXhsJTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, T5ForConditionalGeneration

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/flan-t5-xl&quot;</span>)
model = T5ForConditionalGeneration.from_pretrained(<span class="hljs-string">&quot;google/flan-t5-xl&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>, torch_dtype=torch.float16)`}}),Ae=new T({props:{code:"c291cmNlX2NvbmNlcHQlMjAlM0QlMjAlMjJib3dsJTIyJTBBdGFyZ2V0X2NvbmNlcHQlMjAlM0QlMjAlMjJiYXNrZXQlMjIlMEElMEFzb3VyY2VfdGV4dCUyMCUzRCUyMGYlMjJQcm92aWRlJTIwYSUyMGNhcHRpb24lMjBmb3IlMjBpbWFnZXMlMjBjb250YWluaW5nJTIwYSUyMCU3QnNvdXJjZV9jb25jZXB0JTdELiUyMCUyMiUwQSUyMlRoZSUyMGNhcHRpb25zJTIwc2hvdWxkJTIwYmUlMjBpbiUyMEVuZ2xpc2glMjBhbmQlMjBzaG91bGQlMjBiZSUyMG5vJTIwbG9uZ2VyJTIwdGhhbiUyMDE1MCUyMGNoYXJhY3RlcnMuJTIyJTBBJTBBdGFyZ2V0X3RleHQlMjAlM0QlMjBmJTIyUHJvdmlkZSUyMGElMjBjYXB0aW9uJTIwZm9yJTIwaW1hZ2VzJTIwY29udGFpbmluZyUyMGElMjAlN0J0YXJnZXRfY29uY2VwdCU3RC4lMjAlMjIlMEElMjJUaGUlMjBjYXB0aW9ucyUyMHNob3VsZCUyMGJlJTIwaW4lMjBFbmdsaXNoJTIwYW5kJTIwc2hvdWxkJTIwYmUlMjBubyUyMGxvbmdlciUyMHRoYW4lMjAxNTAlMjBjaGFyYWN0ZXJzLiUyMg==",highlighted:`source_concept = <span class="hljs-string">&quot;bowl&quot;</span>
target_concept = <span class="hljs-string">&quot;basket&quot;</span>

source_text = <span class="hljs-string">f&quot;Provide a caption for images containing a <span class="hljs-subst">{source_concept}</span>. &quot;</span>
<span class="hljs-string">&quot;The captions should be in English and should be no longer than 150 characters.&quot;</span>

target_text = <span class="hljs-string">f&quot;Provide a caption for images containing a <span class="hljs-subst">{target_concept}</span>. &quot;</span>
<span class="hljs-string">&quot;The captions should be in English and should be no longer than 150 characters.&quot;</span>`}}),qe=new T({props:{code:"JTQwdG9yY2gubm9fZ3JhZCUwQWRlZiUyMGdlbmVyYXRlX3Byb21wdHMoaW5wdXRfcHJvbXB0KSUzQSUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplcihpbnB1dF9wcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5pbnB1dF9pZHMudG8oJTIyY3VkYSUyMiklMEElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaW5wdXRfaWRzJTJDJTIwdGVtcGVyYXR1cmUlM0QwLjglMkMlMjBudW1fcmV0dXJuX3NlcXVlbmNlcyUzRDE2JTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMTI4JTJDJTIwdG9wX2slM0QxMCUwQSUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKG91dHB1dHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSk=",highlighted:`<span class="hljs-meta">@torch.no_grad</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">generate_prompts</span>(<span class="hljs-params">input_prompt</span>):
    input_ids = tokenizer(input_prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids.to(<span class="hljs-string">&quot;cuda&quot;</span>)

    outputs = model.generate(
        input_ids, temperature=<span class="hljs-number">0.8</span>, num_return_sequences=<span class="hljs-number">16</span>, do_sample=<span class="hljs-literal">True</span>, max_new_tokens=<span class="hljs-number">128</span>, top_k=<span class="hljs-number">10</span>
    )
    <span class="hljs-keyword">return</span> tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)`}}),Oe=new T({props:{code:"c291cmNlX3Byb21wdHMlMjAlM0QlMjBnZW5lcmF0ZV9wcm9tcHRzKHNvdXJjZV90ZXh0KSUwQXRhcmdldF9wcm9tcHRzJTIwJTNEJTIwZ2VuZXJhdGVfcHJvbXB0cyh0YXJnZXRfdGV4dCk=",highlighted:`source_prompts = generate_prompts(source_text)
target_prompts = generate_prompts(target_text)`}}),tt=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkRpZmZFZGl0UGlwZWxpbmUlMjAlMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvbkRpZmZFZGl0UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi0yLTElMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpJTBBcGlwZWxpbmUlMjAlM0QlMjBwaXBlbGluZS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBcGlwZWxpbmUuZW5hYmxlX3ZhZV9zbGljaW5nKCklMEElMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5tYW51YWxfc2VlZCgwKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionDiffEditPipeline 

pipeline = StableDiffusionDiffEditPipeline.from_pretrained(
    <span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16
)
pipeline = pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.enable_model_cpu_offload()
pipeline.enable_vae_slicing()

generator = torch.manual_seed(<span class="hljs-number">0</span>)`}}),at=new T({props:{code:"aW1wb3J0JTIwdG9yY2glMjAlMEElMEElNDB0b3JjaC5ub19ncmFkKCklMEFkZWYlMjBlbWJlZF9wcm9tcHRzKHNlbnRlbmNlcyUyQyUyMHRva2VuaXplciUyQyUyMHRleHRfZW5jb2RlciUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIpJTNBJTBBJTIwJTIwJTIwJTIwZW1iZWRkaW5ncyUyMCUzRCUyMCU1QiU1RCUwQSUyMCUyMCUyMCUyMGZvciUyMHNlbnQlMjBpbiUyMHNlbnRlbmNlcyUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRleHRfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNlbnQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwYWRkaW5nJTNEJTIybWF4X2xlbmd0aCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1heF9sZW5ndGglM0R0b2tlbml6ZXIubW9kZWxfbWF4X2xlbmd0aCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRydW5jYXRpb24lM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0ZXh0X2lucHV0X2lkcyUyMCUzRCUyMHRleHRfaW5wdXRzLmlucHV0X2lkcyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByb21wdF9lbWJlZHMlMjAlM0QlMjB0ZXh0X2VuY29kZXIodGV4dF9pbnB1dF9pZHMudG8oZGV2aWNlKSUyQyUyMGF0dGVudGlvbl9tYXNrJTNETm9uZSklNUIwJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZW1iZWRkaW5ncy5hcHBlbmQocHJvbXB0X2VtYmVkcyklMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b3JjaC5jb25jYXRlbmF0ZShlbWJlZGRpbmdzJTJDJTIwZGltJTNEMCkubWVhbihkaW0lM0QwKS51bnNxdWVlemUoMCklMEElMEFzb3VyY2VfZW1iZWRkaW5ncyUyMCUzRCUyMGVtYmVkX3Byb21wdHMoc291cmNlX3Byb21wdHMlMkMlMjBwaXBlbGluZS50b2tlbml6ZXIlMkMlMjBwaXBlbGluZS50ZXh0X2VuY29kZXIpJTBBdGFyZ2V0X2VtYmVkZGluZ3MlMjAlM0QlMjBlbWJlZF9wcm9tcHRzKHRhcmdldF9jYXB0aW9ucyUyQyUyMHBpcGVsaW5lLnRva2VuaXplciUyQyUyMHBpcGVsaW5lLnRleHRfZW5jb2Rlcik=",highlighted:`<span class="hljs-keyword">import</span> torch 

<span class="hljs-meta">@torch.no_grad()</span>
<span class="hljs-keyword">def</span> <span class="hljs-title function_">embed_prompts</span>(<span class="hljs-params">sentences, tokenizer, text_encoder, device=<span class="hljs-string">&quot;cuda&quot;</span></span>):
    embeddings = []
    <span class="hljs-keyword">for</span> sent <span class="hljs-keyword">in</span> sentences:
        text_inputs = tokenizer(
            sent,
            padding=<span class="hljs-string">&quot;max_length&quot;</span>,
            max_length=tokenizer.model_max_length,
            truncation=<span class="hljs-literal">True</span>,
            return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
        )
        text_input_ids = text_inputs.input_ids
        prompt_embeds = text_encoder(text_input_ids.to(device), attention_mask=<span class="hljs-literal">None</span>)[<span class="hljs-number">0</span>]
        embeddings.append(prompt_embeds)
    <span class="hljs-keyword">return</span> torch.concatenate(embeddings, dim=<span class="hljs-number">0</span>).mean(dim=<span class="hljs-number">0</span>).unsqueeze(<span class="hljs-number">0</span>)

source_embeddings = embed_prompts(source_prompts, pipeline.tokenizer, pipeline.text_encoder)
target_embeddings = embed_prompts(target_captions, pipeline.tokenizer, pipeline.text_encoder)`}}),st=new T({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERESU1JbnZlcnNlU2NoZWR1bGVyJTJDJTIwRERJTVNjaGVkdWxlciUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBcGlwZWxpbmUuc2NoZWR1bGVyJTIwJTNEJTIwRERJTVNjaGVkdWxlci5mcm9tX2NvbmZpZyhwaXBlbGluZS5zY2hlZHVsZXIuY29uZmlnKSUwQXBpcGVsaW5lLmludmVyc2Vfc2NoZWR1bGVyJTIwJTNEJTIwRERJTUludmVyc2VTY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyklMEElMEFpbWdfdXJsJTIwJTNEJTIwJTIyaHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGWGlhbmctY2QlMkZEaWZmRWRpdC1zdGFibGUtZGlmZnVzaW9uJTJGcmF3JTJGbWFpbiUyRmFzc2V0cyUyRm9yaWdpbi5wbmclMjIlMEFyYXdfaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKGltZ191cmwpLmNvbnZlcnQoJTIyUkdCJTIyKS5yZXNpemUoKDc2OCUyQyUyMDc2OCkpJTBBJTBBJTBBbWFza19pbWFnZSUyMCUzRCUyMHBpcGVsaW5lLmdlbmVyYXRlX21hc2soJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0RyYXdfaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjBzb3VyY2VfcHJvbXB0X2VtYmVkcyUzRHNvdXJjZV9lbWJlZHMlMkMlMEElMjAlMjAlMjAlMjB0YXJnZXRfcHJvbXB0X2VtYmVkcyUzRHRhcmdldF9lbWJlZHMlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEEpJTBBJTBBaW52X2xhdGVudHMlMjAlM0QlMjBwaXBlbGluZS5pbnZlcnQoJTBBJTIwJTIwJTIwJTIwcHJvbXB0X2VtYmVkcyUzRHNvdXJjZV9lbWJlZHMlMkMlMEElMjAlMjAlMjAlMjBpbWFnZSUzRHJhd19pbWFnZSUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRvciUzRGdlbmVyYXRvciUyQyUwQSkubGF0ZW50cyUwQSUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMG1hc2tfaW1hZ2UlM0RtYXNrX2ltYWdlJTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2VfbGF0ZW50cyUzRGludl9sYXRlbnRzJTJDJTBBJTIwJTIwJTIwJTIwcHJvbXB0X2VtYmVkcyUzRHRhcmdldF9lbWJlZGRpbmdzJTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0X2VtYmVkcyUzRHNvdXJjZV9lbWJlZGRpbmdzJTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBKS5pbWFnZXMlMEFpbWFnZXMlNUIwJTVELnNhdmUoJTIyZWRpdGVkX2ltYWdlLnBuZyUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DDIMInverseScheduler, DDIMScheduler
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)

img_url = <span class="hljs-string">&quot;https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png&quot;</span>
raw_image = load_image(img_url).convert(<span class="hljs-string">&quot;RGB&quot;</span>).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>))


mask_image = pipeline.generate_mask(
    image=raw_image,
    source_prompt_embeds=source_embeds,
    target_prompt_embeds=target_embeds,
    generator=generator,
)

inv_latents = pipeline.invert(
    prompt_embeds=source_embeds,
    image=raw_image,
    generator=generator,
).latents

images = pipeline(
    mask_image=mask_image,
    image_latents=inv_latents,
    prompt_embeds=target_embeddings,
    negative_prompt_embeds=source_embeddings,
    generator=generator,
).images
images[<span class="hljs-number">0</span>].save(<span class="hljs-string">&quot;edited_image.png&quot;</span>)`}}),ot=new Tt({}),it=new N({props:{name:"class diffusers.StableDiffusionDiffEditPipeline",anchor:"diffusers.StableDiffusionDiffEditPipeline",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:"inverse_scheduler",val:": DDIMInverseScheduler"},{name:"requires_safety_checker",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDiffEditPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder (<a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a>).`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
A <a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/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.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.inverse_scheduler",description:`<strong>inverse_scheduler</strong> (<code>[DDIMInverseScheduler]</code>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to fill in the unmasked part of the input latents.`,name:"inverse_scheduler"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.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 more details
about a model&#x2019;s potential harms.`,name:"safety_checker"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
A <code>CLIPImageProcessor</code> to extract features from generated images; used as inputs to the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L240"}}),le=new ud({props:{warning:!0,$$slots:{default:[hd]},$$scope:{ctx:X}}}),mt=new N({props:{name:"generate_mask",anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask",parameters:[{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image] = None"},{name:"target_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"target_negative_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"target_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"target_negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"source_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"source_negative_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"source_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"source_negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"num_maps_per_mask",val:": typing.Optional[int] = 10"},{name:"mask_encode_strength",val:": typing.Optional[float] = 0.5"},{name:"mask_thresholding_ratio",val:": typing.Optional[float] = 3.0"},{name:"num_inference_steps",val:": int = 50"},{name:"guidance_scale",val:": float = 7.5"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"output_type",val:": typing.Optional[str] = 'np'"},{name:"cross_attention_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.image",description:`<strong>image</strong> (<code>PIL.Image.Image</code>) &#x2014;
<code>Image</code> or tensor representing an image batch to be used for computing the mask.`,name:"image"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.target_prompt",description:`<strong>target_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide semantic mask generation. If not defined, you need to pass
<code>prompt_embeds</code>.`,name:"target_prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.target_negative_prompt",description:`<strong>target_negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide what to not include in image generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"target_negative_prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.target_prompt_embeds",description:`<strong>target_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument.`,name:"target_prompt_embeds"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.target_negative_prompt_embeds",description:`<strong>target_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 (prompt weighting). If
not provided, <code>negative_prompt_embeds</code> are generated from the <code>negative_prompt</code> input argument.`,name:"target_negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.source_prompt",description:`<strong>source_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide semantic mask generation using DiffEdit. If not defined, you need to
pass <code>source_prompt_embeds</code> or <code>source_image</code> instead.`,name:"source_prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.source_negative_prompt",description:`<strong>source_negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide semantic mask generation away from using DiffEdit. If not defined, you
need to pass <code>source_negative_prompt_embeds</code> or <code>source_image</code> instead.`,name:"source_negative_prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.source_prompt_embeds",description:`<strong>source_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings to guide the semantic mask generation. Can be used to easily tweak text
inputs (prompt weighting). If not provided, text embeddings are generated from <code>source_prompt</code> input
argument.`,name:"source_prompt_embeds"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.source_negative_prompt_embeds",description:`<strong>source_negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings to negatively guide the semantic mask generation. Can be used to easily
tweak text inputs (prompt weighting). If not provided, text embeddings are generated from
<code>source_negative_prompt</code> input argument.`,name:"source_negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.num_maps_per_mask",description:`<strong>num_maps_per_mask</strong> (<code>int</code>, <em>optional</em>, defaults to 10) &#x2014;
The number of noise maps sampled to generate the semantic mask using DiffEdit.`,name:"num_maps_per_mask"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.mask_encode_strength",description:`<strong>mask_encode_strength</strong> (<code>float</code>, <em>optional</em>, defaults to 0.5) &#x2014;
The strength of the noise maps sampled to generate the semantic mask using DiffEdit. Must be between 0
and 1.`,name:"mask_encode_strength"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.mask_thresholding_ratio",description:`<strong>mask_thresholding_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 3.0) &#x2014;
The maximum multiple of the mean absolute difference used to clamp the semantic guidance map before
mask binarization.`,name:"mask_thresholding_ratio"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.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.StableDiffusionDiffEditPipeline.generate_mask.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.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 generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.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 in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow"><code>self.processor</code></a>.`,name:"cross_attention_kwargs"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L863",returnDescription:`
<p>When returning a <code>List[PIL.Image.Image]</code>, the list consists of a batch of single-channel binary images
with dimensions <code>(height // self.vae_scale_factor, width // self.vae_scale_factor)</code>. If it\u2019s
<code>np.array</code>, the shape is <code>(batch_size, height // self.vae_scale_factor, width // self.vae_scale_factor)</code>.</p>
`,returnType:`
<p><code>List[PIL.Image.Image]</code> or <code>np.array</code></p>
`}}),re=new Mr({props:{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.example",$$slots:{default:[bd]},$$scope:{ctx:X}}}),ft=new N({props:{name:"invert",anchor:"diffusers.StableDiffusionDiffEditPipeline.invert",parameters:[{name:"prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image] = None"},{name:"num_inference_steps",val:": int = 50"},{name:"inpaint_strength",val:": float = 0.8"},{name:"guidance_scale",val:": float = 7.5"},{name:"negative_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{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:"decode_latents",val:": bool = False"},{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:": typing.Optional[int] = 1"},{name:"cross_attention_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"lambda_auto_corr",val:": float = 20.0"},{name:"lambda_kl",val:": float = 20.0"},{name:"num_reg_steps",val:": int = 0"},{name:"num_auto_corr_rolls",val:": int = 5"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide image generation. If not defined, you need to pass <code>prompt_embeds</code>.`,name:"prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.image",description:`<strong>image</strong> (<code>PIL.Image.Image</code>) &#x2014;
<code>Image</code> or tensor representing an image batch to produce the inverted latents guided by <code>prompt</code>.`,name:"image"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.inpaint_strength",description:`<strong>inpaint_strength</strong> (<code>float</code>, <em>optional</em>, defaults to 0.8) &#x2014;
Indicates extent of the noising process to run latent inversion. Must be between 0 and 1. When
<code>strength</code> is 1, the inversion process iss ru for the full number of iterations specified in
<code>num_inference_steps</code>. <code>image</code> is used as a reference for the inversion process, adding more noise the
larger the <code>strength</code>. If <code>strength</code> is 0, no inpainting occurs.`,name:"inpaint_strength"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.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.StableDiffusionDiffEditPipeline.invert.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide what to not include in image generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.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 (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.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 (prompt weighting). If
not provided, <code>negative_prompt_embeds</code> are generated from the <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.decode_latents",description:`<strong>decode_latents</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to decode the inverted latents into a generated image. Setting this argument to <code>True</code>
decodes all inverted latents for each timestep into a list of generated images.`,name:"decode_latents"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.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 generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.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>~pipelines.stable_diffusion.DiffEditInversionPipelineOutput</code> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.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 is called. If not specified, the callback is called at
every step.`,name:"callback_steps"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.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 in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow"><code>self.processor</code></a>.`,name:"cross_attention_kwargs"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.lambda_auto_corr",description:`<strong>lambda_auto_corr</strong> (<code>float</code>, <em>optional</em>, defaults to 20.0) &#x2014;
Lambda parameter to control auto correction.`,name:"lambda_auto_corr"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.lambda_kl",description:`<strong>lambda_kl</strong> (<code>float</code>, <em>optional</em>, defaults to 20.0) &#x2014;
Lambda parameter to control Kullback&#x2013;Leibler divergence output.`,name:"lambda_kl"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.num_reg_steps",description:`<strong>num_reg_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
Number of regularization loss steps.`,name:"num_reg_steps"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.num_auto_corr_rolls",description:`<strong>num_auto_corr_rolls</strong> (<code>int</code>, <em>optional</em>, defaults to 5) &#x2014;
Number of auto correction roll steps.`,name:"num_auto_corr_rolls"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L1082",returnDescription:`
<p><code>DiffEditInversionPipelineOutput</code> or
<code>tuple</code>:
If <code>return_dict</code> is <code>True</code>,
<code>DiffEditInversionPipelineOutput</code> is
returned, otherwise a <code>tuple</code> is returned where the first element is the inverted latents tensors
ordered by increasing noise, and the second is the corresponding decoded images if <code>decode_latents</code> is
<code>True</code>, otherwise <code>None</code>.</p>
`}}),pe=new Mr({props:{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.example",$$slots:{default:[_d]},$$scope:{ctx:X}}}),gt=new N({props:{name:"__call__",anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"mask_image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image] = None"},{name:"image_latents",val:": typing.Union[torch.FloatTensor, PIL.Image.Image] = None"},{name:"inpaint_strength",val:": typing.Optional[float] = 0.8"},{name:"num_inference_steps",val:": int = 50"},{name:"guidance_scale",val:": float = 7.5"},{name:"negative_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = 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.StableDiffusionDiffEditPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide image generation. If not defined, you need to pass <code>prompt_embeds</code>.`,name:"prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.mask_image",description:`<strong>mask_image</strong> (<code>PIL.Image.Image</code>) &#x2014;
<code>Image</code> or tensor representing an image batch to mask the generated image. White pixels in the mask are
repainted, while black pixels are preserved. If <code>mask_image</code> is a PIL image, it is converted to a
single channel (luminance) before use. If it&#x2019;s a tensor, it should contain one color channel (L)
instead of 3, so the expected shape would be <code>(B, 1, H, W)</code>.`,name:"mask_image"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.image_latents",description:`<strong>image_latents</strong> (<code>PIL.Image.Image</code> or <code>torch.FloatTensor</code>) &#x2014;
Partially noised image latents from the inversion process to be used as inputs for image generation.`,name:"image_latents"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.inpaint_strength",description:`<strong>inpaint_strength</strong> (<code>float</code>, <em>optional</em>, defaults to 0.8) &#x2014;
Indicates extent to inpaint the masked area. Must be between 0 and 1. When <code>strength</code> is 1, the
denoising process is run on the masked area for the full number of iterations specified in
<code>num_inference_steps</code>. <code>image_latents</code> is used as a reference for the masked area, adding more noise to
that region the larger the <code>strength</code>. If <code>strength</code> is 0, no inpainting occurs.`,name:"inpaint_strength"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__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.StableDiffusionDiffEditPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide what to not include in image generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__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.StableDiffusionDiffEditPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</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. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__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 (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__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 (prompt weighting). If
not provided, <code>negative_prompt_embeds</code> are generated from the <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__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 generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__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/main/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__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 is called. If not specified, the callback is called at
every step.`,name:"callback_steps"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.__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 in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow"><code>self.processor</code></a>.`,name:"cross_attention_kwargs"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L1319",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images and the
second element is a list of <code>bool</code>s indicating whether the corresponding generated image contains
\u201Cnot-safe-for-work\u201D (nsfw) content.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),de=new Mr({props:{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.example",$$slots:{default:[yd]},$$scope:{ctx:X}}}),ut=new N({props:{name:"disable_vae_slicing",anchor:"diffusers.StableDiffusionDiffEditPipeline.disable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L384"}}),bt=new N({props:{name:"disable_vae_tiling",anchor:"diffusers.StableDiffusionDiffEditPipeline.disable_vae_tiling",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L401"}}),yt=new N({props:{name:"enable_model_cpu_offload",anchor:"diffusers.StableDiffusionDiffEditPipeline.enable_model_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L409"}}),wt=new N({props:{name:"enable_vae_slicing",anchor:"diffusers.StableDiffusionDiffEditPipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L376"}}),Mt=new N({props:{name:"enable_vae_tiling",anchor:"diffusers.StableDiffusionDiffEditPipeline.enable_vae_tiling",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L392"}}),Jt=new N({props:{name:"encode_prompt",anchor:"diffusers.StableDiffusionDiffEditPipeline.encode_prompt",parameters:[{name:"prompt",val:""},{name:"device",val:""},{name:"num_images_per_prompt",val:""},{name:"do_classifier_free_guidance",val:""},{name:"negative_prompt",val:" = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"lora_scale",val:": typing.Optional[float] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionDiffEditPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded
device &#x2014; (<code>torch.device</code>):
torch device`,name:"prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) &#x2014;
number of images that should be generated per prompt`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>) &#x2014;
whether to use classifier free guidance or not`,name:"do_classifier_free_guidance"},{anchor:"diffusers.StableDiffusionDiffEditPipeline.encode_prompt.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.StableDiffusionDiffEditPipeline.encode_prompt.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.StableDiffusionDiffEditPipeline.encode_prompt.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.StableDiffusionDiffEditPipeline.encode_prompt.lora_scale",description:`<strong>lora_scale</strong> (<code>float</code>, <em>optional</em>) &#x2014;
A lora scale that will be applied to all LoRA layers of the text encoder if LoRA layers are loaded.`,name:"lora_scale"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py#L469"}}),{c(){w=a("meta"),v=p(),f=a("h1"),U=a("a"),nn=a("span"),g(Me.$$.fragment),Vs=p(),an=a("span"),$s=o("DiffEdit"),fa=p(),Je=a("p"),ve=a("a"),xs=o("DiffEdit: Diffusion-based semantic image editing with mask guidance"),Ns=o(" is by Guillaume Couairon, Jakob Verbeek, Holger Schwenk, and Matthieu Cord."),ga=p(),Ut=a("p"),Fs=o("The abstract from the paper is:"),ua=p(),Zt=a("p"),sn=a("em"),Ys=o("Image generation has recently seen tremendous advances, with diffusion models allowing to synthesize convincing images for a large variety of text prompts. In this article, we propose DiffEdit, a method to take advantage of text-conditioned diffusion models for the task of semantic image editing, where the goal is to edit an image based on a text query. Semantic image editing is an extension of image generation, with the additional constraint that the generated image should be as similar as possible to a given input image. Current editing methods based on diffusion models usually require to provide a mask, making the task much easier by treating it as a conditional inpainting task. In contrast, our main contribution is able to automatically generate a mask highlighting regions of the input image that need to be edited, by contrasting predictions of a diffusion model conditioned on different text prompts. Moreover, we rely on latent inference to preserve content in those regions of interest and show excellent synergies with mask-based diffusion. DiffEdit achieves state-of-the-art editing performance on ImageNet. In addition, we evaluate semantic image editing in more challenging settings, using images from the COCO dataset as well as text-based generated images."),ha=p(),D=a("p"),Ps=o("The original codebase can be found at "),Te=a("a"),Hs=o("Xiang-cd/DiffEdit-stable-diffusion"),zs=o(", and you can try it out in this "),Ue=a("a"),Qs=o("demo"),As=o("."),ba=p(),q=a("p"),Ls=o("This pipeline was contributed by "),Ze=a("a"),qs=o("clarencechen"),Os=o(". \u2764\uFE0F"),_a=p(),F=a("h2"),O=a("a"),on=a("span"),g(Ee.$$.fragment),Ks=p(),ln=a("span"),eo=o("Tips"),ya=p(),Z=a("ul"),rn=a("li"),to=o("The pipeline can generate masks that can be fed into other inpainting pipelines. Check out the code examples below to know more."),no=p(),W=a("li"),ao=o("In order to generate an image using this pipeline, both an image mask (manually specified or generated using "),pn=a("code"),so=o("generate_mask"),oo=o(`)
and a set of partially inverted latents (generated using `),dn=a("code"),io=o("invert"),lo=o(") "),cn=a("em"),ro=o("must"),po=o(` be provided as arguments when calling the pipeline to generate the final edited image.
Refer to the code examples below for more details.`),co=p(),E=a("li"),mo=o("The function "),mn=a("code"),fo=o("generate_mask"),go=o(" exposes two prompt arguments, "),fn=a("code"),uo=o("source_prompt"),ho=o(" and "),gn=a("code"),bo=o("target_prompt"),_o=o(`,
that let you control the locations of the semantic edits in the final image to be generated. Let\u2019s say,
you wanted to translate from \u201Ccat\u201D to \u201Cdog\u201D. In this case, the edit direction will be \u201Ccat -> dog\u201D. To reflect
this in the generated mask, you simply have to set the embeddings related to the phrases including \u201Ccat\u201D to
`),un=a("code"),yo=o("source_prompt_embeds"),wo=o(" and \u201Cdog\u201D to "),hn=a("code"),Mo=o("target_prompt_embeds"),Jo=o(". Refer to the code example below for more details."),vo=p(),G=a("li"),To=o("When generating partially inverted latents using "),bn=a("code"),Uo=o("invert"),Zo=o(`, assign a caption or text embedding describing the
overall image to the `),_n=a("code"),Eo=o("prompt"),Io=o(` argument to help guide the inverse latent sampling process. In most cases, the
source concept is sufficently descriptive to yield good results, but feel free to explore alternatives.
Please refer to `),Et=a("a"),jo=o("this code example"),ko=o(" for more details."),Wo=p(),j=a("li"),Go=o("When calling the pipeline to generate the final edited image, assign the source concept to "),yn=a("code"),Bo=o("negative_prompt"),Ro=o(`
and the target concept to `),wn=a("code"),Xo=o("prompt"),Do=o(`. Taking the above example, you simply have to set the embeddings related to
the phrases including \u201Ccat\u201D to `),Mn=a("code"),Co=o("negative_prompt_embeds"),So=o(" and \u201Cdog\u201D to "),Jn=a("code"),Vo=o("prompt_embeds"),$o=o(`. Refer to the code example
below for more details.`),xo=p(),It=a("li"),No=o("If you wanted to reverse the direction in the example above, i.e., \u201Cdog -> cat\u201D, then it\u2019s recommended to:"),Y=a("ul"),B=a("li"),Fo=o("Swap the "),vn=a("code"),Yo=o("source_prompt"),Po=o(" and "),Tn=a("code"),Ho=o("target_prompt"),zo=o(" in the arguments to "),Un=a("code"),Qo=o("generate_mask"),Ao=o("."),Lo=p(),Ie=a("li"),qo=o("Change the input prompt for "),Zn=a("code"),Oo=o("invert"),Ko=o(" to include \u201Cdog\u201D."),ei=p(),P=a("li"),ti=o("Swap the "),En=a("code"),ni=o("prompt"),ai=o(" and "),In=a("code"),si=o("negative_prompt"),oi=o(" in the arguments to call the pipeline to generate the final edited image."),ii=p(),je=a("li"),li=o("Note that the source and target prompts, or their corresponding embeddings, can also be automatically generated. Please, refer to "),jt=a("a"),ri=o("this discussion"),pi=o(" for more details."),wa=p(),H=a("h2"),K=a("a"),jn=a("span"),g(ke.$$.fragment),di=p(),kn=a("span"),ci=o("Usage example"),Ma=p(),z=a("h3"),ee=a("a"),Wn=a("span"),g(We.$$.fragment),mi=p(),Gn=a("span"),fi=o("Based on an input image with a caption"),Ja=p(),te=a("p"),gi=o(`When the pipeline is conditioned on an input image, we first obtain partially inverted latents from the input image using a
`),Bn=a("code"),ui=o("DDIMInverseScheduler"),hi=o(` with the help of a caption. Then we generate an editing mask to identify relevant regions in the image using the source and target prompts. Finally,
the inverted noise and generated mask is used to start the generation process.`),va=p(),kt=a("p"),bi=o("First, let\u2019s load our pipeline:"),Ta=p(),g(Ge.$$.fragment),Ua=p(),Wt=a("p"),_i=o("Then, we load an input image to edit using our method:"),Za=p(),g(Be.$$.fragment),Ea=p(),Gt=a("p"),yi=o("Then, we employ the source and target prompts to generate the editing mask:"),Ia=p(),g(Re.$$.fragment),ja=p(),Bt=a("p"),wi=o("Then, we employ the caption and the input image to get the inverted latents:"),ka=p(),g(Xe.$$.fragment),Wa=p(),Rt=a("p"),Mi=o("Now, generate the image with the inverted latents and semantically generated mask:"),Ga=p(),g(De.$$.fragment),Ba=p(),Q=a("h2"),ne=a("a"),Rn=a("span"),g(Ce.$$.fragment),Ji=p(),Xn=a("span"),vi=o("Generating image captions for inversion"),Ra=p(),ae=a("p"),Ti=o(`The authors originally used the source concept prompt as the caption for generating the partially inverted latents. However, we can also leverage open source and public image captioning models for the same purpose.
Below, we provide an end-to-end example with the `),Se=a("a"),Ui=o("BLIP"),Zi=o(` model
for generating captions.`),Xa=p(),Xt=a("p"),Ei=o("First, let\u2019s load our automatic image captioning model:"),Da=p(),g(Ve.$$.fragment),Ca=p(),Dt=a("p"),Ii=o("Then, we define a utility to generate captions from an input image using the model:"),Sa=p(),g($e.$$.fragment),Va=p(),Ct=a("p"),ji=o("Then, we load an input image for conditioning and obtain a suitable caption for it:"),$a=p(),g(xe.$$.fragment),xa=p(),St=a("p"),ki=o("Then, we employ the generated caption and the input image to get the inverted latents:"),Na=p(),g(Ne.$$.fragment),Fa=p(),Vt=a("p"),Wi=o("Now, generate the image with the inverted latents and semantically generated mask from our source and target prompts:"),Ya=p(),g(Fe.$$.fragment),Pa=p(),A=a("h2"),se=a("a"),Dn=a("span"),g(Ye.$$.fragment),Gi=p(),Cn=a("span"),Bi=o("Generating source and target embeddings"),Ha=p(),oe=a("p"),Ri=o(`The authors originally required the user to manually provide the source and target prompts for discovering
edit directions. However, we can also leverage open source and public models for the same purpose.
Below, we provide an end-to-end example with the `),Pe=a("a"),Xi=o("Flan-T5"),Di=o(` model
for generating source an target embeddings.`),za=p(),He=a("p"),Sn=a("strong"),Ci=o("1. Load the generation model"),Si=o(":"),Qa=p(),g(ze.$$.fragment),Aa=p(),Qe=a("p"),Vn=a("strong"),Vi=o("2. Construct a starting prompt"),$i=o(":"),La=p(),g(Ae.$$.fragment),qa=p(),$t=a("p"),xi=o("Here, we\u2019re interested in the \u201Cbowl -> basket\u201D direction."),Oa=p(),Le=a("p"),$n=a("strong"),Ni=o("3. Generate prompts"),Fi=o(":"),Ka=p(),xt=a("p"),Yi=o("We can use a utility like so for this purpose."),es=p(),g(qe.$$.fragment),ts=p(),Nt=a("p"),Pi=o("And then we just call it to generate our prompts:"),ns=p(),g(Oe.$$.fragment),as=p(),C=a("p"),Hi=o(`We encourage you to play around with the different parameters supported by the
`),xn=a("code"),zi=o("generate()"),Qi=o(" method ("),Ke=a("a"),Ai=o("documentation"),Li=o(") for the generation quality you are looking for."),ss=p(),et=a("p"),Nn=a("strong"),qi=o("4. Load the embedding model"),Oi=o(":"),os=p(),Ft=a("p"),Ki=o("Here, we need to use the same text encoder model used by the subsequent Stable Diffusion model."),is=p(),g(tt.$$.fragment),ls=p(),nt=a("p"),Fn=a("strong"),el=o("5. Compute embeddings"),tl=o(":"),rs=p(),g(at.$$.fragment),ps=p(),Yt=a("p"),nl=o("And you\u2019re done! Now, you can use these embeddings directly while calling the pipeline:"),ds=p(),g(st.$$.fragment),cs=p(),L=a("h2"),ie=a("a"),Yn=a("span"),g(ot.$$.fragment),al=p(),Pn=a("span"),sl=o("StableDiffusionDiffEditPipeline"),ms=p(),M=a("div"),g(it.$$.fragment),ol=p(),g(le.$$.fragment),il=p(),Hn=a("p"),ll=o("Pipeline for text-guided image inpainting using Stable Diffusion and DiffEdit."),rl=p(),lt=a("p"),pl=o("This model inherits from "),Pt=a("a"),dl=o("DiffusionPipeline"),cl=o(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),ml=p(),zn=a("p"),fl=o("In addition the pipeline inherits the following loading methods:"),gl=p(),rt=a("ul"),pt=a("li"),Qn=a("em"),ul=o("Textual-Inversion"),hl=o(": "),Ht=a("a"),bl=o("loaders.TextualInversionLoaderMixin.load_textual_inversion()"),_l=p(),dt=a("li"),An=a("em"),yl=o("LoRA"),wl=o(": "),zt=a("a"),Ml=o("loaders.LoraLoaderMixin.load_lora_weights()"),Jl=p(),Ln=a("p"),vl=o("as well as the following saving methods:"),Tl=p(),qn=a("ul"),ct=a("li"),On=a("em"),Ul=o("LoRA"),Zl=o(": "),Qt=a("a"),El=o("loaders.LoraLoaderMixin.save_lora_weights()"),Il=p(),S=a("div"),g(mt.$$.fragment),jl=p(),Kn=a("p"),kl=o("Generate a latent mask given a mask prompt, a target prompt, and an image."),Wl=p(),g(re.$$.fragment),Gl=p(),V=a("div"),g(ft.$$.fragment),Bl=p(),ea=a("p"),Rl=o("Generate inverted latents given a prompt and image."),Xl=p(),g(pe.$$.fragment),Dl=p(),$=a("div"),g(gt.$$.fragment),Cl=p(),ta=a("p"),Sl=o("The call function to the pipeline for generation."),Vl=p(),g(de.$$.fragment),$l=p(),ce=a("div"),g(ut.$$.fragment),xl=p(),ht=a("p"),Nl=o("Disable sliced VAE decoding. If "),na=a("code"),Fl=o("enable_vae_slicing"),Yl=o(` was previously enabled, this method will go back to
computing decoding in one step.`),Pl=p(),me=a("div"),g(bt.$$.fragment),Hl=p(),_t=a("p"),zl=o("Disable tiled VAE decoding. If "),aa=a("code"),Ql=o("enable_vae_tiling"),Al=o(` was previously enabled, this method will go back to
computing decoding in one step.`),Ll=p(),fe=a("div"),g(yt.$$.fragment),ql=p(),R=a("p"),Ol=o(`Offload all models to CPU to reduce memory usage with a low impact on performance. Moves one whole model at a
time to the GPU when its `),sa=a("code"),Kl=o("forward"),er=o(` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),oa=a("code"),tr=o("enable_sequential_cpu_offload"),nr=o(`, but performance is much better due to the
iterative execution of the `),ia=a("code"),ar=o("unet"),sr=o("."),or=p(),ge=a("div"),g(wt.$$.fragment),ir=p(),la=a("p"),lr=o(`Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.`),rr=p(),ue=a("div"),g(Mt.$$.fragment),pr=p(),ra=a("p"),dr=o(`Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
processing larger images.`),cr=p(),he=a("div"),g(Jt.$$.fragment),mr=p(),pa=a("p"),fr=o("Encodes the prompt into text encoder hidden states."),this.h()},l(e){const r=fd('[data-svelte="svelte-1phssyn"]',document.head);w=s(r,"META",{name:!0,content:!0}),r.forEach(n),v=d(e),f=s(e,"H1",{class:!0});var vt=i(f);U=s(vt,"A",{id:!0,class:!0,href:!0});var da=i(U);nn=s(da,"SPAN",{});var ca=i(nn);u(Me.$$.fragment,ca),ca.forEach(n),da.forEach(n),Vs=d(vt),an=s(vt,"SPAN",{});var ma=i(an);$s=l(ma,"DiffEdit"),ma.forEach(n),vt.forEach(n),fa=d(e),Je=s(e,"P",{});var gr=i(Je);ve=s(gr,"A",{href:!0,rel:!0});var vr=i(ve);xs=l(vr,"DiffEdit: Diffusion-based semantic image editing with mask guidance"),vr.forEach(n),Ns=l(gr," is by Guillaume Couairon, Jakob Verbeek, Holger Schwenk, and Matthieu Cord."),gr.forEach(n),ga=d(e),Ut=s(e,"P",{});var Tr=i(Ut);Fs=l(Tr,"The abstract from the paper is:"),Tr.forEach(n),ua=d(e),Zt=s(e,"P",{});var Ur=i(Zt);sn=s(Ur,"EM",{});var Zr=i(sn);Ys=l(Zr,"Image generation has recently seen tremendous advances, with diffusion models allowing to synthesize convincing images for a large variety of text prompts. In this article, we propose DiffEdit, a method to take advantage of text-conditioned diffusion models for the task of semantic image editing, where the goal is to edit an image based on a text query. Semantic image editing is an extension of image generation, with the additional constraint that the generated image should be as similar as possible to a given input image. Current editing methods based on diffusion models usually require to provide a mask, making the task much easier by treating it as a conditional inpainting task. In contrast, our main contribution is able to automatically generate a mask highlighting regions of the input image that need to be edited, by contrasting predictions of a diffusion model conditioned on different text prompts. Moreover, we rely on latent inference to preserve content in those regions of interest and show excellent synergies with mask-based diffusion. DiffEdit achieves state-of-the-art editing performance on ImageNet. In addition, we evaluate semantic image editing in more challenging settings, using images from the COCO dataset as well as text-based generated images."),Zr.forEach(n),Ur.forEach(n),ha=d(e),D=s(e,"P",{});var At=i(D);Ps=l(At,"The original codebase can be found at "),Te=s(At,"A",{href:!0,rel:!0});var Er=i(Te);Hs=l(Er,"Xiang-cd/DiffEdit-stable-diffusion"),Er.forEach(n),zs=l(At,", and you can try it out in this "),Ue=s(At,"A",{href:!0,rel:!0});var Ir=i(Ue);Qs=l(Ir,"demo"),Ir.forEach(n),As=l(At,"."),At.forEach(n),ba=d(e),q=s(e,"P",{});var gs=i(q);Ls=l(gs,"This pipeline was contributed by "),Ze=s(gs,"A",{href:!0,rel:!0});var jr=i(Ze);qs=l(jr,"clarencechen"),jr.forEach(n),Os=l(gs,". \u2764\uFE0F"),gs.forEach(n),_a=d(e),F=s(e,"H2",{class:!0});var us=i(F);O=s(us,"A",{id:!0,class:!0,href:!0});var kr=i(O);on=s(kr,"SPAN",{});var Wr=i(on);u(Ee.$$.fragment,Wr),Wr.forEach(n),kr.forEach(n),Ks=d(us),ln=s(us,"SPAN",{});var Gr=i(ln);eo=l(Gr,"Tips"),Gr.forEach(n),us.forEach(n),ya=d(e),Z=s(e,"UL",{});var I=i(Z);rn=s(I,"LI",{});var Br=i(rn);to=l(Br,"The pipeline can generate masks that can be fed into other inpainting pipelines. Check out the code examples below to know more."),Br.forEach(n),no=d(I),W=s(I,"LI",{});var be=i(W);ao=l(be,"In order to generate an image using this pipeline, both an image mask (manually specified or generated using "),pn=s(be,"CODE",{});var Rr=i(pn);so=l(Rr,"generate_mask"),Rr.forEach(n),oo=l(be,`)
and a set of partially inverted latents (generated using `),dn=s(be,"CODE",{});var Xr=i(dn);io=l(Xr,"invert"),Xr.forEach(n),lo=l(be,") "),cn=s(be,"EM",{});var Dr=i(cn);ro=l(Dr,"must"),Dr.forEach(n),po=l(be,` be provided as arguments when calling the pipeline to generate the final edited image.
Refer to the code examples below for more details.`),be.forEach(n),co=d(I),E=s(I,"LI",{});var k=i(E);mo=l(k,"The function "),mn=s(k,"CODE",{});var Cr=i(mn);fo=l(Cr,"generate_mask"),Cr.forEach(n),go=l(k," exposes two prompt arguments, "),fn=s(k,"CODE",{});var Sr=i(fn);uo=l(Sr,"source_prompt"),Sr.forEach(n),ho=l(k," and "),gn=s(k,"CODE",{});var Vr=i(gn);bo=l(Vr,"target_prompt"),Vr.forEach(n),_o=l(k,`,
that let you control the locations of the semantic edits in the final image to be generated. Let\u2019s say,
you wanted to translate from \u201Ccat\u201D to \u201Cdog\u201D. In this case, the edit direction will be \u201Ccat -> dog\u201D. To reflect
this in the generated mask, you simply have to set the embeddings related to the phrases including \u201Ccat\u201D to
`),un=s(k,"CODE",{});var $r=i(un);yo=l($r,"source_prompt_embeds"),$r.forEach(n),wo=l(k," and \u201Cdog\u201D to "),hn=s(k,"CODE",{});var xr=i(hn);Mo=l(xr,"target_prompt_embeds"),xr.forEach(n),Jo=l(k,". Refer to the code example below for more details."),k.forEach(n),vo=d(I),G=s(I,"LI",{});var _e=i(G);To=l(_e,"When generating partially inverted latents using "),bn=s(_e,"CODE",{});var Nr=i(bn);Uo=l(Nr,"invert"),Nr.forEach(n),Zo=l(_e,`, assign a caption or text embedding describing the
overall image to the `),_n=s(_e,"CODE",{});var Fr=i(_n);Eo=l(Fr,"prompt"),Fr.forEach(n),Io=l(_e,` argument to help guide the inverse latent sampling process. In most cases, the
source concept is sufficently descriptive to yield good results, but feel free to explore alternatives.
Please refer to `),Et=s(_e,"A",{href:!0});var Yr=i(Et);jo=l(Yr,"this code example"),Yr.forEach(n),ko=l(_e," for more details."),_e.forEach(n),Wo=d(I),j=s(I,"LI",{});var x=i(j);Go=l(x,"When calling the pipeline to generate the final edited image, assign the source concept to "),yn=s(x,"CODE",{});var Pr=i(yn);Bo=l(Pr,"negative_prompt"),Pr.forEach(n),Ro=l(x,`
and the target concept to `),wn=s(x,"CODE",{});var Hr=i(wn);Xo=l(Hr,"prompt"),Hr.forEach(n),Do=l(x,`. Taking the above example, you simply have to set the embeddings related to
the phrases including \u201Ccat\u201D to `),Mn=s(x,"CODE",{});var zr=i(Mn);Co=l(zr,"negative_prompt_embeds"),zr.forEach(n),So=l(x," and \u201Cdog\u201D to "),Jn=s(x,"CODE",{});var Qr=i(Jn);Vo=l(Qr,"prompt_embeds"),Qr.forEach(n),$o=l(x,`. Refer to the code example
below for more details.`),x.forEach(n),xo=d(I),It=s(I,"LI",{});var ur=i(It);No=l(ur,"If you wanted to reverse the direction in the example above, i.e., \u201Cdog -> cat\u201D, then it\u2019s recommended to:"),Y=s(ur,"UL",{});var Lt=i(Y);B=s(Lt,"LI",{});var ye=i(B);Fo=l(ye,"Swap the "),vn=s(ye,"CODE",{});var Ar=i(vn);Yo=l(Ar,"source_prompt"),Ar.forEach(n),Po=l(ye," and "),Tn=s(ye,"CODE",{});var Lr=i(Tn);Ho=l(Lr,"target_prompt"),Lr.forEach(n),zo=l(ye," in the arguments to "),Un=s(ye,"CODE",{});var qr=i(Un);Qo=l(qr,"generate_mask"),qr.forEach(n),Ao=l(ye,"."),ye.forEach(n),Lo=d(Lt),Ie=s(Lt,"LI",{});var hs=i(Ie);qo=l(hs,"Change the input prompt for "),Zn=s(hs,"CODE",{});var Or=i(Zn);Oo=l(Or,"invert"),Or.forEach(n),Ko=l(hs," to include \u201Cdog\u201D."),hs.forEach(n),ei=d(Lt),P=s(Lt,"LI",{});var qt=i(P);ti=l(qt,"Swap the "),En=s(qt,"CODE",{});var Kr=i(En);ni=l(Kr,"prompt"),Kr.forEach(n),ai=l(qt," and "),In=s(qt,"CODE",{});var ep=i(In);si=l(ep,"negative_prompt"),ep.forEach(n),oi=l(qt," in the arguments to call the pipeline to generate the final edited image."),qt.forEach(n),Lt.forEach(n),ur.forEach(n),ii=d(I),je=s(I,"LI",{});var bs=i(je);li=l(bs,"Note that the source and target prompts, or their corresponding embeddings, can also be automatically generated. Please, refer to "),jt=s(bs,"A",{href:!0});var tp=i(jt);ri=l(tp,"this discussion"),tp.forEach(n),pi=l(bs," for more details."),bs.forEach(n),I.forEach(n),wa=d(e),H=s(e,"H2",{class:!0});var _s=i(H);K=s(_s,"A",{id:!0,class:!0,href:!0});var np=i(K);jn=s(np,"SPAN",{});var ap=i(jn);u(ke.$$.fragment,ap),ap.forEach(n),np.forEach(n),di=d(_s),kn=s(_s,"SPAN",{});var sp=i(kn);ci=l(sp,"Usage example"),sp.forEach(n),_s.forEach(n),Ma=d(e),z=s(e,"H3",{class:!0});var ys=i(z);ee=s(ys,"A",{id:!0,class:!0,href:!0});var op=i(ee);Wn=s(op,"SPAN",{});var ip=i(Wn);u(We.$$.fragment,ip),ip.forEach(n),op.forEach(n),mi=d(ys),Gn=s(ys,"SPAN",{});var lp=i(Gn);fi=l(lp,"Based on an input image with a caption"),lp.forEach(n),ys.forEach(n),Ja=d(e),te=s(e,"P",{});var ws=i(te);gi=l(ws,`When the pipeline is conditioned on an input image, we first obtain partially inverted latents from the input image using a
`),Bn=s(ws,"CODE",{});var rp=i(Bn);ui=l(rp,"DDIMInverseScheduler"),rp.forEach(n),hi=l(ws,` with the help of a caption. Then we generate an editing mask to identify relevant regions in the image using the source and target prompts. Finally,
the inverted noise and generated mask is used to start the generation process.`),ws.forEach(n),va=d(e),kt=s(e,"P",{});var pp=i(kt);bi=l(pp,"First, let\u2019s load our pipeline:"),pp.forEach(n),Ta=d(e),u(Ge.$$.fragment,e),Ua=d(e),Wt=s(e,"P",{});var dp=i(Wt);_i=l(dp,"Then, we load an input image to edit using our method:"),dp.forEach(n),Za=d(e),u(Be.$$.fragment,e),Ea=d(e),Gt=s(e,"P",{});var cp=i(Gt);yi=l(cp,"Then, we employ the source and target prompts to generate the editing mask:"),cp.forEach(n),Ia=d(e),u(Re.$$.fragment,e),ja=d(e),Bt=s(e,"P",{});var mp=i(Bt);wi=l(mp,"Then, we employ the caption and the input image to get the inverted latents:"),mp.forEach(n),ka=d(e),u(Xe.$$.fragment,e),Wa=d(e),Rt=s(e,"P",{});var fp=i(Rt);Mi=l(fp,"Now, generate the image with the inverted latents and semantically generated mask:"),fp.forEach(n),Ga=d(e),u(De.$$.fragment,e),Ba=d(e),Q=s(e,"H2",{class:!0});var Ms=i(Q);ne=s(Ms,"A",{id:!0,class:!0,href:!0});var gp=i(ne);Rn=s(gp,"SPAN",{});var up=i(Rn);u(Ce.$$.fragment,up),up.forEach(n),gp.forEach(n),Ji=d(Ms),Xn=s(Ms,"SPAN",{});var hp=i(Xn);vi=l(hp,"Generating image captions for inversion"),hp.forEach(n),Ms.forEach(n),Ra=d(e),ae=s(e,"P",{});var Js=i(ae);Ti=l(Js,`The authors originally used the source concept prompt as the caption for generating the partially inverted latents. However, we can also leverage open source and public image captioning models for the same purpose.
Below, we provide an end-to-end example with the `),Se=s(Js,"A",{href:!0,rel:!0});var bp=i(Se);Ui=l(bp,"BLIP"),bp.forEach(n),Zi=l(Js,` model
for generating captions.`),Js.forEach(n),Xa=d(e),Xt=s(e,"P",{});var _p=i(Xt);Ei=l(_p,"First, let\u2019s load our automatic image captioning model:"),_p.forEach(n),Da=d(e),u(Ve.$$.fragment,e),Ca=d(e),Dt=s(e,"P",{});var yp=i(Dt);Ii=l(yp,"Then, we define a utility to generate captions from an input image using the model:"),yp.forEach(n),Sa=d(e),u($e.$$.fragment,e),Va=d(e),Ct=s(e,"P",{});var wp=i(Ct);ji=l(wp,"Then, we load an input image for conditioning and obtain a suitable caption for it:"),wp.forEach(n),$a=d(e),u(xe.$$.fragment,e),xa=d(e),St=s(e,"P",{});var Mp=i(St);ki=l(Mp,"Then, we employ the generated caption and the input image to get the inverted latents:"),Mp.forEach(n),Na=d(e),u(Ne.$$.fragment,e),Fa=d(e),Vt=s(e,"P",{});var Jp=i(Vt);Wi=l(Jp,"Now, generate the image with the inverted latents and semantically generated mask from our source and target prompts:"),Jp.forEach(n),Ya=d(e),u(Fe.$$.fragment,e),Pa=d(e),A=s(e,"H2",{class:!0});var vs=i(A);se=s(vs,"A",{id:!0,class:!0,href:!0});var vp=i(se);Dn=s(vp,"SPAN",{});var Tp=i(Dn);u(Ye.$$.fragment,Tp),Tp.forEach(n),vp.forEach(n),Gi=d(vs),Cn=s(vs,"SPAN",{});var Up=i(Cn);Bi=l(Up,"Generating source and target embeddings"),Up.forEach(n),vs.forEach(n),Ha=d(e),oe=s(e,"P",{});var Ts=i(oe);Ri=l(Ts,`The authors originally required the user to manually provide the source and target prompts for discovering
edit directions. However, we can also leverage open source and public models for the same purpose.
Below, we provide an end-to-end example with the `),Pe=s(Ts,"A",{href:!0,rel:!0});var Zp=i(Pe);Xi=l(Zp,"Flan-T5"),Zp.forEach(n),Di=l(Ts,` model
for generating source an target embeddings.`),Ts.forEach(n),za=d(e),He=s(e,"P",{});var hr=i(He);Sn=s(hr,"STRONG",{});var Ep=i(Sn);Ci=l(Ep,"1. Load the generation model"),Ep.forEach(n),Si=l(hr,":"),hr.forEach(n),Qa=d(e),u(ze.$$.fragment,e),Aa=d(e),Qe=s(e,"P",{});var br=i(Qe);Vn=s(br,"STRONG",{});var Ip=i(Vn);Vi=l(Ip,"2. Construct a starting prompt"),Ip.forEach(n),$i=l(br,":"),br.forEach(n),La=d(e),u(Ae.$$.fragment,e),qa=d(e),$t=s(e,"P",{});var jp=i($t);xi=l(jp,"Here, we\u2019re interested in the \u201Cbowl -> basket\u201D direction."),jp.forEach(n),Oa=d(e),Le=s(e,"P",{});var _r=i(Le);$n=s(_r,"STRONG",{});var kp=i($n);Ni=l(kp,"3. Generate prompts"),kp.forEach(n),Fi=l(_r,":"),_r.forEach(n),Ka=d(e),xt=s(e,"P",{});var Wp=i(xt);Yi=l(Wp,"We can use a utility like so for this purpose."),Wp.forEach(n),es=d(e),u(qe.$$.fragment,e),ts=d(e),Nt=s(e,"P",{});var Gp=i(Nt);Pi=l(Gp,"And then we just call it to generate our prompts:"),Gp.forEach(n),ns=d(e),u(Oe.$$.fragment,e),as=d(e),C=s(e,"P",{});var Ot=i(C);Hi=l(Ot,`We encourage you to play around with the different parameters supported by the
`),xn=s(Ot,"CODE",{});var Bp=i(xn);zi=l(Bp,"generate()"),Bp.forEach(n),Qi=l(Ot," method ("),Ke=s(Ot,"A",{href:!0,rel:!0});var Rp=i(Ke);Ai=l(Rp,"documentation"),Rp.forEach(n),Li=l(Ot,") for the generation quality you are looking for."),Ot.forEach(n),ss=d(e),et=s(e,"P",{});var yr=i(et);Nn=s(yr,"STRONG",{});var Xp=i(Nn);qi=l(Xp,"4. Load the embedding model"),Xp.forEach(n),Oi=l(yr,":"),yr.forEach(n),os=d(e),Ft=s(e,"P",{});var Dp=i(Ft);Ki=l(Dp,"Here, we need to use the same text encoder model used by the subsequent Stable Diffusion model."),Dp.forEach(n),is=d(e),u(tt.$$.fragment,e),ls=d(e),nt=s(e,"P",{});var wr=i(nt);Fn=s(wr,"STRONG",{});var Cp=i(Fn);el=l(Cp,"5. Compute embeddings"),Cp.forEach(n),tl=l(wr,":"),wr.forEach(n),rs=d(e),u(at.$$.fragment,e),ps=d(e),Yt=s(e,"P",{});var Sp=i(Yt);nl=l(Sp,"And you\u2019re done! Now, you can use these embeddings directly while calling the pipeline:"),Sp.forEach(n),ds=d(e),u(st.$$.fragment,e),cs=d(e),L=s(e,"H2",{class:!0});var Us=i(L);ie=s(Us,"A",{id:!0,class:!0,href:!0});var Vp=i(ie);Yn=s(Vp,"SPAN",{});var $p=i(Yn);u(ot.$$.fragment,$p),$p.forEach(n),Vp.forEach(n),al=d(Us),Pn=s(Us,"SPAN",{});var xp=i(Pn);sl=l(xp,"StableDiffusionDiffEditPipeline"),xp.forEach(n),Us.forEach(n),ms=d(e),M=s(e,"DIV",{class:!0});var J=i(M);u(it.$$.fragment,J),ol=d(J),u(le.$$.fragment,J),il=d(J),Hn=s(J,"P",{});var Np=i(Hn);ll=l(Np,"Pipeline for text-guided image inpainting using Stable Diffusion and DiffEdit."),Np.forEach(n),rl=d(J),lt=s(J,"P",{});var Zs=i(lt);pl=l(Zs,"This model inherits from "),Pt=s(Zs,"A",{href:!0});var Fp=i(Pt);dl=l(Fp,"DiffusionPipeline"),Fp.forEach(n),cl=l(Zs,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Zs.forEach(n),ml=d(J),zn=s(J,"P",{});var Yp=i(zn);fl=l(Yp,"In addition the pipeline inherits the following loading methods:"),Yp.forEach(n),gl=d(J),rt=s(J,"UL",{});var Es=i(rt);pt=s(Es,"LI",{});var Is=i(pt);Qn=s(Is,"EM",{});var Pp=i(Qn);ul=l(Pp,"Textual-Inversion"),Pp.forEach(n),hl=l(Is,": "),Ht=s(Is,"A",{href:!0});var Hp=i(Ht);bl=l(Hp,"loaders.TextualInversionLoaderMixin.load_textual_inversion()"),Hp.forEach(n),Is.forEach(n),_l=d(Es),dt=s(Es,"LI",{});var js=i(dt);An=s(js,"EM",{});var zp=i(An);yl=l(zp,"LoRA"),zp.forEach(n),wl=l(js,": "),zt=s(js,"A",{href:!0});var Qp=i(zt);Ml=l(Qp,"loaders.LoraLoaderMixin.load_lora_weights()"),Qp.forEach(n),js.forEach(n),Es.forEach(n),Jl=d(J),Ln=s(J,"P",{});var Ap=i(Ln);vl=l(Ap,"as well as the following saving methods:"),Ap.forEach(n),Tl=d(J),qn=s(J,"UL",{});var Lp=i(qn);ct=s(Lp,"LI",{});var ks=i(ct);On=s(ks,"EM",{});var qp=i(On);Ul=l(qp,"LoRA"),qp.forEach(n),Zl=l(ks,": "),Qt=s(ks,"A",{href:!0});var Op=i(Qt);El=l(Op,"loaders.LoraLoaderMixin.save_lora_weights()"),Op.forEach(n),ks.forEach(n),Lp.forEach(n),Il=d(J),S=s(J,"DIV",{class:!0});var Kt=i(S);u(mt.$$.fragment,Kt),jl=d(Kt),Kn=s(Kt,"P",{});var Kp=i(Kn);kl=l(Kp,"Generate a latent mask given a mask prompt, a target prompt, and an image."),Kp.forEach(n),Wl=d(Kt),u(re.$$.fragment,Kt),Kt.forEach(n),Gl=d(J),V=s(J,"DIV",{class:!0});var en=i(V);u(ft.$$.fragment,en),Bl=d(en),ea=s(en,"P",{});var ed=i(ea);Rl=l(ed,"Generate inverted latents given a prompt and image."),ed.forEach(n),Xl=d(en),u(pe.$$.fragment,en),en.forEach(n),Dl=d(J),$=s(J,"DIV",{class:!0});var tn=i($);u(gt.$$.fragment,tn),Cl=d(tn),ta=s(tn,"P",{});var td=i(ta);Sl=l(td,"The call function to the pipeline for generation."),td.forEach(n),Vl=d(tn),u(de.$$.fragment,tn),tn.forEach(n),$l=d(J),ce=s(J,"DIV",{class:!0});var Ws=i(ce);u(ut.$$.fragment,Ws),xl=d(Ws),ht=s(Ws,"P",{});var Gs=i(ht);Nl=l(Gs,"Disable sliced VAE decoding. If "),na=s(Gs,"CODE",{});var nd=i(na);Fl=l(nd,"enable_vae_slicing"),nd.forEach(n),Yl=l(Gs,` was previously enabled, this method will go back to
computing decoding in one step.`),Gs.forEach(n),Ws.forEach(n),Pl=d(J),me=s(J,"DIV",{class:!0});var Bs=i(me);u(bt.$$.fragment,Bs),Hl=d(Bs),_t=s(Bs,"P",{});var Rs=i(_t);zl=l(Rs,"Disable tiled VAE decoding. If "),aa=s(Rs,"CODE",{});var ad=i(aa);Ql=l(ad,"enable_vae_tiling"),ad.forEach(n),Al=l(Rs,` was previously enabled, this method will go back to
computing decoding in one step.`),Rs.forEach(n),Bs.forEach(n),Ll=d(J),fe=s(J,"DIV",{class:!0});var Xs=i(fe);u(yt.$$.fragment,Xs),ql=d(Xs),R=s(Xs,"P",{});var we=i(R);Ol=l(we,`Offload all models to CPU to reduce memory usage with a low impact on performance. Moves one whole model at a
time to the GPU when its `),sa=s(we,"CODE",{});var sd=i(sa);Kl=l(sd,"forward"),sd.forEach(n),er=l(we,` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),oa=s(we,"CODE",{});var od=i(oa);tr=l(od,"enable_sequential_cpu_offload"),od.forEach(n),nr=l(we,`, but performance is much better due to the
iterative execution of the `),ia=s(we,"CODE",{});var id=i(ia);ar=l(id,"unet"),id.forEach(n),sr=l(we,"."),we.forEach(n),Xs.forEach(n),or=d(J),ge=s(J,"DIV",{class:!0});var Ds=i(ge);u(wt.$$.fragment,Ds),ir=d(Ds),la=s(Ds,"P",{});var ld=i(la);lr=l(ld,`Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.`),ld.forEach(n),Ds.forEach(n),rr=d(J),ue=s(J,"DIV",{class:!0});var Cs=i(ue);u(Mt.$$.fragment,Cs),pr=d(Cs),ra=s(Cs,"P",{});var rd=i(ra);dr=l(rd,`Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
processing larger images.`),rd.forEach(n),Cs.forEach(n),cr=d(J),he=s(J,"DIV",{class:!0});var Ss=i(he);u(Jt.$$.fragment,Ss),mr=d(Ss),pa=s(Ss,"P",{});var pd=i(pa);fr=l(pd,"Encodes the prompt into text encoder hidden states."),pd.forEach(n),Ss.forEach(n),J.forEach(n),this.h()},h(){m(w,"name","hf:doc:metadata"),m(w,"content",JSON.stringify(Md)),m(U,"id","diffedit"),m(U,"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"),m(U,"href","#diffedit"),m(f,"class","relative group"),m(ve,"href","https://huggingface.co/papers/2210.11427"),m(ve,"rel","nofollow"),m(Te,"href","https://github.com/Xiang-cd/DiffEdit-stable-diffusion"),m(Te,"rel","nofollow"),m(Ue,"href","https://blog.problemsolversguild.com/technical/research/2022/11/02/DiffEdit-Implementation.html"),m(Ue,"rel","nofollow"),m(Ze,"href","https://github.com/clarencechen"),m(Ze,"rel","nofollow"),m(O,"id","tips"),m(O,"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"),m(O,"href","#tips"),m(F,"class","relative group"),m(Et,"href","#generating-image-captions-for-inversion"),m(jt,"href","#generating-source-and-target-embeddings"),m(K,"id","usage-example"),m(K,"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"),m(K,"href","#usage-example"),m(H,"class","relative group"),m(ee,"id","based-on-an-input-image-with-a-caption"),m(ee,"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"),m(ee,"href","#based-on-an-input-image-with-a-caption"),m(z,"class","relative group"),m(ne,"id","generating-image-captions-for-inversion"),m(ne,"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"),m(ne,"href","#generating-image-captions-for-inversion"),m(Q,"class","relative group"),m(Se,"href","https://huggingface.co/docs/transformers/model_doc/blip"),m(Se,"rel","nofollow"),m(se,"id","generating-source-and-target-embeddings"),m(se,"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"),m(se,"href","#generating-source-and-target-embeddings"),m(A,"class","relative group"),m(Pe,"href","https://huggingface.co/docs/transformers/model_doc/flan-t5"),m(Pe,"rel","nofollow"),m(Ke,"href","https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.generation_tf_utils.TFGenerationMixin.generate"),m(Ke,"rel","nofollow"),m(ie,"id","diffusers.StableDiffusionDiffEditPipeline"),m(ie,"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"),m(ie,"href","#diffusers.StableDiffusionDiffEditPipeline"),m(L,"class","relative group"),m(Pt,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),m(Ht,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion"),m(zt,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),m(Qt,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights"),m(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(me,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(fe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ge,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(ue,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(he,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,r){t(document.head,w),c(e,v,r),c(e,f,r),t(f,U),t(U,nn),h(Me,nn,null),t(f,Vs),t(f,an),t(an,$s),c(e,fa,r),c(e,Je,r),t(Je,ve),t(ve,xs),t(Je,Ns),c(e,ga,r),c(e,Ut,r),t(Ut,Fs),c(e,ua,r),c(e,Zt,r),t(Zt,sn),t(sn,Ys),c(e,ha,r),c(e,D,r),t(D,Ps),t(D,Te),t(Te,Hs),t(D,zs),t(D,Ue),t(Ue,Qs),t(D,As),c(e,ba,r),c(e,q,r),t(q,Ls),t(q,Ze),t(Ze,qs),t(q,Os),c(e,_a,r),c(e,F,r),t(F,O),t(O,on),h(Ee,on,null),t(F,Ks),t(F,ln),t(ln,eo),c(e,ya,r),c(e,Z,r),t(Z,rn),t(rn,to),t(Z,no),t(Z,W),t(W,ao),t(W,pn),t(pn,so),t(W,oo),t(W,dn),t(dn,io),t(W,lo),t(W,cn),t(cn,ro),t(W,po),t(Z,co),t(Z,E),t(E,mo),t(E,mn),t(mn,fo),t(E,go),t(E,fn),t(fn,uo),t(E,ho),t(E,gn),t(gn,bo),t(E,_o),t(E,un),t(un,yo),t(E,wo),t(E,hn),t(hn,Mo),t(E,Jo),t(Z,vo),t(Z,G),t(G,To),t(G,bn),t(bn,Uo),t(G,Zo),t(G,_n),t(_n,Eo),t(G,Io),t(G,Et),t(Et,jo),t(G,ko),t(Z,Wo),t(Z,j),t(j,Go),t(j,yn),t(yn,Bo),t(j,Ro),t(j,wn),t(wn,Xo),t(j,Do),t(j,Mn),t(Mn,Co),t(j,So),t(j,Jn),t(Jn,Vo),t(j,$o),t(Z,xo),t(Z,It),t(It,No),t(It,Y),t(Y,B),t(B,Fo),t(B,vn),t(vn,Yo),t(B,Po),t(B,Tn),t(Tn,Ho),t(B,zo),t(B,Un),t(Un,Qo),t(B,Ao),t(Y,Lo),t(Y,Ie),t(Ie,qo),t(Ie,Zn),t(Zn,Oo),t(Ie,Ko),t(Y,ei),t(Y,P),t(P,ti),t(P,En),t(En,ni),t(P,ai),t(P,In),t(In,si),t(P,oi),t(Z,ii),t(Z,je),t(je,li),t(je,jt),t(jt,ri),t(je,pi),c(e,wa,r),c(e,H,r),t(H,K),t(K,jn),h(ke,jn,null),t(H,di),t(H,kn),t(kn,ci),c(e,Ma,r),c(e,z,r),t(z,ee),t(ee,Wn),h(We,Wn,null),t(z,mi),t(z,Gn),t(Gn,fi),c(e,Ja,r),c(e,te,r),t(te,gi),t(te,Bn),t(Bn,ui),t(te,hi),c(e,va,r),c(e,kt,r),t(kt,bi),c(e,Ta,r),h(Ge,e,r),c(e,Ua,r),c(e,Wt,r),t(Wt,_i),c(e,Za,r),h(Be,e,r),c(e,Ea,r),c(e,Gt,r),t(Gt,yi),c(e,Ia,r),h(Re,e,r),c(e,ja,r),c(e,Bt,r),t(Bt,wi),c(e,ka,r),h(Xe,e,r),c(e,Wa,r),c(e,Rt,r),t(Rt,Mi),c(e,Ga,r),h(De,e,r),c(e,Ba,r),c(e,Q,r),t(Q,ne),t(ne,Rn),h(Ce,Rn,null),t(Q,Ji),t(Q,Xn),t(Xn,vi),c(e,Ra,r),c(e,ae,r),t(ae,Ti),t(ae,Se),t(Se,Ui),t(ae,Zi),c(e,Xa,r),c(e,Xt,r),t(Xt,Ei),c(e,Da,r),h(Ve,e,r),c(e,Ca,r),c(e,Dt,r),t(Dt,Ii),c(e,Sa,r),h($e,e,r),c(e,Va,r),c(e,Ct,r),t(Ct,ji),c(e,$a,r),h(xe,e,r),c(e,xa,r),c(e,St,r),t(St,ki),c(e,Na,r),h(Ne,e,r),c(e,Fa,r),c(e,Vt,r),t(Vt,Wi),c(e,Ya,r),h(Fe,e,r),c(e,Pa,r),c(e,A,r),t(A,se),t(se,Dn),h(Ye,Dn,null),t(A,Gi),t(A,Cn),t(Cn,Bi),c(e,Ha,r),c(e,oe,r),t(oe,Ri),t(oe,Pe),t(Pe,Xi),t(oe,Di),c(e,za,r),c(e,He,r),t(He,Sn),t(Sn,Ci),t(He,Si),c(e,Qa,r),h(ze,e,r),c(e,Aa,r),c(e,Qe,r),t(Qe,Vn),t(Vn,Vi),t(Qe,$i),c(e,La,r),h(Ae,e,r),c(e,qa,r),c(e,$t,r),t($t,xi),c(e,Oa,r),c(e,Le,r),t(Le,$n),t($n,Ni),t(Le,Fi),c(e,Ka,r),c(e,xt,r),t(xt,Yi),c(e,es,r),h(qe,e,r),c(e,ts,r),c(e,Nt,r),t(Nt,Pi),c(e,ns,r),h(Oe,e,r),c(e,as,r),c(e,C,r),t(C,Hi),t(C,xn),t(xn,zi),t(C,Qi),t(C,Ke),t(Ke,Ai),t(C,Li),c(e,ss,r),c(e,et,r),t(et,Nn),t(Nn,qi),t(et,Oi),c(e,os,r),c(e,Ft,r),t(Ft,Ki),c(e,is,r),h(tt,e,r),c(e,ls,r),c(e,nt,r),t(nt,Fn),t(Fn,el),t(nt,tl),c(e,rs,r),h(at,e,r),c(e,ps,r),c(e,Yt,r),t(Yt,nl),c(e,ds,r),h(st,e,r),c(e,cs,r),c(e,L,r),t(L,ie),t(ie,Yn),h(ot,Yn,null),t(L,al),t(L,Pn),t(Pn,sl),c(e,ms,r),c(e,M,r),h(it,M,null),t(M,ol),h(le,M,null),t(M,il),t(M,Hn),t(Hn,ll),t(M,rl),t(M,lt),t(lt,pl),t(lt,Pt),t(Pt,dl),t(lt,cl),t(M,ml),t(M,zn),t(zn,fl),t(M,gl),t(M,rt),t(rt,pt),t(pt,Qn),t(Qn,ul),t(pt,hl),t(pt,Ht),t(Ht,bl),t(rt,_l),t(rt,dt),t(dt,An),t(An,yl),t(dt,wl),t(dt,zt),t(zt,Ml),t(M,Jl),t(M,Ln),t(Ln,vl),t(M,Tl),t(M,qn),t(qn,ct),t(ct,On),t(On,Ul),t(ct,Zl),t(ct,Qt),t(Qt,El),t(M,Il),t(M,S),h(mt,S,null),t(S,jl),t(S,Kn),t(Kn,kl),t(S,Wl),h(re,S,null),t(M,Gl),t(M,V),h(ft,V,null),t(V,Bl),t(V,ea),t(ea,Rl),t(V,Xl),h(pe,V,null),t(M,Dl),t(M,$),h(gt,$,null),t($,Cl),t($,ta),t(ta,Sl),t($,Vl),h(de,$,null),t(M,$l),t(M,ce),h(ut,ce,null),t(ce,xl),t(ce,ht),t(ht,Nl),t(ht,na),t(na,Fl),t(ht,Yl),t(M,Pl),t(M,me),h(bt,me,null),t(me,Hl),t(me,_t),t(_t,zl),t(_t,aa),t(aa,Ql),t(_t,Al),t(M,Ll),t(M,fe),h(yt,fe,null),t(fe,ql),t(fe,R),t(R,Ol),t(R,sa),t(sa,Kl),t(R,er),t(R,oa),t(oa,tr),t(R,nr),t(R,ia),t(ia,ar),t(R,sr),t(M,or),t(M,ge),h(wt,ge,null),t(ge,ir),t(ge,la),t(la,lr),t(M,rr),t(M,ue),h(Mt,ue,null),t(ue,pr),t(ue,ra),t(ra,dr),t(M,cr),t(M,he),h(Jt,he,null),t(he,mr),t(he,pa),t(pa,fr),fs=!0},p(e,[r]){const vt={};r&2&&(vt.$$scope={dirty:r,ctx:e}),le.$set(vt);const da={};r&2&&(da.$$scope={dirty:r,ctx:e}),re.$set(da);const ca={};r&2&&(ca.$$scope={dirty:r,ctx:e}),pe.$set(ca);const ma={};r&2&&(ma.$$scope={dirty:r,ctx:e}),de.$set(ma)},i(e){fs||(b(Me.$$.fragment,e),b(Ee.$$.fragment,e),b(ke.$$.fragment,e),b(We.$$.fragment,e),b(Ge.$$.fragment,e),b(Be.$$.fragment,e),b(Re.$$.fragment,e),b(Xe.$$.fragment,e),b(De.$$.fragment,e),b(Ce.$$.fragment,e),b(Ve.$$.fragment,e),b($e.$$.fragment,e),b(xe.$$.fragment,e),b(Ne.$$.fragment,e),b(Fe.$$.fragment,e),b(Ye.$$.fragment,e),b(ze.$$.fragment,e),b(Ae.$$.fragment,e),b(qe.$$.fragment,e),b(Oe.$$.fragment,e),b(tt.$$.fragment,e),b(at.$$.fragment,e),b(st.$$.fragment,e),b(ot.$$.fragment,e),b(it.$$.fragment,e),b(le.$$.fragment,e),b(mt.$$.fragment,e),b(re.$$.fragment,e),b(ft.$$.fragment,e),b(pe.$$.fragment,e),b(gt.$$.fragment,e),b(de.$$.fragment,e),b(ut.$$.fragment,e),b(bt.$$.fragment,e),b(yt.$$.fragment,e),b(wt.$$.fragment,e),b(Mt.$$.fragment,e),b(Jt.$$.fragment,e),fs=!0)},o(e){_(Me.$$.fragment,e),_(Ee.$$.fragment,e),_(ke.$$.fragment,e),_(We.$$.fragment,e),_(Ge.$$.fragment,e),_(Be.$$.fragment,e),_(Re.$$.fragment,e),_(Xe.$$.fragment,e),_(De.$$.fragment,e),_(Ce.$$.fragment,e),_(Ve.$$.fragment,e),_($e.$$.fragment,e),_(xe.$$.fragment,e),_(Ne.$$.fragment,e),_(Fe.$$.fragment,e),_(Ye.$$.fragment,e),_(ze.$$.fragment,e),_(Ae.$$.fragment,e),_(qe.$$.fragment,e),_(Oe.$$.fragment,e),_(tt.$$.fragment,e),_(at.$$.fragment,e),_(st.$$.fragment,e),_(ot.$$.fragment,e),_(it.$$.fragment,e),_(le.$$.fragment,e),_(mt.$$.fragment,e),_(re.$$.fragment,e),_(ft.$$.fragment,e),_(pe.$$.fragment,e),_(gt.$$.fragment,e),_(de.$$.fragment,e),_(ut.$$.fragment,e),_(bt.$$.fragment,e),_(yt.$$.fragment,e),_(wt.$$.fragment,e),_(Mt.$$.fragment,e),_(Jt.$$.fragment,e),fs=!1},d(e){n(w),e&&n(v),e&&n(f),y(Me),e&&n(fa),e&&n(Je),e&&n(ga),e&&n(Ut),e&&n(ua),e&&n(Zt),e&&n(ha),e&&n(D),e&&n(ba),e&&n(q),e&&n(_a),e&&n(F),y(Ee),e&&n(ya),e&&n(Z),e&&n(wa),e&&n(H),y(ke),e&&n(Ma),e&&n(z),y(We),e&&n(Ja),e&&n(te),e&&n(va),e&&n(kt),e&&n(Ta),y(Ge,e),e&&n(Ua),e&&n(Wt),e&&n(Za),y(Be,e),e&&n(Ea),e&&n(Gt),e&&n(Ia),y(Re,e),e&&n(ja),e&&n(Bt),e&&n(ka),y(Xe,e),e&&n(Wa),e&&n(Rt),e&&n(Ga),y(De,e),e&&n(Ba),e&&n(Q),y(Ce),e&&n(Ra),e&&n(ae),e&&n(Xa),e&&n(Xt),e&&n(Da),y(Ve,e),e&&n(Ca),e&&n(Dt),e&&n(Sa),y($e,e),e&&n(Va),e&&n(Ct),e&&n($a),y(xe,e),e&&n(xa),e&&n(St),e&&n(Na),y(Ne,e),e&&n(Fa),e&&n(Vt),e&&n(Ya),y(Fe,e),e&&n(Pa),e&&n(A),y(Ye),e&&n(Ha),e&&n(oe),e&&n(za),e&&n(He),e&&n(Qa),y(ze,e),e&&n(Aa),e&&n(Qe),e&&n(La),y(Ae,e),e&&n(qa),e&&n($t),e&&n(Oa),e&&n(Le),e&&n(Ka),e&&n(xt),e&&n(es),y(qe,e),e&&n(ts),e&&n(Nt),e&&n(ns),y(Oe,e),e&&n(as),e&&n(C),e&&n(ss),e&&n(et),e&&n(os),e&&n(Ft),e&&n(is),y(tt,e),e&&n(ls),e&&n(nt),e&&n(rs),y(at,e),e&&n(ps),e&&n(Yt),e&&n(ds),y(st,e),e&&n(cs),e&&n(L),y(ot),e&&n(ms),e&&n(M),y(it),y(le),y(mt),y(re),y(ft),y(pe),y(gt),y(de),y(ut),y(bt),y(yt),y(wt),y(Mt),y(Jt)}}}const Md={local:"diffedit",sections:[{local:"tips",title:"Tips "},{local:"usage-example",sections:[{local:"based-on-an-input-image-with-a-caption",title:"Based on an input image with a caption"}],title:"Usage example"},{local:"generating-image-captions-for-inversion",title:"Generating image captions for inversion"},{local:"generating-source-and-target-embeddings",title:"Generating source and target embeddings "},{local:"diffusers.StableDiffusionDiffEditPipeline",title:"StableDiffusionDiffEditPipeline"}],title:"DiffEdit"};function Jd(X){return gd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jd extends dd{constructor(w){super();cd(this,w,Jd,wd,md,{})}}export{jd as default,Md as metadata};
