Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
•
5d7ba0f
1
Parent(s):
6494dc6
Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,7 @@ def invert(x0, prompt_src="", num_diffusion_steps=100, cfg_scale_src = 3.5, eta
|
|
49 |
sd_pipe.scheduler.set_timesteps(num_diffusion_steps)
|
50 |
|
51 |
# vae encode image
|
52 |
-
with
|
53 |
w0 = (sd_pipe.vae.encode(x0).latent_dist.mode() * 0.18215).float()
|
54 |
|
55 |
# find Zs and wts - forward process
|
@@ -63,7 +63,7 @@ def sample(zs, wts, prompt_tar="", cfg_scale_tar=15, skip=36, eta = 1):
|
|
63 |
w0, _ = inversion_reverse_process(sd_pipe, xT=wts[skip], etas=eta, prompts=[prompt_tar], cfg_scales=[cfg_scale_tar], prog_bar=True, zs=zs[skip:])
|
64 |
|
65 |
# vae decode image
|
66 |
-
with
|
67 |
x0_dec = sd_pipe.vae.decode(1 / 0.18215 * w0).sample
|
68 |
if x0_dec.dim()<4:
|
69 |
x0_dec = x0_dec[None,:,:,:]
|
@@ -107,7 +107,7 @@ def load_and_invert(
|
|
107 |
):
|
108 |
|
109 |
|
110 |
-
x0 = load_512(input_image, device=device)
|
111 |
|
112 |
if do_inversion or randomize_seed:
|
113 |
# invert and retrieve noise maps and latent
|
|
|
49 |
sd_pipe.scheduler.set_timesteps(num_diffusion_steps)
|
50 |
|
51 |
# vae encode image
|
52 |
+
with inference_mode():
|
53 |
w0 = (sd_pipe.vae.encode(x0).latent_dist.mode() * 0.18215).float()
|
54 |
|
55 |
# find Zs and wts - forward process
|
|
|
63 |
w0, _ = inversion_reverse_process(sd_pipe, xT=wts[skip], etas=eta, prompts=[prompt_tar], cfg_scales=[cfg_scale_tar], prog_bar=True, zs=zs[skip:])
|
64 |
|
65 |
# vae decode image
|
66 |
+
with inference_mode():
|
67 |
x0_dec = sd_pipe.vae.decode(1 / 0.18215 * w0).sample
|
68 |
if x0_dec.dim()<4:
|
69 |
x0_dec = x0_dec[None,:,:,:]
|
|
|
107 |
):
|
108 |
|
109 |
|
110 |
+
x0 = load_512(input_image, device=device).to(torch.float16)
|
111 |
|
112 |
if do_inversion or randomize_seed:
|
113 |
# invert and retrieve noise maps and latent
|