D2-VPR: A Parameter-efficient Visual-foundation-model-based Visual Place Recognition Method via Knowledge Distillation and Deformable Aggregation
Official repository for the paper "D2-VPR: A Parameter-efficient Visual-foundation-model-based Visual Place Recognition Method via Knowledge Distillation and Deformable Aggregation"
Visual Place Recognition (VPR) aims to determine the geographic location of a query image by retrieving its most visually similar counterpart from a geo-tagged reference database. Recently, the emergence of the powerful visual foundation model, DINOv2, trained in a self-supervised manner on massive datasets, has significantly improved VPR performance. This improvement stems from DINOv2’s exceptional feature generalization capabilities but is often accompanied by increased model complexity and computational overhead that impede deployment on resource-constrained devices. To address this challenge, we propose D2-VPR, a Distillation- and Deformable-based framework that retains the strong feature extraction capabilities of visual foundation models while significantly reducing model parameters and achieving a more favorable performance-efficiency trade-off. Specifically, first, we employ a two-stage training strategy that integrates knowledge distillation and fine-tuning. Additionally, we introduce a Distillation Recovery Module (DRM) to better align the feature spaces between the teacher and student models, thereby minimizing knowledge transfer losses to the greatest extent possible. Second, we design a Top-Down-attention-based Deformable Aggregator (TDDA) that leverages global semantic features to dynamically and adaptively adjust the Regions of Interest (ROI) used for aggregation, thereby improving adaptability to irregular structures. Extensive experiments demonstrate that our method achieves competitive performance compared to state-of-the-art approaches. Meanwhile, it reduces the parameter count by approximately 64.2% and FLOPs by about 62.6% (compared to CricaVPR).
Main Paper: link
This repo follows the framework of CricaVPR and BoQ.
We use GSV-Cities for training, and the Visual Geo-localization Benchmark for evaluation. You can download the GSV-Cities datasets HERE, and refer to VPR-datasets-downloader to prepare test datasets.
The test dataset should be organized in a directory tree as such:
├── datasets_vg
└── datasets
└── pitts30k
└── images
├── train
│ ├── database
│ └── queries
├── val
│ ├── database
│ └── queries
└── test
├── database
└── queriesBefore we begin, please download the CricaVPR weights LINK and Dinov2-small weights LINK.
Please use the following code for distillation:
python distillation.pyBefore starting fine-tuning, please download the msls-val and pitts30k-val validation datasets for testing and update the dataset paths in the finetune.py accordingly. Then select the best distillation weights, change the corresponding path in finetune_script.py and use the following code for finetune:
python finetune.pyThe model (no cross-image encoder).
| DOWNLOAD |
Pitts30k | MSLS-val | SPED | Pitts250k | AmsterTime | Nordland | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | |
| LINK | 91.7 | 95.8 | 96.8 | 90.7 | 95.4 | 96.4 | 86.0 | 92.9 | 94.1 | 94.4 | 98.3 | 98.9 | 49.1 | 70.7 | 76.1 | 77.1 | 88.6 | 91.9 |
The distillation model (cross-image encoder).
| DOWNLOAD |
Pitts30k | SPED | AmsterTime | Pitts250k | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | |
| LINK | 94.9 | 97.3 | 98.0 | 90.9 | 96.0 | 97.2 | 62.9 | 80.8 | 85.3 | 97.8 | 99.4 | 99.7 |
The fine-tuned model (cross-image encoder).
| DOWNLOAD |
MSLS-val | Nordland | ||||
|---|---|---|---|---|---|---|
| R@1 | R@5 | R@10 | R@1 | R@5 | R@10 | |
| LINK | 91.6 | 96.1 | 97.2 | 86.6 | 94.1 | 96.0 |
Pleas download the model weights (no cross-image encoder) into the directory, and use the following code for evaluation:
python eval_no_encoder.pyPleas download the distillation and finetune weights (cross-image encoder) into the directory, and use the following code for evaluation:
python eval_encoder.pyThe framework of the code are based on the excellent work of CricaVPR and BoQ. The experiments are built upon the excellent work of CricaVPR, CosPlace, EigenPlaces, MixVPR, BoQ, SALAD, SuperVLAD, SelaVPR, FoL and EDTformer. The dataset is composed based on the excellent work of gsv-cities, deep-visual-geo-localization-benchmark and VPR-datasets-downloader . We would like to express our gratitude for their open-source efforts.
If you find this repo useful for your research, please cite the paper
@article{zhang2025d,
title={D\textsuperscript{2}-VPR: A Parameter-efficient Visual-foundation-model-based Visual Place Recognition Method via Knowledge Distillation and Deformable Aggregation},
author={Zhang, Zheyuan and Zhang, Jiwei and Zhou, Boyu and Duan, Linzhimeng and Chen, Hong},
journal={arXiv preprint arXiv:2511.12528},
year={2025}
}