CellSAM: a foundation model for cell segmentation

Markus Marks, Uriah Israel, Rohit Dilip, Changhua Yu, Emily Laubscher, Asim Iqbal, Elora Pradhan, Ada Ates, Martin Abt, Caitlin Brown, Edward Pao, Qilin Li, Alexander Pearson-Goulart, Pietro Perona, Georgia Gkioxari, Ross Barnowski, Yisong Yue, David Van ValenNature Methods 2025

TL;DR

Researchers have developed CellSAM, a universal foundation model for cell segmentation that leverages the Segment Anything Model (SAM) and an object detector (CellFinder) to achieve human-level performance across diverse cell types and imaging modalities. This model significantly reduces the need for domain-specific models and enables more scalable bioimage analysis.

What Problem Does This Paper Address?

Accurate cell segmentation is a cornerstone of modern biological imaging, crucial for tasks ranging from spatial genomics to live-cell dynamics studies. However, existing deep learning models are often "specialists," excelling in specific domains (e.g., mammalian cells in brightfield) but failing to generalize to new cell types, imaging modalities, or scales. This necessitates the development and maintenance of numerous specialized models, hindering broad applicability and scalability. Furthermore, manual annotation for training these models is time-consuming and expensive. The authors aim to create a single, generalist model that can segment cells across a wide variety of biological contexts with high accuracy, addressing both the generalization and annotation challenges.

Methods

CellSAM builds upon the Segment Anything Model (SAM) by introducing a novel prompt engineering approach for automated cell segmentation. The core idea is to combine SAM's powerful mask generation capabilities with an object detection model, dubbed CellFinder, to automatically generate prompts for SAM.

  1. CellFinder: This object detector, based on the Anchor DETR framework, is trained to identify bounding boxes around cells within an image. It utilizes the same Vision Transformer (ViT) backbone as SAM for feature extraction, ensuring compatibility.
  2. Prompt Engineering: The bounding boxes generated by CellFinder serve as prompts for SAM. This is a key innovation, as SAM's default automatic prompting (a uniform grid of points) is not well-suited for the high density and varied morphology of cellular images.
  3. Two-Stage Training:
    • Stage 1: CellFinder is trained on the object detection task using ground truth cell masks converted to bounding boxes. The ViT backbone and CellFinder module are trained together.
  4. Stage 2: The ViT and SAM's mask decoder weights are frozen, and the "neck" of the SAM model is fine-tuned using ground truth bounding boxes as prompts and segmentation masks as targets. This step bridges the distribution shift introduced during CellFinder training.

During inference, an input image is processed by the ViT, then by CellFinder to generate bounding boxes. These boxes, along with the ViT features, are fed into SAM's prompt encoder and mask decoder to produce segmentation masks.

Datasets

The authors curated a comprehensive dataset for training and evaluating CellSAM, spanning five broad data archetypes:

  • TissueNet
  • DeepBacs
  • BriFiSeg
  • Cellpose
  • Omnipose
  • YeastNet
  • YeaZ
  • 2018 Kaggle Data Science Bowl (DSB) (for nuclei segmentation)
  • A collection of H&E datasets
  • An internally collected dataset of phase microscopy images (Phase400)

The LIVECell dataset was held out for zero-shot and few-shot evaluation. Data splits were carefully managed to avoid leaks. For the NeurIPS challenge, additional preprocessing was applied, including linear rescaling and CLAHE normalization.

Key Insights and Ideas

  • Foundation Model for Cells: The paper argues for the necessity of a "foundation model" for cell segmentation, analogous to large language models, that can generalize across diverse biological contexts.
  • Prompt Engineering is Key: The success of CellSAM hinges on using an object detector (CellFinder) to generate precise bounding box prompts for SAM, overcoming the limitations of SAM's default auto-prompting for dense cellular images.
  • Generalization Over Specialization: CellSAM-generalist (trained on all data) performs as well as or better than CellSAM-specialist (trained on individual datasets), demonstrating the power of a unified, broadly trained model. This contrasts with Cellpose, where generalist models often underperform specialists.
  • Human-Level Performance: CellSAM achieves accuracy comparable to expert human annotators, a significant benchmark for automated segmentation.
  • Zero-Shot and Few-Shot Learning: CellSAM shows strong performance even on unseen cell types and can be significantly improved with minimal additional labeled data.

