garyzhao / SemGCN

The Pytorch implementation for "Semantic Graph Convolutional Networks for 3D Human Pose Regression" (CVPR 2019).
https://arxiv.org/abs/1904.03345
Apache License 2.0
468 stars 78 forks source link

RuntimeError: Error(s) in loading state_dict for SemGCN #33

Open punjal97 opened 4 years ago

punjal97 commented 4 years ago

Thankyou for your work, I tried running the code using

python main_linear.py --evaluate checkpoint/pretrained/ckpt_linear.pth.tar

python main_gcn.py --evaluate checkpoint/pretrained/ckpt_semgcn.pth.tar
are working fine, but getting missing keys error for this run python main_gcn.py --non_local --evaluate checkpoint/pretrained/ckpt_semgcn_nonlocal.pth.tar

$ python main_gcn.py --non_local --evaluate checkpoint/pretrained/ckpt_semgcn_nonlocal.pth.tar ==> Using settings Namespace(actions='*', batch_size=64, checkpoint='checkpoint', dataset='h36m', downsample=1, dropout=0.0, epochs=100, evaluate='checkpoint/pretrained/ckpt_semgcn_nonlocal.pth.tar', hid_dim=128, keypoints='gt', lr=0.001, lr_decay=100000, lr_gamma=0.96, max_norm=True, non_local=True, num_layers=4, num_workers=8, resume='', snapshot=5) ==> Loading dataset... ==> Preparing data... ==> Loading 2D detections... ==> Creating model... ==> Total parameters: 0.43M ==> Loading checkpoint 'checkpoint/pretrained/ckpt_semgcn_nonlocal.pth.tar' Traceback (most recent call last): File "main_gcn.py", line 320, in <module> main(parse_args()) File "main_gcn.py", line 138, in main model_pos.load_state_dict(ckpt['state_dict']) File "/home/kirk/.pyenv/versions/miniconda3-4.3.30/lib/python3.6/site-packages/torch/nn/modules/module.py", line 839, in load_state_dict self.__class__.__name__, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for SemGCN: Missing key(s) in state_dict: "gconv_input.1.nonlocal1.g.0.weight", "gconv_input.1.nonlocal1.g.0.bias", "gconv_input.1.nonlocal1.theta.weight", "gconv_input.1.nonlocal1.theta.bias", "gconv_input.1.nonlocal1.phi.0.weight", "gconv_input.1.nonlocal1.phi.0.bias", "gconv_input.1.nonlocal1.concat_project.0.weight", "gconv_input.1.nonlocal1.W.0.weight", "gconv_input.1.nonlocal1.W.0.bias", "gconv_input.1.nonlocal1.W.1.weight", "gconv_input.1.nonlocal1.W.1.bias", "gconv_input.1.nonlocal1.W.1.running_mean", "gconv_input.1.nonlocal1.W.1.running_var", "gconv_layers.1.nonlocal1.g.0.weight", "gconv_layers.1.nonlocal1.g.0.bias", "gconv_layers.1.nonlocal1.theta.weight", "gconv_layers.1.nonlocal1.theta.bias", "gconv_layers.1.nonlocal1.phi.0.weight", "gconv_layers.1.nonlocal1.phi.0.bias", "gconv_layers.1.nonlocal1.concat_project.0.weight", "gconv_layers.1.nonlocal1.W.0.weight", "gconv_layers.1.nonlocal1.W.0.bias", "gconv_layers.1.nonlocal1.W.1.weight", "gconv_layers.1.nonlocal1.W.1.bias", "gconv_layers.1.nonlocal1.W.1.running_mean", "gconv_layers.1.nonlocal1.W.1.running_var", "gconv_layers.3.nonlocal1.g.0.weight", "gconv_layers.3.nonlocal1.g.0.bias", "gconv_layers.3.nonlocal1.theta.weight", "gconv_layers.3.nonlocal1.theta.bias", "gconv_layers.3.nonlocal1.phi.0.weight", "gconv_layers.3.nonlocal1.phi.0.bias", "gconv_layers.3.nonlocal1.concat_project.0.weight", "gconv_layers.3.nonlocal1.W.0.weight", "gconv_layers.3.nonlocal1.W.0.bias", "gconv_layers.3.nonlocal1.W.1.weight", "gconv_layers.3.nonlocal1.W.1.bias", "gconv_layers.3.nonlocal1.W.1.running_mean", "gconv_layers.3.nonlocal1.W.1.running_var", "gconv_layers.5.nonlocal1.g.0.weight", "gconv_layers.5.nonlocal1.g.0.bias", "gconv_layers.5.nonlocal1.theta.weight", "gconv_layers.5.nonlocal1.theta.bias", "gconv_layers.5.nonlocal1.phi.0.weight", "gconv_layers.5.nonlocal1.phi.0.bias", "gconv_layers.5.nonlocal1.concat_project.0.weight", "gconv_layers.5.nonlocal1.W.0.weight", "gconv_layers.5.nonlocal1.W.0.bias", "gconv_layers.5.nonlocal1.W.1.weight", "gconv_layers.5.nonlocal1.W.1.bias", "gconv_layers.5.nonlocal1.W.1.running_mean", "gconv_layers.5.nonlocal1.W.1.running_var", "gconv_layers.7.nonlocal1.g.0.weight", "gconv_layers.7.nonlocal1.g.0.bias", "gconv_layers.7.nonlocal1.theta.weight", "gconv_layers.7.nonlocal1.theta.bias", "gconv_layers.7.nonlocal1.phi.0.weight", "gconv_layers.7.nonlocal1.phi.0.bias", "gconv_layers.7.nonlocal1.concat_project.0.weight", "gconv_layers.7.nonlocal1.W.0.weight", "gconv_layers.7.nonlocal1.W.0.bias", "gconv_layers.7.nonlocal1.W.1.weight", "gconv_layers.7.nonlocal1.W.1.bias", "gconv_layers.7.nonlocal1.W.1.running_mean", "gconv_layers.7.nonlocal1.W.1.running_var". Unexpected key(s) in state_dict: "gconv_input.1.nonlocal.g.0.weight", "gconv_input.1.nonlocal.g.0.bias", "gconv_input.1.nonlocal.theta.weight", "gconv_input.1.nonlocal.theta.bias", "gconv_input.1.nonlocal.phi.0.weight", "gconv_input.1.nonlocal.phi.0.bias", "gconv_input.1.nonlocal.concat_project.0.weight", "gconv_input.1.nonlocal.W.0.weight", "gconv_input.1.nonlocal.W.0.bias", "gconv_input.1.nonlocal.W.1.weight", "gconv_input.1.nonlocal.W.1.bias", "gconv_input.1.nonlocal.W.1.running_mean", "gconv_input.1.nonlocal.W.1.running_var", "gconv_input.1.nonlocal.W.1.num_batches_tracked", "gconv_layers.1.nonlocal.g.0.weight", "gconv_layers.1.nonlocal.g.0.bias", "gconv_layers.1.nonlocal.theta.weight", "gconv_layers.1.nonlocal.theta.bias", "gconv_layers.1.nonlocal.phi.0.weight", "gconv_layers.1.nonlocal.phi.0.bias", "gconv_layers.1.nonlocal.concat_project.0.weight", "gconv_layers.1.nonlocal.W.0.weight", "gconv_layers.1.nonlocal.W.0.bias", "gconv_layers.1.nonlocal.W.1.weight", "gconv_layers.1.nonlocal.W.1.bias", "gconv_layers.1.nonlocal.W.1.running_mean", "gconv_layers.1.nonlocal.W.1.running_var", "gconv_layers.1.nonlocal.W.1.num_batches_tracked", "gconv_layers.3.nonlocal.g.0.weight", "gconv_layers.3.nonlocal.g.0.bias", "gconv_layers.3.nonlocal.theta.weight", "gconv_layers.3.nonlocal.theta.bias", "gconv_layers.3.nonlocal.phi.0.weight", "gconv_layers.3.nonlocal.phi.0.bias", "gconv_layers.3.nonlocal.concat_project.0.weight", "gconv_layers.3.nonlocal.W.0.weight", "gconv_layers.3.nonlocal.W.0.bias", "gconv_layers.3.nonlocal.W.1.weight", "gconv_layers.3.nonlocal.W.1.bias", "gconv_layers.3.nonlocal.W.1.running_mean", "gconv_layers.3.nonlocal.W.1.running_var", "gconv_layers.3.nonlocal.W.1.num_batches_tracked", "gconv_layers.5.nonlocal.g.0.weight", "gconv_layers.5.nonlocal.g.0.bias", "gconv_layers.5.nonlocal.theta.weight", "gconv_layers.5.nonlocal.theta.bias", "gconv_layers.5.nonlocal.phi.0.weight", "gconv_layers.5.nonlocal.phi.0.bias", "gconv_layers.5.nonlocal.concat_project.0.weight", "gconv_layers.5.nonlocal.W.0.weight", "gconv_layers.5.nonlocal.W.0.bias", "gconv_layers.5.nonlocal.W.1.weight", "gconv_layers.5.nonlocal.W.1.bias", "gconv_layers.5.nonlocal.W.1.running_mean", "gconv_layers.5.nonlocal.W.1.running_var", "gconv_layers.5.nonlocal.W.1.num_batches_tracked", "gconv_layers.7.nonlocal.g.0.weight", "gconv_layers.7.nonlocal.g.0.bias", "gconv_layers.7.nonlocal.theta.weight", "gconv_layers.7.nonlocal.theta.bias", "gconv_layers.7.nonlocal.phi.0.weight", "gconv_layers.7.nonlocal.phi.0.bias", "gconv_layers.7.nonlocal.concat_project.0.weight", "gconv_layers.7.nonlocal.W.0.weight", "gconv_layers.7.nonlocal.W.0.bias", "gconv_layers.7.nonlocal.W.1.weight", "gconv_layers.7.nonlocal.W.1.bias", "gconv_layers.7.nonlocal.W.1.running_mean", "gconv_layers.7.nonlocal.W.1.running_var", "gconv_layers.7.nonlocal.W.1.num_batches_tracked".

