Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading state dict for SRFBN leads to error #64

Open
foteinosKonstantinos opened this issue Sep 27, 2024 · 1 comment
Open

Loading state dict for SRFBN leads to error #64

foteinosKonstantinos opened this issue Sep 27, 2024 · 1 comment

Comments

@foteinosKonstantinos
Copy link

foteinosKonstantinos commented Sep 27, 2024

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
Copy link
Author

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

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant