Giter Site home page Giter Site logo

gmberton / vpr-methods-evaluation Goto Github PK

View Code? Open in Web Editor NEW
93.0 3.0 9.0 1.34 MB

Easily download and evaluate pre-trained Visual Place Recognition methods. Code built for the ICCV 2023 paper "EigenPlaces: Training Viewpoint Robust Models for Visual Place Recognition"

Python 100.00%
benchmark computer-vision geolocalization image-retrieval localization place-recognition visual-geo-localization visual-place-recognition

vpr-methods-evaluation's Introduction

VPR-methods-evaluation

This repo is used to easily evaluate pre-trained Visual Place Recognition methods, and is released as part of the ICCV 2023 EigenPlaces paper. All train state-of-the-art models since 2016 are supported (namely NetVLAD, AP-GeM, SFRS, Conv-AP, CosPlace, MixVPR, EigenPlaces, AnyLoc, SALAD, EigenPlaces-indoor and SALAD-indoor) and it uses the weights released by the respective authors.

To see the results of these methods on a large number (14!) of VPR datasets check out the EigenPlaces paper.

[ICCV 2023 Open Access] [ArXiv] [Cite/BibTex]

Basic use

Simply run this to try a method on a (unlabeled) toy dataset contained in assets. This is super lightweight and will take a few seconds even running on a CPU of a laptop.

git clone --recursive https://github.com/gmberton/VPR-methods-evaluation
cd VPR-methods-evaluation
python3 main.py --method=cosplace --backbone=ResNet18 --descriptors_dimension=512 \
    --database_folder=toy_dataset/database --queries_folder=toy_dataset/queries \
    --no_labels --image_size 200 200 --num_preds_to_save 3 \
    --log_dir toy_experiment

which will generate images like this within the logs/toy_experiment visual predictions for each query like this one

You can also use this on your own dataset (or any two directories) simply changing the paths parameters.

How to use on a labelled dataset

The code is designed to be readily used with our VPR-datasets-downloader repo, so that using a few simple commands you can download a dataset and test any model on it. The VPR-datasets-downloader code allows you to download multiple VPR datasets that are automatically formatted in the same format as used by this repo.

The format needed by this repo to compute recalls is that each image should use as filename path/to/image/@UTM_east@UTM_north@[email protected]

mkdir VPR-codebase
cd vpr-codebase

git clone https://github.com/gmberton/VPR-datasets-downloader
cd VPR-datasets-downloader
python3 download_st_lucia.py

cd ..

git clone --recursive https://github.com/gmberton/VPR-methods-evaluation
cd VPR-methods-evaluation
python3 main.py --method=cosplace --backbone=ResNet18 --descriptors_dimension=512 \
    --database_folder=../VPR-datasets-downloader/datasets/st_lucia/images/test/database \
    --queries_folder=../VPR-datasets-downloader/datasets/st_lucia/images/test/queries

This should produce this as output R@1: 98.8, R@5: 99.7, R@10: 99.9, R@20: 100.0, which will be saved in a log file under ./logs/

You can easily change the paths for different datasets, and you can use any of the following methods: NetVLAD, AP-GeM, SFRS, CosPlace, Conv-AP, MixVPR, EigenPlaces, AnyLoc, SALAD, EigenPlaces-indoor and SALAD-indoor. Note that each method has weights only for certain architectures. For example NetVLAD only has weights for VGG16 with descriptors_dimension 32768 and 4069 (with PCA).

NB: make sure to use the git clone --recursive, otherwise some third party (like AP-GeM) models can't be used.

Visualize predictions

Predictions can be easily visualized through the num_preds_to_save parameter. For example running this

python3 main.py --method=cosplace --backbone=ResNet18 --descriptors_dimension=512 \
    --num_preds_to_save=3 --log_dir=cosplace_on_stlucia \
    --database_folder=../VPR-datasets-downloader/datasets/st_lucia/images/test/database \
    --queries_folder=../VPR-datasets-downloader/datasets/st_lucia/images/test/queries

