Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
•
eef5fc9
1
Parent(s):
efbd019
Update app.py
Browse filesreconstruction logic change
app.py
CHANGED
@@ -72,6 +72,7 @@ def sample(zs, wts, prompt_tar="", cfg_scale_tar=15, skip=36, eta = 1):
|
|
72 |
|
73 |
|
74 |
def reconstruct(tar_prompt,
|
|
|
75 |
tar_cfg_scale,
|
76 |
skip,
|
77 |
wts, zs,
|
@@ -85,6 +86,8 @@ def reconstruct(tar_prompt,
|
|
85 |
|
86 |
else:
|
87 |
if do_reconstruction:
|
|
|
|
|
88 |
reconstruction_img = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
89 |
reconstruction = gr.State(value=reconstruction_img)
|
90 |
do_reconstruction = False
|
@@ -800,6 +803,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
800 |
|
801 |
reconstruct_button.click(lambda: ddpm_edited_image.update(visible=True), outputs=[ddpm_edited_image]).then(fn = reconstruct,
|
802 |
inputs = [tar_prompt,
|
|
|
803 |
tar_cfg_scale,
|
804 |
skip,
|
805 |
wts, zs,
|
|
|
72 |
|
73 |
|
74 |
def reconstruct(tar_prompt,
|
75 |
+
image_caption,
|
76 |
tar_cfg_scale,
|
77 |
skip,
|
78 |
wts, zs,
|
|
|
86 |
|
87 |
else:
|
88 |
if do_reconstruction:
|
89 |
+
if image_caption.lower() == tar_prompt.lower(): # if image caption was not changed, run actual reconstruction
|
90 |
+
tar_prompt = ""
|
91 |
reconstruction_img = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
92 |
reconstruction = gr.State(value=reconstruction_img)
|
93 |
do_reconstruction = False
|
|
|
803 |
|
804 |
reconstruct_button.click(lambda: ddpm_edited_image.update(visible=True), outputs=[ddpm_edited_image]).then(fn = reconstruct,
|
805 |
inputs = [tar_prompt,
|
806 |
+
image_caption,
|
807 |
tar_cfg_scale,
|
808 |
skip,
|
809 |
wts, zs,
|