Spaces:
Paused
Paused
lllyasviel
commited on
Commit
·
ab65a35
1
Parent(s):
54ce9a5
entry.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import os
|
2 |
import math
|
|
|
|
|
3 |
import numpy as np
|
4 |
import torch
|
5 |
import gc
|
@@ -141,3 +143,15 @@ torch.cuda.empty_cache()
|
|
141 |
torch.cuda.ipc_collect()
|
142 |
|
143 |
a = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import math
|
3 |
+
|
4 |
+
import einops
|
5 |
import numpy as np
|
6 |
import torch
|
7 |
import gc
|
|
|
143 |
torch.cuda.ipc_collect()
|
144 |
|
145 |
a = 0
|
146 |
+
|
147 |
+
|
148 |
+
with torch.no_grad():
|
149 |
+
model.first_stage_model.cuda()
|
150 |
+
samples_x = model.decode_first_stage(samples_z)
|
151 |
+
samples = torch.clamp((samples_x + 1.0) / 2.0, min=0.0, max=1.0)
|
152 |
+
model.first_stage_model.cpu()
|
153 |
+
|
154 |
+
import cv2
|
155 |
+
samples = einops.rearrange(samples, 'b c h w -> b h w c')[0] * 127.5 + 127.5
|
156 |
+
samples = samples.cpu().numpy().clip(0, 255).astype(np.uint8)
|
157 |
+
cv2.imwrite('img.png', samples)
|