Boosting vision transformers for image retrieval

Chull Hwan Song, Jooyoung Yoon, Shunghyun Choi, Yannis Avrithis

Abstract

While Vision Transformers (ViTs) have achieved dominance in classification and detection, they have historically lagged behind Convolutional Neural Networks (CNNs) in instance-level image retrieval. This paper introduces Deep Token Pooling (DToP), a suite of architectural improvements designed to overcome the limitations of "plain" transformers. By integrating a hybrid CNN-ViT backbone, dynamic position embeddings, and multi-layer feature aggregation, DToP establishes a new state-of-the-art in image retrieval benchmarks, significantly outperforming previous CNN and transformer-based models.

Introduction

Instance-level image retrieval requires identifying the exact same object across different images, a task that demands high sensitivity to local spatial patterns. CNNs naturally possess an "inductive bias" well-suited for this. In contrast, standard ViTs focus on global context via the [CLS] token, often discarding the fine-grained spatial nuances necessary for distinguishing similar landmarks. Furthermore, the fixed-size input requirement of standard ViTs hinders performance on retrieval tasks where varying aspect ratios are common. DToP addresses these challenges by re-introducing locality and flexibility into the transformer architecture without significantly increasing model complexity.

Methodology: Deep Token Pooling (DToP)

The DToP framework consists of four primary innovations designed to enhance the spatial awareness and flexibility of ViTs:

  1. Hybrid CNN-ViT Backbone: Instead of processing raw image patches, DToP employs a CNN stem (ResNet50) to extract initial features. This hybrid approach injects essential local inductive bias into the early stages of the network.
  2. Dynamic Position Embedding (DPE): To accommodate images of varying sizes and aspect ratios, DToP uses a learnable position embedding that is dynamically resampled to match the input resolution during inference.
  3. Dual-Branch Feature Aggregation: The model extracts features from the final $k$ layers of the transformer. A Global Branch aggregates [CLS] tokens to capture high-level context, while a Local Branch processes patch tokens to preserve spatial detail.
  4. Enhanced Locality Module (ELM): To counteract the loss of spatial focus in deep ViT layers, the local branch utilizes an ELM. This module incorporates Inverted Residual Blocks and Atrous Spatial Pyramid Pooling (ASPP) to restore spatial awareness and multi-scale context before final descriptor generation.
The DToP architecture featuring the hybrid CNN stem, global/local branches, and the Enhanced Locality Module.

Experimental Results

The authors evaluated DToP on several industry-standard datasets, including ROxford and RParis, with and without the 1M distractor (R1M) challenge. DToP achieves state-of-the-art (SOTA) performance across all major benchmarks.

Performance comparison of DToP against state-of-the-art local and global descriptors across multiple benchmarks.

Key performance highlights include:

  • Superiority over CNNs: On the GLDv2-clean dataset, DToP outperformed the previous SOTA (DOLG) by 7.6% on ROxford Hard and 7.8% on RParis Hard.
  • Transformer Advancements: Compared to previous transformer-based retrieval models like IRT, DToP showed a significant improvement of 10-20% mAP.
  • Efficiency: The DToP components are lightweight, adding only 0.3M parameters to the base ViT model, making it a highly efficient upgrade for existing transformer architectures.

Discussion and Key Insights

The success of DToP highlights several critical factors for transformer-based retrieval:

  • The Hybrid Advantage: The CNN stem is the most significant contributor to performance, proving that convolutional "sliding windows" remain superior for capturing low-level textures essential for retrieval.
  • Multi-Layer Hierarchy: Aggregating features from multiple deep layers provides a richer representation than relying solely on the final layer, which can sometimes become uncorrelated with earlier spatial information.
  • Restoring Locality: Explicitly re-introducing local spatial relationships via the ELM is crucial, as deep ViT layers tend to over-globalize features at the expense of retrieval precision.

Conclusion

DToP demonstrates that with the right architectural modifications, Vision Transformers can surpass CNNs in the domain of image retrieval. While the reliance on a CNN stem remains, the framework provides a highly efficient and effective path forward. Future work may explore pure transformer architectures or self-supervised pre-training to further enhance feature robustness without the need for large-scale labeled datasets.

Summary updated

BibTeX
@inproceedings{song2023boosting,
  author = {Chull Hwan Song and Jooyoung Yoon and Shunghyun Choi and Yannis Avrithis},
  title = {{Boosting vision transformers for image retrieval}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2023},
  doi = {10.1109/wacv56688.2023.00019},
}
Figure