Learning a Domain-Agnostic Visual Representation for Autonomous Driving via Contrastive Loss

Dongseok Shim, H. Jin KimarXiv 2021

Introduction

Training deep neural networks for autonomous driving tasks, such as monocular depth estimation or semantic segmentation, requires massive amounts of pixel-perfect labeled data. While synthetic environments (e.g., simulators or video games) can generate infinite labeled data, models trained on them often fail in the real world due to domain shift. This "reality gap" occurs because a model might learn features specific to synthetic textures and lighting that do not generalize to real-world conditions.

Conceptual overview of DACL bridging synthetic (source) and real (target) domains through a domain-agnostic feature embedding.

Existing Unsupervised Domain Adaptation (UDA) methods attempt to align these domains, but they often struggle to preserve the underlying geometry and structural details of the scene during translation. The authors propose Domain-Agnostic Contrastive Learning (DACL) to create a representation where the model perceives the same "content" regardless of whether the "style" is synthetic or real.

Methodology: The DACL Framework

The authors propose a multi-stage pipeline designed to decouple style from content and learn invariant features. This approach ensures that the structural integrity of the scene is maintained across domain boundaries.

The complete DACL pipeline: Stage 1 involves bidirectional style transfer; Stage 2 performs contrastive representation learning; the final stage involves task-specific finetuning.

Stage 1: Bidirectional Style Transfer

Using a GAN-based architecture (similar to CycleGAN), the system learns to map images from the Source domain ($\mathcal{S}$, synthetic) to the Target domain ($\mathcal{T}$, real) and vice versa. This stage employs adversarial loss, cycle-consistency loss, and identity reconstruction loss. The goal is to ensure that while the visual style changes (e.g., from synthetic to real), the content—such as the positions of cars, roads, and trees—remains structurally consistent.

Stage 2: Contrastive Representation Learning

This is the core innovation of the paper. Inspired by momentum-based contrastive learning (MoCo), the model is trained to recognize that a synthetic image $I_{\mathcal{S}}$ and its stylized-as-real counterpart $I_{\mathcal{S}\to\mathcal{T}}$ represent the same scene.

  • Positive Pairs: A synthetic image and its translated "fake-real" version are treated as a positive pair in the embedding space.
  • Negative Pairs: Other random images from the dataset serve as negatives.
  • Objective: The contrastive loss forces the feature extractor $f_{\mathcal{T}}$ to map positive pairs to nearly identical coordinates in a low-dimensional latent space $\mathcal{Z}$. This teaches the model to ignore domain-specific "noise" and focus on universal structural features.

Task-specific Finetuning

Following pre-training, the domain-agnostic encoder is finetuned on specific downstream tasks like depth prediction or semantic segmentation. This step utilizes the ground-truth labels available in the synthetic source domain to optimize task-specific decoders.

Experimental Results

The DACL framework was evaluated on standard benchmarks including Virtual KITTI (vKITTI) for the source domain and KITTI for the real-world target domain, as well as Cityscapes and GTA5.

  • Monocular Depth Estimation: When integrated with the GASDA baseline, DACL improved the Absolute Relative (Abs Rel) error from 0.149 to 0.118, representing a nearly 20% performance gain. Qualitative results showed significantly sharper object boundaries around complex structures like guardrails and vehicles compared to previous blurry depth maps.
  • Semantic Segmentation: In the vKITTI $\to$ KITTI task, DACL achieved a mean Intersection-over-Union (mIoU) of 30.9, outperforming standard adversarial methods like GRL (28.2) and CycleGAN (26.1).

Conclusion

DACL demonstrates that contrastive learning can be effectively repurposed for domain adaptation by defining positive pairs across the synthetic-real boundary. By decoupling style from content, the framework enables autonomous driving models to learn robust, geometry-preserving features that generalize well to the real world. While the multi-stage training process is computationally intensive and performance on rare categories (like poles) remains a challenge, this domain-agnostic approach offers a promising path for bridging the reality gap in safety-critical vision tasks.

Summary updated

Abstract

Deep neural networks have been widely studied in autonomous driving applications such as semantic segmentation or depth estimation. However, training a neural network in a supervised manner requires a large amount of annotated labels which are expensive and time-consuming to collect. Recent studies leverage synthetic data collected from a virtual environment which are much easier to acquire and more accurate compared to data from the real world, but they usually suffer from poor generalization due to the inherent domain shift problem. In this paper, we propose a Domain-Agnostic Contrastive Learning (DACL) which is a two-stage unsupervised domain adaptation framework with cyclic adversarial training and contrastive loss. DACL leads the neural network to learn domain-agnostic representation to overcome performance degradation when there exists a difference between training and test data distribution. Our proposed approach achieves better performance in the monocular depth estimation task compared to previous state-of-the-art methods and also shows effectiveness in the semantic segmentation task.
BibTeX
@misc{shim2021learning,
  author = {Dongseok Shim and H. Jin Kim},
  title = {{Learning a Domain-Agnostic Visual Representation for Autonomous Driving via Contrastive Loss}},
  year = {2021},
  eprint = {2103.05902},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.05902},
}
Figure