Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
•
7856099
1
Parent(s):
f76efd8
Update app.py
Browse files
app.py
CHANGED
@@ -74,10 +74,15 @@ def reconstruct(tar_prompt,
|
|
74 |
tar_cfg_scale,
|
75 |
skip,
|
76 |
wts, zs,
|
|
|
|
|
77 |
):
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
81 |
|
82 |
|
83 |
def load_and_invert(
|
@@ -90,7 +95,8 @@ def load_and_invert(
|
|
90 |
steps=100,
|
91 |
src_cfg_scale = 3.5,
|
92 |
skip=36,
|
93 |
-
tar_cfg_scale=15,
|
|
|
94 |
|
95 |
):
|
96 |
|
@@ -288,6 +294,10 @@ with gr.Blocks(css='style.css') as demo:
|
|
288 |
do_inversion = True
|
289 |
return do_inversion
|
290 |
|
|
|
|
|
|
|
|
|
291 |
def show_inversion_progress():
|
292 |
return inversion_progress.update(visible=True)
|
293 |
|
@@ -299,6 +309,8 @@ with gr.Blocks(css='style.css') as demo:
|
|
299 |
wts = gr.State()
|
300 |
zs = gr.State()
|
301 |
do_inversion = gr.State(value=True)
|
|
|
|
|
302 |
sega_concepts_counter = gr.State(1)
|
303 |
|
304 |
|
@@ -436,6 +448,8 @@ with gr.Blocks(css='style.css') as demo:
|
|
436 |
|
437 |
],
|
438 |
outputs=[sega_edited_image],
|
|
|
|
|
439 |
).success(
|
440 |
fn = show_reconstruction_button,
|
441 |
outputs = [reconstruct_button]
|
@@ -449,8 +463,9 @@ with gr.Blocks(css='style.css') as demo:
|
|
449 |
inputs = [tar_prompt,
|
450 |
tar_cfg_scale,
|
451 |
skip,
|
452 |
-
wts, zs
|
453 |
-
|
|
|
454 |
).then(fn = show_hide_reconstruction_button, outputs =[reconstruct_button, hide_reconstruct_button])
|
455 |
|
456 |
|
@@ -479,7 +494,9 @@ with gr.Blocks(css='style.css') as demo:
|
|
479 |
],
|
480 |
# outputs=[ddpm_edited_image, wts, zs, do_inversion],
|
481 |
outputs=[wts, zs, do_inversion, inversion_progress],
|
482 |
-
).then(fn = hide_inversion_progress, outputs=[inversion_progress],queue=False)
|
|
|
|
|
483 |
|
484 |
hide_reconstruct_button.click(fn = hide_reconstruction,
|
485 |
outputs=[ddpm_edited_image],
|
@@ -492,13 +509,20 @@ with gr.Blocks(css='style.css') as demo:
|
|
492 |
src_prompt.change(
|
493 |
fn = reset_do_inversion,
|
494 |
outputs = [do_inversion], queue = False
|
|
|
|
|
495 |
)
|
496 |
steps.change(fn = reset_do_inversion,
|
497 |
-
outputs = [do_inversion], queue = False)
|
|
|
|
|
498 |
|
499 |
src_cfg_scale.change(fn = reset_do_inversion,
|
500 |
-
outputs = [do_inversion], queue = False)
|
501 |
-
|
|
|
|
|
|
|
502 |
|
503 |
gr.Examples(
|
504 |
label='Examples',
|
|
|
74 |
tar_cfg_scale,
|
75 |
skip,
|
76 |
wts, zs,
|
77 |
+
do_reconstruction,
|
78 |
+
reconstruction
|
79 |
):
|
80 |
+
|
81 |
+
if do_reconstruction:
|
82 |
+
reconstruction = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
83 |
+
reconstruction = gr.State(value=reconstruction)
|
84 |
+
do_reconstruction = False
|
85 |
+
return reconstruction, do_reconstruction
|
86 |
|
87 |
|
88 |
def load_and_invert(
|
|
|
95 |
steps=100,
|
96 |
src_cfg_scale = 3.5,
|
97 |
skip=36,
|
98 |
+
tar_cfg_scale=15,
|
99 |
+
progress=gr.Progress(track_tqdm=True)
|
100 |
|
101 |
):
|
102 |
|
|
|
294 |
do_inversion = True
|
295 |
return do_inversion
|
296 |
|
297 |
+
def reset_do_reconstruction():
|
298 |
+
do_reconstruction = True
|
299 |
+
return do_reconstruction
|
300 |
+
|
301 |
def show_inversion_progress():
|
302 |
return inversion_progress.update(visible=True)
|
303 |
|
|
|
309 |
wts = gr.State()
|
310 |
zs = gr.State()
|
311 |
do_inversion = gr.State(value=True)
|
312 |
+
do_reconstruction = gr.State(value=True)
|
313 |
+
reconstruction = gr.State()
|
314 |
sega_concepts_counter = gr.State(1)
|
315 |
|
316 |
|
|
|
448 |
|
449 |
],
|
450 |
outputs=[sega_edited_image],
|
451 |
+
).then(
|
452 |
+
fn =reset_do_reconstruction, outputs=[reset_do_reconstruction])
|
453 |
).success(
|
454 |
fn = show_reconstruction_button,
|
455 |
outputs = [reconstruct_button]
|
|
|
463 |
inputs = [tar_prompt,
|
464 |
tar_cfg_scale,
|
465 |
skip,
|
466 |
+
wts, zs, do_reconstruction,
|
467 |
+
reconstruction ],
|
468 |
+
outputs = [ddpm_edited_image,reconstruction,do_reconstruction]
|
469 |
).then(fn = show_hide_reconstruction_button, outputs =[reconstruct_button, hide_reconstruct_button])
|
470 |
|
471 |
|
|
|
494 |
],
|
495 |
# outputs=[ddpm_edited_image, wts, zs, do_inversion],
|
496 |
outputs=[wts, zs, do_inversion, inversion_progress],
|
497 |
+
).then(fn = hide_inversion_progress, outputs=[inversion_progress],queue=False).then(
|
498 |
+
fn =reset_do_reconstruction, outputs=[reset_do_reconstruction])
|
499 |
+
)
|
500 |
|
501 |
hide_reconstruct_button.click(fn = hide_reconstruction,
|
502 |
outputs=[ddpm_edited_image],
|
|
|
509 |
src_prompt.change(
|
510 |
fn = reset_do_inversion,
|
511 |
outputs = [do_inversion], queue = False
|
512 |
+
).then(
|
513 |
+
fn =reset_do_reconstruction, outputs=[reset_do_reconstruction])
|
514 |
)
|
515 |
steps.change(fn = reset_do_inversion,
|
516 |
+
outputs = [do_inversion], queue = False).then(
|
517 |
+
fn =reset_do_reconstruction, outputs=[reset_do_reconstruction])
|
518 |
+
)
|
519 |
|
520 |
src_cfg_scale.change(fn = reset_do_inversion,
|
521 |
+
outputs = [do_inversion], queue = False).then(
|
522 |
+
fn =reset_do_reconstruction, outputs=[reset_do_reconstruction])
|
523 |
+
)
|
524 |
+
|
525 |
+
|
526 |
|
527 |
gr.Examples(
|
528 |
label='Examples',
|