Abstract
Semantic segmentation models are often brittle when faced with domain shifts, such as changes in weather or transitions from synthetic to real-world data. While Test-Time Training (TTT) allows for online adaptation during inference, standard methods often fail due to the extreme class imbalance and complex spatial structures inherent in segmentation. We present Output Contrastive Loss (OCL), a novel approach that applies contrastive learning directly to model predictions. By utilizing a high-temperature mathematical formulation, OCL prevents mode collapse and preserves natural class distributions. Our method achieves significant performance gains, including a 7.5% mIoU improvement on the GTA5 to Cityscapes benchmark, and demonstrates superior stability in adverse weather conditions compared to existing TTT techniques.
Introduction
Deep learning models for semantic segmentation—the task of assigning a category to every pixel in an image—frequently encounter performance drops when deployed in environments different from their training data. This "domain shift" is a critical challenge for applications like autonomous driving. Traditional Domain Adaptation (DA) requires large, offline target datasets, which is impractical for real-time adaptation.
Test-Time Training (TTT) addresses this by adapting the model online using the current stream of unlabeled images. However, early TTT methods designed for image classification often lead to "mode collapse" in segmentation, where the model erroneously predicts a single dominant class (e.g., "road") to minimize uncertainty.
Methodology: Output Contrastive Loss (OCL)
The proposed Output Contrastive Loss (OCL) adapts models by enforcing consistency and diversity in the prediction space. The method introduces three primary innovations:
- Prediction-Space Contrast: Unlike standard contrastive learning that operates on internal feature representations, OCL is applied directly to the final probability predictions. This avoids the need for complex re-alignment of final layers.
- High-Temperature Formulation: Standard contrastive learning typically uses a low temperature parameter ($\tau$) to encourage uniformity. In segmentation, this destroys the natural class imbalance. By employing an infinitely high temperature ($\tau \to \infty$), the authors derive a simplified loss that respects the original scene geometry and class distribution.
- Pairwise Constraints: The loss enforces consistency between a pixel and its horizontally flipped counterpart (positive pairs) while pushing apart predictions of different pixels within the same image (negative pairs) to maintain diversity.
The complete framework also incorporates Batch Normalization (BN) Statistics Modulation and Stochastic Restoration to prevent catastrophic forgetting of the source knowledge.
Experimental Results
The effectiveness of OCL was evaluated across several challenging benchmarks, including synthetic-to-real shifts (GTA5 $\to$ Cityscapes and Synthia $\to$ Cityscapes) and adverse weather conditions (Cityscapes $\to$ ACDC).
Synthetic-to-Real Adaptation
On the GTA5 $\to$ Cityscapes benchmark, OCL achieved a Mean Intersection over Union (mIoU) of 45.0%, representing a 7.5% improvement over the non-adapted source baseline. As shown in the detailed results below, OCL significantly outperforms other TTT methods like TENT and CoTTA across various object categories.
Robustness to Adverse Weather
In the ACDC benchmark, which simulates a sequence of Fog, Night, Rain, and Snow, OCL maintained stable performance over multiple rounds of adaptation. While competing methods like TENT suffered from error accumulation and performance degradation over time, OCL remained robust, demonstrating its suitability for long-term deployment.
Discussion and Conclusion
OCL provides a stable and effective mechanism for test-time adaptation in semantic segmentation. Its primary strength lies in its simplicity: by operating in the output space and utilizing a high-temperature regularizer, it avoids the pitfalls of mode collapse and representation-task misalignment. Furthermore, OCL is complementary to existing offline DA methods, providing additional performance boosts even for pre-optimized models.
Despite its success, the computational overhead remains a challenge. The requirement for forward and backward passes for each test image results in a significant slowdown (roughly 5.7x) compared to standard inference. Future work will focus on optimizing pixel sampling and augmentation strategies to reduce this latency for real-time applications.
Summary updated