Zero-Shot Medical Image Segmentation Based on Sparse Prompt Using Finetuned SAM

Tal Shaharabany, Lior WolfMIDL 2024

TL;DR

This paper tackles the challenge of segmenting medical images with limited annotated data by adapting the powerful Segment Anything Model (SAM). They introduce a two-stage approach: first, generating an initial mask using SAM's internal representations, and second, fine-tuning SAM on the specific medical image to significantly improve segmentation accuracy in a zero-shot setting.

What Problem Does This Paper Address?

Accurate segmentation of medical images is crucial for diagnosis, treatment planning, and monitoring. However, the creation of large, annotated medical image datasets is incredibly time-consuming and expensive, leading to a significant data scarcity problem. Traditional deep learning models rely heavily on this annotated data. While general-purpose segmentation models like SAM show promise, they often struggle when applied directly to specialized domains like medical imaging without domain-specific training. This paper aims to bridge this gap by enabling SAM to perform zero-shot segmentation on medical images using only a few sparse prompts (like points) on the target image, bypassing the need for extensive medical datasets.

Methods

The core of the proposed method is a two-stage process designed to adapt SAM for medical image segmentation without requiring labeled medical data for training.

  1. Initial Mask Generation (Stage 1):
    • The approach leverages the internal visual embeddings generated by SAM's image encoder.
  2. It computes a "self-similarity map" by measuring the cosine similarity between these embeddings at different spatial locations.
  3. Using sparse prompts (a few foreground and background points provided on the test image), it constructs "positive" and "negative" maps from the self-similarity map.
  4. These maps are combined to generate an initial segmentation mask, denoted as $J$. This mask serves as a preliminary segmentation, leveraging the inherent structure captured by SAM's encoder.
  5. Test-Time Fine-Tuning (Stage 2):
    • This stage focuses on improving the initial mask $J$.
  6. Crucially, SAM's visual encoder is fine-tuned specifically for each test image, independently of other images. This is a "test-time" adaptation.
  7. During fine-tuning, SAM's decoder weights are frozen, and prompts are set to null, allowing the encoder to adapt its representations to the specific medical image.
  8. The fine-tuning is guided by a loss function that combines Binary Cross-Entropy (BCE) and Soft-Dice loss, comparing SAM's output mask ($M_o$) with the initial mask $J$. This encourages SAM to produce an output that is close to the initial, albeit potentially imperfect, mask.

The key novelty lies in using SAM's internal representations to generate a useful initial mask and then performing test-time fine-tuning of the image encoder, rather than relying solely on SAM's pre-trained capabilities or traditional fine-tuning on large datasets.

Datasets

The authors evaluated their method on three publicly available medical imaging datasets:

  • AMOS22: An abdominal CT organ segmentation dataset with 240 test images and 14 categories.
  • MoNuSeg: A dataset of microscopic images depicting seven organs, with annotations for individual nuclei.
  • GlaS (Gland Segmentation): A dataset of high-resolution images for gland segmentation.

Key Insights and Ideas

  • SAM's Embeddings Hold Medical Structure: Even though SAM is trained on natural images, its internal visual embeddings capture enough structural information to generate a meaningful initial mask for medical images, especially when guided by sparse prompts.
  • Test-Time Fine-Tuning is Powerful for Domain Adaptation: Fine-tuning SAM's image encoder per image is highly effective for adapting it to the medical domain, significantly outperforming the base SAM with sparse prompts alone. This suggests that a small amount of image-specific adaptation can overcome domain shift.
  • Initial Mask as a "Dense Prompt": The generated initial mask $J$ acts as a form of "dense prompt" for the fine-tuning stage, guiding the model towards a more accurate segmentation than sparse points alone.
  • Few Points Can Be Enough: The method demonstrates strong performance even with a very small number of positive points (e.g., P=1), highlighting its efficiency in scenarios with extreme data scarcity.
  • Zero-Shot is Achievable and Effective: The paper successfully demonstrates a practical zero-shot segmentation approach for medical images, reducing the reliance on large, labeled datasets.

Key Results

  • AMOS22: The proposed method ("Ours w/P") achieved the highest Dice scores for most anatomical structures at P=1, outperforming "Super-Clustering" by over 0.2 Dice score and SAM w/P by a significant margin. With P=10, it maintained high performance and competed favorably with supervised state-of-the-art methods like nnUNet-3D.
  • MoNuSeg: The method achieved a mean IoU of 39.49 (ViT-base), significantly outperforming SAM with the initial mask $J$ as a dense prompt (IoU of 21.33). Performance generally improved with more points.
  • GlaS: The ViT-large version achieved a mean IoU of 58.84, surpassing standard SAM (51.43) and super-clustering (50.75). The method showed superior performance with four marked points, though sensitivity to outliers was noted with fewer points.

Limitations and Future Work

  • Sensitivity to Point Sampling: The quality of the initial mask $J$ and subsequent performance can be sensitive to the random sampling of points, especially in failure cases where unfavorable points are chosen.
  • Generalization of Fine-Tuned Networks: The authors suggest that future work could investigate the generalization ability of these fine-tuned networks to unseen medical images or domains.
  • Meta-Learning for Feed-Forward Models: They also propose training a feed-forward model using meta-learning as a future direction, potentially enabling faster adaptation.

Summary updated

BibTeX
@inproceedings{shaharabany2024zero,
  author = {Tal Shaharabany and Lior Wolf},
  title = {{Zero-Shot Medical Image Segmentation Based on Sparse Prompt Using Finetuned SAM}},
  booktitle = {MIDL},
  year = {2024},
  url = {https://openreview.net/forum?id=TEYGCx02p3},
}
Figure