Closed darcyzhc closed 4 years ago
Could you provide a detailed log when this error occurs? I did not meet any error when using pretrained=False
for testing.
Thank you for pointing out. I did not notice it because I did not use reranking for the paper. The solution is to change Line 119-120 in https://github.com/yxgeee/SpCL/blob/master/spcl/evaluators.py to
distmat_qq, _, _ = pairwise_distance(features, query, query)
distmat_gg, _, _ = pairwise_distance(features, gallery, gallery)
When pretrained=False
, error log is:
Traceback (most recent call last):
File "/home/zmwang/project/darcy/SpCL/examples/test.py", line 124, in <module>
main()
File "/home/zmwang/project/darcy/SpCL/examples/test.py", line 56, in main
main_worker(args)
File "/home/zmwang/project/darcy/SpCL/examples/test.py", line 71, in main_worker
model = models.create(args.arch, pretrained=False, num_features=args.features, dropout=args.dropout, num_classes=0)
File "/home/zmwang/project/darcy/SpCL/spcl/models/__init__.py", line 55, in create
return __factory[name](*args, **kwargs)
File "/home/zmwang/project/darcy/SpCL/spcl/models/resnet.py", line 140, in resnet50
return ResNet(50, **kwargs)
File "/home/zmwang/project/darcy/SpCL/spcl/models/resnet.py", line 69, in __init__
self.reset_params()
File "/home/zmwang/project/darcy/SpCL/spcl/models/resnet.py", line 126, in reset_params
self.base[3].load_state_dict(resnet.layer1.state_dict())
File "/project/zmwang/YeJ/anaconda3/envs/d_SpCL/lib/python3.7/site-packages/torch/nn/modules/module.py", line 777, in load_state_dict
self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for MaxPool2d:
Unexpected key(s) in state_dict: "0.conv1.weight", "0.bn1.weight", "0.bn1.bias", "0.bn1.running_mean", "0.bn1.running_var", "0.bn1.num_batches_tracked", "0.conv2.weight", "0.bn2.weight", "0.bn2.bias", "0.bn2.running_mean", "0.bn2.running_var", "0.bn2.num_batches_tracked", "0.conv3.weight", "0.bn3.weight", "0.bn3.bias", "0.bn3.running_mean", "0.bn3.running_var", "0.bn3.num_batches_tracked", "0.downsample.0.weight", "0.downsample.1.weight", "0.downsample.1.bias", "0.downsample.1.running_mean", "0.downsample.1.running_var", "0.downsample.1.num_batches_tracked", "1.conv1.weight", "1.bn1.weight", "1.bn1.bias", "1.bn1.running_mean", "1.bn1.running_var", "1.bn1.num_batches_tracked", "1.conv2.weight", "1.bn2.weight", "1.bn2.bias", "1.bn2.running_mean", "1.bn2.running_var", "1.bn2.num_batches_tracked", "1.conv3.weight", "1.bn3.weight", "1.bn3.bias", "1.bn3.running_mean", "1.bn3.running_var", "1.bn3.num_batches_tracked", "2.conv1.weight", "2.bn1.weight", "2.bn1.bias", "2.bn1.running_mean", "2.bn1.running_var", "2.bn1.num_batches_tracked", "2.conv2.weight", "2.bn2.weight", "2.bn2.bias", "2.bn2.running_mean", "2.bn2.running_var", "2.bn2.num_batches_tracked", "2.conv3.weight", "2.bn3.weight", "2.bn3.bias", "2.bn3.running_mean", "2.bn3.running_var", "2.bn3.num_batches_tracked".
Process finished with exit code 1
Thanks. I have located the bugs and solved them. You could pull the repo again.
While run the examples/test.py, there are some errors: 1、It failed in
examples/test.py[line:70] model = models.create(args.arch, pretrained=False, num_features=args.features, dropout=args.dropout, num_classes=0)
, the solution is to setpretrained=True
2、It failed in
examples/test.py[line:90] evaluator.evaluate(test_loader, dataset.query, dataset.gallery, cmc_flag=True, rerank=args.rerank)
, where theargs.rerank
is True. The reason is thatAttributeError: 'tuple' object has no attribute 'numpy'
inspcl/evaluators.py[line:121] distmat = re_ranking(distmat.numpy(), distmat_qq.numpy(), distmat_gg.numpy())
, thedistmat_qq
anddistmat_gg
is tuple but not tensor. I don't know how to solve this problem.Please help to solve these problems.