Semantic Self-adaptation: Enhancing Generalization with a Single Sample

Sherwin Bahmani, Oliver Hahn, Eduard Zamfir, Nikita Araslanov, Daniel Cremers, Stefan Roth

Abstract

The lack of out-of-domain generalization is a critical weakness of deep networks for semantic segmentation. Previous studies relied on the assumption of a static model, i. e., once the training process is complete, model parameters remain fixed at test time. In this work, we challenge this premise with a self-adaptive approach for semantic segmentation that adjusts the inference process to each input sample. Self-adaptation operates on two levels. First, it fine-tunes the parameters of convolutional layers to the input image using consistency regularization. Second, in Batch Normalization layers, self-adaptation interpolates between the training and the reference distribution derived from a single test sample. Despite both techniques being well known in the literature, their combination sets new state-of-the-art accuracy on synthetic-to-real generalization benchmarks. Our empirical study suggests that self-adaptation may complement the established practice of model regularization at training time for improving deep network generalization to out-of-domain data.

Introduction

Deep learning models for semantic segmentation are notoriously brittle when faced with "domain shift." A model trained on synthetic data, such as GTA-V, often fails when deployed in real-world environments due to variations in lighting, camera hardware, or geographic location.

Existing solutions typically fall into two categories: Domain Generalization, which aims for robustness during training, and Domain Adaptation, which requires a large batch of unlabeled data from the target environment. However, many real-world applications only provide access to a single image at a time. This paper addresses the "single-sample" generalization challenge: enabling a model to adapt to a specific, never-before-seen image on the fly.

Proposed Methodology

The authors propose a two-level self-adaptation process that occurs entirely during inference, challenging the "static model" fallacy where parameters remain fixed after training.

1. Self-adaptive Normalization (SaN)

Standard Batch Normalization (BN) relies on statistics (mean and variance) learned during training. When a test image deviates from the training distribution, these statistics become inaccurate. SaN addresses this by interpolating between the training statistics and the statistics of the individual test image, effectively "re-centering" the model's features for the specific input.

2. Self-supervised Fine-tuning

Beyond normalization, the model performs a post-hoc optimization for each input. The process involves creating several augmented versions of the input image (e.g., different scales, flips, or grayscale). These are passed through the network to generate a "pseudo-label" based on the most confident pixel predictions. The model then performs a few iterations of gradient descent to update the weights of the upper convolutional layers and the classification head before making a final prediction. Crucially, the weights are reset before processing the next image.

Overview of the semantic self-adaptation pipeline, illustrating the generation of pseudo-labels from augmented images to fine-tune the model at inference time.

Experimental Setup

The study utilizes a principled evaluation framework across multiple domains to ensure true generalization:

  • Source Domains (Training): GTA and SYNTHIA (synthetic datasets).
  • Validation: WildDash (used for hyperparameter tuning).
  • Target Domains (Testing): Cityscapes (Germany), BDD (North America), IDD (India), and Mapillary (Global).
  • Adverse Conditions: The ACDC dataset was used to test robustness against fog, rain, and snow.

Results and Discussion

The proposed method sets new benchmarks for synthetic-to-real generalization. Using a ResNet-101 backbone trained on GTA, self-adaptation improved the mean Intersection-over-Union (mIoU) across target domains from 31.9% to 37.0%.

Quantitative results showing mean Intersection-over-Union (mIoU) and Expected Calibration Error (ECE) across multiple target domains for ResNet backbones.

Key Insights

  • Calibration Improvement: One of the most significant findings is that SaN dramatically improves model calibration. This ensures that the model's confidence scores accurately reflect its likelihood of being correct, which is vital for reliable pseudo-labeling.
  • Efficiency through Sparsity: The authors found that updating only the later layers (conv4, conv5, and the head) provides the best balance of accuracy and speed, preventing the model from losing basic visual features learned during the initial training.
  • Robustness to Weather: On the ACDC dataset, the method outperformed the baseline by 13.5% on average, demonstrating particular strength in challenging conditions like fog and snow.

Conclusion and Future Work

Semantic Self-adaptation proves that the information within a single high-resolution image is sufficient for meaningful test-time adaptation. While the method achieves state-of-the-art results, its primary limitation is latency, as performing backpropagation for every image currently prevents real-time application. Future research will focus on more efficient optimization techniques, such as adaptive step sizes or low-rank updates, to bring this approach closer to real-time performance in autonomous systems.

Summary updated

BibTeX
@article{bahmani2023semantic,
  author = {Sherwin Bahmani and Oliver Hahn and Eduard Zamfir and Nikita Araslanov and Daniel Cremers and Stefan Roth},
  title = {{Semantic Self-adaptation: Enhancing Generalization with a Single Sample}},
  journal = {Accepted by TMLR},
  year = {2023},
  url = {https://openreview.net/forum?id=ILNqQhGbLx},
}
Figure