Closed NguyenVanThanhHust closed 3 years ago
Thank you for the feedback and interest on our work.
When loading weights from the pretrained model, dimensions should match. In case of applying our model to other dataset with different number of classes, the last layer should be ignored when copying weights: https://pytorch.org/tutorials/beginner/saving_loading_models.html.
E.g.
checkpoint = torch.load(checkpoint_file)
model_state_dict = model.state_dict()
new_model_state_dict = `{}`
for k in model_state_dict:
if k in checkpoint[‘state_dict’] and model_state_dict[k].size() == checkpoint[‘state_dict’][k].size():
new_model_state_dict[k] = checkpoint[‘state_dict’][k]
else:
print(‘Skipped loading parameter {}’.format(k))
model.load_state_dict(new_model_state_dict, strict=False)
Thank for your work.
I'm using your pretrained models to test with my dataset. I encounter an error. When i use model for LSP dataset, i run command:
CUDA_VISIBLE_DEVICES=1 python3.7 test.py --dataset LSP --pretrained UniPose_LSP.tar --img_folder my_dataset
I get error:I change to MPII dataset with command:
CUDA_VISIBLE_DEVICES=1 python3.7 test.py --dataset MPII --pretrained UniPose_MPII.tar --img_folder my_dataset
then i get:My
test.py
is justunipose.py
with new args and remove train, validatation code.Can you check your pretrained models or maybe what did i do wrong?