1165048017 commented 4 years ago

same error

garyzhao commented 4 years ago

Hi @Chromium97 ,

I guess you might be using Python 3.

Changing to Python 2 might solve this problem.

Best, Long

punjal97 commented 4 years ago

Hi @garyzhao

I was earlier using Python 3.6.x but tried running the same thing with new virtual env for Python 2.7.18,

Giving the same error for last command, the other two are working okay just like above.

Any idea here? Thanks

HDYYZDN commented 3 years ago

model.load_state_dict(checkpoint['state_dict'], strict=False) 解决问题

SuperAttitude commented 3 years ago

model.load_state_dict(checkpoint['state_dict'], strict=False) 解决问题

您好,打扰您了,这行代码加到哪里运行呢,谢谢,感激不尽

jujakoss commented 3 years ago

model.load_state_dict(checkpoint['state_dict'], strict=False) 解决问题

您好,打扰您了,这行代码加到哪里运行呢,谢谢,感激不尽 @SuperAttitude

in viz.py line 106 model_pos.load_state_dict(ckpt['state_dict'], strict=False)

SuperAttitude commented 3 years ago

model.load_state_dict(checkpoint['state_dict'], strict=False) 解决问题

您好,打扰您了,这行代码加到哪里运行呢,谢谢,感激不尽 @SuperAttitude

in viz.py line 106 model_pos.load_state_dict(ckpt['state_dict'], strict=False)

Thank you, thank you for your help, sincerely wish you good luck.

tamasino52 commented 3 years ago

print("==> Loading checkpoint '{}'".format(ckpt_path)) ckpt = torch.load(ckpt_path) start_epoch = ckpt['epoch'] error_best = ckpt['error'] glob_step = ckpt['step'] lr_now = ckpt['lr']

for k, v in ckpt['state_dict'].copy().items(): ckpt['state_dict'][k.replace('nonlocal', 'non_local')] = ckpt['state_dict'].pop(k)

model_pos.load_state_dict(ckpt['state_dict'])

Rename like this.

PawAlldeller commented 10 months ago

model.load_state_dict(checkpoint['state_dict'], strict=False) 解决问题

您好,打扰您了,这行代码加到哪里运行呢,谢谢,感激不尽 @SuperAttitude

in viz.py line 106 model_pos.load_state_dict(ckpt['state_dict'], strict=False)

Sorry, but where is this viz located?py ? How to find it