Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mrgransky opened this issue Mar 23, 2021 · 3 comments
Open

Comments

@mrgransky
Copy link

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'
@almazan
Copy link
Contributor

almazan commented May 31, 2021

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).

@mrgransky
Copy link
Author

perfectoo :) 👍

@sarlinpe
Copy link

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants