Spaces:
Running
Running
19
Browse files- models/SRFlow/srflow.py +9 -8
models/SRFlow/srflow.py
CHANGED
@@ -26,6 +26,7 @@ def return_SRFlow_result(lr, divide=True, conf_path='models/SRFlow/code/confs/SR
|
|
26 |
if not divide:
|
27 |
lr = np.round(255 * lr).astype(np.uint8)
|
28 |
|
|
|
29 |
scale = opt['scale']
|
30 |
pad_factor = 2
|
31 |
|
@@ -67,20 +68,20 @@ def return_SRFlow_result_from_tensor(lr_tensor, divide):
|
|
67 |
sr_tensor = torch.cat(sr_list, dim=0)
|
68 |
|
69 |
if not divide:
|
70 |
-
sr_tensor = sr_tensor / 255
|
71 |
|
72 |
return sr_tensor
|
73 |
|
74 |
if __name__ == '__main__':
|
75 |
lr = Image.open('images/demo.png')
|
76 |
|
77 |
-
lr_tensor = PILToTensor()(lr).unsqueeze(0)
|
78 |
-
|
79 |
random_tensor = torch.randn(8, 3, 64, 64)
|
80 |
-
sr = return_SRFlow_result_from_tensor(
|
81 |
print(sr)
|
82 |
|
83 |
-
#
|
84 |
-
|
85 |
-
#
|
86 |
-
|
|
|
26 |
if not divide:
|
27 |
lr = np.round(255 * lr).astype(np.uint8)
|
28 |
|
29 |
+
|
30 |
scale = opt['scale']
|
31 |
pad_factor = 2
|
32 |
|
|
|
68 |
sr_tensor = torch.cat(sr_list, dim=0)
|
69 |
|
70 |
if not divide:
|
71 |
+
sr_tensor = torch.ones_like(sr_tensor) - sr_tensor / 255
|
72 |
|
73 |
return sr_tensor
|
74 |
|
75 |
if __name__ == '__main__':
|
76 |
lr = Image.open('images/demo.png')
|
77 |
|
78 |
+
lr_tensor = PILToTensor()(lr).unsqueeze(0) / 255
|
79 |
+
print(lr_tensor.shape)
|
80 |
random_tensor = torch.randn(8, 3, 64, 64)
|
81 |
+
sr = return_SRFlow_result_from_tensor(lr_tensor, divide=False)
|
82 |
print(sr)
|
83 |
|
84 |
+
# Show SR image of the first one in the batch
|
85 |
+
plt.imshow(np.transpose(sr[0].cpu().detach().numpy(), (1, 2, 0)))
|
86 |
+
# plt.axis('off')
|
87 |
+
plt.show()
|