Domain-Specificity Inducing Transformers for Source-Free Domain Adaptation

Sunandini Sanyal, Ashish Ramayee Asokan, Suvaansh Bhambri, Akshay R. Kulkarni, Jogendra Nath Kundu, R. Venkatesh Babu

Introduction

In machine learning, "domain shift" remains a significant hurdle for model deployment. This phenomenon occurs when a model trained on a specific source dataset fails to generalize to a target dataset with different characteristics. Traditionally, researchers have addressed this through domain-invariance, attempting to force the model to ignore domain-specific "style" and focus solely on task-relevant "content." However, this approach can be counterproductive when the gap between domains is substantial.

In "Domain-Specificity Inducing Transformers for Source-Free Domain Adaptation," researchers from the Vision and AI Lab at the Indian Institute of Science (IISc) propose a paradigm shift. Instead of discarding domain-specific information, their framework, DSiT, treats it as a valuable asset. By leveraging the unique architecture of Vision Transformers (ViT), DSiT disentangles domain-specific features from task-specific ones to achieve superior adaptation in source-free environments.

The Challenge of Source-Free Domain Adaptation (SFDA)

Source-Free Domain Adaptation (SFDA) addresses a common real-world constraint: the "Vendor-Client" scenario. In this setting, a vendor provides a pre-trained model (the source) to a client, but cannot share the original training data due to privacy regulations or proprietary concerns. The client must then adapt this black-box model to their own unlabeled target data.

Existing SFDA methods typically attempt to align target features with the implicit source distribution. The authors of DSiT argue that forcing this alignment often leads to a loss of discriminative power. They suggest that a model should instead learn to recognize the unique context of the target domain while preserving the core task knowledge (e.g., object recognition) acquired during source training.

Methodology: Inducing Specificity

The DSiT framework utilizes the modular nature of Vision Transformers to achieve feature disentanglement through several key innovations:

1. Query-Based Specificity

The authors identified that the Query weights ($W_Q$) in the self-attention layers of a ViT are particularly effective at capturing domain-specific information. By freezing the Key ($W_K$) and Value ($W_V$) weights—which largely represent task-specific knowledge—and updating only the Query weights, the model can adapt to the "style" of a new domain without overwriting its fundamental classification capabilities.

2. Domain-Representative Inputs (DRI)

To train the model to distinguish domains without relying on class labels, DSiT employs a "task-label destructive transform" known as patch-shuffling. By shuffling the patches of an image, the spatial structure required for object recognition (task info) is destroyed, but the higher-order statistics and textures (domain info) remain intact. These shuffled images, termed Domain-Representative Inputs, allow the model to focus purely on domain characteristics.

3. Two-Step Training Protocol

The adaptation process follows a bifurcated approach:

  • Step A (Domain Training): The model trains a domain classifier using DRIs. During this phase, only the Query weights and a specialized "domain token" ($z_d$)—analogous to the standard class token—are updated.
  • Step B (Task Training): The model trains the task classifier on original target images. In this phase, the Query weights are frozen to preserve the learned domain-specificity, while other components are updated to refine task performance.

4. Virtual Domain Simulation

To compensate for the lack of multiple source domains in a source-free setting, DSiT uses five label-preserving augmentations (e.g., simulating weather effects or artistic styles) to create virtual domains. This helps the model learn to distinguish between various data distributions more effectively.

Experimental Results

The authors established benchmarks for pure ViT-based SFDA across several standard datasets, including Office-31, Office-Home, VisDA, and the complex DomainNet. DSiT consistently outperformed previous state-of-the-art (SOTA) methods, many of which relied on traditional ResNet backbones.

  • Office-Home: DSiT achieved 80.5% accuracy, surpassing the previous best source-free method (SHOT-B) by 2.4%.
  • DomainNet: On this large-scale benchmark featuring 345 classes, DSiT reached 42.1% average accuracy, outperforming even some methods that had access to source data.
  • Multi-Source Adaptation: In scenarios where multiple source models are available, DSiT reached 84.7% on Office-Home, demonstrating its versatility.

Discussion and Limitations

A key insight from this research is that Transformers are inherently better suited for domain adaptation than Convolutional Neural Networks (CNNs) due to their ability to capture global context and their modular weight structure. The use of patch-shuffling as a feature extraction tool highlights a clever way to isolate "style" from "content."

However, DSiT is not without trade-offs. The primary limitation is training overhead. The alternating two-step training process is computationally intensive; for instance, DSiT required 270 minutes of training on one benchmark compared to just 29 minutes for the SHOT-B baseline. Additionally, the performance is sensitive to the patch-shuffling grid size, with a 4x4 grid found to be optimal for standard resolutions.

Conclusion

DSiT demonstrates that domain-specific information is a powerful tool for adaptation rather than a nuisance to be ignored. By isolating this information within the Query weights of a Vision Transformer, the framework provides a robust solution for Source-Free Domain Adaptation, setting new performance standards across multiple benchmarks. Future work may explore hypernetworks to further automate the disentanglement process and reduce training time.

Summary updated

BibTeX
@inproceedings{sanyal2023domain,
  author = {Sunandini Sanyal and Ashish Ramayee Asokan and Suvaansh Bhambri and Akshay R. Kulkarni and Jogendra Nath Kundu and R. Venkatesh Babu},
  title = {{Domain-Specificity Inducing Transformers for Source-Free Domain Adaptation}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
}
Figure