Closed yja1 closed 6 years ago
I use your pcb_model_weights
Maybe you should use python 2
and I modify the remove_fc
function in resnet.py:
def remove_fc(state_dict):
"""Remove the fc layer parameters from state_dict."""
no_fc_dict = state_dict.copy()
for key, value in state_dict.items():
if key.startswith('fc.'):
del no_fc_dict[key]
return no_fc_dict
right! thx
@yja1 @ECer23 Thank you very much for pointing out this dictionary discrepancy between python 2 and 3.
comprehensions is better:
def remove_fc(state_dict):
return {key: value for key, value in state_dict.items() if key.startswith('fc.')}
@ghostbody Thanks for your good idea! Just one thing, here you miss the not
. The correct version is
def remove_fc(state_dict):
return {key: value for key, value in state_dict.items() if not key.startswith('fc.')}
@huanghoujing yes, u r right.
python script/experiment/train_pcb.py \ -d '(0,)' \ --only_test true \ --dataset duke \ --exp_dir /data/exp_directory \ --model_weight_file /data/pcb_model_weights/duke/model_weight.pth
the error is: duke test set
NO. Images: 31969 NO. IDs: 751 NO. Query Images: 3368 NO. Gallery Images: 15913 NO. Multi-query Images: 12688
Traceback (most recent call last): File "script/experiment/train_pcb.py", line 495, in
main()
File "script/experiment/train_pcb.py", line 304, in main
train_set = create_dataset(**cfg.train_set_kwargs)
File "./bpm/model/PCBModel.py", line 19, in init
self.base = resnet50(pretrained=True, last_conv_stride=last_conv_stride)
File "./bpm/model/resnet.py", line 190, in resnet50
model.load_state_dict(remove_fc(model_zoo.load_url(model_urls['resnet50'])))
File "./bpm/model/resnet.py", line 152, in remove_fc
for key, value in state_dict.items():
RuntimeError: OrderedDict mutated during iteration