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

Error load models #15

Open
microvnn opened this issue Mar 9, 2023 · 1 comment
Open

Error load models #15

microvnn opened this issue Mar 9, 2023 · 1 comment

Comments

@microvnn
Copy link

microvnn commented Mar 9, 2023

sys.path.append('./vendors/Sphereface')
config_path = os.path.join('./vendors', 'Sphereface',
'20220428_232053', 'config.yml')
with open(config_path, 'r') as f:
test_config = yaml.load(f, yaml.SafeLoader)

build model

bkb_net = build_from_cfg(
test_config['model']['backbone']['net'],
'model.backbone',
)
bkb_net.eval()
checkpoint = os.path.join('./vendors', 'Sphereface',
'20220428_232053', 'models', 'backbone_80000.pth')
state_dict = torch.load(checkpoint, map_location=torch.device('cpu'))
bkb_net.load_state_dict(state_dict)
print(bkb_net)

Please help me.

Result:
RuntimeError: Error(s) in loading state_dict for SFNet_deprecated:
Missing key(s) in state_dict: "layer1.0.conv1.weight", "layer1.0.conv1.bias", "layer1.1.conv1.weight", "layer1.1.conv1.bias", "layer1.1.conv2.weight", "layer1.1.conv2.bias", "layer2.0.conv1.weight", "layer2.0.conv1.bias", "layer2.1.conv1.weight", "layer2.1.conv1.bias", "layer2.1.conv2.weight", "layer2.1.conv2.bias", "layer2.2.conv1.weight", "layer2.2.conv1.bias", "layer2.2.conv2.weight", "layer2.2.conv2.bias", "layer3.0.conv1.weight", "layer3.0.conv1.bias", "layer3.1.conv1.weight", "layer3.1.conv1.bias", "layer3.1.conv2.weight", "layer3.1.conv2.bias", "layer3.2.conv1.weight", "layer3.2.conv1.bias", "layer3.2.conv2.weight", "layer3.2.conv2.bias", "layer3.3.conv1.weight", "layer3.3.conv1.bias", "layer3.3.conv2.weight", "layer3.3.conv2.bias", "layer3.4.conv1.weight", "layer3.4.conv1.bias", "layer3.4.conv2.weight", "layer3.4.conv2.bias", "layer4.0.conv1.weight", "layer4.0.conv1.bias", "layer4.1.conv1.weight", "layer4.1.conv1.bias", "layer4.1.conv2.weight", "layer4.1.conv2.bias", "fc.weight", "fc.bias".
Unexpected key(s) in state_dict: "module.layer1.0.conv1.weight", "module.layer1.0.conv1.bias", "module.layer1.1.conv1.weight", "module.layer1.1.conv1.bias", "module.layer1.1.conv2.weight", "module.layer1.1.conv2.bias", "module.layer2.0.conv1.weight", "module.layer2.0.conv1.bias", "module.layer2.1.conv1.weight", "module.layer2.1.conv1.bias", "module.layer2.1.conv2.weight", "module.layer2.1.conv2.bias", "module.layer2.2.conv1.weight", "module.layer2.2.conv1.bias", "module.layer2.2.conv2.weight", "module.layer2.2.conv2.bias", "module.layer3.0.conv1.weight", "module.layer3.0.conv1.bias", "module.layer3.1.conv1.weight", "module.layer3.1.conv1.bias", "module.layer3.1.conv2.weight", "module.layer3.1.conv2.bias", "module.layer3.2.conv1.weight", "module.layer3.2.conv1.bias", "module.layer3.2.conv2.weight", "module.layer3.2.conv2.bias", "module.layer3.3.conv1.weight", "module.layer3.3.conv1.bias", "module.layer3.3.conv2.weight", "module.layer3.3.conv2.bias", "module.layer3.4.conv1.weight", "module.layer3.4.conv1.bias", "module.layer3.4.conv2.weight", "module.layer3.4.conv2.bias", "module.layer4.0.conv1.weight", "module.layer4.0.conv1.bias", "module.layer4.1.conv1.weight", "module.layer4.1.conv1.bias", "module.layer4.1.conv2.weight", "module.layer4.1.conv2.bias",
"module.fc.weight", "module.fc.bias".

@ydwen
Copy link
Owner

ydwen commented Mar 9, 2023

Hey microvnn,

You can try wrapping the model to DDP before loading the parameters.

example:
ddp_model = DDP(model, device_ids=[rank])

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

2 participants