Introduction
Vision-Language Models (VLMs) like CLIP have revolutionized image retrieval by learning joint representations of visual and textual data. However, real-world applications often encounter scenarios where the model must retrieve images belonging to categories it has never seen (category shift) or presented in artistic styles it wasn't trained on (domain shift). This paper introduces UCDR-Adapter, a framework designed for Universal Cross-Domain Retrieval (UCDR), which addresses these challenges simultaneously through a novel two-phase adaptation strategy.
The UCDR Challenge
In traditional retrieval tasks, models typically operate within a closed set of classes and a consistent domain. UCDR breaks these boundaries by introducing three distinct scenarios:
- Unseen classes + Seen domain ($U^cCDR$): Retrieving new objects (e.g., a cookie) in a known style (e.g., painting).
- Seen classes + Unseen domain ($U^dCDR$): Retrieving known objects (e.g., a lion) in a new style (e.g., a sketch).
- Unseen classes + Unseen domain (UCDR): The most difficult task, requiring the model to generalize across both category and style shifts simultaneously.
Existing methods often rely on static prompts—fixed text descriptions like "a photo of a [class]." These prompts lack the flexibility to adapt when the data distribution shifts significantly during deployment, leading to performance degradation in cross-domain environments.
Proposed Method: UCDR-Adapter
To overcome the limitations of static prompts, the authors propose a two-phase training strategy that enhances pre-trained VLMs with learnable adapters and dynamic prompt generation.
Phase 1: Source Adapter Learning
In the first phase, the model learns to associate specific class semantics with domain-specific visual traits using a Learnable Textual Semantic Template. Instead of a fixed string, the model uses a template: "A photo of [class] from the [domain] domain," where the domain component is represented by a learnable vector.
To ensure robust feature learning, the framework employs a Momentum Encoder and a feature queue, inspired by MoCo. This setup maintains a diverse set of features, preventing the model from forgetting established patterns while learning new ones. The training is guided by a dual loss function: Triplet Loss, which clusters similar features while pushing dissimilar ones apart, and Image-Text Contrastive (ITC) Loss, which aligns visual features with the semantic template.
Phase 2: Target Prompt Generation
The second phase is the "secret sauce" for generalization. The model trains a Target Prompt Generation (TPG) module to handle unseen data. During this phase, the model simulates being in an unknown environment by masking out the known source prompts learned in Phase 1. The TPG module learns to analyze an image and generate a dynamic prompt by attending to the masked knowledge. This process forces the model to learn how to interpolate and predict features for unknown data, effectively "practicing" for unseen domains and categories.
Inference Efficiency: A key advantage of UCDR-Adapter is its efficiency. At test time, the model does not require text input. It uses only the image branch and the TPG module to generate prompts on the fly, making the retrieval process fast and lightweight for real-world deployment.
Experimental Results
The researchers evaluated UCDR-Adapter on three major benchmarks: DomainNet (345 classes across 6 domains), Sketchy, and TU-Berlin.
Key findings include:
- State-of-the-Art Performance: On the DomainNet UCDR benchmark, the model improved the Mean Average Precision (mAP@200) by +16.84% over the previous state-of-the-art (SASA).
- Domain Generalization: In $U^dCDR$ settings, it achieved a +19.08% mAP improvement, demonstrating exceptional resilience to style shifts.
- Qualitative Clarity: t-SNE visualizations confirm that while standard CLIP features often "entangle" different classes in new domains, UCDR-Adapter maintains clear, distinct clusters for unseen categories.
Conclusion
UCDR-Adapter demonstrates that dynamic, image-content-based prompt generation is far superior to static prompting for cross-domain tasks. By combining learnable adapters with a masking-based generation strategy, the framework provides a robust and efficient solution for finding anything, anywhere, regardless of shifts in category or artistic style.
Summary updated