deep-image-retrieval icon indicating copy to clipboard operation
deep-image-retrieval copied to clipboard

checkpoint name wrong and error with latest version of scikit-learn

Open mrgransky opened this issue 3 years ago • 3 comments

In the section reproducing results in README.md, you have:

python -m dirtorch.extract_features --dataset RParis6K \
		--checkpoint dirtorch/data/Resnet101-AP-GeM.pt \
		--output rparis6k_features.npy \
		--whiten Landmarks_clean --whitenp 0.25 --gpu 0

The name of the checkpoint (dirtorch/data/Resnet101-AP-GeM.pt) is wrong and needs to be replaced with dirtorch/data/Resnet-101-AP-GeM.pt.

Besides, $ conda install -c anaconda scikit-learn installs the latest version v0.24.1 as in March 2021 which returns the following error:

Traceback (most recent call last):
  File "/home/alijani/.conda/envs/py37/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/alijani/.conda/envs/py37/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/alijani/WS_Farid/OxfordRobotCar/AP-GeM/dirtorch/test_dir.py", line 214, in <module>
    net = load_model(args.checkpoint, args.iscuda)
  File "/home/alijani/WS_Farid/OxfordRobotCar/AP-GeM/dirtorch/test_dir.py", line 168, in load_model
    checkpoint = common.load_checkpoint(path, iscuda)
  File "/home/alijani/WS_Farid/OxfordRobotCar/AP-GeM/dirtorch/utils/common.py", line 121, in load_checkpoint
    checkpoint = torch.load(filename, map_location=lambda storage, loc: storage)
  File "/home/alijani/.conda/envs/py37/lib/python3.7/site-packages/torch/serialization.py", line 595, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/alijani/.conda/envs/py37/lib/python3.7/site-packages/torch/serialization.py", line 774, in _legacy_load
    result = unpickler.load()
ModuleNotFoundError: No module named 'sklearn.decomposition.pca'

mrgransky avatar Mar 23 '21 16:03 mrgransky

Hi @mrgransky! First of all, sorry for the late reply.

Thanks for catching the typo in the README! I'll update it.

PCA whitening was trained with an older version of sklearn, and the code is currently not compatible with 0.24 and above. I need to update the code to fix this bug, but in the meantime you can run the code using an older version of sklearn (eg 0.22, which I know it should work fine).

almazan avatar May 31 '21 13:05 almazan

perfectoo :) :+1:

mrgransky avatar May 31 '21 13:05 mrgransky

Hi @almazan, we have integrated DIR into our localization toolbox hloc and this sklearn error is a little annoying. We have a workaround for recent sklearn versions but it is brittle. It would be great to have a permanent fix, e.g. by updating the checkpoints to not pickle PCA but only its parameters. Thanks :)

sarlinpe avatar Jun 26 '21 07:06 sarlinpe