On the Fly Neural Style Smoothing for Risk-Averse Domain Generalization

Akshay Mehra, Yunbei Zhang, Bhavya Kailkhura, Jihun Hamm

Abstract

Achieving high accuracy on data from domains unseen during training is a fundamental challenge in domain generalization (DG). While state-of-the-art DG classifiers have demonstrated impressive performance across various tasks, they have shown a bias towards domain-dependent information, such as image styles, rather than domain-invariant information, such as image content. This bias renders them unreliable for deployment in risk-sensitive scenarios such as autonomous driving where a misclassification could lead to catastrophic consequences. To enable risk-averse predictions from a DG classifier, we propose a novel inference procedure, Test-Time Neural Style Smoothing (TT-NSS), that uses a "style-smoothed" version of the DG classifier for prediction at test time. Specifically, the style-smoothed classifier classifies a test image as the most probable class predicted by the DG classifier on random re-stylizations of the test image. TT-NSS uses a neural style transfer module to stylize a test image on the fly, requires only black-box access to the DG classifier, and crucially, abstains when predictions of the DG classifier on the stylized test images lack consensus. Additionally, we propose a neural style smoothing (NSS) based training procedure that can be seamlessly integrated with existing DG methods. This procedure enhances prediction consistency, improving the performance of TT-NSS on non-abstained samples. Our empirical results demonstrate the effectiveness of TT-NSS and NSS at producing and improving risk-averse predictions on unseen domains from DG classifiers trained with SOTA training methods on various benchmark datasets and their variations.

Introduction

Domain Generalization (DG) aims to maintain model performance on data distributions not encountered during training. However, current state-of-the-art models are often biased toward "style" (textures, lighting, and colors) rather than "content" (object geometry and semantics). This bias leads to overconfident but incorrect predictions when models encounter new environments, making them unsuitable for risk-sensitive applications like autonomous driving or medical diagnosis. This paper introduces a framework to mitigate this risk by prioritizing prediction consensus over raw model confidence.

Methodology

Test-Time Neural Style Smoothing (TT-NSS)

TT-NSS is an inference-time procedure that treats image style as a form of noise to be "smoothed out." When a test image arrives from an unseen domain, the system uses a style transfer network (AdaIN) to generate multiple stylized versions of that image. Crucially, these versions are stylized to match the "look" of the original training data—a technique called source-domain anchoring. The classifier predicts a label for each version, and a final prediction is only issued if a clear consensus (exceeding a threshold $\alpha$) is reached. If the model is inconsistent across stylizations, it abstains and defers to a human expert.

Overview of the TT-NSS inference procedure, illustrating the pipeline from style transfer to the final prediction or abstention decision.

Neural Style Smoothing (NSS) Training

To improve the base classifier's performance under TT-NSS, we propose the NSS training procedure. This method integrates two additional loss functions into standard training:

  1. Stylized Misclassification Loss: Penalizes errors on stylized versions of training data.
  2. Style Consistency Loss: Uses Kullback–Leibler (KL) divergence to force the model’s predictions to remain consistent across different stylizations of the same content.

Experiments and Results

We evaluated our approach on standard DG benchmarks (PACS, VLCS, Office-Home) and more difficult variations involving Wikiart styles and common corruptions (e.g., blur, snow).

Accuracy vs. abstention curves across different styles and corruption levels, demonstrating the robustness of the consensus-based approach.

As shown in the results, TT-NSS consistently outperforms standard confidence-based rejection methods. By abstaining when consensus is low, the model maintains high accuracy on the remaining samples, even under severe domain shifts or corruptions. Furthermore, the NSS training procedure significantly improves the Area Under the Curve (AUC) for accuracy-vs-abstention. Practically, the system is efficient; generating 15 stylized versions adds only approximately 0.26 seconds of overhead on modern hardware (Nvidia A100).

Conclusion

TT-NSS and NSS provide a robust path toward risk-averse domain generalization by shifting the focus from mathematical softmax confidence to empirical prediction consistency. This approach ensures that models only predict when they can reliably recognize content regardless of its stylistic presentation. Future work will explore extending this smoothing concept to object detection and semantic segmentation.

Summary updated

Abstract

Achieving high accuracy on data from domains unseen during training is a fundamental challenge in domain generalization (DG). While state-of-the-art DG classifiers have demonstrated impressive performance across various tasks, they have shown a bias towards domain-dependent information, such as image styles, rather than domain-invariant information, such as image content. This bias renders them unreliable for deployment in risk-sensitive scenarios such as autonomous driving where a misclassification could lead to catastrophic consequences. To enable risk-averse predictions from a DG classifier, we propose a novel inference procedure, Test-Time Neural Style Smoothing (TT-NSS), that uses a "style-smoothed" version of the DG classifier for prediction at test time. Specifically, the style-smoothed classifier classifies a test image as the most probable class predicted by the DG classifier on random re-stylizations of the test image. TT-NSS uses a neural style transfer module to stylize a test image on the fly, requires only black-box access to the DG classifier, and crucially, abstains when predictions of the DG classifier on the stylized test images lack consensus. Additionally, we propose a neural style smoothing (NSS) based training procedure that can be seamlessly integrated with existing DG methods. This procedure enhances prediction consistency, improving the performance of TT-NSS on non-abstained samples. Our empirical results demonstrate the effectiveness of TT-NSS and NSS at producing and improving risk-averse predictions on unseen domains from DG classifiers trained with SOTA training methods on various benchmark datasets and their variations.
BibTeX
@inproceedings{mehra2024fly,
  author = {Akshay Mehra and Yunbei Zhang and Bhavya Kailkhura and Jihun Hamm},
  title = {{On the Fly Neural Style Smoothing for Risk-Averse Domain Generalization}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2024},
  url = {https://openreview.net/forum?id=kw3yoBa4Hu},
}
Figure