Spaces:
Runtime error
Runtime error
jositonaranja
commited on
Commit
•
e6a393f
1
Parent(s):
ace8b65
Update app.py
Browse files
app.py
CHANGED
@@ -40,19 +40,22 @@ 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 |
-
|
55 |
-
|
|
|
|
|
56 |
# Sampling parameters
|
57 |
batch_size = 1
|
58 |
guidance_scale = 3.0
|
@@ -122,7 +125,7 @@ def run(prompt):
|
|
122 |
|
123 |
# Show the output
|
124 |
print(' # Show the output')
|
125 |
-
show_images(samples)
|
126 |
##############################
|
127 |
# Upsample the 64x64 samples #
|
128 |
##############################
|
@@ -167,7 +170,6 @@ def run(prompt):
|
|
167 |
|
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
|
|
|
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 |
def show_images(batch: th.Tensor):
|
44 |
""" Display a batch of images inline. """
|
45 |
scaled = ((batch + 1)*127.5).round().clamp(0,255).to(th.uint8).cpu()
|
46 |
reshaped = scaled.permute(2, 0, 3, 1).reshape([batch.shape[2], -1, 3])
|
47 |
+
#display(Image.fromarray(reshaped.numpy()))
|
48 |
+
#Image.fromarray(reshaped.numpy()).save('image.png')
|
49 |
+
|
50 |
+
|
51 |
def get_images(batch: th.Tensor):
|
52 |
""" Display a batch of images inline. """
|
53 |
scaled = ((batch + 1)*127.5).round().clamp(0,255).to(th.uint8).cpu()
|
54 |
reshaped = scaled.permute(2, 0, 3, 1).reshape([batch.shape[2], -1, 3])
|
55 |
+
img = Image.fromarray(reshaped.numpy())
|
56 |
+
#img.save('img.png')
|
57 |
+
return img
|
58 |
+
|
59 |
# Sampling parameters
|
60 |
batch_size = 1
|
61 |
guidance_scale = 3.0
|
|
|
125 |
|
126 |
# Show the output
|
127 |
print(' # Show the output')
|
128 |
+
#show_images(samples)
|
129 |
##############################
|
130 |
# Upsample the 64x64 samples #
|
131 |
##############################
|
|
|
170 |
|
171 |
# Show the output
|
172 |
print('# Show the output')
|
|
|
173 |
out_images = get_images(up_samples)
|
174 |
|
175 |
return out_images
|