XiaoshuiHuang / fmr

This repository is the implementation of our CVPR 2020 work: "Feature-metric Registration: A Fast Semi-supervised Approach for Robust Point Cloud Registration without Correspondences"
MIT License
151 stars 20 forks source link

Evaluation fails when attempting to load pre-trained model #6

Open DustinReagan opened 3 years ago

DustinReagan commented 3 years ago

I successfully trained a model using: python train.py -data modelnet

Now, I'm attempting to evaluate the trained model using: python evaluate.py -data modelnet --pretrained=result/fmr_model.pth

I receive the following error:

(fmr) drreagan@ubuntupc:~/code/fmr$ python evaluate.py -data modelnet  --pretrained=result/fmr_model.pth 
Traceback (most recent call last):
  File "evaluate.py", line 111, in <module>
    main(ARGS)
  File "evaluate.py", line 80, in main
    run(args, testset, fmr)
  File "evaluate.py", line 91, in run
    model.load_state_dict(torch.load(args.pretrained, map_location='cpu'))
  File "/home/drreagan/miniconda3/envs/fmr/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1052, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for SolveRegistration:
        Unexpected key(s) in state_dict: "decoder.bn1.weight", "decoder.bn1.bias", "decoder.bn1.running_mean", "decoder.bn1.running_var", "decoder.bn1.num_batches_tracked", "decoder.bn2.weight", "decoder.bn2.bias", "decoder.bn2.running_mean", "decoder.bn2.running_var", "decoder.bn2.num_batches_tracked", "decoder.bn3.weight", "decoder.bn3.bias", "decoder.bn3.running_mean", "decoder.bn3.running_var", "decoder.bn3.num_batches_tracked", "decoder.fc1.weight", "decoder.fc1.bias", "decoder.fc2.weight", "decoder.fc2.bias", "decoder.fc3.weight", "decoder.fc3.bias", "decoder.fc4.weight", "decoder.fc4.bias". 

Any help/tips would be appreciated.

Thank you!

DustinReagan commented 3 years ago

I was able to fix this error by deleting any keys starting with 'decoder.' from the saved model checkpoint:

around line 90 in evaluate.py:

decoder_keys =  [key for key in pretrained.keys() if key.startswith('decoder.')]            
for key in decoder_keys:
    del pretrained[key]

However, I get the same results when I run without loading a pretrained model and when I run with a trained model. I'm not sure how to interpret the results yet, however...

Dengzhi-USTC commented 3 years ago

may be you can try more diffcult data