Contrastive Learning with Diffusion Features for Weakly Supervised Medical Image Segmentation

Dewen Zeng, Xinrong Hu, Yu-Jen Chen, Yawen Wu, Xiaowei Xu, Yiyu ShiarXiv 2025 · DOI

Abstract

Training medical image segmentation models typically requires exhaustive pixel-level annotations, which are costly and time-consuming to obtain. This paper presents CLDF (Contrastive Learning with Diffusion Features), a novel framework for Weakly Supervised Semantic Segmentation (WSSS) that utilizes only image-level tags. By leveraging the rich semantic representations within pre-trained Conditional Diffusion Models (CDMs) and employing a targeted contrastive learning strategy, CLDF achieves high-fidelity segmentation masks that rival fully supervised methods.

Introduction: The Challenge of Weak Supervision

In medical imaging, the goal of Weakly Supervised Semantic Segmentation (WSSS) is to identify anatomical structures or pathologies using only simple binary labels (e.g., "tumor present") instead of detailed hand-drawn masks. The standard approach relies on Class Activation Maps (CAMs). While CAMs can localize objects, they are often "blurry," typically highlighting only the most discriminative regions (under-activation) and failing to capture precise boundaries.

Recent advances in generative modeling, specifically Conditional Diffusion Models (CDMs), offer a potential solution. While CDMs' internal saliency maps are often noisy, they contain deep structural information. CLDF aims to bridge the gap by combining the localization capabilities of CAMs with the structural precision of diffusion-derived features.

Methodology: The CLDF Framework

The CLDF workflow integrates diffusion features with a robust pseudo-mask generation process and contrastive refinement.

The CLDF architecture extracts features from a frozen CDM and uses a fusion of CAMs and Gradient Maps to supervise a pixel decoder via contrastive learning.

The process consists of four primary stages:

  1. Feature Extraction: Internal "noise-prediction" features are extracted from a frozen, pre-trained CDM. These features are rich in semantic and structural information.
  2. Pseudo-Mask Fusion: To generate a reliable training signal without ground-truth masks, the method fuses two complementary sources:
  3. CAMs: Provide general object localization but lack precision.
  4. Gradient Maps: Derived from the CDM’s external classifier, these offer sharper boundaries but are prone to background noise. By intersecting these maps, the model identifies high-confidence foreground and background pixels, effectively filtering out the errors inherent in each individual source.

  5. Contrastive Learning: A lightweight "pixel decoder" (a 4-layer MLP) is trained using a supervised contrastive loss. This objective forces the model to cluster foreground pixel features together in an embedding space while maximizing their distance from background pixel features.

  6. Inference: During inference, images are processed through the CDM and pixel decoder. The final binary segmentation mask is produced by applying K-means clustering to the resulting embeddings.

Experimental Evaluation

The CLDF method was evaluated on two prominent medical imaging benchmarks:

  • BraTS21: Brain tumor segmentation using multi-modal MRI scans. The authors processed four MRI modalities as a single 4-channel input to mirror clinical practice.
  • FLARE21: Segmentation of abdominal organs (Kidney, Spleen, Liver) from 3D CT scans.

Results and Discussion

CLDF demonstrates a significant performance leap over existing state-of-the-art WSSS techniques.

Qualitative comparison of CLDF against other WSSS methods across brain MRI and abdominal CT datasets.

Quantitative Performance

  • BraTS21: CLDF achieved a 0.880 Dice score, significantly outperforming the previous best WSSS method (0.827) and approaching the performance of fully supervised models (0.920).
  • FLARE21 Kidney: The method improved the Dice score from a previous state-of-the-art of 0.514 to 0.740.

Qualitative Insights

Visual analysis confirms that CLDF produces masks that adhere closely to anatomical boundaries. While competing methods often generate amorphous "blobs" or fail to detect smaller structures, CLDF maintains high structural fidelity. The study also found that the dimensionality of the output embedding has minimal impact on performance, suggesting that the underlying diffusion features are inherently well-separated.

Conclusion and Future Directions

CLDF establishes a new benchmark for weakly supervised medical image segmentation by effectively repurposing diffusion models as feature extractors. While it significantly narrows the gap to fully supervised learning, challenges remain. Future work will focus on extending the framework to multi-class segmentation and further reducing the performance gap for complex organs like the spleen. Additionally, optimizing the computational overhead of diffusion-based feature extraction will be critical for real-time clinical applications.

Summary updated

BibTeX
@misc{zeng2025contrastive,
  author = {Dewen Zeng and Xinrong Hu and Yu-Jen Chen and Yawen Wu and Xiaowei Xu and Yiyu Shi},
  title = {{Contrastive Learning with Diffusion Features for Weakly Supervised Medical Image Segmentation}},
  year = {2025},
  eprint = {2506.23460},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.23460},
}
Figure