Transformer-Based Source-Free Domain Adaptation

Guanglei Yang, Hao Tang, Zhun Zhong, Mingli Ding, Ling Shao, Nicu Sebe, Elisa RicciarXiv 2021

Introduction

Domain shift remains a significant hurdle in deploying computer vision models across diverse environments. While traditional Domain Adaptation (DA) techniques mitigate this by training on source and target data simultaneously, real-world constraints often prevent access to source data. This has given rise to Source-Free Domain Adaptation (SFDA), where a model must adapt to a new target domain using only a pre-trained "black box" source model and unlabeled target data.

Current SFDA methods primarily focus on aligning feature distributions. However, they often overlook the generalization capabilities of the initial source model. If the source model focuses on domain-specific background features rather than the actual objects, the adaptation process is prone to failure.

Motivation: The Attention Gap

Empirical studies using Grad-CAM visualizations reveal a strong correlation between a model's focus and its predictive accuracy on unseen target samples. When the network's attention is "focused" on the object of interest, accuracy is significantly higher compared to when it is "non-focused" (i.e., attending to background noise).

Grad-CAM visualization and accuracy analysis showing that model performance is tied to its ability to focus on object regions.

As shown in the analysis above, target samples where the model attends to the background (non-focused) exhibit a sharp decline in accuracy. This suggests that improving the model's "objectness" focus is key to robust domain adaptation.

The TransDA Framework

To address the locality bias of standard Convolutional Neural Networks (CNNs), the authors propose TransDA. This framework introduces two core components: Transformer integration and self-supervised knowledge distillation.

1. Transformer Integration

TransDA injects a Transformer module after the final convolutional layer of a ResNet-50 backbone. Unlike CNNs, which excel at capturing local patterns, Transformers utilize Multi-Head Self-Attention (MSA) to model long-range dependencies. This global context forces the network to integrate information across the entire image, effectively shifting its focus from local domain-specific textures to the underlying structure of the objects.

2. Self-Supervised Knowledge Distillation

The adaptation phase employs a teacher-student architecture to refine the model on the unlabeled target domain.

The TransDA architecture featuring source training, target adaptation with a teacher-student distillation strategy, and the detailed Transformer block.
  • Student Model ($f_t^{Stu}$): Updated via gradient descent using a combination of Information Maximization (IM) and distillation losses.
  • Teacher Model ($f_t^{Tea}$): A temporal ensemble of the student model, updated via Exponential Moving Average (EMA). The teacher provides stable "soft" pseudo-labels, which are further refined through clustering-based self-labeling.
  • Distillation Loss ($\mathcal{L}_{kd}$): This loss encourages the student to match the teacher's predictions, stabilizing the learning process and preventing error accumulation from noisy pseudo-labels.

Experimental Evaluation

TransDA was evaluated on three major benchmarks: Office-31, Office-Home, and VisDA-2017, covering closed-set, partial-set, and open-set scenarios.

  • Office-Home: TransDA achieved a state-of-the-art (SOTA) accuracy of 79.3% in the closed-set task, significantly outperforming previous methods like SHOT (71.8%).
  • VisDA-2017: Using a ResNet-50 backbone, TransDA reached 83.0% accuracy, surpassing several methods that utilized the larger ResNet-101 architecture.
  • Versatility: The method proved versatile, achieving SOTA results in partial-set (81.3%) and open-set (76.8%) adaptation on Office-Home, demonstrating its ability to handle mismatched class distributions.

Conclusion

TransDA demonstrates that injecting global context via Transformers and employing a stable teacher-student distillation strategy can significantly improve source-free domain adaptation. By forcing the model to focus on "objectness" rather than domain-specific backgrounds, TransDA achieves superior generalization across various challenging benchmarks. Future work may extend this attention-centric approach to more complex tasks such as source-free semantic segmentation and object detection.

Summary updated

BibTeX
@misc{yang2021transformer,
  author = {Guanglei Yang and Hao Tang and Zhun Zhong and Mingli Ding and Ling Shao and Nicu Sebe and Elisa Ricci},
  title = {{Transformer-Based Source-Free Domain Adaptation}},
  year = {2021},
  eprint = {2105.14138},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.14138},
}
Figure