DGFamba: Learning Flow Factorized State Space for Visual Domain Generalization

Qi Bi, Jingjun Yi, Hao Zheng, Haolan Zhan, Wei Ji, Yawen Huang, Yuexiang Li

Abstract

Domain Generalization (DG) remains a critical challenge in computer vision, requiring models to perform reliably on unseen target domains. While State Space Models (SSMs) like Mamba offer promising efficiency and global receptive fields, they often struggle with style-induced domain gaps. We present DGFamba, a novel framework that introduces "flow factorization" to SSMs. By treating style transitions as physical dynamic processes in a latent space and regularizing them with physics-informed neural networks (PINNs) using the Hamilton-Jacobi equation, DGFamba effectively decouples style from content. Our method sets new state-of-the-art benchmarks on PACS (92.6%) and OfficeHome (78.5%), outperforming established CNN and Transformer architectures.

Introduction

The "domain gap"—the discrepancy between training (source) and testing (target) data distributions—is a major hurdle for robust AI. While semantic content remains constant across domains (e.g., a "dog" in a photo vs. a sketch), varying styles like texture and color often mislead models. Traditional CNNs are sensitive to local style textures, while Vision Transformers (ViTs) are computationally intensive. DGFamba leverages the efficiency of Selective State Space Models (specifically VMamba) and introduces a mechanism to ensure the model focuses on domain-invariant content.

Methodology: Flow Factorized State Space

DGFamba integrates three core components into the VMamba backbone to achieve style-blind generalization:

  1. State Style Randomization (SSR): During training, the model "hallucinates" diverse styles by injecting random statistics into feature embeddings via Adaptive Instance Normalization (AdaIN). This prepares the model for the variability of unseen domains.
  2. State Flow Encoding (SFE): Features from both original and style-augmented images are mapped into a latent "flow space" using a Variational Auto-Encoder (VAE) architecture.
  3. State Flow Constraint (SFC): This component treats style shifts as a continuous mechanical flow. By applying the Benamou-Brenier Formula and Hamilton-Jacobi (HJ) equations, the model minimizes the "cost" of transitioning between styles. A PINN loss ensures that the probability paths between different styles are aligned, forcing the latent representation to be style-agnostic.
The DGFamba architecture, highlighting State Style Randomization, State Flow Encoding, and the State Flow Constraint using PINN loss.

Experimental Results

DGFamba was evaluated on standard "leave-one-domain-out" benchmarks, including PACS, VLCS, OfficeHome, and TerraIncognita.

Performance and Efficiency

DGFamba significantly outperforms previous state-of-the-art methods. On the PACS dataset, it achieved an average accuracy of 92.6%, surpassing the previous SSM-based leader, DGMamba, by 1.4%. On OfficeHome, it reached 78.5%, notably beating high-end Transformer models like GMoE (72.4%).

Crucially, DGFamba maintains a competitive balance between accuracy and parameter efficiency. As shown in the comparison below, it achieves the highest average accuracy while keeping trainable parameters significantly lower than some large-scale Transformer alternatives.

Average Accuracy vs. Trainable Parameters across various SOTA domain generalization methods. DGFamba achieves superior accuracy with moderate complexity.

Qualitative Analysis

Visualizations using t-SNE confirm that DGFamba's feature space is organized primarily by semantic class rather than domain style. This indicates that the flow factorization successfully filters out domain-specific noise, allowing the classifier to operate on pure content features.

Conclusion

DGFamba demonstrates that physics-inspired regularization can effectively bridge the domain gap in State Space Models. By modeling style as a continuous path and optimizing it via the Hamilton-Jacobi equation, the framework achieves a robust, style-invariant representation. Future work will explore extending this flow factorization approach to other modalities, such as medical imaging and video domain generalization.

Summary updated

BibTeX
@inproceedings{bi2025dgfamba,
  author = {Qi Bi and Jingjun Yi and Hao Zheng and Haolan Zhan and Wei Ji and Yawen Huang and Yuexiang Li},
  title = {{DGFamba: Learning Flow Factorized State Space for Visual Domain Generalization}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i2.32181},
}
Figure