Linoy Tsaban
commited on
Commit
·
5bd9802
1
Parent(s):
5f4a965
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,14 +75,14 @@ def reconstruct(tar_prompt,
|
|
| 75 |
skip,
|
| 76 |
wts, zs,
|
| 77 |
do_reconstruction,
|
| 78 |
-
reconstruction
|
| 79 |
):
|
| 80 |
|
| 81 |
if do_reconstruction:
|
| 82 |
reconstruction_img = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
| 83 |
reconstruction = gr.State(value=reconstruction_img)
|
| 84 |
do_reconstruction = False
|
| 85 |
-
return reconstruction.value, reconstruction, do_reconstruction
|
| 86 |
|
| 87 |
|
| 88 |
def load_and_invert(
|
|
@@ -121,6 +121,7 @@ def edit(input_image,
|
|
| 121 |
steps,
|
| 122 |
skip,
|
| 123 |
tar_cfg_scale,
|
|
|
|
| 124 |
edit_concept_1,edit_concept_2,edit_concept_3,
|
| 125 |
guidnace_scale_1,guidnace_scale_2,guidnace_scale_3,
|
| 126 |
warmup_1, warmup_2, warmup_3,
|
|
@@ -149,7 +150,7 @@ def edit(input_image,
|
|
| 149 |
num_images_per_prompt=1,
|
| 150 |
num_inference_steps=steps,
|
| 151 |
use_ddpm=True, wts=wts.value, zs=zs.value[skip:], **editing_args)
|
| 152 |
-
return sega_out.images[0]
|
| 153 |
|
| 154 |
|
| 155 |
|
|
@@ -440,6 +441,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 440 |
steps,
|
| 441 |
skip,
|
| 442 |
tar_cfg_scale,
|
|
|
|
| 443 |
edit_concept_1,edit_concept_2,edit_concept_3,
|
| 444 |
guidnace_scale_1,guidnace_scale_2,guidnace_scale_3,
|
| 445 |
warmup_1, warmup_2, warmup_3,
|
|
@@ -447,12 +449,9 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 447 |
threshold_1, threshold_2, threshold_3
|
| 448 |
|
| 449 |
],
|
| 450 |
-
outputs=[sega_edited_image],
|
| 451 |
).then(
|
| 452 |
fn =reset_do_reconstruction, outputs=[do_reconstruction]
|
| 453 |
-
).success(
|
| 454 |
-
fn = show_reconstruction_button,
|
| 455 |
-
outputs = [reconstruct_button]
|
| 456 |
)
|
| 457 |
|
| 458 |
reconstruct_button.click(
|
|
@@ -464,9 +463,9 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 464 |
tar_cfg_scale,
|
| 465 |
skip,
|
| 466 |
wts, zs, do_reconstruction,
|
| 467 |
-
reconstruction ],
|
| 468 |
-
outputs = [ddpm_edited_image,reconstruction,do_reconstruction]
|
| 469 |
-
)
|
| 470 |
|
| 471 |
|
| 472 |
# Automatically start inverting upon input_image change
|
|
|
|
| 75 |
skip,
|
| 76 |
wts, zs,
|
| 77 |
do_reconstruction,
|
| 78 |
+
reconstruction, reconstruct_button, hide_reconstruct_button
|
| 79 |
):
|
| 80 |
|
| 81 |
if do_reconstruction:
|
| 82 |
reconstruction_img = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
| 83 |
reconstruction = gr.State(value=reconstruction_img)
|
| 84 |
do_reconstruction = False
|
| 85 |
+
return reconstruction.value, reconstruction, do_reconstruction, reconstruct_button.update(visible=False), hide_reconstruct_button.update(visible=True)
|
| 86 |
|
| 87 |
|
| 88 |
def load_and_invert(
|
|
|
|
| 121 |
steps,
|
| 122 |
skip,
|
| 123 |
tar_cfg_scale,
|
| 124 |
+
reconstruct_button,
|
| 125 |
edit_concept_1,edit_concept_2,edit_concept_3,
|
| 126 |
guidnace_scale_1,guidnace_scale_2,guidnace_scale_3,
|
| 127 |
warmup_1, warmup_2, warmup_3,
|
|
|
|
| 150 |
num_images_per_prompt=1,
|
| 151 |
num_inference_steps=steps,
|
| 152 |
use_ddpm=True, wts=wts.value, zs=zs.value[skip:], **editing_args)
|
| 153 |
+
return sega_out.images[0], reconstruct_button.update(visible=True)
|
| 154 |
|
| 155 |
|
| 156 |
|
|
|
|
| 441 |
steps,
|
| 442 |
skip,
|
| 443 |
tar_cfg_scale,
|
| 444 |
+
reconstruct_button,
|
| 445 |
edit_concept_1,edit_concept_2,edit_concept_3,
|
| 446 |
guidnace_scale_1,guidnace_scale_2,guidnace_scale_3,
|
| 447 |
warmup_1, warmup_2, warmup_3,
|
|
|
|
| 449 |
threshold_1, threshold_2, threshold_3
|
| 450 |
|
| 451 |
],
|
| 452 |
+
outputs=[sega_edited_image, reconstruct_button],
|
| 453 |
).then(
|
| 454 |
fn =reset_do_reconstruction, outputs=[do_reconstruction]
|
|
|
|
|
|
|
|
|
|
| 455 |
)
|
| 456 |
|
| 457 |
reconstruct_button.click(
|
|
|
|
| 463 |
tar_cfg_scale,
|
| 464 |
skip,
|
| 465 |
wts, zs, do_reconstruction,
|
| 466 |
+
reconstruction, reconstruct_button, hide_reconstruct_button ],
|
| 467 |
+
outputs = [ddpm_edited_image,reconstruction,do_reconstruction, reconstruct_button, hide_reconstruct_button]
|
| 468 |
+
)
|
| 469 |
|
| 470 |
|
| 471 |
# Automatically start inverting upon input_image change
|