Context-Aware Domain Adaptation in Semantic Segmentation

Jinyu Yang, Weizhi An, Chaochao Yan, Peilin Zhao, Junzhou Huang

Introduction

Deep learning models for semantic segmentation typically require vast amounts of pixel-level annotations, which are costly and time-consuming to acquire for real-world datasets. While synthetic data from game engines (e.g., GTA5, SYNTHIA) offers an abundant source of labeled data, models trained on these "source" domains often suffer from a significant performance drop when applied to "target" real-world domains like Cityscapes. This phenomenon, known as the domain gap, arises from differences in lighting, texture, and sensor characteristics.

Existing Unsupervised Domain Adaptation (UDA) techniques primarily focus on aligning global feature distributions or performing image-to-image translation. However, they often neglect the structural and contextual dependencies inherent in urban scenes—relationships like "cars are usually on roads" or "sidewalks are adjacent to buildings." These contextual relationships are largely invariant across domains. This paper introduces CDANet (Cross-Domain Attention Network), a framework designed to explicitly model and transfer these shared contextual dependencies to bridge the domain gap.

Methodology: The CDANet Framework

CDANet leverages a bidirectional cross-attention mechanism to capture dependencies across the source and target domains. Unlike standard self-attention, which models intra-image relationships, cross-attention identifies and aggregates relevant features from one domain to refine the representation of the other.

Overview of the CDANet architecture featuring cross-domain spatial and channel attention modules.

The architecture consists of two core modules:

  1. Cross-Domain Spatial Attention Module (CD-SAM): This module computes the similarity between every spatial position in the source and target feature maps. It updates the target features by selectively aggregating contextually relevant information from the source domain, and vice versa.
  2. Cross-Domain Channel Attention Module (CD-CAM): This module models dependencies between feature channels, which often correspond to specific semantic concepts or shapes. By aligning channel-wise responses, the network ensures that the "concept" of an object (e.g., a tree) is consistent across domains.

To further refine the adaptation, the framework employs adversarial training with three separate discriminators to align the outputs of the spatial module, the channel module, and the final aggregated predictions.

Key Insights: Context as a Universal Language

The fundamental premise of CDANet is that while the visual appearance of objects changes between synthetic and real worlds, their spatial and semantic relationships remain consistent. By treating context as a transferable bridge, the model can "learn" the appearance of a real-world object by looking at its synthetic counterpart in a similar context.

Visualization of cross-domain contextual dependencies between synthetic (source) and real (target) images.

As shown in the visualization above, the cross-attention mechanism identifies corresponding semantic regions (like vehicles or vegetation) across the domain boundary, allowing the network to borrow high-level structural information from the labeled source domain to guide the segmentation of the unlabeled target domain.

Experimental Results

The model was rigorously evaluated on two standard synthetic-to-real benchmarks: GTA5 to Cityscapes and SYNTHIA to Cityscapes.

  • State-of-the-Art Performance: On the GTA5 to Cityscapes benchmark, CDANet achieved a Mean Intersection-over-Union (mIoU) of 49.2% using a ResNet101 backbone, outperforming established methods such as BDL and FADA.
  • Robustness to Large Gaps: For the SYNTHIA to Cityscapes task, which typically presents a larger domain shift, the model reached 52.4% mIoU.
  • Rare Class Recovery: A significant advantage of context-aware modeling is the improved detection of rare or difficult classes. For instance, CDANet showed a 16.1% improvement in the "train" class compared to the CyCADA baseline, likely due to the consistent contextual placement of trains relative to tracks and urban structures.

Conclusion and Future Work

CDANet demonstrates that explicitly modeling cross-domain contextual dependencies is a powerful strategy for unsupervised domain adaptation. By moving beyond simple statistical alignment and focusing on the "universal language" of scene structure, the framework achieves superior segmentation accuracy.

While the spatial attention module introduces quadratic computational complexity relative to pixel count, the authors mitigate this through feature downsampling. Future research may explore more efficient attention mechanisms or extend this context-aware approach to other dense prediction tasks like depth estimation and instance segmentation.

Summary updated

BibTeX
@inproceedings{yang2021context,
  author = {Jinyu Yang and Weizhi An and Chaochao Yan and Peilin Zhao and Junzhou Huang},
  title = {{Context-Aware Domain Adaptation in Semantic Segmentation}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2021},
  doi = {10.1109/wacv48630.2021.00056},
}
Figure