Spaces:
Runtime error
Runtime error
Commit
·
752a92c
1
Parent(s):
bb31867
update
Browse files- autoregressive/models/generate.py +2 -2
- model.py +5 -3
autoregressive/models/generate.py
CHANGED
|
@@ -138,7 +138,7 @@ def decode_n_tokens(
|
|
| 138 |
|
| 139 |
@torch.no_grad()
|
| 140 |
def generate(model, cond, max_new_tokens, emb_masks=None, cfg_scale=1.0, cfg_interval=-1, condition=None, condition_null=None, condition_token_nums=0, **sampling_kwargs):
|
| 141 |
-
print("cond", torch.any(torch.isnan(cond)))
|
| 142 |
if condition is not None:
|
| 143 |
with torch.no_grad():
|
| 144 |
# print(f'nan: {torch.any(torch.isnan(model.adapter.model.embeddings.patch_embeddings.projection.weight))}')
|
|
@@ -147,7 +147,7 @@ def generate(model, cond, max_new_tokens, emb_masks=None, cfg_scale=1.0, cfg_int
|
|
| 147 |
# print("before condition", condition)
|
| 148 |
# condition = torch.ones_like(condition)
|
| 149 |
condition = model.adapter_mlp(condition)
|
| 150 |
-
print("condition", torch.any(torch.isnan(condition)))
|
| 151 |
if model.model_type == 'c2i':
|
| 152 |
if cfg_scale > 1.0:
|
| 153 |
cond_null = torch.ones_like(cond) * model.num_classes
|
|
|
|
| 138 |
|
| 139 |
@torch.no_grad()
|
| 140 |
def generate(model, cond, max_new_tokens, emb_masks=None, cfg_scale=1.0, cfg_interval=-1, condition=None, condition_null=None, condition_token_nums=0, **sampling_kwargs):
|
| 141 |
+
# print("cond", torch.any(torch.isnan(cond)))
|
| 142 |
if condition is not None:
|
| 143 |
with torch.no_grad():
|
| 144 |
# print(f'nan: {torch.any(torch.isnan(model.adapter.model.embeddings.patch_embeddings.projection.weight))}')
|
|
|
|
| 147 |
# print("before condition", condition)
|
| 148 |
# condition = torch.ones_like(condition)
|
| 149 |
condition = model.adapter_mlp(condition)
|
| 150 |
+
# print("condition", torch.any(torch.isnan(condition)))
|
| 151 |
if model.model_type == 'c2i':
|
| 152 |
if cfg_scale > 1.0:
|
| 153 |
cond_null = torch.ones_like(cond) * model.num_classes
|
model.py
CHANGED
|
@@ -57,7 +57,7 @@ class Model:
|
|
| 57 |
|
| 58 |
def to(self, device):
|
| 59 |
self.gpt_model_canny.to('cuda')
|
| 60 |
-
print(next(self.gpt_model_canny.adapter.parameters()).device)
|
| 61 |
# print(self.gpt_model_canny.device)
|
| 62 |
|
| 63 |
def load_vq(self):
|
|
@@ -88,7 +88,7 @@ class Model:
|
|
| 88 |
# print("prev:", model_weight['adapter.model.embeddings.patch_embeddings.projection.weight'])
|
| 89 |
gpt_model.load_state_dict(model_weight, strict=True)
|
| 90 |
gpt_model.eval()
|
| 91 |
-
print("loaded:", gpt_model.adapter.model.embeddings.patch_embeddings.projection.weight)
|
| 92 |
print("gpt model is loaded")
|
| 93 |
return gpt_model
|
| 94 |
|
|
@@ -123,10 +123,11 @@ class Model:
|
|
| 123 |
image = resize_image_to_16_multiple(image, 'canny')
|
| 124 |
W, H = image.size
|
| 125 |
print(W, H)
|
|
|
|
| 126 |
self.t5_model.model.to('cuda')
|
| 127 |
self.gpt_model_canny.to('cuda')
|
| 128 |
self.vq_model.to('cuda')
|
| 129 |
-
print("after cuda", self.gpt_model_canny.adapter.model.embeddings.patch_embeddings.projection.weight)
|
| 130 |
|
| 131 |
condition_img = self.get_control_canny(np.array(image), low_threshold,
|
| 132 |
high_threshold)
|
|
@@ -202,6 +203,7 @@ class Model:
|
|
| 202 |
image = resize_image_to_16_multiple(image, 'depth')
|
| 203 |
W, H = image.size
|
| 204 |
print(W, H)
|
|
|
|
| 205 |
self.t5_model.model.to(self.device)
|
| 206 |
self.gpt_model_depth.to(self.device)
|
| 207 |
self.get_control_depth.model.to(self.device)
|
|
|
|
| 57 |
|
| 58 |
def to(self, device):
|
| 59 |
self.gpt_model_canny.to('cuda')
|
| 60 |
+
# print(next(self.gpt_model_canny.adapter.parameters()).device)
|
| 61 |
# print(self.gpt_model_canny.device)
|
| 62 |
|
| 63 |
def load_vq(self):
|
|
|
|
| 88 |
# print("prev:", model_weight['adapter.model.embeddings.patch_embeddings.projection.weight'])
|
| 89 |
gpt_model.load_state_dict(model_weight, strict=True)
|
| 90 |
gpt_model.eval()
|
| 91 |
+
# print("loaded:", gpt_model.adapter.model.embeddings.patch_embeddings.projection.weight)
|
| 92 |
print("gpt model is loaded")
|
| 93 |
return gpt_model
|
| 94 |
|
|
|
|
| 123 |
image = resize_image_to_16_multiple(image, 'canny')
|
| 124 |
W, H = image.size
|
| 125 |
print(W, H)
|
| 126 |
+
self.gpt_model_depth.to('cpu')
|
| 127 |
self.t5_model.model.to('cuda')
|
| 128 |
self.gpt_model_canny.to('cuda')
|
| 129 |
self.vq_model.to('cuda')
|
| 130 |
+
# print("after cuda", self.gpt_model_canny.adapter.model.embeddings.patch_embeddings.projection.weight)
|
| 131 |
|
| 132 |
condition_img = self.get_control_canny(np.array(image), low_threshold,
|
| 133 |
high_threshold)
|
|
|
|
| 203 |
image = resize_image_to_16_multiple(image, 'depth')
|
| 204 |
W, H = image.size
|
| 205 |
print(W, H)
|
| 206 |
+
self.gpt_model_canny.to('cpu')
|
| 207 |
self.t5_model.model.to(self.device)
|
| 208 |
self.gpt_model_depth.to(self.device)
|
| 209 |
self.get_control_depth.model.to(self.device)
|