ConDiSR: Contrastive Disentanglement and Style Regularization for Single Domain Generalization

Aleksandr Matsun, Numan Saeed, Fadillah Adamsyah Maani, Mohammad Yaqub · DOI

Abstract

Medical data often exhibits distribution shifts, which cause test-time performance degradation for deep learning models trained using standard supervised learning pipelines. This challenge is addressed in the field of Domain Generalization (DG) with the sub-field of Single Domain Generalization (SDG) being specifically interesting due to the privacy- or logistics-related issues often associated with medical data. Existing disentanglement-based SDG methods heavily rely on structural information embedded in segmentation masks, however classification labels do not provide such dense information. This work introduces a novel SDG method aimed at medical image classification that leverages channel-wise contrastive disentanglement. It is further enhanced with reconstruction-based style regularization to ensure extraction of distinct style and structure feature representations. We evaluate our method on the complex task of multicenter histopathology image classification, comparing it against state-of-the-art (SOTA) SDG baselines. Results demonstrate that our method surpasses the SOTA by a margin of 1% in average accuracy while also showing more stable performance.

Introduction: The Challenge of Distribution Shift

Deep learning models in healthcare are notoriously sensitive to "distribution shift." A model trained to detect malignancy at one hospital may fail at another simply because the second facility uses a different scanner brand or a slightly different chemical stain for pathology slides. While Multi-Source Domain Generalization (training on data from many hospitals) is a potential solution, privacy regulations and logistical hurdles often restrict researchers to data from a single source.

This leads to the challenge of Single Domain Generalization (SDG): training a robust model on one "source" domain that can generalize to unseen "target" domains. Unlike segmentation tasks, where dense pixel-level labels help models distinguish anatomy from noise, classification tasks provide only a single label per image, making it difficult for models to learn which features are clinically relevant (structure) and which are merely scanner-specific artifacts (style).

Histopathology images from five different medical centers (Center 0-4) demonstrating significant variations in staining, color, and texture despite representing the same underlying tissue types.

Methodology: The ConDiSR Framework

The authors propose ConDiSR (Contrastive Disentanglement and Style Regularization), a framework designed to force a neural network to separate its internal representations into two distinct components: Structure-rich features ($f_{str}$), containing essential clinical information, and Style-rich features ($f_{sty}$), containing domain-specific textures and colors.

The ConDiSR architecture: Input images are augmented to create style variations. A shared encoder ($\\mathcal{F}_{DM}$) extracts features that are disentangled into structure and style paths, optimized via contrastive ($\\mathcal{L}_{c,str}$, $\\mathcal{L}_{c,sty}$), classification ($\\mathcal{L}_{ce}$), and reconstruction ($\\mathcal{L}_{rec}$) losses.

Key Components

  1. Channel-wise Disentanglement: Rather than using complex multi-stream architectures, ConDiSR uses learnable parameters to determine which channels in the feature map should carry style versus structure information.
  2. Contrastive Learning: By creating augmented versions of the same image (altering colors while preserving anatomy), the model is trained to ensure that structure features remain invariant across versions, while style features are forced to capture the differences.
  3. Style Regularization via Reconstruction: To prevent the "style" component from being empty or redundant, the model must use these features to reconstruct a downsampled version of the original image. Targeting a lower resolution ensures the model captures broad style patterns (like color balance) without "cheating" by picking up fine structural details.

Experimental Results

The framework was evaluated on two major benchmarks: the Camelyon17-WILDS dataset (breast cancer histopathology) and Diabetic Retinopathy (DR) Grading (fundus eye images).

  • Performance Gains: On Camelyon17-WILDS, ConDiSR outperformed standard Empirical Risk Minimization (ERM) and previous state-of-the-art methods (like $C^2$SDG) by approximately 1-2% in average accuracy.
  • Stability: A key finding was the reduction in performance variance. ConDiSR remained consistent regardless of which hospital was used as the training source, whereas baseline models showed high sensitivity to the initial training domain.
  • Interpretability: Grad-CAM visualizations confirmed that ConDiSR focuses more accurately on actual tumor regions, while baseline models were frequently distracted by background staining textures.

Conclusion

ConDiSR demonstrates that even in "information-poor" classification tasks, effective disentanglement can be achieved through clever regularization and contrastive objectives. By successfully isolating clinical structure from domain style, the framework provides a more reliable path for deploying medical AI across diverse clinical environments.

Summary updated

BibTeX
@inproceedings{matsun2025condisr,
  author = {Aleksandr Matsun and Numan Saeed and Fadillah Adamsyah Maani and Mohammad Yaqub},
  title = {{ConDiSR: Contrastive Disentanglement and Style Regularization for Single Domain Generalization}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  doi = {10.1109/wacv61041.2025.00285},
}
Figure