Leveraging Segment Anything Model for Source-Free Domain Adaptation via Dual Feature Guided Auto-Prompting

Zheang Huai, Hui Tang, Yi Li, Zhuangzhuang Chen, Xiaomeng Li

Introduction

Deep learning models for medical image segmentation frequently encounter performance degradation when deployed across different clinical environments. This phenomenon, known as domain shift, occurs when a model trained on one data distribution (e.g., MRI scans) is applied to another (e.g., CT scans). Source-Free Domain Adaptation (SFDA) has emerged as a critical paradigm to address this, allowing for the adaptation of a pre-trained source model to a target domain using only unlabeled target data. This approach is particularly valuable in healthcare as it preserves patient privacy and circumvents the logistical challenges of transmitting large source datasets.

However, traditional SFDA methods are often limited by the inherent bias of the source model. While vision foundation models like the Segment Anything Model (SAM) and its medical variant, MedSAM, offer powerful zero-shot capabilities, they typically require manual prompts (such as bounding boxes) to achieve high accuracy. In an SFDA context, generating these prompts automatically is difficult because the adapted model’s initial predictions are often too noisy to serve as reliable guides. This paper introduces a novel Dual Feature Guided (DFG) auto-prompting framework designed to bridge this gap by automating the prompt generation process for MedSAM.

Methodology

The proposed DFG framework automates the search for optimal bounding box prompts through a three-phase process that leverages the complementary strengths of the target model and the foundation model.

1. Feature Aggregation (FA)

To prepare the target model for prompt searching, the authors first perform Feature Aggregation. In this phase, target features are pulled toward the source model's class prototypes. This process forces the target features to form distinct clusters, which helps the model maintain a coherent understanding of different anatomical structures despite the domain shift.

2. Dual Feature Guided Box Prompt Search (DBS)

The core innovation of the paper is the Dual Feature Guided Box Prompt Search. The system initializes a small bounding box around high-confidence pixels and expands it iteratively using two distinct guidance mechanisms:

  • Target Model Feature Guidance (TBS): The box expands based on the clustered features of the target model. The expansion is governed by the "Stable Interval" phenomenon—an observation that MedSAM’s segmentation output remains relatively constant when the bounding box prompt is near the true object boundary. This serves as an unsupervised stopping criterion.
  • MedSAM Feature Guidance (MBS): Since the target model may miss portions of an organ due to domain-specific feature dispersion, the system switches to MedSAM’s own feature space. MedSAM possesses superior "feature affinity," allowing it to group similar pixels together even when the target model lacks the semantic confidence to do so. Sequential use of both feature spaces ensures that the search covers the blind spots of each individual model.

3. Connectivity-based Post-processing (CP)

Recognizing that medical organs are typically contiguous structures, the framework employs a post-processing step that retains only the largest connected component for each predicted class. This effectively filters out isolated false-positive pixels that may have been generated during the prompt expansion phase.

Experimental Results

The authors evaluated the DFG framework on datasets specifically excluded from MedSAM’s training corpus to ensure a true zero-shot evaluation. These included 3D abdominal datasets (BTCV, CHAOS, CURVAS) for cross-modality adaptation and 2D prostate datasets (NCI-ISBI, QUBIQ) for multi-site adaptation.

  • Cross-Modality Performance: On the CHAOS → BTCV (MRI to CT) task, the DFG method achieved a Dice score of 84.9%. This significantly outperforms the previous state-of-the-art method, ProtoContra, which reached 74.4%. Notably, simply using ProtoContra's raw output as a prompt for MedSAM only yielded a marginal improvement to 75.3%, highlighting the necessity of the DFG search algorithm.
  • Near-Supervised Accuracy: In the NCI-ISBI → QUBIQ prostate segmentation task, the framework achieved a 93.3% Dice score. This result is remarkably close to the fully supervised upper bound of 94.4%, demonstrating that automated prompting can rival human-annotated performance in specific domains.

Discussion and Conclusion

A key insight from this research is that fine-tuning foundation models like SAM with noisy pseudo-labels can be counterproductive; the authors found that their prompt-search method outperformed fine-tuning approaches because it avoided "teaching" the model the errors present in the initial pseudo-labels.

While the DFG framework shows immense promise, it faces limitations when dealing with very large organs (like the liver) where visual features are highly heterogeneous, potentially causing the expansion search to terminate prematurely. Future work will likely focus on refining the "stable interval" detection and developing more robust criteria for pixel inclusion within the box prompts. Nonetheless, this work represents a significant step forward in making foundation models truly autonomous for clinical domain adaptation tasks.

Summary updated

BibTeX
@article{huai2025leveraging,
  author = {Zheang Huai and Hui Tang and Yi Li and Zhuangzhuang Chen and Xiaomeng Li},
  title = {{Leveraging Segment Anything Model for Source-Free Domain Adaptation via Dual Feature Guided Auto-Prompting}},
  journal = {IEEE Trans. Medical Imaging},
  year = {2025},
  doi = {10.1109/tmi.2025.3587733},
}
Figure