XPixelGroup / BasicSR

Open Source Image and Video Restoration Toolbox for Super-resolution, Denoise, Deblurring, etc. Currently, it includes EDSR, RCAN, SRResNet, SRGAN, ESRGAN, EDVR, BasicVSR, SwinIR, ECBSR, etc. Also support StyleGAN2, DFDNet.
https://basicsr.readthedocs.io/en/latest/
Apache License 2.0
6.52k stars 1.15k forks source link

ESRGAN train error #112

Open hifn123p opened 5 years ago

hifn123p commented 5 years ago

RuntimeError: Given groups=1, weight of size [64, 3, 3, 3], expected input[16, 1, 32, 32] to have 3 channels, but got 1 channels instead

19-04-24 17:02:01.110 - INFO: Start training from epoch: 0, iter: 0
Traceback (most recent call last):
  File "E:/ryh/ESRGAN/code/codes/train.py", line 173, in <module>
    main()
  File "E:/ryh/ESRGAN/code/codes/train.py", line 106, in main
    model.optimize_parameters(current_step)
  File "E:\ryh\ESRGAN\code\codes\models\SRRaGAN_model.py", line 120, in optimize_parameters
    self.fake_H = self.netG(self.var_L)
  File "C:\Users\1508-T3630\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\Users\1508-T3630\AppData\Roaming\Python\Python36\site-packages\torch\nn\parallel\data_parallel.py", line 121, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "C:\Users\1508-T3630\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "E:\ryh\ESRGAN\code\codes\models\modules\architecture.py", line 77, in forward
    x = self.model(x)
  File "C:\Users\1508-T3630\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\Users\1508-T3630\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\container.py", line 91, in forward
    input = module(input)
  File "C:\Users\1508-T3630\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\Users\1508-T3630\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\conv.py", line 301, in forward
    self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight of size [64, 3, 3, 3], expected input[16, 1, 32, 32] to have 3 channels, but got 1 channels instead
xinntao commented 5 years ago

The inputs should have RGB 3 channels. Otherwise, you need to modify the network arch/configurations.

hifn123p commented 5 years ago

Yes,i use gray images. But it have 3 channels, and each channel has the same value. What should I modify?

xinntao commented 5 years ago

You may need to check your input. According to the error log: expected input[16, 1, 32, 32] to have 3 channels, your input has only 1 channel.

924175302 commented 4 years ago

@ hifn123p I have the same problem as you. I have also checked the data set. It is indeed a three-channel image, but it is the same error as you reported. Have you solved this problem?

RuntimeError: Given groups=1, weight of size 64 3 3 3, expected input[1, 1, 380, 200] to have 3 channels, but got 1 channels instead