Spaces:
Runtime error
Runtime error
jositonaranja
commited on
Commit
•
ace8b65
1
Parent(s):
60509e3
Update app.py
Browse files
app.py
CHANGED
@@ -39,11 +39,20 @@ if has_cuda:
|
|
39 |
model_up.to(device)
|
40 |
model_up.load_state_dict(load_checkpoint('upsample', device))
|
41 |
print('total upsampler parameters', sum(x.numel() for x in model_up.parameters()))
|
|
|
|
|
42 |
def show_images(batch: th.Tensor):
|
43 |
""" Display a batch of images inline. """
|
44 |
scaled = ((batch + 1)*127.5).round().clamp(0,255).to(th.uint8).cpu()
|
45 |
reshaped = scaled.permute(2, 0, 3, 1).reshape([batch.shape[2], -1, 3])
|
46 |
display(Image.fromarray(reshaped.numpy()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
# Sampling parameters
|
48 |
batch_size = 1
|
49 |
guidance_scale = 3.0
|
@@ -159,8 +168,9 @@ def run(prompt):
|
|
159 |
# Show the output
|
160 |
print('# Show the output')
|
161 |
# show_images(up_samples)
|
|
|
162 |
|
163 |
-
return
|
164 |
|
165 |
|
166 |
|
|
|
39 |
model_up.to(device)
|
40 |
model_up.load_state_dict(load_checkpoint('upsample', device))
|
41 |
print('total upsampler parameters', sum(x.numel() for x in model_up.parameters()))
|
42 |
+
|
43 |
+
|
44 |
def show_images(batch: th.Tensor):
|
45 |
""" Display a batch of images inline. """
|
46 |
scaled = ((batch + 1)*127.5).round().clamp(0,255).to(th.uint8).cpu()
|
47 |
reshaped = scaled.permute(2, 0, 3, 1).reshape([batch.shape[2], -1, 3])
|
48 |
display(Image.fromarray(reshaped.numpy()))
|
49 |
+
|
50 |
+
def get_images(batch: th.Tensor):
|
51 |
+
""" Display a batch of images inline. """
|
52 |
+
scaled = ((batch + 1)*127.5).round().clamp(0,255).to(th.uint8).cpu()
|
53 |
+
reshaped = scaled.permute(2, 0, 3, 1).reshape([batch.shape[2], -1, 3])
|
54 |
+
return Image.fromarray(reshaped.numpy())
|
55 |
+
|
56 |
# Sampling parameters
|
57 |
batch_size = 1
|
58 |
guidance_scale = 3.0
|
|
|
168 |
# Show the output
|
169 |
print('# Show the output')
|
170 |
# show_images(up_samples)
|
171 |
+
out_images = get_images(up_samples)
|
172 |
|
173 |
+
return out_images
|
174 |
|
175 |
|
176 |
|