will generate under the path ./logs/cosplace_on_stlucia/*/preds images such as

Given that saving predictions for each query might take long, you can also pass the parameter --save_only_wrong_preds which will save only predictions for wrongly predicted queries (i.e. where the first prediction is wrong).

Acknowledgements / Cite / BibTex

If you use this repository please cite our paper

@inproceedings{Berton_2023_EigenPlaces,
  title={EigenPlaces: Training Viewpoint Robust Models for Visual Place Recognition},
  author={Berton, Gabriele and Trivigno, Gabriele and Caputo, Barbara and Masone, Carlo},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
  year={2023},
  month={October},
  pages={11080-11090}
}

Kudos to the authors of NetVLAD, AP-GeM, SFRS, CosPlace, Conv-AP, MixVPR, EigenPlaces, AnyLoc, SALAD, EigenPlaces-indoor and SALAD-indoor for open sourcing their models' weights. The code for each model has been taken from their respective repositories, except for the code for NetVLAD which has been taken from hloc. Make sure to cite them if you use each model's code.

vpr-methods-evaluation's People

Contributors

enrico-chiavassa avatar gmberton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vpr-methods-evaluation's Issues

RuntimeError: GET was unable to find an engine to execute this computation

Hi @gmberton,

Would you help me to fix the following error?

2024-06-05 21:50:30 main.py --method=mixvpr --backbone=ResNet50 --descriptors_dimension=512 --database_folder=../VPR-datasets-downloader/msls/val/database/ --queries_folder=../VPR-datasets-downloader/msls/val/queries/ --image_size 480 640
2024-06-05 21:50:30 Arguments: Namespace(positive_dist_threshold=25, method='mixvpr', backbone='ResNet50', descriptors_dimension=512, database_folder='../VPR-datasets-downloader/msls/val/database/', queries_folder='../VPR-datasets-downloader/msls/val/queries/', num_workers=4, batch_size=4, log_dir='default', device='cuda', recall_values=[1, 5, 10, 20], no_labels=False, num_preds_to_save=0, save_only_wrong_preds=False, image_size=[480, 640], use_labels=True)
2024-06-05 21:50:30 Testing with mixvpr with a ResNet50 backbone and descriptors dimension 512
2024-06-05 21:50:30 The outputs are being saved in logs/default/2024-06-05_23-50-30
Searching test images in ../VPR-datasets-downloader/msls/val/database/ with glob()
Searching test images in ../VPR-datasets-downloader/msls/val/queries/ with glob()
2024-06-05 21:50:32 Testing on < #queries: 11084; #database: 18871 >
0%| | 0/4718 [00:01<?, ?it/s]
2024-06-05 21:50:33
Traceback (most recent call last):
File "/home/robert/VPR-methods-evaluation/main.py", line 43, in
descriptors = model(images.to(args.device))
File "/home/robert/.pyenv/versions/vpr_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/robert/VPR-methods-evaluation/vpr_models/mixvpr.py", line 118, in forward
x = self.backbone(x)
File "/home/robert/.pyenv/versions/vpr_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/robert/VPR-methods-evaluation/vpr_models/mixvpr.py", line 100, in forward
x = self.model.conv1(x1)
File "/home/robert/.pyenv/versions/vpr_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/robert/.pyenv/versions/vpr_env/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 463, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/home/robert/.pyenv/versions/vpr_env/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: GET was unable to find an engine to execute this computation

Best,
Robert

Ask some queestion for match

Hi, I am a student of University of Chinese Academy of Sciences ,this is a good framework for VPR;
I have a question about image matching between these different methods, in this experiment faiss was used for prediction but I want to use some of our own collected data for querying, some of the coordinate formats they have are not the same as the open source data format
So I would like to know whether all of these different methods are doing matching by multiplying the query image and the db image vectors to find the maximal vector product to find the top image
Thanks

Issue with Low Performance of MixVPR on msls_val Evaluation

Hello, @gmberton!

I am trying to measure the msls_val performance using the following code.
The backbone is ResNet50 and the method is MixVPR.

python3 main.py \
--database_folder=../VPR-datasets-downloader/datasets/msls/images/val/database \
--queries_folder=../VPR-datasets-downloader/datasets/msls/images/val/queries \
--method=mixvpr \
--backbone=ResNet50 \
--descriptors_dimension=512

However, I encountered an error due to an image size issue. To resolve this, I used the following command:

python3 main.py \
--database_folder=../VPR-datasets-downloader/datasets/msls/images/val/database \
--queries_folder=../VPR-datasets-downloader/datasets/msls/images/val/queries \
--method=mixvpr \
--backbone=ResNet50 \
--descriptors_dimension=512 \
--image_size 480 640

This resolved the error, but the performance results were significantly lower compared to other results with the same conditions.

2024-06-03 04:17:33   Testing with mixvpr with a ResNet50 backbone and descriptors dimension 512
2024-06-03 04:17:33   The outputs are being saved in logs/default/2024-06-03_04-17-33
Searching test images in /mnt/hdd2/VPR-datasets-downloader/datasets/msls/images/test/database with glob()
Searching test images in /mnt/hdd2/VPR-datasets-downloader/datasets/msls/images/test/queries with glob()
2024-06-03 04:17:35   Testing on < #queries: 11084; #database: 18871 >
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4718/4718 [04:05<00:00, 19.19it/s]
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 11084/11084 [02:34<00:00, 71.71it/s]
2024-06-03 04:24:16   R@1: 79.8, R@5: 88.4, R@10: 90.6, R@20: 92.5

Compared to the results on the MixVPR GitHub:

R@1: 84.1
R@5: 91.8
R@10: 93.7

And the EigenPlaces paper Table 3:

R@1: 83.6

These results seem to indicate a problem.
Is it not recommended to measure msls_val performance with this VPR-methods-evaluation?

Looking forward to your reply. Thank you in advance!

The questions about Anyloc's output

AnyLoc's desc dim is set to 49152.
However, I noticed that the log message printed:

VLAD caching is disabled.
Desc dim set to 1536

Does this affect experimental evaluation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.