Source-linked AI summary

$R^{2}$Former: Unified $R$etrieval and $R$eranking Transformer for Place Recognition

Sijie Zhu, Linjie Yang, Chen Chen, Mubarak Shah, Xiaohui Shen, Heng Wang

arXiv:2304.03410v1cs.CV

TL;DR

VPR reranking commonly relies on RANSAC geometry, leaving other potentially useful information unused. R^2Former unifies retrieval and reranking in a transformer framework that also uses local-feature correlations, attention, and token coordinates. Across VPR datasets, it outperforms retrieval-only and retrieval-plus-reranking state-of-the-art methods, with >4.7× QPS and <22% memory consumption versus previous methods [26] [53].

  • Problem

    Existing VPR reranking commonly uses RANSAC geometric verification, while other potentially useful task-relevant information remains unused.

    Source: §1 · p. 1
  • Method

    R^2Former unifies transformer-based global retrieval and learned reranking, using local-token correlations, attention, and xy coordinates to score whether image pairs depict the same place.

    Source: §1 · p. 2
  • Results

    >4.7× QPS and <22% memory consumption versus previous methods [26] [53], while outperforming retrieval-only and retrieval-plus-reranking state-of-the-art methods across a wide range of VPR datasets.

    Source: §1 · p. 2
  • Takeaways & Limitations

    Vision-transformer tokens are comparable to or sometimes better than CNN local features for reranking, and the reranking module can be used with either CNN or transformer backbones.

    Source: §5 · p. 8, §4.4 · p. 8

Abstract

from arXiv · show

Visual Place Recognition (VPR) estimates the location of query images by matching them with images in a reference database. Conventional methods generally adopt aggregated CNN features for global retrieval and RANSAC-based geometric verification for reranking. However, RANSAC only employs geometric information but ignores other possible information that could be useful for reranking, e.g. local feature correlations, and attention values. In this paper, we propose a unified place recognition framework that handles both retrieval and reranking with a novel transformer model, named $R^{2}$Former. The proposed reranking module takes feature correlation, attention value, and xy coordinates into account, and learns to determine whether the image pair is from the same location. The whole pipeline is end-to-end trainable and the reranking module alone can also be adopted on other CNN or transformer backbones as a generic component. Remarkably, $R^{2}$Former significantly outperforms state-of-the-art methods on major VPR datasets with much less inference time and memory consumption. It also achieves the state-of-the-art on the hold-out MSLS challenge set and could serve as a simple yet strong solution for real-world large-scale applications. Experiments also show vision transformer tokens are comparable and sometimes better than CNN local features on local matching. The code is released at https://github.com/Jeff-Zilence/R2Former.

1. Introduction

R2Former unifies global retrieval and reranking with transformers, using local-token correlations, coordinates, and attention to learn matches. The paper reports state-of-the-art VPR results with substantially lower latency and memory use than prior reranking methods.

  • Conventional VPR retrieves candidates with aggregated CNN features and often reranks top-k matches using RANSAC, but this geometric-only process is costly and may not scale to large databases or high QPS.The passage reports typical RANSAC reranking costs of over 1 second and 1 MB per image, with scalability concerns for databases exceeding 1 million images.Source: §1 · p. 1
  • R2Former uses the class token for global retrieval and other image tokens as local features, reranking pairs from token correlations, xy coordinates, and attention information.Its retrieval and reranking modules can be trained end-to-end or tuned alternately, and the reranker can also be used with CNN or transformer backbones.Source: §1 · p. 2
  • The paper reports that vision-transformer tokens are comparable to CNN local features for reranking and can sometimes perform better in local matching.This addresses uncertainty about whether transformer tokens retain useful local information despite global token correlations.Source: §1 · p. 2
  • R2Former achieves state-of-the-art VPR performance with less than 22% of previous methods’ inference latency and memory consumption, over 4.7× QPS, and over 20× multi-GPU reranking speedup.The speed and memory comparisons are against previous methods [26] [53].Source: §1 · p. 2

2. Related Work

Related work describes VPR as global image retrieval, commonly followed by geometric reranking, and identifies a gap in unified transformer-based retrieval and reranking. It also motivates investigating vision-transformer tokens for local matching in VPR.

Visual Place Recognition

  • Predominant VPR methods use CNN feature extractors with trainable aggregation or pooling, while CosPlace formulates the task as classification using orientation information [3] [4] [5] [6] [26] [53] [24].Earlier approaches used nearest-neighbor search on aggregated hand-crafted features; later work further improved global representations following NetVLAD [3].Source: §2 · p. 2
  • Leading VPR methods pair global retrieval with RANSAC reranking, while related-task learned matchers either generalize poorly to VPR or use a different problem setting [26] [53] [31] [48] [29].R²Former integrates retrieval and reranking in a unified VPR framework using pure transformers.Source: §2 · p. 2

Vision Transformer

  • Vision transformers treat image patches as tokens; prior VPR work used vanilla ViT for global retrieval or transformers atop CNN backbones, leaving transformer tokens’ local-matching performance unexplored.The passage notes vanilla ViT may need large-scale training data for CNN-comparable results, while DeiT’s data-efficient strategy outperforms CNN on ImageNet-1k [17] [27] [51].Source: §2 · pp. 2–3

3. R2Former

R2Former combines global image retrieval with learned reranking, using shared-transformer features and a reranker that considers local-feature similarity, attention, and position.

