swz30 / MPRNet

[CVPR 2021] Multi-Stage Progressive Image Restoration. SOTA results for Image deblurring, deraining, and denoising.
Other
1.16k stars 188 forks source link

The program reports an error when running test.py #78

Closed gudianyue closed 2 years ago

gudianyue commented 2 years ago

When I finished the training and tested it, the program reported an error.

===>Testing using weights: ./checkpoints/Deraining/models/MPRNet/model_best.pth 0%| | 0/200 [00:00<?, ?it/s] Traceback (most recent call last): File "test.py", line 62, in restored = modelrestoration(input) File "/home/HWL/anaconda3/envs/pt1.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, kwargs) File "/home/HWL/anaconda3/envs/pt1.4/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 150, in forward return self.module(*inputs[0], *kwargs[0]) File "/home/HWL/anaconda3/envs/pt1.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, kwargs) File "/home/HWL/code/MPRNet/Deraining/MPRNet.py", line 300, in forward res1_top = self.stage1_decoder(feat1_top) File "/home/HWL/anaconda3/envs/pt1.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, *kwargs) File "/home/HWL/code/MPRNet/Deraining/MPRNet.py", line 148, in forward x = self.up21(dec2, self.skip_attn1(enc1)) File "/home/HWL/anaconda3/envs/pt1.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, **kwargs) File "/home/HWL/code/MPRNet/Deraining/MPRNet.py", line 183, in forward x = x + y RuntimeError: The size of tensor a (480) must match the size of tensor b (481) at non-singleton dimension 3

The test samples I used for testing were from Rain100H dataset.

szpxmu commented 2 years ago

i have the same question.

adityac8 commented 2 years ago

Hi,

The error occurs when the image size is not a multiple of 16. Could you please check the image size of Rain100H as the dataset that we uploaded is of size 480x320.

Thanks

szpxmu commented 2 years ago

When testing images, you need to minus one for the image resolution to pass the test.

adityac8 commented 2 years ago

The test.py file works on the given deraining datasets. If you want to test the model on other images, you can run demo.py.