Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ import numpy as np
|
|
10 |
from PIL import Image, ImageDraw, ImageFont
|
11 |
from functools import partial
|
12 |
import math
|
13 |
-
from utils import
|
14 |
from gradio import processing_utils
|
15 |
from typing import Optional
|
16 |
|
@@ -95,10 +95,11 @@ def inference(device, unet, vae, tokenizer, text_encoder, prompt, bboxes, object
|
|
95 |
generator=generator,
|
96 |
).to(device)
|
97 |
|
98 |
-
noise_scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
|
|
|
99 |
|
100 |
# generator = torch.Generator("cuda").manual_seed(1024)
|
101 |
-
noise_scheduler.set_timesteps(
|
102 |
|
103 |
latents = latents * noise_scheduler.init_noise_sigma
|
104 |
|
@@ -119,14 +120,14 @@ def inference(device, unet, vae, tokenizer, text_encoder, prompt, bboxes, object
|
|
119 |
|
120 |
# update latents with guidence from gaussian blob
|
121 |
|
122 |
-
loss =
|
123 |
object_positions=object_positions) * loss_scale
|
124 |
|
125 |
-
print(loss.item() / loss_scale)
|
126 |
|
127 |
grad_cond = torch.autograd.grad(loss.requires_grad_(True), [latents])[0]
|
128 |
|
129 |
-
latents = latents - grad_cond
|
130 |
iteration += 1
|
131 |
torch.cuda.empty_cache()
|
132 |
torch.cuda.empty_cache()
|
|
|
10 |
from PIL import Image, ImageDraw, ImageFont
|
11 |
from functools import partial
|
12 |
import math
|
13 |
+
from utils import compute_loco_v2
|
14 |
from gradio import processing_utils
|
15 |
from typing import Optional
|
16 |
|
|
|
95 |
generator=generator,
|
96 |
).to(device)
|
97 |
|
98 |
+
# noise_scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
|
99 |
+
noise_scheduler = DDIMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", clip_sample=False, set_alpha_to_one=False)
|
100 |
|
101 |
# generator = torch.Generator("cuda").manual_seed(1024)
|
102 |
+
noise_scheduler.set_timesteps(50)
|
103 |
|
104 |
latents = latents * noise_scheduler.init_noise_sigma
|
105 |
|
|
|
120 |
|
121 |
# update latents with guidence from gaussian blob
|
122 |
|
123 |
+
loss = compute_loco_v2(attn_map_integrated_mid, attn_map_integrated_up, bboxes=bboxes,
|
124 |
object_positions=object_positions) * loss_scale
|
125 |
|
126 |
+
# print(loss.item() / loss_scale)
|
127 |
|
128 |
grad_cond = torch.autograd.grad(loss.requires_grad_(True), [latents])[0]
|
129 |
|
130 |
+
latents = latents - grad_cond
|
131 |
iteration += 1
|
132 |
torch.cuda.empty_cache()
|
133 |
torch.cuda.empty_cache()
|