Key Results

  • Human-Level Accuracy: CellSAM achieved human-level accuracy for generalized cell segmentation across multiple data categories (Tissue, Cell Culture, H&E, Bacteria, Yeast, Nuclear), with non-significant differences compared to human annotators.
  • Superior Generalization: CellSAM-generalist outperformed Cellpose-generalist on all tested data categories. Furthermore, CellSAM-generalist's performance was equivalent to or better than CellSAM-specialist across all categories.
  • Zero-Shot Performance: On the LIVECell dataset, CellSAM showed significant improvement over Cellpose in zero-shot performance (error reduced from 0.13 to 0.40 in F1).
  • Few-Shot Improvement: With as few as 10 additional FOVs (10^2-10^3 cells), CellSAM's performance improved, particularly for cell lines with morphologies closer to the training distribution.
  • Workflow Integration: CellSAM was successfully integrated into diverse bioimage analysis workflows, including spatial transcriptomics and live-cell imaging, without requiring task-specific adaptations.

Limitations and Future Work

  • Prompting Strategy: The authors note that bounding boxes might have limitations as a prompting strategy for SAM, particularly for cell lines with morphologies far from the training data distribution (e.g., SH-SY5Y).
  • Three-Dimensional Segmentation: While a workflow for 3D segmentation using CellSAM is presented (via u-Segment3D), extending the core model to inherently handle 3D data is a future direction.
  • Vision-Language Models: Integrating natural language labels with cell-level annotations could lead to more powerful vision-language models for cellular image analysis.
  • Data Diversity: Continued expansion of the training dataset, especially with challenging morphologies and perturbed cells, is crucial for robust generalization.
  • Compute-Efficient Fine-Tuning: Developing more efficient fine-tuning strategies is needed for flexible adaptation to new image domains.
  • Prompt Engineering: Further research into prompt engineering for SAM models, especially for novel datasets, is an active area.

Summary updated

Abstract

Cells are a fundamental unit of biological organization, and identifying them in imaging data-cell segmentation-is a critical task for various cellular imaging experiments. Although deep learning methods have led to substantial progress on this problem, most models are specialist models that work well for specific domains but cannot be applied across domains or scale well with large amounts of data. Here we present CellSAM, a universal model for cell segmentation that generalizes across diverse cellular imaging data. CellSAM builds on top of the Segment Anything Model (SAM) by developing a prompt engineering approach for mask generation. We train an object detector, CellFinder, to automatically detect cells and prompt SAM to generate segmentations. We show that this approach allows a single model to achieve human-level performance for segmenting images of mammalian cells, yeast and bacteria collected across various imaging modalities. We show that CellSAM has strong zero-shot performance and can be improved with a few examples via few-shot learning. Additionally, we demonstrate how CellSAM can be applied across diverse bioimage analysis workflows. A deployed version of CellSAM is available at https://cellsam.deepcell.org/ .
BibTeX
@inproceedings{marks2025cellsam,
  author = {Markus Marks and Uriah Israel and Rohit Dilip and Changhua Yu and Emily Laubscher and Asim Iqbal and Elora Pradhan and Ada Ates and Martin Abt and Caitlin Brown and Edward Pao and Qilin Li and Alexander Pearson-Goulart and Pietro Perona and Georgia Gkioxari and Ross Barnowski and Yisong Yue and David Van Valen and David Van Valen},
  title = {{CellSAM: a foundation model for cell segmentation}},
  booktitle = {Nature Methods},
  year = {2025},
  doi = {10.1038/s41592-025-02879-w},
}
Figure