Update app.py
Browse files
app.py
CHANGED
|
@@ -114,7 +114,8 @@ def inference(image, upscale, large_input_flag, color_fix):
|
|
| 114 |
|
| 115 |
# img2tensor
|
| 116 |
y = np.array(image).astype(np.float32) / 255.
|
| 117 |
-
y = torch.from_numpy(np.transpose(y[:, :, [2, 1, 0]], (2, 0, 1))).float()
|
|
|
|
| 118 |
y = y.unsqueeze(0).to(device)
|
| 119 |
|
| 120 |
# inference
|
|
@@ -147,11 +148,15 @@ def inference(image, upscale, large_input_flag, color_fix):
|
|
| 147 |
output = wavelet_reconstruction(output, y)
|
| 148 |
# tensor2img
|
| 149 |
output = output.data.squeeze().float().cpu().clamp_(0, 1).numpy()
|
| 150 |
-
if output.ndim == 3:
|
| 151 |
-
|
| 152 |
output = (output * 255.0).round().astype(np.uint8)
|
| 153 |
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
|
| 157 |
|
|
@@ -233,8 +238,11 @@ demo = gr.Interface(
|
|
| 233 |
ImageSlider(label="Super-Resolved Image",
|
| 234 |
type="pil",
|
| 235 |
show_download_button=True,
|
| 236 |
-
|
| 237 |
-
gr.Image(
|
|
|
|
|
|
|
|
|
|
| 238 |
],
|
| 239 |
title=title,
|
| 240 |
description=description,
|
|
|
|
| 114 |
|
| 115 |
# img2tensor
|
| 116 |
y = np.array(image).astype(np.float32) / 255.
|
| 117 |
+
# y = torch.from_numpy(np.transpose(y[:, :, [2, 1, 0]], (2, 0, 1))).float()
|
| 118 |
+
y = torch.from_numpy(np.transpose(y, (2, 0, 1))).float()
|
| 119 |
y = y.unsqueeze(0).to(device)
|
| 120 |
|
| 121 |
# inference
|
|
|
|
| 148 |
output = wavelet_reconstruction(output, y)
|
| 149 |
# tensor2img
|
| 150 |
output = output.data.squeeze().float().cpu().clamp_(0, 1).numpy()
|
| 151 |
+
# if output.ndim == 3:
|
| 152 |
+
# output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0))
|
| 153 |
output = (output * 255.0).round().astype(np.uint8)
|
| 154 |
|
| 155 |
+
# save results
|
| 156 |
+
save_path = './out.png'
|
| 157 |
+
cv2.imwrite(save_path, output)
|
| 158 |
+
|
| 159 |
+
return (image, Image.fromarray(output)), save_path
|
| 160 |
|
| 161 |
|
| 162 |
|
|
|
|
| 238 |
ImageSlider(label="Super-Resolved Image",
|
| 239 |
type="pil",
|
| 240 |
show_download_button=True,
|
| 241 |
+
),
|
| 242 |
+
gr.Image(
|
| 243 |
+
label="Download Output",
|
| 244 |
+
type='filepath'
|
| 245 |
+
),
|
| 246 |
],
|
| 247 |
title=title,
|
| 248 |
description=description,
|