Hi Filip, thank you for this great work. I am trying to use this codes to evaluate the off-the-shelf networks, I tested with "vgg" and "mac" features and it works well. But when I tried using 'rmac' pooling method, I got the following error.
zxw@Dell:~/codes/cnnimageretrieval-pytorch$ python3 -m cirtorch.examples.test --gpu-id '0' --network-offtheshelf 'vgg16-rmac' --datasets 'oxford5k' --multiscale
>> Loading off-the-shelf network:
>>>> 'vgg16-rmac'
>> imageretrievalnet.py: for 'vgg16' custom pretrained features 'imagenet-caffe-vgg16-features-d369c8e.pth' are used
>>>> loaded network:
(meta): dict(
architecture: vgg16
pooling: rmac
whitening: False
outputdim: 512
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
)
>> oxford5k: Extracting...
>> oxford5k: database images...
Traceback (most recent call last):
File "/home/zxw/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/zxw/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/zxw/codes/cnnimageretrieval-pytorch/cirtorch/examples/test.py", line 207, in <module>
main()
File "/home/zxw/codes/cnnimageretrieval-pytorch/cirtorch/examples/test.py", line 178, in main
vecs = extract_vectors(net, images, args.image_size, transform, ms=ms, msp=msp)
File "/home/zxw/codes/cnnimageretrieval-pytorch/cirtorch/networks/imageretrievalnet.py", line 181, in extract_vectors
vecs[:, i] = extract_ms(net, input_var, ms, msp)
File "/home/zxw/codes/cnnimageretrieval-pytorch/cirtorch/networks/imageretrievalnet.py", line 203, in extract_ms
v += net(input_var_t).pow(msp).cpu().data.squeeze()
File "/home/zxw/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/zxw/codes/cnnimageretrieval-pytorch/cirtorch/networks/imageretrievalnet.py", line 68, in forward
o = self.norm(self.pool(self.features(x))).squeeze(-1).squeeze(-1)
File "/home/zxw/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
result = self.forward(*input, **kwargs)
File "/home/zxw/codes/cnnimageretrieval-pytorch/cirtorch/layers/pooling.py", line 54, in forward
return LF.rmac(x, L=self.L, eps=self.eps)
File "/home/zxw/codes/cnnimageretrieval-pytorch/cirtorch/layers/functional.py", line 39, in rmac
Wd = idx.tolist()[0]
TypeError: 'int' object is not subscriptable
I checked the code, It seems that 'idx.tolist()' is an integer so it is not subscriptable, I change the code for rmac feature in functional.py in line 39:
Wd = idx.tolist()[0]
to
Wd = idx.tolist()
also, in line 41:
Hd = idx.tolist()[0]
to
Hd = idx.tolist()
then I tested the code (using rmac pooling method) and it works well.