Granularity-Aware Adaptation for Image Retrieval Over Multiple Tasks

Jon Almazán, ByungSoo Ko, Geonmo Gu, Diane Larlus, Yannis Kalantidis

Abstract

Strong image search models can be learned for a specific domain, i.e. set of labels, provided that some labeled images of that domain are available. A practical visual search model, however, should be versatile enough to solve multiple retrieval tasks simultaneously, even if those cover very different specialized domains. Additionally, it should be able to benefit from even unlabeled images from these various retrieval tasks. This is the more practical scenario that we consider in this paper. We address it with the proposed Grappa, an approach that starts from a strong pretrained model, and adapts it to tackle multiple retrieval tasks concurrently, using only unlabeled images from the different task domains. We extend the pretrained model with multiple independently trained sets of adaptors that use pseudo-label sets of different sizes, effectively mimicking different pseudo-granularities. We reconcile all adaptor sets into a single unified model suited for all retrieval tasks by learning fusion layers that we guide by propagating pseudo-granularity attentions across neighbors in the feature space. Results on a benchmark composed of six heterogeneous retrieval tasks show that the unsupervised model improves the zero-shot performance of a state-of-the-art self-supervised learning model, and in some places reaches or improves over a task label-aware oracle that selects the most fitting pseudo-granularity per task.

The Challenge of Generalist Image Retrieval

In modern image retrieval, most state-of-the-art models are specialists. A model optimized to distinguish between specific bird species often fails when applied to consumer products or aircraft. Developing a "generalist" model—a single system capable of handling multiple specialized domains simultaneously—presents three significant hurdles:

  1. Label Scarcity: High-quality annotations for specialized domains are expensive and difficult to acquire.
  2. Granularity Mismatch: Different tasks require varying levels of detail. Identifying a specific dog breed requires fine-grained features, whereas identifying a general flower type might only require coarse features.
  3. Task Interference: Fine-tuning a model on a new task often leads to "catastrophic forgetting" of previously learned domains.

The Grappa Framework

To address these challenges, the authors introduce Grappa (Granularity-aware Adaptation by Attention Propagation). This framework adapts a frozen Vision Transformer (ViT) backbone, such as one pretrained with DINO, using a three-step unsupervised process:

  1. Learning Pseudo-labels: Unlabeled training data is clustered at $N$ different scales using k-means. Each scale represents a "pseudo-granularity," ranging from coarse to fine.
  2. Training Independent Adaptors: Small, trainable "bottleneck adaptors" are inserted into the ViT blocks for each granularity. These adaptors are trained to solve classification tasks based on the pseudo-labels while the main backbone remains frozen, preserving general knowledge.
  3. Neighborhood-aware Fusion: The $N$ adaptors are unified via a fusion layer. Using a technique called Attention Propagation, the model determines the optimal combination of adaptors by looking at an image's neighbors in the feature space. A loss function based on Barlow Twins ensures that visually similar images utilize consistent adaptor combinations.
The Grappa framework consists of three steps: (a) generating pseudo-labels via multi-scale clustering, and (b) training independent adaptors followed by a neighborhood-aware fusion mechanism.

The MRT Benchmark and Evaluation

To evaluate multi-task performance, the authors introduced the Multiple Retrieval Tasks (MRT) Benchmark. This benchmark aggregates six diverse datasets: Aircraft, Cars, CUB (birds), Flowers, Food-101, and Stanford Online Products. During training, all datasets are merged and class labels are discarded to simulate a purely unsupervised scenario.

Key Results

Grappa demonstrates significant improvements over the state-of-the-art DINO baseline across all tasks. Notable gains in R-Precision (RP) include +4.7 points on Flowers and +3.5 points on Food-101.

Comparison of R-Precision (RP) gains for Grappa relative to the DINO baseline across the six tasks in the MRT benchmark.

Key insights from the experiments include:

  • Granularity is Context-Dependent: The optimal granularity for a query depends heavily on the search gallery. Grappa's ability to fuse different granularities provides a more robust representation than selecting a single level of detail.
  • Zero-Shot Excellence: Despite the lack of task-specific labels during training, Grappa often reaches or exceeds the performance of specialized "Oracle" models that are manually tuned for specific tasks.
  • Efficiency: By training only the small adaptor layers, Grappa remains highly parameter-efficient compared to full model fine-tuning.

Limitations and Future Outlook

While Grappa shows strong performance, the authors noted some sensitivity to hyperparameters, particularly on the "Products" dataset, where the data topology differs significantly from other benchmarks. Future research may explore dynamic adaptation, where the model adjusts its granularity preferences in real-time based on the specific gallery being searched.

Summary updated

BibTeX
@inproceedings{almazan2022granularity,
  author = {Jon Almazán and ByungSoo Ko and Geonmo Gu and Diane Larlus and Yannis Kalantidis},
  title = {{Granularity-Aware Adaptation for Image Retrieval Over Multiple Tasks}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  url = {https://openreview.net/forum?id=oJmsWYJe_UW},
}
Figure