Hi authors, thanks for sharing your code. However, When I tried to reproduce the results, I failed. Currently, I foucsed on UIEB dataset and downloaded the provided checkpoints. After running "python test_sucode.py", I got following output logs:
(SUcode) [mit@hpcgpu01 SUCode-main]$ python test_sucode.py
/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/timm/models/layers/init.py:49: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
warnings.warn(f"Importing from {name} is deprecated, please import via timm.layers", FutureWarning)
Loading pretrained model LPIPS from /home/mit/.cache/torch/hub/pyiqa/LPIPS_v0.1_alex-df73285e.pth
test_sucode.py:40: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
model_params = torch.load(weight_path)['params']
Codebook dimension list: [[32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256]]
/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/torch/functional.py:513: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3609.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
Layer (type:depth-idx) Output Shape Param #
SUCode [1, 3, 128, 128] --
├─MultiScaleEncoder: 1-1 [1, 128, 64, 64] --
│ └─Conv2d: 2-1 [1, 64, 127, 127] 3,136
│ └─ModuleList: 2-2 -- --
│ │ └─Sequential: 3-1 [1, 128, 64, 64] 665,216
│ │ └─Sequential: 3-2 [1, 256, 32, 32] 2,657,536
│ │ └─Sequential: 3-3 [1, 256, 16, 16] 2,952,448
│ │ └─SwinLayers: 3-4 [1, 256, 16, 16] 21,357,760
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-3 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-4 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-5 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-6 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-7 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-8 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-9 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-10 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-11 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-12 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-13 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-14 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-15 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-16 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-17 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-18 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-19 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-20 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-21 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-22 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-23 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-24 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-25 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-26 [1, 256, 16, 16] 590,080
├─WeightPredictor: 1-26 [1, 8, 16, 16] --
│ └─ModuleList: 2-27 -- --
│ │ └─SwinLayers: 3-5 [1, 256, 16, 16] 21,357,760
│ │ └─Conv2d: 3-6 [1, 8, 16, 16] 2,056
├─ModuleList: 1-27 -- --
│ └─DecoderBlock: 2-28 [1, 256, 32, 32] --
│ │ └─Sequential: 3-7 [1, 256, 32, 32] 2,952,448
│ └─DecoderBlock: 2-29 [1, 128, 64, 64] --
│ │ └─Sequential: 3-8 [1, 128, 64, 64] 886,400
│ └─DecoderBlock: 2-30 [1, 64, 128, 128] --
│ │ └─Sequential: 3-9 [1, 64, 128, 128] 222,016
├─Conv2d: 1-28 [1, 3, 128, 128] 1,731
├─MultiScaleDecoder: 1-29 [1, 64, 128, 128] --
│ └─ModuleList: 2-35 -- (recursive)
│ │ └─Sequential: 3-10 [1, 256, 32, 32] 3,542,272
│ └─ModuleList: 2-36 -- (recursive)
│ │ └─FreqFuseBlock: 3-11 [1, 256, 32, 32] 3,804,160
│ └─ModuleList: 2-35 -- (recursive)
│ │ └─Sequential: 3-12 [1, 128, 64, 64] 1,181,312
│ └─ModuleList: 2-36 -- (recursive)
│ │ └─FreqFuseBlock: 3-13 [1, 128, 64, 64] 951,808
│ └─ModuleList: 2-35 -- (recursive)
│ │ └─Sequential: 3-14 [1, 64, 128, 128] 295,744
│ └─ModuleList: 2-36 -- (recursive)
│ │ └─FreqFuseBlock: 3-15 [1, 64, 128, 128] 238,336
├─Conv2d: 1-30 [1, 3, 128, 128] 1,731
Total params: 68,845,134
Trainable params: 68,845,134
Non-trainable params: 0
Total mult-adds (G): 43.80
Input size (MB): 0.20
Forward/backward pass size (MB): 734.74
Params size (MB): 272.93
Estimated Total Size (MB): 1007.87
Test 924_img_.png: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 90/90 [00:16<00:00, 5.49image/s]
Result for ./models/net_sucode_g_best_.pth
{'psnr': 8.612529871198866, 'ssim': 0.19825143831266712, 'lpips': 0.7905487020810446}
By the way, when directly run the command, I got follwing issues:
Traceback (most recent call last):
File "test_sucode.py", line 164, in
main(args)
File "test_sucode.py", line 111, in main
metric_results[name] += metric_funcs[name](img_HR_tensor, output).item()
File "/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1562, in call_impl
return forward_call(*args, **kwargs)
File "/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/pyiqa/models/inference_model.py", line 109, in forward
self.is_valid_input(target)
File "/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/pyiqa/models/inference_model.py", line 85, in is_valid_input
assert x.min() > -self.eps and x.max() < 1 + self.eps, (
AssertionError: Input must be normalized to [0, 1], but got min=-0.0046, max=1.0084
Test 107_img.png: 0%|
To tackle it, I just add "img_HR_tensor = img_HR_tensor.clamp(0, 1)".
Thank you for you time. Please help to figure it out.
Best
Hi authors, thanks for sharing your code. However, When I tried to reproduce the results, I failed. Currently, I foucsed on UIEB dataset and downloaded the provided checkpoints. After running "python test_sucode.py", I got following output logs:
(SUcode) [mit@hpcgpu01 SUCode-main]$ python test_sucode.py
/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/timm/models/layers/init.py:49: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
warnings.warn(f"Importing from {name} is deprecated, please import via timm.layers", FutureWarning)
Loading pretrained model LPIPS from /home/mit/.cache/torch/hub/pyiqa/LPIPS_v0.1_alex-df73285e.pth
test_sucode.py:40: FutureWarning: You are using
torch.loadwithweights_only=False(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value forweights_onlywill be flipped toTrue. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user viatorch.serialization.add_safe_globals. We recommend you start settingweights_only=Truefor any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.model_params = torch.load(weight_path)['params']
Codebook dimension list: [[32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256], [32, 256, 256]]
/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/torch/functional.py:513: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3609.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
Layer (type:depth-idx) Output Shape Param #
SUCode [1, 3, 128, 128] --
├─MultiScaleEncoder: 1-1 [1, 128, 64, 64] --
│ └─Conv2d: 2-1 [1, 64, 127, 127] 3,136
│ └─ModuleList: 2-2 -- --
│ │ └─Sequential: 3-1 [1, 128, 64, 64] 665,216
│ │ └─Sequential: 3-2 [1, 256, 32, 32] 2,657,536
│ │ └─Sequential: 3-3 [1, 256, 16, 16] 2,952,448
│ │ └─SwinLayers: 3-4 [1, 256, 16, 16] 21,357,760
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-3 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-4 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-5 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-6 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-7 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-8 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-9 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-10 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-11 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-12 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-13 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-14 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-15 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-16 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-17 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-18 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-19 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-20 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-21 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-22 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-23 [1, 256, 16, 16] 590,080
├─ModuleList: 1-23 -- (recursive)
│ └─Conv2d: 2-24 [1, 256, 16, 16] 65,792
├─ModuleList: 1-24 -- (recursive)
│ └─VectorQuantizer: 2-25 [1, 256, 16, 16] 65,536
├─ModuleList: 1-25 -- (recursive)
│ └─Conv2d: 2-26 [1, 256, 16, 16] 590,080
├─WeightPredictor: 1-26 [1, 8, 16, 16] --
│ └─ModuleList: 2-27 -- --
│ │ └─SwinLayers: 3-5 [1, 256, 16, 16] 21,357,760
│ │ └─Conv2d: 3-6 [1, 8, 16, 16] 2,056
├─ModuleList: 1-27 -- --
│ └─DecoderBlock: 2-28 [1, 256, 32, 32] --
│ │ └─Sequential: 3-7 [1, 256, 32, 32] 2,952,448
│ └─DecoderBlock: 2-29 [1, 128, 64, 64] --
│ │ └─Sequential: 3-8 [1, 128, 64, 64] 886,400
│ └─DecoderBlock: 2-30 [1, 64, 128, 128] --
│ │ └─Sequential: 3-9 [1, 64, 128, 128] 222,016
├─Conv2d: 1-28 [1, 3, 128, 128] 1,731
├─MultiScaleDecoder: 1-29 [1, 64, 128, 128] --
│ └─ModuleList: 2-35 -- (recursive)
│ │ └─Sequential: 3-10 [1, 256, 32, 32] 3,542,272
│ └─ModuleList: 2-36 -- (recursive)
│ │ └─FreqFuseBlock: 3-11 [1, 256, 32, 32] 3,804,160
│ └─ModuleList: 2-35 -- (recursive)
│ │ └─Sequential: 3-12 [1, 128, 64, 64] 1,181,312
│ └─ModuleList: 2-36 -- (recursive)
│ │ └─FreqFuseBlock: 3-13 [1, 128, 64, 64] 951,808
│ └─ModuleList: 2-35 -- (recursive)
│ │ └─Sequential: 3-14 [1, 64, 128, 128] 295,744
│ └─ModuleList: 2-36 -- (recursive)
│ │ └─FreqFuseBlock: 3-15 [1, 64, 128, 128] 238,336
├─Conv2d: 1-30 [1, 3, 128, 128] 1,731
Total params: 68,845,134
Trainable params: 68,845,134
Non-trainable params: 0
Total mult-adds (G): 43.80
Input size (MB): 0.20
Forward/backward pass size (MB): 734.74
Params size (MB): 272.93
Estimated Total Size (MB): 1007.87
Test 924_img_.png: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 90/90 [00:16<00:00, 5.49image/s]
Result for ./models/net_sucode_g_best_.pth
{'psnr': 8.612529871198866, 'ssim': 0.19825143831266712, 'lpips': 0.7905487020810446}
By the way, when directly run the command, I got follwing issues:
Traceback (most recent call last):
File "test_sucode.py", line 164, in
main(args)
File "test_sucode.py", line 111, in main
metric_results[name] += metric_funcs[name](img_HR_tensor, output).item()
File "/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1562, in call_impl
return forward_call(*args, **kwargs)
File "/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/pyiqa/models/inference_model.py", line 109, in forward
self.is_valid_input(target)
File "/home/mit/miniconda3/envs/SUcode/lib/python3.8/site-packages/pyiqa/models/inference_model.py", line 85, in is_valid_input
assert x.min() > -self.eps and x.max() < 1 + self.eps, (
AssertionError: Input must be normalized to [0, 1], but got min=-0.0046, max=1.0084
Test 107_img.png: 0%|
To tackle it, I just add "img_HR_tensor = img_HR_tensor.clamp(0, 1)".
Thank you for you time. Please help to figure it out.
Best