Linoy Tsaban
commited on
Commit
·
3cc1754
1
Parent(s):
dbc34e0
Update app.py
Browse files
app.py
CHANGED
|
@@ -125,7 +125,6 @@ def invert_and_reconstruct(
|
|
| 125 |
input_image,
|
| 126 |
do_inversion,
|
| 127 |
wts, zs,
|
| 128 |
-
seed, randomize_seed,
|
| 129 |
src_prompt ="",
|
| 130 |
tar_prompt="",
|
| 131 |
steps=100,
|
|
@@ -138,7 +137,6 @@ def invert_and_reconstruct(
|
|
| 138 |
|
| 139 |
|
| 140 |
x0 = load_512(input_image, device=device)
|
| 141 |
-
seed = randomize_seed_fn(seed, randomize_seed)
|
| 142 |
|
| 143 |
if do_inversion:
|
| 144 |
# invert and retrieve noise maps and latent
|
|
@@ -149,7 +147,7 @@ def invert_and_reconstruct(
|
|
| 149 |
|
| 150 |
output = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
| 151 |
|
| 152 |
-
return output, wts, zs, do_inversion
|
| 153 |
|
| 154 |
|
| 155 |
|
|
@@ -289,11 +287,13 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 289 |
# gr.Markdown(help_text)
|
| 290 |
|
| 291 |
invert_button.click(
|
|
|
|
|
|
|
|
|
|
| 292 |
fn=invert_and_reconstruct,
|
| 293 |
inputs=[input_image,
|
| 294 |
do_inversion,
|
| 295 |
wts, zs,
|
| 296 |
-
seed, randomize_seed,
|
| 297 |
src_prompt,
|
| 298 |
tar_prompt,
|
| 299 |
steps,
|
|
@@ -301,8 +301,24 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 301 |
skip,
|
| 302 |
tar_cfg_scale,
|
| 303 |
],
|
| 304 |
-
outputs=[ddpm_edited_image, wts, zs, do_inversion
|
| 305 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
|
| 307 |
edit_button.click(
|
| 308 |
fn=edit,
|
|
|
|
| 125 |
input_image,
|
| 126 |
do_inversion,
|
| 127 |
wts, zs,
|
|
|
|
| 128 |
src_prompt ="",
|
| 129 |
tar_prompt="",
|
| 130 |
steps=100,
|
|
|
|
| 137 |
|
| 138 |
|
| 139 |
x0 = load_512(input_image, device=device)
|
|
|
|
| 140 |
|
| 141 |
if do_inversion:
|
| 142 |
# invert and retrieve noise maps and latent
|
|
|
|
| 147 |
|
| 148 |
output = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
| 149 |
|
| 150 |
+
return output, wts, zs, do_inversion
|
| 151 |
|
| 152 |
|
| 153 |
|
|
|
|
| 287 |
# gr.Markdown(help_text)
|
| 288 |
|
| 289 |
invert_button.click(
|
| 290 |
+
fn = randomize_seed_fn,
|
| 291 |
+
inputs = [seed, randomize_seed],
|
| 292 |
+
outputs = [seed]).then(
|
| 293 |
fn=invert_and_reconstruct,
|
| 294 |
inputs=[input_image,
|
| 295 |
do_inversion,
|
| 296 |
wts, zs,
|
|
|
|
| 297 |
src_prompt,
|
| 298 |
tar_prompt,
|
| 299 |
steps,
|
|
|
|
| 301 |
skip,
|
| 302 |
tar_cfg_scale,
|
| 303 |
],
|
| 304 |
+
outputs=[ddpm_edited_image, wts, zs, do_inversion],
|
| 305 |
+
).success(fn=edit,
|
| 306 |
+
inputs=[input_image,
|
| 307 |
+
do_inversion,
|
| 308 |
+
wts, zs,
|
| 309 |
+
seed,
|
| 310 |
+
src_prompt,
|
| 311 |
+
tar_prompt,
|
| 312 |
+
steps,
|
| 313 |
+
skip,
|
| 314 |
+
tar_cfg_scale,
|
| 315 |
+
edit_concept,
|
| 316 |
+
sega_edit_guidance,
|
| 317 |
+
warm_up,
|
| 318 |
+
# neg_guidance,
|
| 319 |
+
|
| 320 |
+
],
|
| 321 |
+
outputs=[sega_edited_image])
|
| 322 |
|
| 323 |
edit_button.click(
|
| 324 |
fn=edit,
|