Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
•
26f3c98
1
Parent(s):
206842b
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,7 @@ def caption_image(input_image):
|
|
35 |
return generated_caption, generated_caption
|
36 |
|
37 |
def sample(zs, wts, prompt_tar="", cfg_scale_tar=15, skip=36, eta=1):
|
38 |
-
latents = wts
|
39 |
img = pipe(
|
40 |
prompt=prompt_tar,
|
41 |
init_latents=latents,
|
@@ -205,10 +205,11 @@ def edit(input_image,
|
|
205 |
|
206 |
return sega_out.images[0], reconstruct_button.update(visible=True), do_reconstruction, reconstruction, wts, zs, do_inversion, show_share_button
|
207 |
|
|
|
208 |
else: # if sega concepts were not added, performs regular ddpm sampling
|
209 |
|
210 |
if do_reconstruction: # if ddpm sampling wasn't computed
|
211 |
-
pure_ddpm_img = sample(zs, wts, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
212 |
reconstruction = gr.State(value=pure_ddpm_img)
|
213 |
do_reconstruction = False
|
214 |
return pure_ddpm_img, reconstruct_button.update(visible=False), do_reconstruction, reconstruction, wts, zs, do_inversion, show_share_button
|
|
|
35 |
return generated_caption, generated_caption
|
36 |
|
37 |
def sample(zs, wts, prompt_tar="", cfg_scale_tar=15, skip=36, eta=1):
|
38 |
+
latents = wts[-1].expand(1, -1, -1, -1)
|
39 |
img = pipe(
|
40 |
prompt=prompt_tar,
|
41 |
init_latents=latents,
|
|
|
205 |
|
206 |
return sega_out.images[0], reconstruct_button.update(visible=True), do_reconstruction, reconstruction, wts, zs, do_inversion, show_share_button
|
207 |
|
208 |
+
|
209 |
else: # if sega concepts were not added, performs regular ddpm sampling
|
210 |
|
211 |
if do_reconstruction: # if ddpm sampling wasn't computed
|
212 |
+
pure_ddpm_img = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
213 |
reconstruction = gr.State(value=pure_ddpm_img)
|
214 |
do_reconstruction = False
|
215 |
return pure_ddpm_img, reconstruct_button.update(visible=False), do_reconstruction, reconstruction, wts, zs, do_inversion, show_share_button
|