Style-Adaptive Detection Transformer for Single-Source Domain Generalized Object Detection

Jianhong Han, Yupei Wang, Liang Chen · DOI

Abstract

Single-source domain generalization (SDG) in object detection aims to develop a detector using only source domain data that generalizes well to unseen target domains. Existing methods are primarily CNN-based and improve robustness through data augmentation combined with feature alignment. However, these methods are limited, as augmentation is only effective when the synthetic distribution approximates that of unseen domains, thus failing to ensure generalization across diverse scenarios. While DEtection TRansformer (DETR) has shown strong generalization in domain adaptation due to global context modeling, its potential for SDG remains underexplored. To this end, we propose Style-Adaptive DEtection TRansformer (SA-DETR), a DETR-based detector tailored for SDG. SA-DETR introduces an online domain style adapter that projects the style representation of unseen domains into the source domain via a dynamic memory bank. This bank self-organizes into diverse style prototypes and is continuously updated under a test-time adaptation framework, enabling effective style rectification. Additionally, we design an object-aware contrastive learning module to promote extraction of domain-invariant features. By applying gating masks that constrain contrastive learning in both spatial and semantic dimensions, this module facilitates instance-level cross-domain contrast and enhances generalization. Extensive experiments across five distinct weather scenarios demonstrate that SA-DETR consistently outperforms existing methods in both detection accuracy and domain generalization capability.

Introduction

Object detection models often encounter significant performance degradation when deployed in environments that differ from their training data, a phenomenon known as domain shift. Single-Source Domain Generalization (SDG) is the challenging task of training a model on a single source domain (e.g., clear weather) such that it generalizes effectively to any number of unseen target domains (e.g., heavy rain, night-time fog).

Traditional approaches typically rely on CNN-based architectures and static data augmentation. However, these methods struggle when the unseen environment's distribution deviates significantly from the augmented training samples. The Style-Adaptive Detection Transformer (SA-DETR) addresses these limitations by leveraging the global context modeling inherent in the DETR architecture, combined with dynamic style adaptation and instance-level feature alignment.

The SA-DETR Framework

SA-DETR is built upon the DINO detector and incorporates two primary innovations to bridge the gap between source and unseen target domains.

Online Domain Style Adapter (ODS-Adapter)

Unlike static style modulation techniques, the ODS-Adapter maintains a dynamic memory bank of style prototypes, represented by feature means and variances. During inference, the module uses the Wasserstein distance to compare the style of a new, unseen image to its stored prototypes. It then projects the new style back into the known training domain using a weighted AdaIN modulation. Furthermore, the system supports Test-Time Adaptation (TTA), allowing the memory bank to continuously absorb and adapt to novel styles encountered during deployment.

Overview of the SA-DETR framework, illustrating the ODS-Adapter and the style space rectification process.

Object-aware Contrastive Learning (OCL)

To ensure the detector focuses on domain-invariant object features rather than background noise or weather-specific textures, the OCL module utilizes gating masks derived from annotations. These masks aggregate instance-level features into categorical prototypes. The module then employs contrastive learning to pull features of the same category together across domains while pushing different categories apart, effectively learning the core semantic features of objects like "cars" or "pedestrians" regardless of environmental conditions.

The Object-aware Contrastive Learning (OCL) module facilitates instance-level cross-domain contrast between source and augmented domains.

Experimental Evaluation

The model was trained on the "Daytime-Clear" domain of the BDD-100K dataset and evaluated across five distinct weather scenarios, including Daytime-Foggy, Dusk-Rainy, Night-Clear, and Night-Rainy. These target domains were sourced from public datasets such as Cityscapes and Adverse-Weather.

Key Results

SA-DETR achieved state-of-the-art performance across all tested scenarios:

  • Significant Gains in Challenging Scenarios: In the "Dusk-Rainy" scene, SA-DETR improved mAP by 8.4% over previous best methods.
  • Source Domain Robustness: Even on the original "Daytime-Clear" source domain, it outperformed existing methods by 5.7% mAP.
  • Efficiency: The ODS-Adapter adds minimal runtime overhead (~7ms per image), ensuring the framework remains viable for real-time applications like autonomous driving.

Conclusion

SA-DETR demonstrates that combining the global context modeling of transformers with dynamic style rectification and object-aware feature alignment significantly enhances a detector's ability to generalize from a single source. While the current framework relies on initial data augmentation, future research will explore domain generalization under extreme small-sample conditions where training data is severely limited.

Summary updated

BibTeX
@misc{han2025style,
  author = {Jianhong Han and Yupei Wang and Liang Chen},
  title = {{Style-Adaptive Detection Transformer for Single-Source Domain Generalized Object Detection}},
  year = {2025},
  eprint = {2504.20498},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.20498},
}
Figure