Granularity-aware Adaptation for Image Retrieval over Multiple Tasks

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

Introduction

In the field of image retrieval, practitioners often face a dichotomy between general-purpose foundation models and specialized, task-specific extractors. Large-scale pretrained models, such as DINO, offer robust zero-shot performance across a wide variety of domains but frequently lack the precision required for fine-grained tasks like identifying specific bird species or aircraft models. Conversely, fine-tuning a model for a specific domain often results in "tunnel vision," where the model loses its ability to generalize to other tasks.

This paper introduces Grappa (Granularity-aware Adaptors by Attention Propagation), an unsupervised framework designed to adapt a single pretrained Vision Transformer (ViT) to multiple diverse retrieval tasks simultaneously. By leveraging unlabeled data and a novel attention-based fusion mechanism, Grappa bridges the gap between generalist and specialist models without requiring human-annotated labels.

The Grappa Framework

Grappa addresses the multi-task, zero-shot challenge through a three-stage unsupervised pipeline that preserves the core knowledge of a foundation model while specializing its feature space for specific downstream domains.

1. Multi-Granularity Pseudo-labeling

Because the target tasks are unlabeled, Grappa generates supervision signals by performing k-means clustering on the training data at multiple scales. By varying the number of clusters ($k$), the system captures data relationships at different levels of granularity—ranging from broad categories to fine-grained sub-types. This hierarchical approach ensures the model can recognize features relevant to both coarse and fine retrieval tasks.

2. Independent Adaptor Training

To avoid the computational cost and potential catastrophic forgetting associated with full-model fine-tuning, Grappa utilizes small bottleneck layers known as adaptors. These adaptors are inserted into a frozen ViT backbone. For each level of granularity identified in the previous step, a specific set of adaptors is trained. Because the massive backbone remains untouched, the model retains its original general knowledge while the adaptors "nudge" the features to be more discriminative for specific domains.

3. Attention-based Fusion and Propagation

The final challenge is determining which adaptors to use for a given query image. Grappa introduces a fusion layer that learns to assign attention weights to different adaptors. To train this without labels, the authors propose an Attention Propagation Loss. This mechanism operates on the principle that images residing in the same neighborhood of the feature space likely belong to the same task or granularity level. Using a Barlow Twins-style loss, Grappa enforces consistency in adaptor selection across neighboring images, allowing the model to learn task identity implicitly from the local structure of the data.

Experimental Setup: The MRT Benchmark

To evaluate the effectiveness of Grappa, the authors introduced the Multiple Retrieval Tasks (MRT) benchmark. This suite unifies six distinct fine-grained datasets into a single evaluation framework:

  • Aircraft & Cars: Identification of specific models and makes.
  • CUB: North American bird species classification.
  • Flowers: Diverse botanical identification.
  • Food-101: Categorization of various dish types.
  • Stanford Online Products (SOP): Large-scale commercial item retrieval.

Performance and Key Insights

Grappa demonstrates consistent performance improvements over the standard DINO baseline across all six tasks in the MRT benchmark. Notable results include:

  • Significant Precision Gains: On the "Flowers" dataset, Grappa achieved a +4.7 point gain in R-Precision over the DINO baseline. Similarly, it saw a +3.5 point gain on "Food-101."
  • Surpassing the Oracle: One of the most striking findings was that Grappa often outperformed a "granularity oracle"—a theoretical model that manually selects the single best granularity for a specific task. This suggests that the fusion of multiple granularities provides a richer, more flexible feature representation than any single scale can offer.
  • Robustness through Neighbors: The success of the Attention Propagation Loss confirms that the local topology of unlabeled data is a powerful proxy for task identity, enabling effective adaptation in zero-shot environments.

Limitations and Future Directions

While Grappa excels in natural image domains, it faces challenges with datasets like Stanford Online Products, where the unique topology of commercial imagery differs significantly from natural categories like birds or flowers. Additionally, the method's performance is sensitive to the range of $k$ used in clustering and the number of neighbors selected for propagation.

Future work aims to explore dynamic adaptation, where models can integrate new, unseen tasks on the fly as unlabeled data streams become available, further pushing the boundaries of unified visual search systems.

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