huanglianghua / siamfc-pytorch

A clean PyTorch implementation of SiamFC tracking/training, evaluated on 7 datasets.
MIT License
623 stars 133 forks source link

Error(s) in loading state_dict for SiamFC #16

Closed wujiyoung closed 5 years ago

wujiyoung commented 5 years ago

Error happened when loading state_dict from the pretrained model (download from google drive) for SiamFC.

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    tracker = TrackerSiamFC(net_path=net_path)
  File "F:\code\MOT\DRL_MOT\CDRL\siamfc-pytorch\siamfc.py", line 84, in __init__
    net_path, map_location=lambda storage, loc: storage))
  File "D:\anaconda3\lib\site-packages\torch\nn\modules\module.py", line 721, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for SiamFC:
        Unexpected key(s) in state_dict: "feature.1.num_batches_tracked", "feature.5.num_batches_tracked", "feature.9.num_batches_tracked", "feature.12.num_batches_tracked".
huanglianghua commented 5 years ago

This may caused by different versions of PyTorch. The num_batches_tracked is included in newer PyTorch versions.

You can set net.load_state_dict(..., strict=False) to avoid the error.

wujiyoung commented 5 years ago

This may caused by different versions of PyTorch. The num_batches_tracked is included in newer PyTorch versions.

You can set net.load_state_dict(..., strict=False) to avoid the error.

you are right, it worked, thank you.