Giter Site home page Giter Site logo

anyloc / anyloc Goto Github PK

View Code? Open in Web Editor NEW
368.0 9.0 28.0 45.75 MB

AnyLoc: Universal Visual Place Recognition (RA-L 2023)

Home Page: https://anyloc.github.io/

License: BSD 3-Clause "New" or "Revised" License

Python 90.22% Shell 9.78%
deep-learning image-retrieval localization place-recognition robotics descriptors vlad anyloc

anyloc's Introduction

AnyLoc: Towards Universal Visual Place Recognition

License: BSD-3 stars arXiv githubio github YouTube Hugging Face Space Open In Colab: Global Descriptors Open In Colab: Cluster visualizations Public Release on IIITH-OneDrive Hugging Face Paper

Table of contents

Contents

The contents of this repository are as follows

S. No. Item Description
1 demo Contains standalone demo scripts (Quick start, Jupyter Notebook, and Gradio app) to run our AnyLoc-VLAD-DINOv2 method. Also contains guides for APIs. This folder is self-contained (doesn't use anything outside it).
2 scripts Contains all scripts for development. Use the -h option for argument information.
3 configs.py Global configurations for the repository
4 utilities Utility Classes & Functions (includes DINOv2 hooks & VLAD)
5 conda-environment.yml The conda environment (it could fail to install OpenAI CLIP as it includes a git+ URL). We suggest you use the setup_conda.sh script.
6 requirements.txt Requirements file for pip virtual environment. Probably out of date.
7 custom_datasets Custom datalaoder implementations for VPR.
8 examples Miscellaneous example scripts
9 MixVPR Minimal MixVPR inference code
10 clip_wrapper.py A wrapper around two CLIP implementations (OpenAI and OpenCLIP).
11 models_mae.py MAE implementation
12 dino_extractor.py DINO (v1) feature extractor
13 CONTRIBUTING.md Note for contributors
14 paper_utils Paper scripts (formatting for figures, etc.)

Included Repositories

Includes the following repositories (currently not submodules) as subfolders.

Directory Link Cloned On Description
dvgl-benchmark gmberton/deep-visual-geo-localization-benchmark 2023-02-12 For benchmarking
datasets-vg gmberton/datasets_vg 2023-02-13 For dataset download and formatting
CosPlace gmberton/CosPlace 2023-03-20 Baseline Comparisons

Included Datasets

We release all the benchmarking datasets in our public release.

  1. Download the .tar.gz files from here > Datasets-All (for the datasets you want to use)

  2. Unzip them using tar -xvzf ./NAME.tar.gz. They should unzip into a directory with NAME.

    • If you're using our benchmarking scripts, this directory where you're storing the datasets is the parameter --prog.data-vg-dir (in most scripts).
    • See Dataset Setup for detailed information (including how the data directory structure should look after unzipping)

We thank the following sources for the rich datasets

  1. Baidu Autonomous Driving Business Unit for the Baidu Mall dataset present in baidu_datasets.tar.gz
  2. Queensland University of Technology for the Gardens Point dataset present in gardens.tar.gz
  3. York University for the 17 Places dataset present in 17places.tar.gz
  4. Tokyo Institute of Technology, INRIA, and CTU Prague for the Pitts-30k dataset present in pitts30k.tar.gz
  5. Queensland University of Technology for the St. Lucia dataset present in st_lucia.tar.gz
  6. University of Oxford for the Oxford dataset present in Oxford_Robotcar.tar.gz
  7. AirLab at CMU for the Hawkins dataset present in hawkins_long_corridor.tar.gz, the Laurel Caverns dataset present in laurel_caverns.tar.gz, and the Nardo Air dataset present in test_40_midref_rot0.tar.gz (not rotated) and test_40_midref_rot90.tar.gz (rotated).
  8. Fraunhofer FKIE and TU Munich for the VP-Air dataset present in VPAir.tar.gz
  9. Ifremer and University of Toulon for the Mid-Atlantic Ridge dataset present in eiffel.tar.gz

Most of the contents of the zipped folders are from the original sources. We generate the ground truth for some of the datasets as .npy files; see this issue for more information.

The copyright of each dataset is held by the original sources.

PapersWithCode Badges

PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC

Getting Started

Tip: You can explore the HuggingFace Space and the Colab notebooks (no GPU needed).

Clone this repository

git clone https://github.com/AnyLoc/AnyLoc.git
cd AnyLoc

Set up the conda environment (you can also use mamba instead of conda; the script will automatically detect it)

conda create -n anyloc python=3.9
conda activate anyloc
bash ./setup_conda.sh
# If you want to install the developer tools as well
bash ./setup_conda.sh --dev

The setup takes about 11 GB of disk space. You can also use an existing conda environment, say vl-vpr, by doing

bash ./setup_conda.sh vl-vpr

Note the following:

  • All our public release files can be found in our public release.
    • If the conda environment setup is taking time, you could just unzip conda-env.tar.gz (GB) in your ~/anaconda3/envs folder (but compatibility is not guaranteed).
  • The ./scripts folder is for validating our results and seeing the main scripts. Most applications are in the ./demo folder. See the list of demos before running anything.
  • If you're running something in the ./scripts folder, run it with pwd in this (repository) folder. For example, python scripts are run as python ./scripts/<script>.py and bash scripts are run as bash ./scripts/<script>.sh. For the demos and other baselines, you should cd into respective folders.
  • The utilities.py file is mainly for ./scripts files. All demos actually use the demo/utilities.py file (which is distilled and minimal). Using the latter should be enough to implement our SOTA method.

Using the SOTA: AnyLoc-VLAD-DINOv2

Open In Colab Local Python script

Using the APIs

Import the utilities

from utilities import DinoV2ExtractFeatures
from utilities import VLAD

DINOv2

DINOv2 feature extractor can be used as follows

extractor = DinoV2ExtractFeatures("dinov2_vitg14", desc_layer,
        desc_facet, device=device)

Get the descriptors using

# Make image patchable (14, 14 patches)
c, h, w = img_pt.shape
h_new, w_new = (h // 14) * 14, (w // 14) * 14
img_pt = tvf.CenterCrop((h_new, w_new))(img_pt)[None, ...]
# Main extraction
ret = extractor(img_pt) # [1, num_patches, desc_dim]

VLAD

The VLAD aggregator can be loaded with vocabulary (cluster centers) from a c_centers.pt file.

# Main VLAD object
vlad = VLAD(num_c, desc_dim=None, cache_dir=os.path.dirname(c_centers_file))
vlad.fit(None)  # Load the vocabulary (and auto-detect `desc_dim`)
# Cluster centers have shape: [num_c, desc_dim]
#   - num_c: number of clusters
#   - desc_dim: descriptor dimension

If you have a database of descriptors you want to fit, use

vlad.fit(ein.rearrange(full_db_vlad, "n k d -> (n k) d"))
# n: number of images
# k: number of patches/descriptors per image
# d: descriptor dimension

To get the VLAD representations of multiple images, use

db_vlads: torch.Tensor = vlad.generate_multi(full_db)
# Shape of full_db: [n_db, n_d, d_dim]
#   - n_db: number of images in the database
#   - n_d: number of descriptors per image
#   - d_dim: descriptor dimension
# Shape of db_vlads: [n_db, num_c * d_dim]
#   - num_c: number of clusters (centers)

DINOv1

This is present in dino_extractor.py (not a part of demo/utilities.py).

Initialize and use it as follows the extractor

# Import it
from dino_extractor import ViTExtractor
...

# Initialize it (layer and key are when extracting descriptors)
extractor = ViTExtractor("dino_vits8", stride=4, 
        device=device)
...

# Use it to extract patch descriptors
img = ein.rearrange(img, "c h w -> 1 c h w").to(device)
img = F.interpolate(img, (224, 298))    # For 4:3 images
desc = extractor.extract_descriptors(img,
        layer=11, facet="key") # [1, 1, num_descs, d_dim]
...

Validating the Results

You don't need to read further if you're not experimentally validating the entire results (enjoy the demos instead) or building on this repository from source.

The following sections are for the curious minds who want to reproduce the results.

Note to/for contributors: Please follow contributing guidelines. This is mainly for developers/authors who'll be pushing to this repository.

All the runs were done on a machine with the following specifications:

  • CPU: Two Intel Xeon Gold 5317 CPUs (12C24T each)
  • CPU RAM: 256 GB
  • GPUs: Four NVIDIA RTX 3090 GPUs (24 GB, 10496 CUDA cores each)
  • Storage: 3.5 TB HDD on /scratch. However, all datasets will take 32+ GB, have more for other requirements (for VLAD cluster centers, caching, models, etc.). We noticed that singularity (with SIF, cache, and tmp) used 90+ GB.
    • Driver Version (NVIDIA-SMI): 570.47.03
    • CUDA (SMI): 11.6

We use only one GPU; however, some experiments (with large datasets) might need all of the CPU RAM (for efficient/fast nearest neighbor search). Ideally, a 16 GB GPU should also work.

Do the following

  1. Clone the repository and setup the NVIDIA NGC container (run everything inside it)
  2. Setup the datasets (download, format, and extract them)
  3. Run the script you want to test from scripts folder

Start by cloning/setting up the repository

cd ~/Documents
git clone https://github.com/AnyLoc/AnyLoc.git vl-vpr

NVIDIA NGC Singularity Container Setup

Despite using recommended practices of reproducibility (see function seed_everything in utilities.py) in PyTorch, we noticed minor changes across GPU types and CUDA versions. To mitigate this, we recommend using a singularity container.

Setting up the environment in a singularity container (in a SLURM environment)

TL;DR: Run the following (this system is a different one). This was tested on CMU's Bridges-2 partition of PSC HPC. Don't use this if you want to replicate the tables in the paper (but the numbers come close).

salloc -p GPU-small -t 01:00:00 --ntasks-per-node=5 --gres=gpu:v100-32:1
cd /ocean/containers/ngc/pytorch/
singularity instance start --nv pytorch_22.12-py3.sif vlvpr
singularity run --nv instance://vlvpr
cd /ocean/projects/cis220039p/nkeetha/data/singularity/venv
source vlvpr/bin/activate
cd /ocean/projects/cis220039p/<path to vl-vpr scripts folder>

Main setup: For Singularity on IIITH's Ada HPC (Ubuntu 18.04) - our main setup for validation. Use this if you want to replicate the tables in the paper (hardware should be same as listed before).

The script below assumes that this repository is cloned in ~/Documents/vl-vpr. That is, this README is at ~/Documents/vl-vpr/README.md.

# Load the module and configurations
module load u18/singularity-ce/3.9.6
mkdir -p /scratch/$USER/singularity && cd $_ && mkdir .cache .tmp venvs
export SINGULARITY_CACHEDIR=/scratch/$USER/singularity/.cache
export SINGULARITY_TMPDIR=/scratch/$USER/singularity/.tmp
# Ensure that the next command gives output "1" (or anything other than "0")
cat /proc/sys/kernel/unprivileged_userns_clone
# Setup the container (download the image if not there already) - (15 GB cache + 7.5 GB file)
singularity pull ngc_pytorch_22.12-py3 docker://nvcr.io/nvidia/pytorch:22.12-py3
# Test container through shell
singularity shell --nv ngc_pytorch_22.12-py3
# Start and run the container (mount the symlinked and scratch folders)
singularity instance start --mount "type=bind,source=/scratch/$USER,destination=/scratch/$USER" \
    --nv ngc_pytorch_22.12-py3 vl-vpr
singularity run --nv instance://vl-vpr
# Create virtual environment
cd ~/Documents/vl-vpr/
pip install virtualenv
cd venvs
virtualenv --system-site-packages vl-vpr
# Activate virtualenv and install all packages
cd ~/Documents/vl-vpr/
source ./venvs/vl-vpr/bin/activate
bash ./setup_virtualenv_ngc.sh
# Run anything you want (from here, but find the file in scripts)
cd ~/Documents/vl-vpr/
python ./scripts/<task name>.py <args>
# The baseline scripts should be run in their own folders. For example, to run CosPlace, do
cd ~/Documents/vl-vpr/
cd CosPlace
python ./<script>.py

Dataset Setup

Datasets Note: See the Datasets-All folder in our public material (for .tar.gz files). Also see included datasets.

Set them up in a folder with sufficient space

mkdir -p /scratch/$USER/vl-vpr/datasets && cd $_

Download (and unzip) the datasets from here (Datasets-All folder) into this folder. Link this folder (for easy access form this repository)

cd ~/Documents/vl-vpr/
cd ./datasets-vg
ln -s /scratch/$USER/vl-vpr/datasets datasets

After setting up all datasets, the folders should look like this (in the dataset folder). Run the following command to get the tree structure.

tree ./eiffel ./hawkins*/ ./laurel_caverns ./VPAir ./test_40_midref_rot*/ ./Oxford_Robotcar ./gardens ./17places ./baidu_datasets ./st_lucia ./pitts30k --filelimit=20 -h
  • The test_40_midref_rot0 is Nardo Air. This is also referred as Tartan_GNSS_notrotated in our scripts.
  • The test_40_midref_rot90 is Nardo Air-R (rotated). This is also referred as Tartan_GNSS_rotated in out scripts.
  • The hawkins_long_corridor is the Hawkins dataset (degraded environment).
  • The eiffel dataset is Mid-Atlantic Ridge (underwater dataset).

Output will be something like

./eiffel
├── [4.0K]  db_images [65 entries exceeds filelimit, not opening dir]
├── [2.2K]  eiffel_gt.npy
└── [4.0K]  q_images [101 entries exceeds filelimit, not opening dir]
./hawkins_long_corridor/
├── [4.0K]  db_images [127 entries exceeds filelimit, not opening dir]
├── [ 12K]  images [314 entries exceeds filelimit, not opening dir]
├── [ 17K]  pose_topic_list.npy
└── [4.0K]  q_images [118 entries exceeds filelimit, not opening dir]
./laurel_caverns
├── [4.0K]  db_images [141 entries exceeds filelimit, not opening dir]
├── [ 20K]  images [744 entries exceeds filelimit, not opening dir]
├── [ 41K]  pose_topic_list.npy
└── [4.0K]  q_images [112 entries exceeds filelimit, not opening dir]
./VPAir
├── [ 677]  camera_calibration.yaml
├── [420K]  distractors [10000 entries exceeds filelimit, not opening dir]
├── [4.0K]  distractors_temp
├── [ 321]  License.txt
├── [177K]  poses.csv
├── [ 72K]  queries [2706 entries exceeds filelimit, not opening dir]
├── [160K]  reference_views [2706 entries exceeds filelimit, not opening dir]
├── [ 96K]  reference_views_npy [2706 entries exceeds filelimit, not opening dir]
└── [ 82K]  vpair_gt.npy
./test_40_midref_rot0/
├── [ 46K]  gt_matches.csv
├── [2.8K]  network_config_dump.yaml
├── [5.3K]  query.csv
├── [4.0K]  query_images [71 entries exceeds filelimit, not opening dir]
├── [2.9K]  reference.csv
└── [4.0K]  reference_images [102 entries exceeds filelimit, not opening dir]
./test_40_midref_rot90/
├── [ 46K]  gt_matches.csv
├── [2.8K]  network_config_dump.yaml
├── [5.3K]  query.csv
├── [4.0K]  query_images [71 entries exceeds filelimit, not opening dir]
├── [2.9K]  reference.csv
└── [4.0K]  reference_images [102 entries exceeds filelimit, not opening dir]
./Oxford_Robotcar
├── [4.0K]  __MACOSX
│   └── [4.0K]  oxDataPart
├── [4.0K]  oxDataPart
│   ├── [4.0K]  1-m [191 entries exceeds filelimit, not opening dir]
│   ├── [ 24K]  1-m.npz
│   ├── [ 13K]  1-m.txt
│   ├── [4.0K]  1-s [191 entries exceeds filelimit, not opening dir]
│   ├── [ 24K]  1-s.npz
│   ├── [4.0K]  1-s-resized [191 entries exceeds filelimit, not opening dir]
│   ├── [ 13K]  1-s.txt
│   ├── [4.0K]  2-s [191 entries exceeds filelimit, not opening dir]
│   ├── [ 24K]  2-s.npz
│   ├── [4.0K]  2-s-resized [191 entries exceeds filelimit, not opening dir]
│   └── [ 13K]  2-s.txt
├── [ 15K]  oxdatapart.mat
└── [ 66M]  oxdatapart_seg.npz
./gardens
├── [4.0K]  day_left [200 entries exceeds filelimit, not opening dir]
├── [4.0K]  day_right [200 entries exceeds filelimit, not opening dir]
├── [3.6K]  gardens_gt.npy
└── [4.0K]  night_right [200 entries exceeds filelimit, not opening dir]
./17places
├── [ 14K]  ground_truth_new.npy
├── [ 13K]  my_ground_truth_new.npy
├── [ 12K]  query [406 entries exceeds filelimit, not opening dir]
├── [ 514]  ReadMe.txt
└── [ 12K]  ref [406 entries exceeds filelimit, not opening dir]
./baidu_datasets
├── [4.0G]  IDL_dataset_cvpr17_3852.zip
├── [387M]  mall.pcd
├── [108K]  query_gt [2292 entries exceeds filelimit, not opening dir]
├── [ 96K]  query_images_undistort [2292 entries exceeds filelimit, not opening dir]
├── [2.7K]  readme.txt
├── [ 44K]  training_gt [689 entries exceeds filelimit, not opening dir]
└── [ 36K]  training_images_undistort [689 entries exceeds filelimit, not opening dir]
./st_lucia
├── [4.0K]  images
│   └── [4.0K]  test
│       ├── [180K]  database [1549 entries exceeds filelimit, not opening dir]
│       └── [184K]  queries [1464 entries exceeds filelimit, not opening dir]
└── [695K]  map_st_lucia.png
./pitts30k
└── [4.0K]  images
    ├── [4.0K]  test
    │   ├── [1.2M]  database [10000 entries exceeds filelimit, not opening dir]
    │   ├── [5.9M]  database.npy
    │   ├── [864K]  queries [6816 entries exceeds filelimit, not opening dir]
    │   └── [4.0M]  queries.npy
    ├── [4.0K]  train
    │   ├── [1.3M]  database [10000 entries exceeds filelimit, not opening dir]
    │   ├── [5.9M]  database.npy
    │   ├── [948K]  queries [7416 entries exceeds filelimit, not opening dir]
    │   └── [4.4M]  queries.npy
    └── [4.0K]  val
        ├── [1.3M]  database [10000 entries exceeds filelimit, not opening dir]
        ├── [5.8M]  database.npy
        ├── [980K]  queries [7608 entries exceeds filelimit, not opening dir]
        └── [4.4M]  queries.npy

These directories are put under ./datasets_vg/datasets folder (can store them in scratch and symlink it there). For example, the 17places dataset can be found under ./datasets_vg/datasets/17places folder.

Original dataset webpages:

Some datasets can be found at other places

References

We thank the authors of the following repositories for their open source code and data:

Cite Our Work

Thanks for using our work. You can cite it as:

@article{keetha2023anyloc,
  title={AnyLoc: Towards Universal Visual Place Recognition}, 
  author={Keetha, Nikhil and Mishra, Avneesh and Karhade, Jay and Jatavallabhula, Krishna Murthy and Scherer, Sebastian and Krishna, Madhava and Garg, Sourav},
  journal={IEEE Robotics and Automation Letters},
  year={2023},
  publisher={IEEE},
  volume={9},
  number={2},
  pages={1286-1293},
  doi={10.1109/LRA.2023.3343602}
}

Developers:

anyloc's People

Contributors

gmberton avatar nik-v9 avatar oravus avatar theprojectsguy 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anyloc's Issues

Question about VP_AIR Dataset and Table 4 results.

Thank you for sharing your great work.
I have a quetion about vpair_gt.npy file and Experiment results(Table4).

< Question 1 >
I want to use the dino_v2_vlad.py code to check the recall results for the VPAir dataset, but VP-Air dataset does not provide the vpair_gt.npy file.
How can I get this file?

./VPAir
├── [ 677] camera_calibration.yaml
├── [420K] distractors [10000 entries exceeds filelimit, not opening dir]
├── [4.0K] distractors_temp
├── [ 321] License.txt
├── [177K] poses.csv
├── [ 72K] queries [2706 entries exceeds filelimit, not opening dir]
├── [160K] reference_views [2706 entries exceeds filelimit, not opening dir] ├── [ 96K] poses.csv
├── [ 96K] reference_views_npy [2706 entries exceeds filelimit, not opening dir] ├── [ 96K] reference_views_npy [2706 entries exceeds filelimit, not opening dir] â
└── [ 82K] vpair_gt.npy

< Question 2 >
In Table 4, the results of calculating the recall using Dinov2 are presented. Since the VLAD layer is not used here, I wonder how the recall result was obtained by processing the features obtained by the Dino feature extractor.

vpr bench error

Hi, thanks for your great work.
I am trying to run dino_v2_global_vpr.py from scripts with my own dataset (database + queries ). but faced error with generate_positives_and_utms function from datasets_ws.py.it asks for ground_truth_new.npy.

join(self.dataset_folder,'ground_truth_new.npy'))

Would u plz, tell me how to get/generate this file from my dataset and what it should contain?

Question about SAM

Amazing job!

I noticed that in addition to dino, you also tried other fundamental models such as sam and clip, and sam's model selection is reflected in the following two lines in the document:

model_types=("vit_b")

out_layer_numbers=(12)

num_clusters=(128)

I'm curious about that what is the consideration behind these choices? Why isn't the cluster center set to 32 like dinov2? And have you considered to use larger sam ​like sam-vit-L?

Looking forward to your reply.

Windows

Pretty amazing work, will windows be supported in the future?

How to achieve demo positioning effect?

Hi I'm a newbie, how can I use anyloc to achieve the positioning effect in the demo demo locally? Specifically, given the left image, locate the position from the image library as below.
image

VLAD Caching for the database and query

Hi,
I am tying to cache my own database and query, but faced this bug:

Unhandled exception
Traceback (most recent call last):
  File "/home/yazan/.local/lib/python3.8/site-packages/torch/serialization.py", line 423, in save
    _save(obj, opened_zipfile, pickle_module, pickle_protocol)
  File "/home/yazan/.local/lib/python3.8/site-packages/torch/serialization.py", line 650, in _save
    zip_file.write_record(name, storage.data_ptr(), num_bytes)
RuntimeError: [enforce fail at inline_container.cc:445] . PytorchStreamWriter failed writing file data/0: file write failed

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "dino_v2_global_vocab_vlad.py", line 737, in <module>
    main(largs)
  File "/home/yazan/.local/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "dino_v2_global_vocab_vlad.py", line 528, in main
    db_vlads, qu_vlads = build_vlads_fm_global(largs, vpr_ds,
  File "/home/yazan/.local/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "dino_v2_global_vocab_vlad.py", line 406, in build_vlads_fm_global
    db_vlads: torch.Tensor = vlad.generate_multi(full_db,
  File "/home/yazan/workspace/AnyLoc/utilities.py", line 1188, in generate_multi
    res = [self.generate(q, c) \
  File "/home/yazan/workspace/AnyLoc/utilities.py", line 1188, in <listcomp>
    res = [self.generate(q, c) \
  File "/home/yazan/workspace/AnyLoc/utilities.py", line 1107, in generate
    residuals = self.generate_res_vec(query_descs, cache_id)
  File "/home/yazan/workspace/AnyLoc/utilities.py", line 1242, in generate_res_vec
    torch.save(residuals,f"{self.cache_dir}/{cache_id}_r.pt")
  File "/home/yazan/.local/lib/python3.8/site-packages/torch/serialization.py", line 424, in save
    return
  File "/home/yazan/.local/lib/python3.8/site-packages/torch/serialization.py", line 290, in __exit__
    self.file_like.write_end_of_file()
RuntimeError: [enforce fail at inline_container.cc:325] . unexpected pos 320 vs 245 

Any ideas how to fix this?

Releasing the model on torch.hub?

Are there any plans to release the trained AnyLoc model on torch.hub? It is quite simple to do and allows people to use your model with two lines of code, allowing more people to use your model and helping to spread your work!
For example I did it for CosPlace, and the trained model can be automatically downloaded from anywhere without cloning the repo just like this

import torch
model = torch.hub.load("gmberton/cosplace", "get_trained_model", backbone="ResNet50", fc_output_dim=2048)

I'd be happy to help if needed :-)

Minor issues for the next release

Listing minor proposed changes/discovered issues for the next release

In README.md

  • HuggingFace Paper badge HF-Paper points to the wrong URL. Use the correct URL.
  • Dataset Setup > ... Download (and unzip) the datasets from here into this folder ...: From where? Add public release link (already there in the badge). Use the modified link.
  • Change the website badge to anyloc.github.io (no left label) from the present badge.
  • Issue tracker shield

Repository

About GT.npy of the datasets in the paper

Hello, @TheProjectsGuy ,thank you very much for your great work!
At present, the GT.npy of the datasets in the repo is not very clear for me to understand.
Can you provide GT.npy for all datasets? They are in the format of the Gardens Point dataset, or can you provide scripts for other datasets that generate GT.npy similar to Gardens Point? (Such GT.npy can reflect the relationship between the query and the ref, that is, one query corresponds to several refs ).

Hope to receive your reply soon :)
Thanks & Best Regards!

demo for image retrieval

HI, thanks for you great work, but would you release the demo for image retrieval, I'm new to this area, and when I read your demos I couldn't imagine how this cluster would be used in image retrieval.

Distance used for query (image retrieval)

Thanks for sharing your work! The paper is very interesting and this repo looks extremely good and detailed.

I have a question that I couldn't find the answer in the paper.

I see there are several option for an image descriptor:

  • DinoV2 CLS token
  • GeM pooling over DINOv2 ViT features
  • VLAD over DINOv2 ViT feature

My question is:
For each one of these descriptors.. what is the distance you used for image retrieval (to fetch the most relevant image in dataset).
Cosine distance? L2 distance?

Some questions that need help

I have been reading this code recently. What I found is that the image input for extract_patch_descriptors is processed one by one. Would it be better to improve efficiency using batch size (if there are more GPUs)?

Another question is, instead of using dinov2 to train the benchmark's training dataset (e.g. Pitts30K/images/train) and then using dinov2 to test the benchmark's test dataset (e.g. Pitts310K/images/test), the AnyLoc project Just loaded the pretrained dinov2_vitg14 model to extract patch descriptors?

I would greatly appreciate it if you could reply

Question about MSLS

Great work!
May I ask why MSLS dataset is not used in your paper? Will you use it in future work?

Recall reproduce

Hi thanks for your amazing work, the performance is absolutely impressive. just one question, I am trying to reproduce the result of Recall rate, but find there is no code for it? any plan to release this part of code? your reply is very appreciate.

Question about the "Anyloc vocabularies"

Thank you for sharing your great work.

I have some questions about how to get "Anyloc vocabularies" which is different from "VLAD vocabularies".
According to the link below, the vocabulary by the Anyloc method is mentioned to be different from the VLAD vocabulary.
(#22)

I would like to reproduce the results of the paper, using the Vocabulary generated by the Anyloc method (I understood this to be the cluster center corresponding to each Domain) and Anyloc-VLAD-dinoV2.

To sum up, my question is as belows.

  1. How can i get vocabularies which is made by "Anyloc method"?
  • I'm wondering if I should download the vocabularies already created(e.g. download from links), or if I should do the PCA projection of descriptors by GeM global pooling as mentioned in the paper and get the vocabularies for each domain by myself.
    If I need to create a vocabulary, can you tell me how to create?
  1. In Table 4 of the paper, the recall values are calculated for each dataset. For Anyloc-VLAD-DINOv2, I am curious to know which Vocabulary was used to obtain each of these results. In particular, I am interested in the results for the dataset in the Aerial domain.
    The reason I am interested in this is that I would like to reproduce the results in the paper.
    Additionally, to get the results of Anyloc-VLAD-DINOv2 after creating a cluster, can I use anyloc_vlad_generate.py?
    image

Thank you.

need help when run run the cmd python dino_v2_vlad.py on terminal

there is an error
I add print(db_vlads) in script->dino_v2_vlad.py row of 368th

whilch show tensor([NAN]) after run the cmd python dino_v2_vlad.py on terminal

when I modify script->dino_v2_vlad.py row of 93th desc_facet: Literal["query", "key", "value", "token"] = "query" or "value"
and modify anyloc (main directory)-> config.py row of 82th vg_dataset_name = "st_lucia"

the dataset download from the onedriver mentioned in the readme.md

tree ./st_lucia is

./st_lucia
|-- [  26]  images
|   `-- [  49]  test
|       |-- [148K]  database [1549 entries exceeds filelimit, not opening dir]
|       `-- [140K]  queries [1464 entries exceeds filelimit, not opening dir]
`-- [695K]  map_st_lucia.png

I would greatly appreciate it if you could reply

NetVLAD Results

Hi,

Thank you so much for releasing your code for this interesting paper and documenting it. Quick question, you include code for MixVPR and CosPlace approaches that you used for comparison in your paper, but I can't find any references to NetVLAD. How did you produce the results for that approach, is there code for that in this repository?

vlad cluster center for custom dataset

Hi @TheProjectsGuy , thank you for such a great project.
I can run the anyloc_vlad_generate.py file. But now I wan to extract the feature with dinov2+vlad on my custom dataset. Iam struggling in creating the cluster center with Vlad. Can you guide me how to create cluster center ?
Tks~

Conda environment installation error

Hi,
I am installing the environment via setup_conda.sh and when I run to the code conda install -y -c pytorch faiss-gpu==1.7.2, the following error is reported:

Collecting package metadata (current_repodata.json): done                       
Solving environment: failed with initial frozen solve. Retrying with flexible solve.                                                                            
Collecting package metadata (repodata.json): done                               
Solving environment: failed with initial frozen solve. Retrying with flexible solve.                                                                            
Solving environment: \                                                          
Found conflicts! Looking for incompatible packages.                             
This can take several minutes.  Press CTRL-C to abort.                          
failed                                                                          
                                                                                
UnsatisfiableError: The following specifications were found                     
to be incompatible with the existing python installation in your environment:   
                                                                                
Specifications:                                                                 
                                                                                
  - faiss-gpu==1.7.2 -> python[version='>=3.6,<3.7.0a0|>=3.8,<3.9.0a0|>=3.7,<3.8.0a0']                                                                          
                      
Your python: python=3.9

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

The following specifications were found to be incompatible with your system:

  - feature:/linux-64::__glibc==2.35=0
  - faiss-gpu==1.7.2 -> libgcc-ng[version='>=9.3.0'] -> __glibc[version='>=2.17']
  - python=3.9 -> libgcc-ng[version='>=11.2.0'] -> __glibc[version='>=2.17']

Your installed version is: 2.35

And when I install via conda install -c conda-forge faiss-gpu=1.7.2, the above error does not occur, but it installs a second cuda in my environment as follows:

The following packages will be downloaded.

    package | build
    ---------------------------|-----------------
    cudatoolkit-11.8.0 | h4ba93d1_12 682.8 MB conda-forge
    faiss-1.7.2 |py39cuda112h460e57a_4_cuda 1.2 MB conda-forge
    faiss-gpu-1.7.2 | h788eb59_4 15 KB conda-forge
    libfaiss-1.7.2 |cuda112hb18a002_4_cuda 51.4 MB conda-forge
    libfaiss-avx2-1.7.2 |cuda112h1234567_4_cuda 51.4 MB conda-forge

Here's part of my conda list:

cuda-cudart               11.7.99                       0    nvidia
cuda-cupti                11.7.101                      0    nvidia
cuda-libraries            11.7.1                        0    nvidia
cuda-nvrtc                11.7.99                       0    nvidia
cuda-nvtx                 11.7.91                       0    nvidia
cuda-runtime              11.7.1                        0    nvidia
cudatoolkit               11.8.0              h4ba93d1_12    conda-forge

How do I install packages so that my environment doesn't conflict?

AttributeError: 'DinoV2ExtractFeatures' object has no attribute 'fh_handle'

custom data, when run : python ./demo/anyloc_vlad_generate.py raise
Exception ignored in: <function DinoV2ExtractFeatures.del at 0x7f8ce6d56b80>
Traceback (most recent call last):
File "./AnyLoc/demo/utilities.py", line 101, in del
self.fh_handle.remove()
AttributeError: 'DinoV2ExtractFeatures' object has no attribute 'fh_handle'

Question about Nardo-Air datasets

Thanks for sharing your great work. This isn't a question about AnyLoc, but I'd like to know how you were able to access the Nardo-Air dataset you used for testing.
I couldn't find an access link when I googled it, is there any chance you could shed some light on that?

Thanks in advance.

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.