Generalized Semantic Segmentation by Self-Supervised Source Domain Projection and Multi-Level Contrastive Learning

Liwei Yang, Xiang Gu, Jian Sun

Introduction

Semantic segmentation models often struggle with "domain shift," where a model trained on synthetic datasets (e.g., GTAV) fails to generalize to real-world environments (e.g., Cityscapes). While Domain Adaptation (DA) utilizes target data during training, Domain Generalization (DG) requires models to perform on unseen domains without prior exposure. This paper proposes Domain Projection and Contrastive Learning (DPCL), a framework that aligns target data with the source domain style and employs hierarchical contrastive learning to extract robust, category-level features.

Methodology

The DPCL framework introduces three key components to bridge the domain gap by treating generalization as a data-alignment and structured feature-learning problem.

1. Self-supervised Source Domain Projection (SSDP)

Instead of seeking domain-invariant features—which often discards useful information—SSDP projects unseen target images into the source domain's style. An encoder-decoder sub-network is trained using heavy augmentations on source data to reconstruct original images. At inference, an AdaIN-like mechanism replaces the target image's style statistics (mean and variance) with learned source statistics. This ensures the segmentation model operates on data that "looks" familiar to its training distribution.

2. Multi-Level Contrastive Learning (MLCL)

To ensure category-level robustness, the authors implement a hierarchical contrastive loss across three granularities:

  • Pixel-to-Pixel: This level focuses on local consistency. The authors model this as a "Transition Probability Matrix" matching problem, using Jensen-Shannon divergence to ensure that neighboring pixels belonging to the same semantic category maintain similar feature representations.
  • Pixel-to-Class: This pulls individual pixel features toward their respective "class prototypes"—the moving average of features for a specific category across the dataset.
  • Instance-to-Class: By utilizing a triplet loss, the model ensures that specific object instances (e.g., a single distinct car) are mapped closer to their class prototype than to the prototypes of other classes, enhancing discriminative power.

3. Test-Time Adaptation (TTA)

A significant challenge in domain generalization is adapting to the specific noise or lighting of a new test image. While many methods update model weights during inference, this can lead to instability. DPCL instead keeps the segmentation model frozen and optimizes the input image itself. By iteratively adjusting the image to minimize the contrastive loss, the TTA step ensures the input better fits the model's learned expectations.

Experimental Results

The method was evaluated on standard synthetic-to-real benchmarks, using GTAV and SYNTHIA as source data and Cityscapes, BDD100K, and Mapillary Vistas as target data.

Qualitative comparison of the proposed SSDP and MLCL modules against baseline and ground truth.

As shown in the figure above, the SSDP module successfully aligns the target data's visual style with the source domain, leading to significantly cleaner segmentation masks compared to the baseline. Quantitatively, DPCL achieved a mean Intersection over Union (mIoU) of 43.94% on ResNet50 (GTAV → Real), outperforming the previous state-of-the-art DIRL (40.60%). On lightweight backbones like ShuffleNetV2, the improvement was even more pronounced, jumping from a baseline of 25.44% to 36.98% mIoU. The TTA strategy further pushed the ResNet50 score on Cityscapes to 46.34% mIoU.

Conclusion

DPCL demonstrates that treating domain generalization as a data-alignment problem, supported by hierarchical feature learning, is highly effective for robust semantic segmentation. While the SSDP projection adds some computational overhead, the gains in accuracy across diverse real-world datasets suggest it is a powerful approach for safety-critical applications like autonomous driving. Future work includes exploring the framework's compatibility with Vision Transformer (ViT) architectures.

Summary updated

BibTeX
@inproceedings{yang2023generalized,
  author = {Liwei Yang and Xiang Gu and Jian Sun},
  title = {{Generalized Semantic Segmentation by Self-Supervised Source Domain Projection and Multi-Level Contrastive Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i9.26280},
}
Figure