Paper99 / SRFBN_CVPR19

Pytorch code for our paper "Feedback Network for Image Super-Resolution" (CVPR2019)
MIT License
550 stars 126 forks source link

Loading state dict for SRFBN leads to error #64

Open foteinosKonstantinos opened 1 month ago

foteinosKonstantinos commented 1 month ago

I am trying to load parameters from "SRFBN_x2_BI.pth" to your torch model "SRFBN", but the following error is raised (i have not use your solver):

RuntimeError: Error(s) in loading state_dict for SRFBN:
    Missing key(s) in state_dict: "sub_mean.weight", "sub_mean.bias", "conv_in.0.weight", "conv_in.0.bias", "conv_in.1.weight", "feat_in.0.weight", "feat_in.0.bias", "feat_in.1.weight", "block.compress_in.0.weight", "block.compress_in.0.bias", "block.compress_in.1.weight", "block.upBlocks.0.0.weight", "block.upBlocks.0.0.bias", "block.upBlocks.0.1.weight", "block.upBlocks.1.0.weight", "block.upBlocks.1.0.bias", "block.upBlocks.1.1.weight", "block.upBlocks.2.0.weight", "block.upBlocks.2.0.bias", "block.upBlocks.2.1.weight", "block.upBlocks.3.0.weight", "block.upBlocks.3.0.bias", "block.upBlocks.3.1.weight", "block.upBlocks.4.0.weight", "block.upBlocks.4.0.bias", "block.upBlocks.4.1.weight", "block.upBlocks.5.0.weight", "block.upBlocks.5.0.bias", "block.upBlocks.5.1.weight", "block.downBlocks.0.0.weight", "block.downBlocks.0.0.bias", "block.downBlocks.0.1.weight", "block." ..................................

My code is show below:

import torch
from SRFBN_CVPR19_Models.srfbn_arch import SRFBN
sr_model = SRFBN(in_channels=3,out_channels=3,num_features=64,num_steps=4,num_groups=6,upscale_factor=2)
params = torch.load("/home/<USER NAME>/<DIR>/SRFBN_CVPR19_Models/SRFBN_x2_BI.pth")
if 'state_dict' in params.keys(): params = params['state_dict']
sr_model.load_state_dict(params)

Thanks in advance 🙂

image

foteinosKonstantinos commented 1 month ago

I think that this could be a solution. I just removed "module." from the beginning of the dictionary keys' names.

image