angelvillar96 / super-resolution-noisy-images

Official implementation of "Deep learning architectural designs for super-resolution of noisy images" by Villar et al. ICASSP 2021
MIT License
12 stars 1 forks source link

The size of the output image is inconsistent with the input #1

Closed Admgan closed 2 years ago

Admgan commented 2 years ago

Excuse me, I use the trained network to perform noise elimination test. Why is the size of the input image inconsistent with that of the output image?The size of the image I input is 1 2048 1536, and the size of the output is 1 4096 3072

The code is as follows:

0%| | 0/6 [00:00<?, ?it/s]F:\Anaconda3\envs\mypytorch\lib\site-packages\torch\nn\modules\loss.py:96: UserWarning: Using a target size (torch.Size([1, 3, 3072, 4096])) that is different to the input size (torch.Size([1, 3, 1536, 2048])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. return F.l1_loss(input, target, reduction=self.reduction) 0%| | 0/6 [02:20<?, ?it/s] Traceback (most recent call last): File "E:/PaperSource/DEEP LEARNING ARCHITECTURAL DESIGNS FOR SUPER-RESOLUTION OF NOISY IMAGES/code/src/03_evaluate.py", line 180, in results = evaluator.test_model() File "F:\Anaconda3\envs\mypytorch\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context return func(*args, *kwargs) File "E:/PaperSource/DEEP LEARNING ARCHITECTURAL DESIGNS FOR SUPER-RESOLUTION OF NOISY IMAGES/code/src/03_evaluate.py", line 144, in test_model loss = self.loss_function(hr_imgs, recovered_images) File "F:\Anaconda3\envs\mypytorch\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(input, **kwargs) File "F:\Anaconda3\envs\mypytorch\lib\site-packages\torch\nn\modules\loss.py", line 96, in forward return F.l1_loss(input, target, reduction=self.reduction) File "F:\Anaconda3\envs\mypytorch\lib\site-packages\torch\nn\functional.py", line 2894, in l1_loss expanded_input, expanded_target = torch.broadcast_tensors(input, target) File "F:\Anaconda3\envs\mypytorch\lib\site-packages\torch\functional.py", line 74, in broadcast_tensors return _VF.broadcast_tensors(tensors) # type: ignore RuntimeError: The size of tensor a (2048) must match the size of tensor b (4096) at non-singleton dimension 3

Process finished with exit code 1

angelvillar96 commented 2 years ago

That size mismatch should not happen. I have just tested the following command: python 03_evaluate.py -d Div2k_Exps/no_denoiser_div2k --epoch -1 but I was not able to reproduce the error.

Which dataset and model are you using? Could you share the experiment_parameters.json file you are using?

Admgan commented 2 years ago

Thank you for your reply. I used the dataset I created, and actively added salt and pepper noise of 0.1 intensity. The mature training model I use: median filter prenet_ div2k. After debugging, I found that the noise removal effect is very poor. Is it the wrong way to use your code? I look forward to your reply.

angelvillar96 commented 2 years ago

Keep in mind that the focus of our work in on super-resolution of noisy images, and not only denoising. Therefore, the output of the model will have a larger (x2) spatial dimensionality than the input. This could be the reason for the target/output size mismatch in your first comment.

Regarding the denoising capabilities of the model. The cascade of median filter and WDSR model, i.e. median pre-net, often leads to reasonable denoised and upsampled results. Below you have three examples on three different datasets (MNIST, SVHN, DIV2K). The images were downsampled by a factor of 2, and corrupted with salt-and-pepper noise with 20% probability of corrupting a pixel. You can see the expected quality of median pre-net outputs.

generalization_mnist_salt_pepper_0,3 generalization_svhn_salt_pepper_0,2 generalization_salt_pepper

Admgan commented 2 years ago

Thank you for your reply. I will try my best to solve these problems.