WeakMedSAM: Weakly-Supervised Medical Image Segmentation via SAM With Sub-Class Exploration and Prompt Affinity Mining

Haoran Wang, Lian Huai, Wenbin Li, Lei Qi, Xingqun Jiang, Yinghuan Shi

Abstract

Adapting the Segment Anything Model (SAM) to the medical domain typically requires extensive pixel-wise annotations, which are costly and labor-intensive to produce. WeakMedSAM introduces a novel framework for weakly-supervised medical image segmentation (WSS) that utilizes only image-level labels. By integrating two innovative modules—Sub-Class Exploration (SCE) and Prompt Affinity Mining (PAM)—WeakMedSAM overcomes common WSS challenges such as tissue co-occurrence and structural blurring. Experimental results across multiple modalities (MRI and CT) demonstrate that WeakMedSAM significantly outperforms existing weakly-supervised methods and approaches the performance of fully-supervised models.

Introduction

While the Segment Anything Model (SAM) has set new benchmarks in general computer vision, its application to medical imaging is hindered by a significant "domain gap." Medical scans differ fundamentally from the natural images used to train SAM, necessitating fine-tuning. However, traditional fine-tuning requires thousands of manual, expert-level mask annotations. WeakMedSAM addresses this by enabling SAM to learn from simple image-level tags, making large-scale medical image segmentation more accessible.

Challenges in Weakly-Supervised Medical Segmentation

Standard weakly-supervised approaches often rely on Class Activation Maps (CAMs) generated from image-level labels. In the medical context, these suffer from two primary issues:

  1. The Co-occurrence Problem: Certain anatomical structures or pathologies consistently appear together (e.g., edema surrounding a brain tumor). Standard classifiers often fail to distinguish between them, leading to CAMs that activate across the entire region rather than the specific target.
  2. Structural Blur: CAMs tend to be "blobby," highlighting only the most discriminative parts of an object while ignoring fine boundaries and complex anatomical structures.

The WeakMedSAM Framework

WeakMedSAM is designed as a "plug-and-play" enhancement for SAM-based backbones (such as SAMUS or EfficientSAM). It introduces two core components to refine segmentation without additional manual labeling.

Sub-Class Exploration (SCE)

To resolve the co-occurrence trap, SCE employs unsupervised clustering (e.g., K-means) on image features to identify latent "sub-classes" within a primary category. By training the network to recognize these subtle variations, the model is forced to learn a more nuanced feature space. This regularization prevents the model from overfitting on spurious background correlations and helps isolate the target tissue from its frequent neighbors.

Prompt Affinity Mining (PAM)

PAM leverages SAM’s inherent "promptability" to recover structural details. The system deploys a grid of point prompts across the image to generate a series of local masks. These masks are then aggregated into a global affinity map, which quantifies the likelihood that any two pixels belong to the same structure. A "random walk" algorithm uses this map to propagate initial CAM activations, ensuring the final segmentation follows the natural boundaries of the anatomy. Unlike previous methods, PAM utilizes SAM’s existing parameters, avoiding the need for auxiliary affinity networks.

Experimental Evaluation

The framework was evaluated on three diverse benchmark datasets representing different modalities and organs:

  • BraTS 2019: Multi-modal MRI for brain tumor segmentation.
  • AbdomenCT-1K: CT scans for abdominal organ segmentation (liver, kidney, spleen, pancreas).
  • MSD Cardiac: MRI for left ventricle segmentation.
  • BraTS-Core: A specialized subset focused on small, difficult-to-segment tumor cores.

Key Results

WeakMedSAM established new state-of-the-art performance levels for weakly-supervised segmentation:

  • Superior Accuracy: On BraTS 2019, the model achieved a 79.69% Dice score, significantly outperforming the previous leading WSS method, TOCO (74.61%).
  • Closing the Supervision Gap: The performance on BraTS (79.69%) came remarkably close to the fully-supervised upper bound of 80.99%.
  • Cross-Modality Generalization: The model reached 75.87% Dice on AbdomenCT-1K, proving its effectiveness across both CT and MRI modalities.
  • Improved Small Target Detection: The combination of SCE and PAM provided a significant boost in segmenting small tumors, which are often missed by traditional weakly-supervised methods.

Conclusion

WeakMedSAM demonstrates that SAM can be effectively adapted for medical imaging using only minimal supervision. By using sub-class exploration to clean feature representations and prompt-based affinity mining to refine structural boundaries, the framework bridges the gap between image-level labels and pixel-perfect segmentation. Future work will focus on automating hyperparameter selection and tighter end-to-end integration of the SCE and PAM modules to further enhance generalizability.

Summary updated

BibTeX
@article{wang2025weakmedsam,
  author = {Haoran Wang and Lian Huai and Wenbin Li and Lei Qi and Xingqun Jiang and Yinghuan Shi},
  title = {{WeakMedSAM: Weakly-Supervised Medical Image Segmentation via SAM With Sub-Class Exploration and Prompt Affinity Mining}},
  journal = {IEEE Trans. Medical Imaging},
  year = {2025},
  url = {https://openreview.net/forum?id=E560S7lvdO},
}
Figure