Abstract
In real-world applications, the sample distribution at the inference stage often differs from the one at the training stage, causing performance degradation of trained deep models. The research on domain generalization (DG) aims to develop robust algorithms that can improve the generalized performance in unseen domains by training on a few domains. However, the domain-agnostic vision model, trained on a limited number of domains using traditional domain generalization methods, cannot guarantee its effectiveness in dealing with unseen domains. The introduction of language can break the closed cognition space of the vision model, providing additional semantic information that cannot be inferred from vision-only datasets. In this paper, we propose to overcome the challenge in previous DG methods by introducing the style prompt in the language modality to adapt the trained model dynamically. In particular, we train a style prompter to extract style information of the current image into an embedding in the token embedding space and place it in front of the candidate category words as prior knowledge to prompt the model. Our open space partition of the style token embedding space and the hand-crafted style regularization enable the trained style prompter to handle data from unknown domains effectively. Extensive experiments verify the effectiveness of our method and demonstrate state-of-the-art performances on multiple public datasets.
Introduction
Deep learning models are notoriously brittle. A model trained to recognize objects in high-resolution photos often fails when asked to identify the same objects in sketches, cartoons, or infrared imagery. This is the core challenge of Domain Generalization (DG): how do we train a model on a few "source" domains so that it performs well on "unseen" domains?
Traditional methods often try to force models to ignore style and focus solely on domain-invariant features. However, vision-only models typically have a "closed cognition space," making it difficult for them to describe or understand styles they haven't encountered. StylePrompter addresses this by bringing language into the mix, providing the model with a much richer vocabulary to describe the context of what it's seeing.
Methodology
The authors introduce StylePrompter, a lightweight module designed to work alongside large, pre-trained Vision-Language Models (VLMs) like CLIP. It dynamically extracts style information from images at test-time and converts it into language prompts.
The Style Prompter Module
The core of the system is a small network trained to map an image's visual features into the "token embedding space" of the language model. This creates a "pseudo-word" or Style Prior (SP) that captures the image's style. During inference, instead of just asking the model "Is this a [CLASS]?", the system constructs a prompt: "SP [CLASS]". The model effectively adapts its recognition based on the identified style (e.g., "Given this sketch style, is this a horse?").
Robust Adaptation and Open Space Partitioning
The framework offers two versions of the prompter: a Basic MLP and a Gaussian version that models style as a probability distribution to prevent overfitting. To handle completely unknown styles, the authors use an Open Domain Discrimination Loss. Unlike standard classifiers that pigeonhole every input into a known category, this loss uses a contrastive mechanism to push styles from different domains apart while leaving "open space" in the embedding map for unknown styles. Additionally, Style Regularization uses hand-crafted text prompts to "anchor" the learned style embeddings, ensuring they stay semantically meaningful.
Key Results
StylePrompter achieved state-of-the-art (SOTA) performance across four gold-standard benchmarks: PACS, VLCS, Office-Home, and DomainNet.
- Accuracy Boost: On the PACS dataset using a ResNet-50 backbone, StylePrompter reached 93.5% accuracy, compared to the baseline CLIP's 91.0%.
- Large Scale Success: On the difficult DomainNet dataset, it outperformed the previous best method (PromptStyler) by over 1%, a significant margin given the scale of the benchmark.
- Zero-Shot Potential: The model proved it could handle "cross-domain and cross-category" tasks—for example, training on one set of styles and successfully identifying categories it had never seen during the prompter training by leveraging the VLM's broad pre-trained knowledge.
Conclusion
StylePrompter demonstrates that language provides a vital bridge for generalization. By extracting style as a linguistic prior in a single forward pass, the method enables efficient test-time adaptation without the need for slow backpropagation. Future work may involve leveraging the reasoning capabilities of Large Language Models (LLMs) to further refine how models interpret environmental context.
Summary updated