Evaluating Contrastive Models for Instance-based Image Retrieval

Tarun Krishna, Kevin McGuinness, Noel O'ConnorarXiv 2021 · DOI

TL;DR

Self-supervised contrastive learning models (like SimCLR and MoCo) make excellent, off-the-shelf feature extractors for instance-based image retrieval. Without using a single human label during training, these models match or outperform traditional ImageNet-supervised baselines across multiple standard benchmarks.

What Problem Does This Paper Address?

When you search for an image online, you are often looking for a specific object or scene—a task known as instance-based image retrieval. Historically, engineers have used deep convolutional networks (ConvNets) pre-trained on ImageNet to extract image features for this task.

However, there is a fundamental mismatch here. ImageNet models are trained via supervised learning to minimize inter-class variance—meaning they try to make all dogs look similar and all buildings look similar. But for instance retrieval, you don't want to find just any building; you want to find the exact building from your query. This requires capturing fine-grained, instance-level details. While fine-tuning models on specific landmark datasets can fix this, it requires tedious data cleaning and expensive post-processing. This paper investigates whether unsupervised contrastive learning models, which are inherently trained to discriminate between individual image instances, can serve as superior, off-the-shelf feature extractors without any fine-tuning.

Methods

The authors evaluate several prominent self-supervised contrastive architectures—AMDIM, MoCo (v1 and v2), and SimCLR ($1\times, 2\times, 4\times$)—using a ResNet-50 backbone. Crucially, they treat these models as fixed feature extractors, meaning no weights are altered for the retrieval task.

The evaluation pipeline follows a standard image retrieval workflow:

  1. Extract feature maps from the network's final convolutional layer.
  2. Aggregate spatial features into a compact vector using Regional Maximum Activation of Convolutions (R-MAC) pooling.
  3. Post-process the vectors using $L_2$ normalization, Principal Component Analysis (PCA-whitening), and a final $L_2$ normalization.

To push performance further, they also experiment with advanced ranking techniques like Average Query Expansion (AQE), Database Augmentation (DBA), and Diffusion (DFS), alongside model ensembling (concatenating features from different models).

Datasets

The models are benchmarked across three widely accepted image retrieval datasets:

  • Oxford 5k: Images of Oxford landmarks.
  • Paris 6k: Images of Paris landmarks.
  • INSTRE: A dataset containing various everyday objects under challenging conditions (clutter, changes in scale).

They also evaluate on the updated, more rigorous rOxford 5k and rParis 6k benchmarks, which introduce distinct "Easy", "Medium", and "Hard" evaluation protocols to better test model robustness.

Key Insights and Ideas

  • Instance Discrimination Aligns Naturally with Retrieval: Because contrastive learning forces a network to treat every single image as its own distinct class, the model naturally learns to retain the unique, fine-grained structural details necessary for instance retrieval.
  • Complementary Feature Spaces: Ensembling different contrastive models (e.g., combining SimCLR and MoCo features) yields a noticeable performance boost. This indicates that different self-supervised objectives cause networks to look at images through unique, complementary lenses.
  • The Danger of "True" Dimensions: Counterintuitively, using the full, unreduced feature vector from the network often hurts retrieval performance. Applying PCA-whitening filters out noisy, low-variance principal components, significantly boosting mean Average Precision (mAP).

Key Results

  • Outperforming the Supervised Baseline: In a basic global search on the Oxford 5k dataset, SimCLR $4\times$ achieved an mAP of 59.40%, comfortably beating the ImageNet-supervised baseline of 55.12%.
  • Ensemble Power: Combining SimCLR $2\times$ and SimCLR $4\times$ pushed the Oxford 5k global search score to 61.89%, and reached a massive 86.02% when combined with query expansion and diffusion techniques, as shown in Table 1.
Table 1: Comparing mAP (%) score across different models. Bold (red) best performing ensemble if it exists.
  • Robustness on Harder Benchmarks: On the revised rOxford 5k dataset under the "Easy" split, SimCLR $2\times$ scored 54.95% mAP compared to the baseline's 45.65%, proving its superior capability in cleaner instance matching (see Table 2).
Table 2: Comparison on global ranking across different model. Bold (red) best performing ensemble if it exists.
  • Dimensionality Impact: As detailed in Table 3, reducing the feature dimensions via PCA-whitening consistently outperformed using the unreduced "True dim." vector for almost all contrastive models.
Table 3: Comparison of mAP (%) across different PCA dimen- sion and the true dimension.

Limitations and Future Work

While most contrastive models excelled, AMDIM performed poorly across the board. The authors attribute this to the spatial resolution downsampling required to keep the evaluation uniform, which heavily penalized AMDIM's multi-scale feature maps.

Additionally, this study focuses entirely on using these models as fixed feature extractors. The authors suggest that explicitly fine-tuning these already-robust contrastive representations for retrieval tasks represents a highly promising direction for future research.

Summary updated

BibTeX
@misc{krishna2021evaluating,
  author = {Tarun Krishna and Kevin McGuinness and Noel O'Connor},
  title = {{Evaluating Contrastive Models for Instance-based Image Retrieval}},
  year = {2021},
  eprint = {2104.14939},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.14939},
}
Figure