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.
I get the following error when trying to test the pretrained SRGAN model
Traceback (most recent call last): File "test.py", line 34, in <module> model = create_model(opt) File "/new_data/gpu/sroutray/BasicSR/codes/models/__init__.py", line 18, in create_model m = M(opt) File "/new_data/gpu/sroutray/BasicSR/codes/models/SRGAN_model.py", line 27, in __init__ self.load() # load G and D if needed File "/new_data/gpu/sroutray/BasicSR/codes/models/SRGAN_model.py", line 232, in load self.load_network(load_path_G, self.netG) File "/new_data/gpu/sroutray/BasicSR/codes/models/base_model.py", line 63, in load_network network.load_state_dict(torch.load(load_path), strict=strict) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 769, in load_state_dict self.__class__.__name__, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for SRResNet: Missing key(s) in state_dict: "model.7.weight", "model.7.bias". Unexpected key(s) in state_dict: "model.8.weight", "model.8.bias", "model.10.weight", "model.10.bias". size mismatch for model.5.weight: copying a param with shape torch.Size([256, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]). size mismatch for model.5.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([64]).
It seems that the pre-trained model and the network are different.
You need to first check whether the network (code defined) and the pre-trained models have the same structure.
I get the following error when trying to test the pretrained SRGAN model
Traceback (most recent call last): File "test.py", line 34, in <module> model = create_model(opt) File "/new_data/gpu/sroutray/BasicSR/codes/models/__init__.py", line 18, in create_model m = M(opt) File "/new_data/gpu/sroutray/BasicSR/codes/models/SRGAN_model.py", line 27, in __init__ self.load() # load G and D if needed File "/new_data/gpu/sroutray/BasicSR/codes/models/SRGAN_model.py", line 232, in load self.load_network(load_path_G, self.netG) File "/new_data/gpu/sroutray/BasicSR/codes/models/base_model.py", line 63, in load_network network.load_state_dict(torch.load(load_path), strict=strict) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 769, in load_state_dict self.__class__.__name__, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for SRResNet: Missing key(s) in state_dict: "model.7.weight", "model.7.bias". Unexpected key(s) in state_dict: "model.8.weight", "model.8.bias", "model.10.weight", "model.10.bias". size mismatch for model.5.weight: copying a param with shape torch.Size([256, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]). size mismatch for model.5.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([64]).
Any suggestions on how to resolve this?