Spaces:
Runtime error
Runtime error
Fix image color.
Browse files
test.py
CHANGED
@@ -24,6 +24,7 @@ base = os.path.splitext(os.path.basename(img_path))[0]
|
|
24 |
# read image
|
25 |
print(img_path);
|
26 |
img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
|
|
|
27 |
img = torch.from_numpy(img[np.newaxis, :, :]).float()
|
28 |
img_LR = img.unsqueeze(0)
|
29 |
img_LR = img_LR.to(device)
|
@@ -31,5 +32,7 @@ img_LR = img_LR.to(device)
|
|
31 |
print('Start upscaling...')
|
32 |
output = model(img_LR).squeeze(dim=0).float().cpu().clamp_(0, 1).numpy()
|
33 |
output = np.transpose(output, (1, 2, 0))
|
|
|
34 |
print('Finished upscaling, saving image.')
|
|
|
35 |
cv2.imwrite(output_dir, output, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
|
|
|
24 |
# read image
|
25 |
print(img_path);
|
26 |
img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
|
27 |
+
img = img * 1.0 / 255
|
28 |
img = torch.from_numpy(img[np.newaxis, :, :]).float()
|
29 |
img_LR = img.unsqueeze(0)
|
30 |
img_LR = img_LR.to(device)
|
|
|
32 |
print('Start upscaling...')
|
33 |
output = model(img_LR).squeeze(dim=0).float().cpu().clamp_(0, 1).numpy()
|
34 |
output = np.transpose(output, (1, 2, 0))
|
35 |
+
output = (output * 255.0).round()
|
36 |
print('Finished upscaling, saving image.')
|
37 |
+
print(output_dir)
|
38 |
cv2.imwrite(output_dir, output, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
|