import{S as nd,i as ad,s as sd,e as a,k as p,w as g,t as s,M as od,c as o,d as n,m as d,a as l,x as h,h as i,b as m,G as t,g as c,y as b,q as y,o as _,B as w,v as id,L as gr}from"../../../chunks/vendor-hf-doc-builder.js";import{T as ld}from"../../../chunks/Tip-hf-doc-builder.js";import{D as L}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as T}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Jt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as ur}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function rd(X){let u,v;return{c(){u=a("p"),v=s("This is an experimental feature!")},l(f){u=o(f,"P",{});var U=l(u);v=i(U,"This is an experimental feature!"),U.forEach(n)},m(f,U){c(f,u,U),t(u,v)},d(f){f&&n(u)}}}function pd(X){let u,v;return u=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(u.$$.fragment)},l(f){h(u.$$.fragment,f)},m(f,U){b(u,f,U),v=!0},p:gr,i(f){v||(y(u.$$.fragment,f),v=!0)},o(f){_(u.$$.fragment,f),v=!1},d(f){w(u,f)}}}function dd(X){let u,v;return u=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(u.$$.fragment)},l(f){h(u.$$.fragment,f)},m(f,U){b(u,f,U),v=!0},p:gr,i(f){v||(y(u.$$.fragment,f),v=!0)},o(f){_(u.$$.fragment,f),v=!1},d(f){w(u,f)}}}function cd(X){let u,v;return u=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(u.$$.fragment)},l(f){h(u.$$.fragment,f)},m(f,U){b(u,f,U),v=!0},p:gr,i(f){v||(y(u.$$.fragment,f),v=!0)},o(f){_(u.$$.fragment,f),v=!1},d(f){w(u,f)}}}function md(X){let u,v,f,U,en,we,Xs,tn,Cs,da,Me,Je,Ds,Vs,ca,vt,Ss,ma,Tt,nn,$s,fa,C,Ns,ve,xs,Fs,Te,Ys,Hs,ua,q,zs,Ue,Ps,Qs,ga,x,K,an,Ze,As,sn,Ls,ha,Z,on,qs,Ks,W,Os,ln,eo,to,rn,no,ao,pn,so,oo,io,E,lo,dn,ro,po,cn,co,mo,mn,fo,uo,fn,go,ho,un,bo,yo,_o,G,wo,gn,Mo,Jo,hn,vo,To,Ut,Uo,Zo,Eo,I,jo,bn,Io,ko,yn,Wo,Go,_n,Bo,Ro,wn,Xo,Co,Do,Zt,Vo,F,B,So,Mn,$o,No,Jn,xo,Fo,vn,Yo,Ho,zo,Ee,Po,Tn,Qo,Ao,Lo,Y,qo,Un,Ko,Oo,Zn,ei,ti,ni,je,ai,Et,si,oi,ba,H,O,En,Ie,ii,jn,li,ya,z,ee,In,ke,ri,kn,pi,_a,te,di,Wn,ci,mi,wa,jt,fi,Ma,We,Ja,It,ui,va,Ge,Ta,kt,gi,Ua,Be,Za,Wt,hi,Ea,Re,ja,Gt,bi,Ia,Xe,ka,P,ne,Gn,Ce,yi,Bn,_i,Wa,ae,wi,De,Mi,Ji,Ga,Bt,vi,Ba,Ve,Ra,Rt,Ti,Xa,Se,Ca,Xt,Ui,Da,$e,Va,Ct,Zi,Sa,Ne,$a,Dt,Ei,Na,xe,xa,Q,se,Rn,Fe,ji,Xn,Ii,Fa,oe,ki,Ye,Wi,Gi,Ya,He,Cn,Bi,Ri,Ha,ze,za,Pe,Dn,Xi,Ci,Pa,Qe,Qa,Vt,Di,Aa,Ae,Vn,Vi,Si,La,St,$i,qa,Le,Ka,$t,Ni,Oa,qe,es,D,xi,Sn,Fi,Yi,Ke,Hi,zi,ts,Oe,$n,Pi,Qi,ns,Nt,Ai,as,et,ss,tt,Nn,Li,qi,os,nt,is,xt,Ki,ls,at,rs,A,ie,xn,st,Oi,Fn,el,ps,M,ot,tl,le,nl,Yn,al,sl,it,ol,Ft,il,ll,rl,Hn,pl,dl,lt,rt,zn,cl,ml,Yt,fl,ul,pt,Pn,gl,hl,Ht,bl,yl,Qn,_l,wl,An,dt,Ln,Ml,Jl,zt,vl,Tl,V,ct,Ul,qn,Zl,El,re,jl,S,mt,Il,Kn,kl,Wl,pe,Gl,$,ft,Bl,On,Rl,Xl,de,Cl,ce,ut,Dl,gt,Vl,ea,Sl,$l,Nl,me,ht,xl,bt,Fl,ta,Yl,Hl,zl,fe,yt,Pl,R,Ql,na,Al,Ll,aa,ql,Kl,sa,Ol,er,tr,ue,_t,nr,oa,ar,sr,ge,wt,or,ia,ir,ds;return we=new Jt({}),Ze=new Jt({}),Ie=new Jt({}),ke=new Jt({}),We=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>)`}}),Ge=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>))`}}),Be=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,
)`}}),Re=new T({props:{code:"aW52X2xhdGVudHMlMjAlM0QlMjBwaXBlbGluZS5pbnZlcnQocHJvbXB0JTNEc291cmNlX3Byb21wdCUyQyUyMGltYWdlJTNEcmF3X2ltYWdlJTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yKS5sYXRlbnRz",highlighted:"inv_latents = pipeline.invert(prompt=source_prompt, image=raw_image, generator=generator).latents"}}),Xe=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 Jt({}),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>)`}}),Se=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`}}),$e=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`}}),xe=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>)`}}),Fe=new Jt({}),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)`}}),Qe=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>`}}),Le=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>)`}}),qe=new T({props:{code:"c291cmNlX3Byb21wdHMlMjAlM0QlMjBnZW5lcmF0ZV9wcm9tcHRzKHNvdXJjZV90ZXh0KSUwQXRhcmdldF9wcm9tcHRzJTIwJTNEJTIwZ2VuZXJhdGVfcHJvbXB0cyh0YXJnZXRfdGV4dCk=",highlighted:`source_prompts = generate_prompts(source_text)
target_prompts = generate_prompts(target_text)`}}),et=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>)`}}),nt=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)`}}),at=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>)`}}),st=new Jt({}),ot=new L({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 ld({props:{warning:!0,$$slots:{default:[rd]},$$scope:{ctx:X}}}),ct=new L({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#L837",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 ur({props:{anchor:"diffusers.StableDiffusionDiffEditPipeline.generate_mask.example",$$slots:{default:[pd]},$$scope:{ctx:X}}}),mt=new L({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#L1049",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 ur({props:{anchor:"diffusers.StableDiffusionDiffEditPipeline.invert.example",$$slots:{default:[dd]},$$scope:{ctx:X}}}),ft=new L({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#L1281",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 ur({props:{anchor:"diffusers.StableDiffusionDiffEditPipeline.__call__.example",$$slots:{default:[cd]},$$scope:{ctx:X}}}),ut=new L({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"}}),ht=new L({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 L({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"}}),_t=new L({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"}}),wt=new L({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"}}),{c(){u=a("meta"),v=p(),f=a("h1"),U=a("a"),en=a("span"),g(we.$$.fragment),Xs=p(),tn=a("span"),Cs=s("DiffEdit"),da=p(),Me=a("p"),Je=a("a"),Ds=s("DiffEdit: Diffusion-based semantic image editing with mask guidance"),Vs=s(" is by Guillaume Couairon, Jakob Verbeek, Holger Schwenk, and Matthieu Cord."),ca=p(),vt=a("p"),Ss=s("The abstract from the paper is:"),ma=p(),Tt=a("p"),nn=a("em"),$s=s("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."),fa=p(),C=a("p"),Ns=s("The original codebase can be found at "),ve=a("a"),xs=s("Xiang-cd/DiffEdit-stable-diffusion"),Fs=s(", and you can try it out in this "),Te=a("a"),Ys=s("demo"),Hs=s("."),ua=p(),q=a("p"),zs=s("This pipeline was contributed by "),Ue=a("a"),Ps=s("clarencechen"),Qs=s(". \u2764\uFE0F"),ga=p(),x=a("h2"),K=a("a"),an=a("span"),g(Ze.$$.fragment),As=p(),sn=a("span"),Ls=s("Tips"),ha=p(),Z=a("ul"),on=a("li"),qs=s("The pipeline can generate masks that can be fed into other inpainting pipelines. Check out the code examples below to know more."),Ks=p(),W=a("li"),Os=s("In order to generate an image using this pipeline, both an image mask (manually specified or generated using "),ln=a("code"),eo=s("generate_mask"),to=s(`)
and a set of partially inverted latents (generated using `),rn=a("code"),no=s("invert"),ao=s(") "),pn=a("em"),so=s("must"),oo=s(` be provided as arguments when calling the pipeline to generate the final edited image.
Refer to the code examples below for more details.`),io=p(),E=a("li"),lo=s("The function "),dn=a("code"),ro=s("generate_mask"),po=s(" exposes two prompt arguments, "),cn=a("code"),co=s("source_prompt"),mo=s(" and "),mn=a("code"),fo=s("target_prompt"),uo=s(`,
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
`),fn=a("code"),go=s("source_prompt_embeds"),ho=s(" and \u201Cdog\u201D to "),un=a("code"),bo=s("target_prompt_embeds"),yo=s(". Refer to the code example below for more details."),_o=p(),G=a("li"),wo=s("When generating partially inverted latents using "),gn=a("code"),Mo=s("invert"),Jo=s(`, assign a caption or text embedding describing the
overall image to the `),hn=a("code"),vo=s("prompt"),To=s(` 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 `),Ut=a("a"),Uo=s("this code example"),Zo=s(" for more details."),Eo=p(),I=a("li"),jo=s("When calling the pipeline to generate the final edited image, assign the source concept to "),bn=a("code"),Io=s("negative_prompt"),ko=s(`
and the target concept to `),yn=a("code"),Wo=s("prompt"),Go=s(`. Taking the above example, you simply have to set the embeddings related to
the phrases including \u201Ccat\u201D to `),_n=a("code"),Bo=s("negative_prompt_embeds"),Ro=s(" and \u201Cdog\u201D to "),wn=a("code"),Xo=s("prompt_embeds"),Co=s(`. Refer to the code example
below for more details.`),Do=p(),Zt=a("li"),Vo=s("If you wanted to reverse the direction in the example above, i.e., \u201Cdog -> cat\u201D, then it\u2019s recommended to:"),F=a("ul"),B=a("li"),So=s("Swap the "),Mn=a("code"),$o=s("source_prompt"),No=s(" and "),Jn=a("code"),xo=s("target_prompt"),Fo=s(" in the arguments to "),vn=a("code"),Yo=s("generate_mask"),Ho=s("."),zo=p(),Ee=a("li"),Po=s("Change the input prompt for "),Tn=a("code"),Qo=s("invert"),Ao=s(" to include \u201Cdog\u201D."),Lo=p(),Y=a("li"),qo=s("Swap the "),Un=a("code"),Ko=s("prompt"),Oo=s(" and "),Zn=a("code"),ei=s("negative_prompt"),ti=s(" in the arguments to call the pipeline to generate the final edited image."),ni=p(),je=a("li"),ai=s("Note that the source and target prompts, or their corresponding embeddings, can also be automatically generated. Please, refer to "),Et=a("a"),si=s("this discussion"),oi=s(" for more details."),ba=p(),H=a("h2"),O=a("a"),En=a("span"),g(Ie.$$.fragment),ii=p(),jn=a("span"),li=s("Usage example"),ya=p(),z=a("h3"),ee=a("a"),In=a("span"),g(ke.$$.fragment),ri=p(),kn=a("span"),pi=s("Based on an input image with a caption"),_a=p(),te=a("p"),di=s(`When the pipeline is conditioned on an input image, we first obtain partially inverted latents from the input image using a
`),Wn=a("code"),ci=s("DDIMInverseScheduler"),mi=s(` 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.`),wa=p(),jt=a("p"),fi=s("First, let\u2019s load our pipeline:"),Ma=p(),g(We.$$.fragment),Ja=p(),It=a("p"),ui=s("Then, we load an input image to edit using our method:"),va=p(),g(Ge.$$.fragment),Ta=p(),kt=a("p"),gi=s("Then, we employ the source and target prompts to generate the editing mask:"),Ua=p(),g(Be.$$.fragment),Za=p(),Wt=a("p"),hi=s("Then, we employ the caption and the input image to get the inverted latents:"),Ea=p(),g(Re.$$.fragment),ja=p(),Gt=a("p"),bi=s("Now, generate the image with the inverted latents and semantically generated mask:"),Ia=p(),g(Xe.$$.fragment),ka=p(),P=a("h2"),ne=a("a"),Gn=a("span"),g(Ce.$$.fragment),yi=p(),Bn=a("span"),_i=s("Generating image captions for inversion"),Wa=p(),ae=a("p"),wi=s(`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 `),De=a("a"),Mi=s("BLIP"),Ji=s(` model
for generating captions.`),Ga=p(),Bt=a("p"),vi=s("First, let\u2019s load our automatic image captioning model:"),Ba=p(),g(Ve.$$.fragment),Ra=p(),Rt=a("p"),Ti=s("Then, we define a utility to generate captions from an input image using the model:"),Xa=p(),g(Se.$$.fragment),Ca=p(),Xt=a("p"),Ui=s("Then, we load an input image for conditioning and obtain a suitable caption for it:"),Da=p(),g($e.$$.fragment),Va=p(),Ct=a("p"),Zi=s("Then, we employ the generated caption and the input image to get the inverted latents:"),Sa=p(),g(Ne.$$.fragment),$a=p(),Dt=a("p"),Ei=s("Now, generate the image with the inverted latents and semantically generated mask from our source and target prompts:"),Na=p(),g(xe.$$.fragment),xa=p(),Q=a("h2"),se=a("a"),Rn=a("span"),g(Fe.$$.fragment),ji=p(),Xn=a("span"),Ii=s("Generating source and target embeddings"),Fa=p(),oe=a("p"),ki=s(`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 `),Ye=a("a"),Wi=s("Flan-T5"),Gi=s(` model
for generating source an target embeddings.`),Ya=p(),He=a("p"),Cn=a("strong"),Bi=s("1. Load the generation model"),Ri=s(":"),Ha=p(),g(ze.$$.fragment),za=p(),Pe=a("p"),Dn=a("strong"),Xi=s("2. Construct a starting prompt"),Ci=s(":"),Pa=p(),g(Qe.$$.fragment),Qa=p(),Vt=a("p"),Di=s("Here, we\u2019re interested in the \u201Cbowl -> basket\u201D direction."),Aa=p(),Ae=a("p"),Vn=a("strong"),Vi=s("3. Generate prompts"),Si=s(":"),La=p(),St=a("p"),$i=s("We can use a utility like so for this purpose."),qa=p(),g(Le.$$.fragment),Ka=p(),$t=a("p"),Ni=s("And then we just call it to generate our prompts:"),Oa=p(),g(qe.$$.fragment),es=p(),D=a("p"),xi=s(`We encourage you to play around with the different parameters supported by the
`),Sn=a("code"),Fi=s("generate()"),Yi=s(" method ("),Ke=a("a"),Hi=s("documentation"),zi=s(") for the generation quality you are looking for."),ts=p(),Oe=a("p"),$n=a("strong"),Pi=s("4. Load the embedding model"),Qi=s(":"),ns=p(),Nt=a("p"),Ai=s("Here, we need to use the same text encoder model used by the subsequent Stable Diffusion model."),as=p(),g(et.$$.fragment),ss=p(),tt=a("p"),Nn=a("strong"),Li=s("5. Compute embeddings"),qi=s(":"),os=p(),g(nt.$$.fragment),is=p(),xt=a("p"),Ki=s("And you\u2019re done! Now, you can use these embeddings directly while calling the pipeline:"),ls=p(),g(at.$$.fragment),rs=p(),A=a("h2"),ie=a("a"),xn=a("span"),g(st.$$.fragment),Oi=p(),Fn=a("span"),el=s("StableDiffusionDiffEditPipeline"),ps=p(),M=a("div"),g(ot.$$.fragment),tl=p(),g(le.$$.fragment),nl=p(),Yn=a("p"),al=s("Pipeline for text-guided image inpainting using Stable Diffusion and DiffEdit."),sl=p(),it=a("p"),ol=s("This model inherits from "),Ft=a("a"),il=s("DiffusionPipeline"),ll=s(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),rl=p(),Hn=a("p"),pl=s("In addition the pipeline inherits the following loading methods:"),dl=p(),lt=a("ul"),rt=a("li"),zn=a("em"),cl=s("Textual-Inversion"),ml=s(": "),Yt=a("a"),fl=s("loaders.TextualInversionLoaderMixin.load_textual_inversion()"),ul=p(),pt=a("li"),Pn=a("em"),gl=s("LoRA"),hl=s(": "),Ht=a("a"),bl=s("loaders.LoraLoaderMixin.load_lora_weights()"),yl=p(),Qn=a("p"),_l=s("as well as the following saving methods:"),wl=p(),An=a("ul"),dt=a("li"),Ln=a("em"),Ml=s("LoRA"),Jl=s(": "),zt=a("a"),vl=s("loaders.LoraLoaderMixin.save_lora_weights()"),Tl=p(),V=a("div"),g(ct.$$.fragment),Ul=p(),qn=a("p"),Zl=s("Generate a latent mask given a mask prompt, a target prompt, and an image."),El=p(),g(re.$$.fragment),jl=p(),S=a("div"),g(mt.$$.fragment),Il=p(),Kn=a("p"),kl=s("Generate inverted latents given a prompt and image."),Wl=p(),g(pe.$$.fragment),Gl=p(),$=a("div"),g(ft.$$.fragment),Bl=p(),On=a("p"),Rl=s("The call function to the pipeline for generation."),Xl=p(),g(de.$$.fragment),Cl=p(),ce=a("div"),g(ut.$$.fragment),Dl=p(),gt=a("p"),Vl=s("Disable sliced VAE decoding. If "),ea=a("code"),Sl=s("enable_vae_slicing"),$l=s(` was previously enabled, this method will go back to
computing decoding in one step.`),Nl=p(),me=a("div"),g(ht.$$.fragment),xl=p(),bt=a("p"),Fl=s("Disable tiled VAE decoding. If "),ta=a("code"),Yl=s("enable_vae_tiling"),Hl=s(` was previously enabled, this method will go back to
computing decoding in one step.`),zl=p(),fe=a("div"),g(yt.$$.fragment),Pl=p(),R=a("p"),Ql=s(`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 `),na=a("code"),Al=s("forward"),Ll=s(` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),aa=a("code"),ql=s("enable_sequential_cpu_offload"),Kl=s(`, but performance is much better due to the
iterative execution of the `),sa=a("code"),Ol=s("unet"),er=s("."),tr=p(),ue=a("div"),g(_t.$$.fragment),nr=p(),oa=a("p"),ar=s(`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.`),sr=p(),ge=a("div"),g(wt.$$.fragment),or=p(),ia=a("p"),ir=s(`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.`),this.h()},l(e){const r=od('[data-svelte="svelte-1phssyn"]',document.head);u=o(r,"META",{name:!0,content:!0}),r.forEach(n),v=d(e),f=o(e,"H1",{class:!0});var Mt=l(f);U=o(Mt,"A",{id:!0,class:!0,href:!0});var la=l(U);en=o(la,"SPAN",{});var ra=l(en);h(we.$$.fragment,ra),ra.forEach(n),la.forEach(n),Xs=d(Mt),tn=o(Mt,"SPAN",{});var pa=l(tn);Cs=i(pa,"DiffEdit"),pa.forEach(n),Mt.forEach(n),da=d(e),Me=o(e,"P",{});var lr=l(Me);Je=o(lr,"A",{href:!0,rel:!0});var hr=l(Je);Ds=i(hr,"DiffEdit: Diffusion-based semantic image editing with mask guidance"),hr.forEach(n),Vs=i(lr," is by Guillaume Couairon, Jakob Verbeek, Holger Schwenk, and Matthieu Cord."),lr.forEach(n),ca=d(e),vt=o(e,"P",{});var br=l(vt);Ss=i(br,"The abstract from the paper is:"),br.forEach(n),ma=d(e),Tt=o(e,"P",{});var yr=l(Tt);nn=o(yr,"EM",{});var _r=l(nn);$s=i(_r,"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."),_r.forEach(n),yr.forEach(n),fa=d(e),C=o(e,"P",{});var Pt=l(C);Ns=i(Pt,"The original codebase can be found at "),ve=o(Pt,"A",{href:!0,rel:!0});var wr=l(ve);xs=i(wr,"Xiang-cd/DiffEdit-stable-diffusion"),wr.forEach(n),Fs=i(Pt,", and you can try it out in this "),Te=o(Pt,"A",{href:!0,rel:!0});var Mr=l(Te);Ys=i(Mr,"demo"),Mr.forEach(n),Hs=i(Pt,"."),Pt.forEach(n),ua=d(e),q=o(e,"P",{});var cs=l(q);zs=i(cs,"This pipeline was contributed by "),Ue=o(cs,"A",{href:!0,rel:!0});var Jr=l(Ue);Ps=i(Jr,"clarencechen"),Jr.forEach(n),Qs=i(cs,". \u2764\uFE0F"),cs.forEach(n),ga=d(e),x=o(e,"H2",{class:!0});var ms=l(x);K=o(ms,"A",{id:!0,class:!0,href:!0});var vr=l(K);an=o(vr,"SPAN",{});var Tr=l(an);h(Ze.$$.fragment,Tr),Tr.forEach(n),vr.forEach(n),As=d(ms),sn=o(ms,"SPAN",{});var Ur=l(sn);Ls=i(Ur,"Tips"),Ur.forEach(n),ms.forEach(n),ha=d(e),Z=o(e,"UL",{});var j=l(Z);on=o(j,"LI",{});var Zr=l(on);qs=i(Zr,"The pipeline can generate masks that can be fed into other inpainting pipelines. Check out the code examples below to know more."),Zr.forEach(n),Ks=d(j),W=o(j,"LI",{});var he=l(W);Os=i(he,"In order to generate an image using this pipeline, both an image mask (manually specified or generated using "),ln=o(he,"CODE",{});var Er=l(ln);eo=i(Er,"generate_mask"),Er.forEach(n),to=i(he,`)
and a set of partially inverted latents (generated using `),rn=o(he,"CODE",{});var jr=l(rn);no=i(jr,"invert"),jr.forEach(n),ao=i(he,") "),pn=o(he,"EM",{});var Ir=l(pn);so=i(Ir,"must"),Ir.forEach(n),oo=i(he,` be provided as arguments when calling the pipeline to generate the final edited image.
Refer to the code examples below for more details.`),he.forEach(n),io=d(j),E=o(j,"LI",{});var k=l(E);lo=i(k,"The function "),dn=o(k,"CODE",{});var kr=l(dn);ro=i(kr,"generate_mask"),kr.forEach(n),po=i(k," exposes two prompt arguments, "),cn=o(k,"CODE",{});var Wr=l(cn);co=i(Wr,"source_prompt"),Wr.forEach(n),mo=i(k," and "),mn=o(k,"CODE",{});var Gr=l(mn);fo=i(Gr,"target_prompt"),Gr.forEach(n),uo=i(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
`),fn=o(k,"CODE",{});var Br=l(fn);go=i(Br,"source_prompt_embeds"),Br.forEach(n),ho=i(k," and \u201Cdog\u201D to "),un=o(k,"CODE",{});var Rr=l(un);bo=i(Rr,"target_prompt_embeds"),Rr.forEach(n),yo=i(k,". Refer to the code example below for more details."),k.forEach(n),_o=d(j),G=o(j,"LI",{});var be=l(G);wo=i(be,"When generating partially inverted latents using "),gn=o(be,"CODE",{});var Xr=l(gn);Mo=i(Xr,"invert"),Xr.forEach(n),Jo=i(be,`, assign a caption or text embedding describing the
overall image to the `),hn=o(be,"CODE",{});var Cr=l(hn);vo=i(Cr,"prompt"),Cr.forEach(n),To=i(be,` 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 `),Ut=o(be,"A",{href:!0});var Dr=l(Ut);Uo=i(Dr,"this code example"),Dr.forEach(n),Zo=i(be," for more details."),be.forEach(n),Eo=d(j),I=o(j,"LI",{});var N=l(I);jo=i(N,"When calling the pipeline to generate the final edited image, assign the source concept to "),bn=o(N,"CODE",{});var Vr=l(bn);Io=i(Vr,"negative_prompt"),Vr.forEach(n),ko=i(N,`
and the target concept to `),yn=o(N,"CODE",{});var Sr=l(yn);Wo=i(Sr,"prompt"),Sr.forEach(n),Go=i(N,`. Taking the above example, you simply have to set the embeddings related to
the phrases including \u201Ccat\u201D to `),_n=o(N,"CODE",{});var $r=l(_n);Bo=i($r,"negative_prompt_embeds"),$r.forEach(n),Ro=i(N," and \u201Cdog\u201D to "),wn=o(N,"CODE",{});var Nr=l(wn);Xo=i(Nr,"prompt_embeds"),Nr.forEach(n),Co=i(N,`. Refer to the code example
below for more details.`),N.forEach(n),Do=d(j),Zt=o(j,"LI",{});var rr=l(Zt);Vo=i(rr,"If you wanted to reverse the direction in the example above, i.e., \u201Cdog -> cat\u201D, then it\u2019s recommended to:"),F=o(rr,"UL",{});var Qt=l(F);B=o(Qt,"LI",{});var ye=l(B);So=i(ye,"Swap the "),Mn=o(ye,"CODE",{});var xr=l(Mn);$o=i(xr,"source_prompt"),xr.forEach(n),No=i(ye," and "),Jn=o(ye,"CODE",{});var Fr=l(Jn);xo=i(Fr,"target_prompt"),Fr.forEach(n),Fo=i(ye," in the arguments to "),vn=o(ye,"CODE",{});var Yr=l(vn);Yo=i(Yr,"generate_mask"),Yr.forEach(n),Ho=i(ye,"."),ye.forEach(n),zo=d(Qt),Ee=o(Qt,"LI",{});var fs=l(Ee);Po=i(fs,"Change the input prompt for "),Tn=o(fs,"CODE",{});var Hr=l(Tn);Qo=i(Hr,"invert"),Hr.forEach(n),Ao=i(fs," to include \u201Cdog\u201D."),fs.forEach(n),Lo=d(Qt),Y=o(Qt,"LI",{});var At=l(Y);qo=i(At,"Swap the "),Un=o(At,"CODE",{});var zr=l(Un);Ko=i(zr,"prompt"),zr.forEach(n),Oo=i(At," and "),Zn=o(At,"CODE",{});var Pr=l(Zn);ei=i(Pr,"negative_prompt"),Pr.forEach(n),ti=i(At," in the arguments to call the pipeline to generate the final edited image."),At.forEach(n),Qt.forEach(n),rr.forEach(n),ni=d(j),je=o(j,"LI",{});var us=l(je);ai=i(us,"Note that the source and target prompts, or their corresponding embeddings, can also be automatically generated. Please, refer to "),Et=o(us,"A",{href:!0});var Qr=l(Et);si=i(Qr,"this discussion"),Qr.forEach(n),oi=i(us," for more details."),us.forEach(n),j.forEach(n),ba=d(e),H=o(e,"H2",{class:!0});var gs=l(H);O=o(gs,"A",{id:!0,class:!0,href:!0});var Ar=l(O);En=o(Ar,"SPAN",{});var Lr=l(En);h(Ie.$$.fragment,Lr),Lr.forEach(n),Ar.forEach(n),ii=d(gs),jn=o(gs,"SPAN",{});var qr=l(jn);li=i(qr,"Usage example"),qr.forEach(n),gs.forEach(n),ya=d(e),z=o(e,"H3",{class:!0});var hs=l(z);ee=o(hs,"A",{id:!0,class:!0,href:!0});var Kr=l(ee);In=o(Kr,"SPAN",{});var Or=l(In);h(ke.$$.fragment,Or),Or.forEach(n),Kr.forEach(n),ri=d(hs),kn=o(hs,"SPAN",{});var ep=l(kn);pi=i(ep,"Based on an input image with a caption"),ep.forEach(n),hs.forEach(n),_a=d(e),te=o(e,"P",{});var bs=l(te);di=i(bs,`When the pipeline is conditioned on an input image, we first obtain partially inverted latents from the input image using a
`),Wn=o(bs,"CODE",{});var tp=l(Wn);ci=i(tp,"DDIMInverseScheduler"),tp.forEach(n),mi=i(bs,` 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.`),bs.forEach(n),wa=d(e),jt=o(e,"P",{});var np=l(jt);fi=i(np,"First, let\u2019s load our pipeline:"),np.forEach(n),Ma=d(e),h(We.$$.fragment,e),Ja=d(e),It=o(e,"P",{});var ap=l(It);ui=i(ap,"Then, we load an input image to edit using our method:"),ap.forEach(n),va=d(e),h(Ge.$$.fragment,e),Ta=d(e),kt=o(e,"P",{});var sp=l(kt);gi=i(sp,"Then, we employ the source and target prompts to generate the editing mask:"),sp.forEach(n),Ua=d(e),h(Be.$$.fragment,e),Za=d(e),Wt=o(e,"P",{});var op=l(Wt);hi=i(op,"Then, we employ the caption and the input image to get the inverted latents:"),op.forEach(n),Ea=d(e),h(Re.$$.fragment,e),ja=d(e),Gt=o(e,"P",{});var ip=l(Gt);bi=i(ip,"Now, generate the image with the inverted latents and semantically generated mask:"),ip.forEach(n),Ia=d(e),h(Xe.$$.fragment,e),ka=d(e),P=o(e,"H2",{class:!0});var ys=l(P);ne=o(ys,"A",{id:!0,class:!0,href:!0});var lp=l(ne);Gn=o(lp,"SPAN",{});var rp=l(Gn);h(Ce.$$.fragment,rp),rp.forEach(n),lp.forEach(n),yi=d(ys),Bn=o(ys,"SPAN",{});var pp=l(Bn);_i=i(pp,"Generating image captions for inversion"),pp.forEach(n),ys.forEach(n),Wa=d(e),ae=o(e,"P",{});var _s=l(ae);wi=i(_s,`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 `),De=o(_s,"A",{href:!0,rel:!0});var dp=l(De);Mi=i(dp,"BLIP"),dp.forEach(n),Ji=i(_s,` model
for generating captions.`),_s.forEach(n),Ga=d(e),Bt=o(e,"P",{});var cp=l(Bt);vi=i(cp,"First, let\u2019s load our automatic image captioning model:"),cp.forEach(n),Ba=d(e),h(Ve.$$.fragment,e),Ra=d(e),Rt=o(e,"P",{});var mp=l(Rt);Ti=i(mp,"Then, we define a utility to generate captions from an input image using the model:"),mp.forEach(n),Xa=d(e),h(Se.$$.fragment,e),Ca=d(e),Xt=o(e,"P",{});var fp=l(Xt);Ui=i(fp,"Then, we load an input image for conditioning and obtain a suitable caption for it:"),fp.forEach(n),Da=d(e),h($e.$$.fragment,e),Va=d(e),Ct=o(e,"P",{});var up=l(Ct);Zi=i(up,"Then, we employ the generated caption and the input image to get the inverted latents:"),up.forEach(n),Sa=d(e),h(Ne.$$.fragment,e),$a=d(e),Dt=o(e,"P",{});var gp=l(Dt);Ei=i(gp,"Now, generate the image with the inverted latents and semantically generated mask from our source and target prompts:"),gp.forEach(n),Na=d(e),h(xe.$$.fragment,e),xa=d(e),Q=o(e,"H2",{class:!0});var ws=l(Q);se=o(ws,"A",{id:!0,class:!0,href:!0});var hp=l(se);Rn=o(hp,"SPAN",{});var bp=l(Rn);h(Fe.$$.fragment,bp),bp.forEach(n),hp.forEach(n),ji=d(ws),Xn=o(ws,"SPAN",{});var yp=l(Xn);Ii=i(yp,"Generating source and target embeddings"),yp.forEach(n),ws.forEach(n),Fa=d(e),oe=o(e,"P",{});var Ms=l(oe);ki=i(Ms,`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 `),Ye=o(Ms,"A",{href:!0,rel:!0});var _p=l(Ye);Wi=i(_p,"Flan-T5"),_p.forEach(n),Gi=i(Ms,` model
for generating source an target embeddings.`),Ms.forEach(n),Ya=d(e),He=o(e,"P",{});var pr=l(He);Cn=o(pr,"STRONG",{});var wp=l(Cn);Bi=i(wp,"1. Load the generation model"),wp.forEach(n),Ri=i(pr,":"),pr.forEach(n),Ha=d(e),h(ze.$$.fragment,e),za=d(e),Pe=o(e,"P",{});var dr=l(Pe);Dn=o(dr,"STRONG",{});var Mp=l(Dn);Xi=i(Mp,"2. Construct a starting prompt"),Mp.forEach(n),Ci=i(dr,":"),dr.forEach(n),Pa=d(e),h(Qe.$$.fragment,e),Qa=d(e),Vt=o(e,"P",{});var Jp=l(Vt);Di=i(Jp,"Here, we\u2019re interested in the \u201Cbowl -> basket\u201D direction."),Jp.forEach(n),Aa=d(e),Ae=o(e,"P",{});var cr=l(Ae);Vn=o(cr,"STRONG",{});var vp=l(Vn);Vi=i(vp,"3. Generate prompts"),vp.forEach(n),Si=i(cr,":"),cr.forEach(n),La=d(e),St=o(e,"P",{});var Tp=l(St);$i=i(Tp,"We can use a utility like so for this purpose."),Tp.forEach(n),qa=d(e),h(Le.$$.fragment,e),Ka=d(e),$t=o(e,"P",{});var Up=l($t);Ni=i(Up,"And then we just call it to generate our prompts:"),Up.forEach(n),Oa=d(e),h(qe.$$.fragment,e),es=d(e),D=o(e,"P",{});var Lt=l(D);xi=i(Lt,`We encourage you to play around with the different parameters supported by the
`),Sn=o(Lt,"CODE",{});var Zp=l(Sn);Fi=i(Zp,"generate()"),Zp.forEach(n),Yi=i(Lt," method ("),Ke=o(Lt,"A",{href:!0,rel:!0});var Ep=l(Ke);Hi=i(Ep,"documentation"),Ep.forEach(n),zi=i(Lt,") for the generation quality you are looking for."),Lt.forEach(n),ts=d(e),Oe=o(e,"P",{});var mr=l(Oe);$n=o(mr,"STRONG",{});var jp=l($n);Pi=i(jp,"4. Load the embedding model"),jp.forEach(n),Qi=i(mr,":"),mr.forEach(n),ns=d(e),Nt=o(e,"P",{});var Ip=l(Nt);Ai=i(Ip,"Here, we need to use the same text encoder model used by the subsequent Stable Diffusion model."),Ip.forEach(n),as=d(e),h(et.$$.fragment,e),ss=d(e),tt=o(e,"P",{});var fr=l(tt);Nn=o(fr,"STRONG",{});var kp=l(Nn);Li=i(kp,"5. Compute embeddings"),kp.forEach(n),qi=i(fr,":"),fr.forEach(n),os=d(e),h(nt.$$.fragment,e),is=d(e),xt=o(e,"P",{});var Wp=l(xt);Ki=i(Wp,"And you\u2019re done! Now, you can use these embeddings directly while calling the pipeline:"),Wp.forEach(n),ls=d(e),h(at.$$.fragment,e),rs=d(e),A=o(e,"H2",{class:!0});var Js=l(A);ie=o(Js,"A",{id:!0,class:!0,href:!0});var Gp=l(ie);xn=o(Gp,"SPAN",{});var Bp=l(xn);h(st.$$.fragment,Bp),Bp.forEach(n),Gp.forEach(n),Oi=d(Js),Fn=o(Js,"SPAN",{});var Rp=l(Fn);el=i(Rp,"StableDiffusionDiffEditPipeline"),Rp.forEach(n),Js.forEach(n),ps=d(e),M=o(e,"DIV",{class:!0});var J=l(M);h(ot.$$.fragment,J),tl=d(J),h(le.$$.fragment,J),nl=d(J),Yn=o(J,"P",{});var Xp=l(Yn);al=i(Xp,"Pipeline for text-guided image inpainting using Stable Diffusion and DiffEdit."),Xp.forEach(n),sl=d(J),it=o(J,"P",{});var vs=l(it);ol=i(vs,"This model inherits from "),Ft=o(vs,"A",{href:!0});var Cp=l(Ft);il=i(Cp,"DiffusionPipeline"),Cp.forEach(n),ll=i(vs,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),vs.forEach(n),rl=d(J),Hn=o(J,"P",{});var Dp=l(Hn);pl=i(Dp,"In addition the pipeline inherits the following loading methods:"),Dp.forEach(n),dl=d(J),lt=o(J,"UL",{});var Ts=l(lt);rt=o(Ts,"LI",{});var Us=l(rt);zn=o(Us,"EM",{});var Vp=l(zn);cl=i(Vp,"Textual-Inversion"),Vp.forEach(n),ml=i(Us,": "),Yt=o(Us,"A",{href:!0});var Sp=l(Yt);fl=i(Sp,"loaders.TextualInversionLoaderMixin.load_textual_inversion()"),Sp.forEach(n),Us.forEach(n),ul=d(Ts),pt=o(Ts,"LI",{});var Zs=l(pt);Pn=o(Zs,"EM",{});var $p=l(Pn);gl=i($p,"LoRA"),$p.forEach(n),hl=i(Zs,": "),Ht=o(Zs,"A",{href:!0});var Np=l(Ht);bl=i(Np,"loaders.LoraLoaderMixin.load_lora_weights()"),Np.forEach(n),Zs.forEach(n),Ts.forEach(n),yl=d(J),Qn=o(J,"P",{});var xp=l(Qn);_l=i(xp,"as well as the following saving methods:"),xp.forEach(n),wl=d(J),An=o(J,"UL",{});var Fp=l(An);dt=o(Fp,"LI",{});var Es=l(dt);Ln=o(Es,"EM",{});var Yp=l(Ln);Ml=i(Yp,"LoRA"),Yp.forEach(n),Jl=i(Es,": "),zt=o(Es,"A",{href:!0});var Hp=l(zt);vl=i(Hp,"loaders.LoraLoaderMixin.save_lora_weights()"),Hp.forEach(n),Es.forEach(n),Fp.forEach(n),Tl=d(J),V=o(J,"DIV",{class:!0});var qt=l(V);h(ct.$$.fragment,qt),Ul=d(qt),qn=o(qt,"P",{});var zp=l(qn);Zl=i(zp,"Generate a latent mask given a mask prompt, a target prompt, and an image."),zp.forEach(n),El=d(qt),h(re.$$.fragment,qt),qt.forEach(n),jl=d(J),S=o(J,"DIV",{class:!0});var Kt=l(S);h(mt.$$.fragment,Kt),Il=d(Kt),Kn=o(Kt,"P",{});var Pp=l(Kn);kl=i(Pp,"Generate inverted latents given a prompt and image."),Pp.forEach(n),Wl=d(Kt),h(pe.$$.fragment,Kt),Kt.forEach(n),Gl=d(J),$=o(J,"DIV",{class:!0});var Ot=l($);h(ft.$$.fragment,Ot),Bl=d(Ot),On=o(Ot,"P",{});var Qp=l(On);Rl=i(Qp,"The call function to the pipeline for generation."),Qp.forEach(n),Xl=d(Ot),h(de.$$.fragment,Ot),Ot.forEach(n),Cl=d(J),ce=o(J,"DIV",{class:!0});var js=l(ce);h(ut.$$.fragment,js),Dl=d(js),gt=o(js,"P",{});var Is=l(gt);Vl=i(Is,"Disable sliced VAE decoding. If "),ea=o(Is,"CODE",{});var Ap=l(ea);Sl=i(Ap,"enable_vae_slicing"),Ap.forEach(n),$l=i(Is,` was previously enabled, this method will go back to
computing decoding in one step.`),Is.forEach(n),js.forEach(n),Nl=d(J),me=o(J,"DIV",{class:!0});var ks=l(me);h(ht.$$.fragment,ks),xl=d(ks),bt=o(ks,"P",{});var Ws=l(bt);Fl=i(Ws,"Disable tiled VAE decoding. If "),ta=o(Ws,"CODE",{});var Lp=l(ta);Yl=i(Lp,"enable_vae_tiling"),Lp.forEach(n),Hl=i(Ws,` was previously enabled, this method will go back to
computing decoding in one step.`),Ws.forEach(n),ks.forEach(n),zl=d(J),fe=o(J,"DIV",{class:!0});var Gs=l(fe);h(yt.$$.fragment,Gs),Pl=d(Gs),R=o(Gs,"P",{});var _e=l(R);Ql=i(_e,`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 `),na=o(_e,"CODE",{});var qp=l(na);Al=i(qp,"forward"),qp.forEach(n),Ll=i(_e,` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),aa=o(_e,"CODE",{});var Kp=l(aa);ql=i(Kp,"enable_sequential_cpu_offload"),Kp.forEach(n),Kl=i(_e,`, but performance is much better due to the
iterative execution of the `),sa=o(_e,"CODE",{});var Op=l(sa);Ol=i(Op,"unet"),Op.forEach(n),er=i(_e,"."),_e.forEach(n),Gs.forEach(n),tr=d(J),ue=o(J,"DIV",{class:!0});var Bs=l(ue);h(_t.$$.fragment,Bs),nr=d(Bs),oa=o(Bs,"P",{});var ed=l(oa);ar=i(ed,`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.`),ed.forEach(n),Bs.forEach(n),sr=d(J),ge=o(J,"DIV",{class:!0});var Rs=l(ge);h(wt.$$.fragment,Rs),or=d(Rs),ia=o(Rs,"P",{});var td=l(ia);ir=i(td,`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.`),td.forEach(n),Rs.forEach(n),J.forEach(n),this.h()},h(){m(u,"name","hf:doc:metadata"),m(u,"content",JSON.stringify(fd)),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(Je,"href","https://huggingface.co/papers/2210.11427"),m(Je,"rel","nofollow"),m(ve,"href","https://github.com/Xiang-cd/DiffEdit-stable-diffusion"),m(ve,"rel","nofollow"),m(Te,"href","https://blog.problemsolversguild.com/technical/research/2022/11/02/DiffEdit-Implementation.html"),m(Te,"rel","nofollow"),m(Ue,"href","https://github.com/clarencechen"),m(Ue,"rel","nofollow"),m(K,"id","tips"),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","#tips"),m(x,"class","relative group"),m(Ut,"href","#generating-image-captions-for-inversion"),m(Et,"href","#generating-source-and-target-embeddings"),m(O,"id","usage-example"),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","#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(P,"class","relative group"),m(De,"href","https://huggingface.co/docs/transformers/model_doc/blip"),m(De,"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(Q,"class","relative group"),m(Ye,"href","https://huggingface.co/docs/transformers/model_doc/flan-t5"),m(Ye,"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(A,"class","relative group"),m(Ft,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),m(Yt,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion"),m(Ht,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),m(zt,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights"),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(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($,"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(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(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(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,u),c(e,v,r),c(e,f,r),t(f,U),t(U,en),b(we,en,null),t(f,Xs),t(f,tn),t(tn,Cs),c(e,da,r),c(e,Me,r),t(Me,Je),t(Je,Ds),t(Me,Vs),c(e,ca,r),c(e,vt,r),t(vt,Ss),c(e,ma,r),c(e,Tt,r),t(Tt,nn),t(nn,$s),c(e,fa,r),c(e,C,r),t(C,Ns),t(C,ve),t(ve,xs),t(C,Fs),t(C,Te),t(Te,Ys),t(C,Hs),c(e,ua,r),c(e,q,r),t(q,zs),t(q,Ue),t(Ue,Ps),t(q,Qs),c(e,ga,r),c(e,x,r),t(x,K),t(K,an),b(Ze,an,null),t(x,As),t(x,sn),t(sn,Ls),c(e,ha,r),c(e,Z,r),t(Z,on),t(on,qs),t(Z,Ks),t(Z,W),t(W,Os),t(W,ln),t(ln,eo),t(W,to),t(W,rn),t(rn,no),t(W,ao),t(W,pn),t(pn,so),t(W,oo),t(Z,io),t(Z,E),t(E,lo),t(E,dn),t(dn,ro),t(E,po),t(E,cn),t(cn,co),t(E,mo),t(E,mn),t(mn,fo),t(E,uo),t(E,fn),t(fn,go),t(E,ho),t(E,un),t(un,bo),t(E,yo),t(Z,_o),t(Z,G),t(G,wo),t(G,gn),t(gn,Mo),t(G,Jo),t(G,hn),t(hn,vo),t(G,To),t(G,Ut),t(Ut,Uo),t(G,Zo),t(Z,Eo),t(Z,I),t(I,jo),t(I,bn),t(bn,Io),t(I,ko),t(I,yn),t(yn,Wo),t(I,Go),t(I,_n),t(_n,Bo),t(I,Ro),t(I,wn),t(wn,Xo),t(I,Co),t(Z,Do),t(Z,Zt),t(Zt,Vo),t(Zt,F),t(F,B),t(B,So),t(B,Mn),t(Mn,$o),t(B,No),t(B,Jn),t(Jn,xo),t(B,Fo),t(B,vn),t(vn,Yo),t(B,Ho),t(F,zo),t(F,Ee),t(Ee,Po),t(Ee,Tn),t(Tn,Qo),t(Ee,Ao),t(F,Lo),t(F,Y),t(Y,qo),t(Y,Un),t(Un,Ko),t(Y,Oo),t(Y,Zn),t(Zn,ei),t(Y,ti),t(Z,ni),t(Z,je),t(je,ai),t(je,Et),t(Et,si),t(je,oi),c(e,ba,r),c(e,H,r),t(H,O),t(O,En),b(Ie,En,null),t(H,ii),t(H,jn),t(jn,li),c(e,ya,r),c(e,z,r),t(z,ee),t(ee,In),b(ke,In,null),t(z,ri),t(z,kn),t(kn,pi),c(e,_a,r),c(e,te,r),t(te,di),t(te,Wn),t(Wn,ci),t(te,mi),c(e,wa,r),c(e,jt,r),t(jt,fi),c(e,Ma,r),b(We,e,r),c(e,Ja,r),c(e,It,r),t(It,ui),c(e,va,r),b(Ge,e,r),c(e,Ta,r),c(e,kt,r),t(kt,gi),c(e,Ua,r),b(Be,e,r),c(e,Za,r),c(e,Wt,r),t(Wt,hi),c(e,Ea,r),b(Re,e,r),c(e,ja,r),c(e,Gt,r),t(Gt,bi),c(e,Ia,r),b(Xe,e,r),c(e,ka,r),c(e,P,r),t(P,ne),t(ne,Gn),b(Ce,Gn,null),t(P,yi),t(P,Bn),t(Bn,_i),c(e,Wa,r),c(e,ae,r),t(ae,wi),t(ae,De),t(De,Mi),t(ae,Ji),c(e,Ga,r),c(e,Bt,r),t(Bt,vi),c(e,Ba,r),b(Ve,e,r),c(e,Ra,r),c(e,Rt,r),t(Rt,Ti),c(e,Xa,r),b(Se,e,r),c(e,Ca,r),c(e,Xt,r),t(Xt,Ui),c(e,Da,r),b($e,e,r),c(e,Va,r),c(e,Ct,r),t(Ct,Zi),c(e,Sa,r),b(Ne,e,r),c(e,$a,r),c(e,Dt,r),t(Dt,Ei),c(e,Na,r),b(xe,e,r),c(e,xa,r),c(e,Q,r),t(Q,se),t(se,Rn),b(Fe,Rn,null),t(Q,ji),t(Q,Xn),t(Xn,Ii),c(e,Fa,r),c(e,oe,r),t(oe,ki),t(oe,Ye),t(Ye,Wi),t(oe,Gi),c(e,Ya,r),c(e,He,r),t(He,Cn),t(Cn,Bi),t(He,Ri),c(e,Ha,r),b(ze,e,r),c(e,za,r),c(e,Pe,r),t(Pe,Dn),t(Dn,Xi),t(Pe,Ci),c(e,Pa,r),b(Qe,e,r),c(e,Qa,r),c(e,Vt,r),t(Vt,Di),c(e,Aa,r),c(e,Ae,r),t(Ae,Vn),t(Vn,Vi),t(Ae,Si),c(e,La,r),c(e,St,r),t(St,$i),c(e,qa,r),b(Le,e,r),c(e,Ka,r),c(e,$t,r),t($t,Ni),c(e,Oa,r),b(qe,e,r),c(e,es,r),c(e,D,r),t(D,xi),t(D,Sn),t(Sn,Fi),t(D,Yi),t(D,Ke),t(Ke,Hi),t(D,zi),c(e,ts,r),c(e,Oe,r),t(Oe,$n),t($n,Pi),t(Oe,Qi),c(e,ns,r),c(e,Nt,r),t(Nt,Ai),c(e,as,r),b(et,e,r),c(e,ss,r),c(e,tt,r),t(tt,Nn),t(Nn,Li),t(tt,qi),c(e,os,r),b(nt,e,r),c(e,is,r),c(e,xt,r),t(xt,Ki),c(e,ls,r),b(at,e,r),c(e,rs,r),c(e,A,r),t(A,ie),t(ie,xn),b(st,xn,null),t(A,Oi),t(A,Fn),t(Fn,el),c(e,ps,r),c(e,M,r),b(ot,M,null),t(M,tl),b(le,M,null),t(M,nl),t(M,Yn),t(Yn,al),t(M,sl),t(M,it),t(it,ol),t(it,Ft),t(Ft,il),t(it,ll),t(M,rl),t(M,Hn),t(Hn,pl),t(M,dl),t(M,lt),t(lt,rt),t(rt,zn),t(zn,cl),t(rt,ml),t(rt,Yt),t(Yt,fl),t(lt,ul),t(lt,pt),t(pt,Pn),t(Pn,gl),t(pt,hl),t(pt,Ht),t(Ht,bl),t(M,yl),t(M,Qn),t(Qn,_l),t(M,wl),t(M,An),t(An,dt),t(dt,Ln),t(Ln,Ml),t(dt,Jl),t(dt,zt),t(zt,vl),t(M,Tl),t(M,V),b(ct,V,null),t(V,Ul),t(V,qn),t(qn,Zl),t(V,El),b(re,V,null),t(M,jl),t(M,S),b(mt,S,null),t(S,Il),t(S,Kn),t(Kn,kl),t(S,Wl),b(pe,S,null),t(M,Gl),t(M,$),b(ft,$,null),t($,Bl),t($,On),t(On,Rl),t($,Xl),b(de,$,null),t(M,Cl),t(M,ce),b(ut,ce,null),t(ce,Dl),t(ce,gt),t(gt,Vl),t(gt,ea),t(ea,Sl),t(gt,$l),t(M,Nl),t(M,me),b(ht,me,null),t(me,xl),t(me,bt),t(bt,Fl),t(bt,ta),t(ta,Yl),t(bt,Hl),t(M,zl),t(M,fe),b(yt,fe,null),t(fe,Pl),t(fe,R),t(R,Ql),t(R,na),t(na,Al),t(R,Ll),t(R,aa),t(aa,ql),t(R,Kl),t(R,sa),t(sa,Ol),t(R,er),t(M,tr),t(M,ue),b(_t,ue,null),t(ue,nr),t(ue,oa),t(oa,ar),t(M,sr),t(M,ge),b(wt,ge,null),t(ge,or),t(ge,ia),t(ia,ir),ds=!0},p(e,[r]){const Mt={};r&2&&(Mt.$$scope={dirty:r,ctx:e}),le.$set(Mt);const la={};r&2&&(la.$$scope={dirty:r,ctx:e}),re.$set(la);const ra={};r&2&&(ra.$$scope={dirty:r,ctx:e}),pe.$set(ra);const pa={};r&2&&(pa.$$scope={dirty:r,ctx:e}),de.$set(pa)},i(e){ds||(y(we.$$.fragment,e),y(Ze.$$.fragment,e),y(Ie.$$.fragment,e),y(ke.$$.fragment,e),y(We.$$.fragment,e),y(Ge.$$.fragment,e),y(Be.$$.fragment,e),y(Re.$$.fragment,e),y(Xe.$$.fragment,e),y(Ce.$$.fragment,e),y(Ve.$$.fragment,e),y(Se.$$.fragment,e),y($e.$$.fragment,e),y(Ne.$$.fragment,e),y(xe.$$.fragment,e),y(Fe.$$.fragment,e),y(ze.$$.fragment,e),y(Qe.$$.fragment,e),y(Le.$$.fragment,e),y(qe.$$.fragment,e),y(et.$$.fragment,e),y(nt.$$.fragment,e),y(at.$$.fragment,e),y(st.$$.fragment,e),y(ot.$$.fragment,e),y(le.$$.fragment,e),y(ct.$$.fragment,e),y(re.$$.fragment,e),y(mt.$$.fragment,e),y(pe.$$.fragment,e),y(ft.$$.fragment,e),y(de.$$.fragment,e),y(ut.$$.fragment,e),y(ht.$$.fragment,e),y(yt.$$.fragment,e),y(_t.$$.fragment,e),y(wt.$$.fragment,e),ds=!0)},o(e){_(we.$$.fragment,e),_(Ze.$$.fragment,e),_(Ie.$$.fragment,e),_(ke.$$.fragment,e),_(We.$$.fragment,e),_(Ge.$$.fragment,e),_(Be.$$.fragment,e),_(Re.$$.fragment,e),_(Xe.$$.fragment,e),_(Ce.$$.fragment,e),_(Ve.$$.fragment,e),_(Se.$$.fragment,e),_($e.$$.fragment,e),_(Ne.$$.fragment,e),_(xe.$$.fragment,e),_(Fe.$$.fragment,e),_(ze.$$.fragment,e),_(Qe.$$.fragment,e),_(Le.$$.fragment,e),_(qe.$$.fragment,e),_(et.$$.fragment,e),_(nt.$$.fragment,e),_(at.$$.fragment,e),_(st.$$.fragment,e),_(ot.$$.fragment,e),_(le.$$.fragment,e),_(ct.$$.fragment,e),_(re.$$.fragment,e),_(mt.$$.fragment,e),_(pe.$$.fragment,e),_(ft.$$.fragment,e),_(de.$$.fragment,e),_(ut.$$.fragment,e),_(ht.$$.fragment,e),_(yt.$$.fragment,e),_(_t.$$.fragment,e),_(wt.$$.fragment,e),ds=!1},d(e){n(u),e&&n(v),e&&n(f),w(we),e&&n(da),e&&n(Me),e&&n(ca),e&&n(vt),e&&n(ma),e&&n(Tt),e&&n(fa),e&&n(C),e&&n(ua),e&&n(q),e&&n(ga),e&&n(x),w(Ze),e&&n(ha),e&&n(Z),e&&n(ba),e&&n(H),w(Ie),e&&n(ya),e&&n(z),w(ke),e&&n(_a),e&&n(te),e&&n(wa),e&&n(jt),e&&n(Ma),w(We,e),e&&n(Ja),e&&n(It),e&&n(va),w(Ge,e),e&&n(Ta),e&&n(kt),e&&n(Ua),w(Be,e),e&&n(Za),e&&n(Wt),e&&n(Ea),w(Re,e),e&&n(ja),e&&n(Gt),e&&n(Ia),w(Xe,e),e&&n(ka),e&&n(P),w(Ce),e&&n(Wa),e&&n(ae),e&&n(Ga),e&&n(Bt),e&&n(Ba),w(Ve,e),e&&n(Ra),e&&n(Rt),e&&n(Xa),w(Se,e),e&&n(Ca),e&&n(Xt),e&&n(Da),w($e,e),e&&n(Va),e&&n(Ct),e&&n(Sa),w(Ne,e),e&&n($a),e&&n(Dt),e&&n(Na),w(xe,e),e&&n(xa),e&&n(Q),w(Fe),e&&n(Fa),e&&n(oe),e&&n(Ya),e&&n(He),e&&n(Ha),w(ze,e),e&&n(za),e&&n(Pe),e&&n(Pa),w(Qe,e),e&&n(Qa),e&&n(Vt),e&&n(Aa),e&&n(Ae),e&&n(La),e&&n(St),e&&n(qa),w(Le,e),e&&n(Ka),e&&n($t),e&&n(Oa),w(qe,e),e&&n(es),e&&n(D),e&&n(ts),e&&n(Oe),e&&n(ns),e&&n(Nt),e&&n(as),w(et,e),e&&n(ss),e&&n(tt),e&&n(os),w(nt,e),e&&n(is),e&&n(xt),e&&n(ls),w(at,e),e&&n(rs),e&&n(A),w(st),e&&n(ps),e&&n(M),w(ot),w(le),w(ct),w(re),w(mt),w(pe),w(ft),w(de),w(ut),w(ht),w(yt),w(_t),w(wt)}}}const fd={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 ud(X){return id(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Md extends nd{constructor(u){super();ad(this,u,ud,md,sd,{})}}export{Md as default,fd as metadata};
