Closed ozturkoktay closed 3 years ago
The input channel is changed from 3 to 1, and the output channel is also modified to ensure that the loaded image is grayscale.
Ok, I've changed the output layer too and passed that step. Now I get RuntimeError: The size of tensor a (192) must match the size of tensor b (96) at non-singleton dimension 3
This error seems to be a discriminator problem. Can you give the details of the error code line.
Of course:
Traceback (most recent call last):
File "train.py", line 609, in <module>
main()
File "train.py", line 152, in main
main_worker(args.gpu, ngpus_per_node, args)
File "train.py", line 361, in main_worker
psnr_optimizer, epoch, psnr_writer, scaler, args)
File "train.py", line 443, in train_psnr
mse_loss = pixel_criterion(sr, hr)
File "/home/naldwig/Desktop/Files/SRGAN-PyTorch/env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/naldwig/Desktop/Files/SRGAN-PyTorch/env/lib/python3.7/site-packages/torch/nn/modules/loss.py", line 528, in forward
return F.mse_loss(input, target, reduction=self.reduction)
File "/home/naldwig/Desktop/Files/SRGAN-PyTorch/env/lib/python3.7/site-packages/torch/nn/functional.py", line 2928, in mse_loss
expanded_input, expanded_target = torch.broadcast_tensors(input, target)
File "/home/naldwig/Desktop/Files/SRGAN-PyTorch/env/lib/python3.7/site-packages/torch/functional.py", line 74, in broadcast_tensors
return _VF.broadcast_tensors(tensors) # type: ignore
RuntimeError: The size of tensor a (192) must match the size of tensor b (96) at non-singleton dimension 3
SR image size is 192, But HR image size is 96.
Cause of error the upscale factor. When I changed the upscale factor to 2 throws an error, default parameter (4) causes no error. Do you have any idea?
you set --arch srgan_2x2
?
Problem solved, thanks! Maybe grayscale parameter can be added.
Ok, new but similar error when calculating gmsd after first epoch:
Error:
Traceback (most recent call last):
File "train.py", line 612, in <module>
main()
File "train.py", line 152, in main
main_worker(args.gpu, ngpus_per_node, args)
File "train.py", line 370, in main_worker
dataloader=test_dataloader, model=generator, gpu=args.gpu)
File "/home/naldwig/Desktop/Files/SRGAN-PyTorch/srgan_pytorch/utils/estimate.py", line 94, in test
total_gmsd_value += gmsd_loss(sr, hr)
File "/home/naldwig/Desktop/Files/SRGAN-PyTorch/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/naldwig/Desktop/Files/SRGAN-PyTorch/srgan_pytorch/utils/image_quality_assessment/calculate_gmsd.py", line 66, in forward
out = torch.mean(self.gmsd(source * 255, target * 255))
File "/home/naldwig/Desktop/Files/SRGAN-PyTorch/srgan_pytorch/utils/image_quality_assessment/calculate_gmsd.py", line 40, in gmsd
stride=2, padding=0, groups=3)
RuntimeError: Given groups=3, weight of size [3, 1, 2, 2], expected input[19, 1, 96, 96] to have 3 channels, but got 1 channels instead
GMSD support RGB image, not support gray image.
Hi, when I was trying to train grayscale tiff images I get
RuntimeError: Given groups=1, weight of size [64, 1, 9, 9], expected input[16, 3, 48, 48] to have 1 channels, but got 3 channels instead
.I changed first Conv2d input channel 3 to 1 but still the same. Can you help?