Update injection_main.py
Browse files- injection_main.py +4 -3
injection_main.py
CHANGED
|
@@ -324,8 +324,8 @@ def invert(
|
|
| 324 |
# Set num inference steps
|
| 325 |
pipe.scheduler.set_timesteps(num_inference_steps, device=device)
|
| 326 |
|
| 327 |
-
# Reversed timesteps
|
| 328 |
-
timesteps = reversed(pipe.scheduler.timesteps)
|
| 329 |
|
| 330 |
for i in tqdm(
|
| 331 |
range(1, num_inference_steps),
|
|
@@ -361,7 +361,7 @@ def invert(
|
|
| 361 |
)
|
| 362 |
|
| 363 |
current_t = max(0, t.item() - (1000 // num_inference_steps)) # t
|
| 364 |
-
next_t = t # min(999, t.item() + (1000//num_inference_steps)) # t+1
|
| 365 |
alpha_t = pipe.scheduler.alphas_cumprod[current_t]
|
| 366 |
alpha_t_next = pipe.scheduler.alphas_cumprod[next_t]
|
| 367 |
|
|
@@ -376,6 +376,7 @@ def invert(
|
|
| 376 |
return torch.cat(intermediate_latents)
|
| 377 |
|
| 378 |
|
|
|
|
| 379 |
def style_image_with_inversion(
|
| 380 |
pipe,
|
| 381 |
input_image,
|
|
|
|
| 324 |
# Set num inference steps
|
| 325 |
pipe.scheduler.set_timesteps(num_inference_steps, device=device)
|
| 326 |
|
| 327 |
+
# Reversed timesteps
|
| 328 |
+
timesteps = list(reversed(pipe.scheduler.timesteps))
|
| 329 |
|
| 330 |
for i in tqdm(
|
| 331 |
range(1, num_inference_steps),
|
|
|
|
| 361 |
)
|
| 362 |
|
| 363 |
current_t = max(0, t.item() - (1000 // num_inference_steps)) # t
|
| 364 |
+
next_t = t # min(999, t.item() + (1000 // num_inference_steps)) # t+1
|
| 365 |
alpha_t = pipe.scheduler.alphas_cumprod[current_t]
|
| 366 |
alpha_t_next = pipe.scheduler.alphas_cumprod[next_t]
|
| 367 |
|
|
|
|
| 376 |
return torch.cat(intermediate_latents)
|
| 377 |
|
| 378 |
|
| 379 |
+
|
| 380 |
def style_image_with_inversion(
|
| 381 |
pipe,
|
| 382 |
input_image,
|