HRNet-Facial-Landmark-Detection
HRNet-Facial-Landmark-Detection copied to clipboard
Missing keys while loading the model
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
I found this problem only for model trained on 300w dataset.
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
Thank you. It solved the problem. Do you know the reason for the problem to occur?
@testingshanu @ElPatou have you train the network again? can you get the same training nme with the author's?
@testingshanu The 300W model is saved through 'torch.save(model.state_dict())' not 'torch.save(model.module.state_dict())'.
@wqz960 I retrained on my own dataset
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.
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.