txytju/Faster-RCNN-LocNet

KeyError: 'unexpected key "head.cls_loc.weight" in state_dict'

zhongjunping opened this issue · 0 comments

Hi, thank you for your work. I got the following error when i run train.py. It may be caused by the initial model weight. I used the torchvision_pretrain.path. Can you help me for that? thanks

zhong@zhong-System-Product-Name:~/zhong/Faster-RCNN-LocNet$ python3 train.py train
======user config========
{'caffe_pretrain': False,
'caffe_pretrain_path': 'checkpoints/vgg16_caffe.pth',
'data': 'voc',
'debug_file': '/tmp/debugf',
'env': 'faster-rcnn',
'epoch': 50,
'load_path': '/home/zhong/zhong/Faster-RCNN-LocNet/checkpoints/fasterrcnn_12211511_0.701052458187_torchvision_pretrain.pth',
'lr': 0.0001,
'lr_decay': 0.1,
'max_size': 1000,
'min_size': 600,
'num_workers': 8,
'plot_every': 100,
'port': 8097,
'pretrained_model': 'vgg16',
'prob_thre': 0.5,
'roi_sigma': 1e-05,
'rpn_sigma': 3.0,
'test_num': 10000,
'test_num_workers': 8,
'use_adam': False,
'use_chainer': False,
'use_drop': False,
'voc_data_dir': '/home/zhong/zhong/Faster-RCNN-LocNet/data/VOCdevkit/VOC2007/',
'weight_decay': 0.0005}
==========end============
load data
model construct completed
Traceback (most recent call last):
File "train.py", line 201, in
fire.Fire()
File "/home/zhong/anaconda3/lib/python3.5/site-packages/fire/core.py", line 127, in Fire
component_trace = _Fire(component, args, context, name)
File "/home/zhong/anaconda3/lib/python3.5/site-packages/fire/core.py", line 366, in _Fire
component, remaining_args)
File "/home/zhong/anaconda3/lib/python3.5/site-packages/fire/core.py", line 542, in _CallCallable
result = fn(*varargs, **kwargs)
File "train.py", line 84, in train
trainer.load(opt.load_path)
File "/home/zhong/zhong/Faster-RCNN-LocNet/trainer.py", line 225, in load
self.faster_rcnn.load_state_dict(state_dict['model'])
File "/home/zhong/anaconda3/lib/python3.5/site-packages/torch/nn/modules/module.py", line 522, in load_state_dict
.format(name))
KeyError: 'unexpected key "head.cls_loc.weight" in state_dict'

If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True