3.1. Problem Formulation and Training Objective

  • Global retrieval learns embeddings with margin triplet loss from positives within 10 meters and negatives beyond 25 meters; reranking uses binary cross-entropy.Training first freezes retrieval while reranking learns from randomly selected negatives among the database’s top-k hardest candidates, then finetunes both modules together with partial negative mining.Source: §3.1 · p. 3

3.2. Global Retrieval Module

  • A shared ViT encoder produces global features from its class token and local features from penultimate-layer patch tokens, without separate aggregation or keypoint modules.Linear heads reduce the global and local features to 256 and 128 dimensions, respectively, and positional embeddings are interpolated to support arbitrary input resolutions.Source: §3.2 · p. 4

3.3. Reranking Transformer Module

  • The reranker selects the 500 patches with highest class-token attention and stores each local feature with its attention value and x,y coordinates.This attention-based selection reduces the number of local features saved for large-scale use; each stored feature has 131 dimensions.Source: §3.3 · p. 4
  • Reranking encodes every selected feature pair’s coordinates, attention values, and cosine similarity, then uses two transformer blocks to classify image pairs as matches or non-matches.The pairwise correlation matrix has shape 500 × 500 × 7; the model retains each token’s five nearest neighbors to reduce computation before aggregation.Source: §3.3 · p. 5

4. Experiment

R²Former improves R@1 on MSLS, achieves state-of-the-art results on Pitts30k and Tokyo24/7, and outperforms VG benchmark models at comparable computational cost. Its reranking is faster and more memory-efficient than prior reranking methods, while ablations examine reranking choices, training, backbones, and model components.

4.1. Datasets and Evaluation Metrics

  • Experiments train on MSLS, finetune on Pitts30k for urban datasets, evaluate recall@k at a 25-meter threshold, and rerank top-100 ViT-S candidates.Evaluation includes MSLS Val and the hold-out MSLS Challenge set, Pitts30k, Tokyo 24/7, R-SF, and St Lucia; the default ViT-S backbone has 12 layers and 384 dimensions.Source: §4.1 · p. 5, §4.2 · p. 5

4.3. Comparison with State-of-the-art

  • R@1 improves by 2.9% on MSLS Val and 9.1% on MSLS Challenge; the model also reaches state of the art on Pitts30k and Tokyo24/7 and beats VG’s best models at comparable cost.The model is trained on MSLS and finetuned on Pitts30k for the urban datasets.Source: §4.3 · p. 6, Table 1 · p. 6, Table 2 · p. 6
  • 47.17 ms/query on 4 GPUs gives a 20.2× speedup; MSLS Val storage is 4.79 GB, 189× below Patch-NetVLAD-p’s 908.3 GB.For the R-SF dataset with over 1M reference images, memory is 244.01 GB, or 122 GB with float16 and no observed performance drop; other reranking methods typically need over 4× more memory.Source: §4.3 · pp. 6–7, Table 3 · p. 6

4.4. Ablation Study

  • R²Former reranking outperforms RANSAC using less than 22% of its inference time and also surpasses two recent landmark-retrieval reranking methods.The comparison uses the same global and local features from the default backbone; RRT is trained on that backbone, while CVNet uses its pretrained Google Landmark model.Source: §4.4 · p. 7, Table 4 · p. 7
  • Separate training with global hard-negative mining achieves the best performance; end-to-end training offers a simpler trade-off, and all reranking strategies outperform prior state-of-the-art methods on R@5.The authors attribute the benefit to global hard-negative mining for reranker training.Source: §4.4 · p. 7, Table 5 · p. 7
  • ViT-Small tokens are a good alternative to CNN local features, while ViT-Base improves global retrieval and RANSAC reranking but adds little overall improvement beyond R@10.ResNet50+GeM also achieves competitive retrieval and reranking results and significantly outperforms prior works, supporting the reranking module’s use with CNN and transformer backbones.Source: §4.4 · pp. 7–8, Table 6 · p. 7
  • Transformer Block-2 and Correlation Value matter most; random feature selection moderately hurts performance, while removing other listed components causes slight drops.Removing positional embeddings or replacing top-5 pair selection with top-1 has negligible effect; the authors say the top-1 pair contains most reranking-relevant information.Source: Table 7 · p. 7, §4.4 · p. 8

4.5. Visualization

  • In a case where global retrieval fails on the top three results, R²Former finds more correct references in the top three after reranking.Its highly attended patch pairs are mostly correct matches, though they may lack RANSAC’s tight geometric consistency and provide task-relevant reranking information.Source: §4.5 · p. 8, Figure 4 · p. 8

5. Conclusion

The paper presents an all-transformer framework for place-recognition retrieval and reranking, reporting better performance on major datasets with lower inference time and memory use. It also finds vision-transformer tokens comparable to or better than CNN local features for reranking.

  • The framework significantly outperforms previous methods on major datasets while using much less inference time and memory.Source: §5 · p. 8
  • The proposed framework unifies place-recognition retrieval and reranking using only transformers.Source: §5 · p. 8
  • Vision-transformer tokens are comparable to or better than CNN local features for reranking.Source: §5 · p. 8
  • The generic reranking module can be adopted on CNN or transformer backbones.Source: §5 · p. 8
  • The method can provide possible matched local pairs like RANSAC, and future work could improve it with geometric modeling.Source: §5 · p. 8
Loading 2304.03410v1…