HRNet-Facial-Landmark-Detection icon indicating copy to clipboard operation
HRNet-Facial-Landmark-Detection copied to clipboard

Missing keys while loading the model

Open testingshanu opened this issue 5 years ago • 8 comments

Hi,

I was trying out test.py, but I get the error missing keys(s) in state_dict and list of keys. Am I missing something ?

RuntimeError: Error(s) in loading state_dict for HighResolutionNet: Missing key(s) in state_dict: "conv1.weight", "bn1.weight", "bn1.bias", "bn1.running_mean", .... goes on

testingshanu avatar Jun 12 '19 14:06 testingshanu

I found this problem only for model trained on 300w dataset.

testingshanu avatar Jun 13 '19 14:06 testingshanu

Yes, there is something wrong in that model / code. I tried model.load_state_dict(state_dict) instead of model.module.load_state_dict(state_dict). It seems to be working

SebastienLinker avatar Jun 17 '19 02:06 SebastienLinker

Thank you. It solved the problem. Do you know the reason for the problem to occur?

testingshanu avatar Jun 17 '19 09:06 testingshanu

@testingshanu @ElPatou have you train the network again? can you get the same training nme with the author's?

wqz960 avatar Jul 19 '19 01:07 wqz960

@testingshanu The 300W model is saved through 'torch.save(model.state_dict())' not 'torch.save(model.module.state_dict())'.

chuan92 avatar Aug 14 '19 08:08 chuan92

@wqz960 I retrained on my own dataset

SebastienLinker avatar Oct 01 '19 01:10 SebastienLinker

When i run the command below: python tools/test.py --cfg experiments/300w/face_alignment_300w_hrnet_w18.yaml --model-file output/300W/face_alignment_300w_hrnet_w18/model_best.pth and raise the error AttributeError: 'HighResolutionNet' object has no attribute 'keys' but when i run the command below: python tools/test.py --cfg experiments/300w/face_alignment_300w_hrnet_w18.yaml --model-file output/300W/face_alignment_300w_hrnet_w18/final_state.pth It works OK. I meet the load problems in both 300W and WFLW.

738654805 avatar Nov 25 '19 05:11 738654805

When i run the command below: python tools/test.py --cfg experiments/300w/face_alignment_300w_hrnet_w18.yaml --model-file output/300W/face_alignment_300w_hrnet_w18/model_best.pth and raise the error AttributeError: 'HighResolutionNet' object has no attribute 'keys' but when i run the command below: python tools/test.py --cfg experiments/300w/face_alignment_300w_hrnet_w18.yaml --model-file output/300W/face_alignment_300w_hrnet_w18/final_state.pth It works OK. I meet the load problems in both 300W and WFLW.

Me too, I change the model-file to finale_state.pth while processing test.py, which is save by torch.save(model.state_dict(), final_model_state_file) in train.py, it works.

ishuowang avatar Nov 07 '21 09:11 ishuowang