Unsupervised Domain Adaptation via Bidirectional Cross-Attention Transformer

Xiyu Wang, Pengxin Guo, Yu Zhang

Introduction

Domain shift remains a significant challenge in computer vision, where models trained on a labeled "source" domain (e.g., synthetic data) often fail to generalize to an unlabeled "target" domain (e.g., real-world images). While Vision Transformers (ViTs) have improved performance over traditional CNNs by capturing global context, existing domain adaptation (DA) methods often rely on unidirectional cross-attention or restrictive batching requirements. The Bidirectional Cross-Attention Transformer (BCAT) addresses these limitations through a novel quadruple-branch architecture that facilitates bidirectional information exchange between domains.

The Quadruple Transformer Block

The core of BCAT is the Quadruple Transformer Block, which replaces standard single-stream Transformer layers. This structure consists of four parallel branches that share weights to ensure the model learns domain-invariant features:

  1. Source Branch: Processes source images using standard Multi-head Self-Attention (MSA).
  2. Target Branch: Processes target images using standard MSA.
  3. Target-to-Source (T2S) Branch: Employs Multi-head Cross-Attention (MCA) where target queries ($Q_t$) interact with source keys ($K_s$) and values ($V_s$).
  4. Source-to-Target (S2T) Branch: Employs MCA where source queries ($Q_s$) interact with target keys ($K_t$) and values ($V_t$).
The complete BCAT pipeline illustrating the training process with quadruple branches and the two inference modes (KD and DTF).

This bidirectional approach creates a "bridge" in the feature space. By generating T2S and S2T features, the model performs Implicit Feature Mixup, producing intermediate representations that are easier to align than the raw source and target features. This symmetry ensures that both domains influence each other, leading to more robust adaptation.

Training and Inference Strategies

To optimize the BCAT architecture, the authors utilize a multi-faceted loss function during training:

  • Classification Loss ($\mathcal{L}_{cls}$): Standard cross-entropy for labeled source data and a pseudo-labeling strategy for unlabeled target data.
  • Transfer Loss ($\mathcal{L}_{transfer}$): Maximum Mean Discrepancy (MMD) is applied to minimize the distance between the source-dominant and target-dominant feature distributions.

One practical challenge of cross-attention is the requirement for both source and target data during inference. BCAT overcomes this through two specialized modes:

  • Knowledge Distillation (KD): A standard Transformer "student" model is trained to mimic the quadruple-branch "teacher," allowing for efficient deployment.
  • Double Target Feature (DTF): A clever inference-time trick where target features are duplicated to simulate the presence of a second domain, bypassing the need for source data at test time.
The complete BCAT pipeline illustrating the training process with quadruple branches and the two inference modes (KD and DTF).

Key Results and Benchmarks

BCAT achieves state-of-the-art (SOTA) results across several major domain adaptation benchmarks, demonstrating its versatility across different scales:

  • Office-Home: Reached an average accuracy of 85.5%, significantly outperforming previous Transformer-based methods.
  • DomainNet: On the particularly difficult Painting-to-Real (P→R) task, BCAT delivered a 10.6% performance increase over the previous best method, CDTrans.
  • VisDA-2017: Demonstrated strong performance in large-scale simulation-to-real scenarios.
  • Office-31: Achieved a high average accuracy of 94.1% using a ViT-B backbone.

Visual analysis via attention maps confirms that BCAT is more effective at isolating the object of interest and ignoring domain-specific background noise compared to models trained solely on source data.

Conclusion and Future Work

BCAT represents a significant step forward in domain adaptation by leveraging bidirectional cross-attention to bridge the gap between disparate data distributions. While the quadruple-branch structure increases training complexity, the introduction of KD and DTF inference modes ensures the model remains practical for real-world deployment. Future research directions include extending this bidirectional logic to pixel-level tasks such as semantic segmentation and further reducing the computational overhead of the training phase.

Summary updated

BibTeX
@inproceedings{wang2023unsupervised,
  author = {Xiyu Wang and Pengxin Guo and Yu Zhang},
  title = {{Unsupervised Domain Adaptation via Bidirectional Cross-Attention Transformer}},
  booktitle = {ECML/PKDD},
  year = {2023},
  doi = {10.1007/978-3-031-43424-2\_19},
}

Loading related content...

Figure