CellViT: Vision Transformers for Precise Cell Segmentation and Classification

Fabian Hörst, Moritz Rempe, Lukas Heine, Constantin Seibold, Julius Keyl, Giulia Baldini, Selma Ugurel, Jens Siveke, Barbara Grünwald, Jan Egger, Jens KleesiekMedical Image Analysis 2023 · DOI

Abstract

Nuclei detection and segmentation in hematoxylin and eosin-stained (H&E) tissue images are critical clinical tasks for a wide range of applications. However, challenges such as nuclei variance in staining and size, overlapping boundaries, and clustering persist. While convolutional neural networks (CNNs) have traditionally dominated this field, we introduce CellViT, a deep learning architecture based on Vision Transformers (ViTs). Trained and evaluated on the PanNuke dataset, CellViT leverages large-scale pre-trained encoders, including the Segment Anything Model (SAM) and a ViT-encoder trained on 104 million histological patches. CellViT achieves state-of-the-art performance with a mean panoptic quality of 0.50 and an F1-detection score of 0.83, while significantly improving inference speed.

Introduction

In digital pathology, identifying and classifying individual cell nuclei is foundational for cancer diagnosis and prognosis. The task is notoriously difficult due to the morphological diversity of nuclei and their tendency to cluster in dense tissue environments. Standard CNN-based models, such as HoVer-Net, often struggle to capture the long-range spatial relationships necessary for precise segmentation in complex scenes. Furthermore, the computational demand of processing gigapixel whole-slide images (WSIs) necessitates more efficient architectures. CellViT addresses these gaps by replacing traditional CNN encoders with Vision Transformers to enhance both precision and throughput.

Methodology

CellViT utilizes a U-Net-shaped encoder-decoder architecture where the standard CNN backbone is replaced by a Vision Transformer (ViT). This design allows the model to leverage global context more effectively than local convolutional filters.

Detailed architecture of CellViT showing the Transformer-based encoder and multi-task decoder branches (NP, HV, and NT branches).

Key technical components include:

  • Multi-Task Learning: The decoder features three specialized branches: the NP-branch for binary nuclei prediction, the HV-branch for horizontal and vertical distance maps (to separate overlapping nuclei), and the NT-branch for nuclei type classification.
  • Large-Scale Pre-training: The model benefits from encoders pre-trained on massive datasets, such as the 1.1 billion masks of the Segment Anything Model (SAM), which provides robust feature extraction even for specialized medical imagery.
  • Efficient Inference: Optimized for 1024x1024 patches, CellViT reduces redundant computations compared to traditional small-patch processing methods.

Experimental Setup and Datasets

The model was primarily trained and evaluated on the PanNuke dataset, one of the most challenging benchmarks in the field. It contains nearly 200,000 annotated nuclei across 19 tissue types and 5 clinical classes (Neoplastic, Inflammatory, Epithelial, Connective, and Dead cells).

Distribution of cell types across 19 tissue types in the PanNuke dataset, highlighting the class imbalance and diversity of the data.

To test generalization, the researchers also utilized MoNuSeg for zero-shot evaluation and CoNSeP for token analysis, ensuring the model's internal representations align with biological cell types.

Results and Key Insights

CellViT established new state-of-the-art (SOTA) benchmarks on the PanNuke dataset:

  • Performance: Achieved a Mean Panoptic Quality (mPQ) of 0.50 and an F1-detection score of 0.83, outperforming established models like HoVer-Net and StarDist.
  • Speed: The inference pipeline is 1.85x faster than HoVer-Net when processing large tissue sections, making it more viable for clinical workflows.
  • The "Cell-Token" Synergy: At standard pathology resolutions (0.25 µm/px), a single ViT token (16x16 pixels) roughly corresponds to the size of a cell nucleus. This allows the model to naturally associate a specific feature vector, or "cell embedding," with each detected instance.

Conclusion and Future Work

While CellViT demonstrates superior performance, it remains sensitive to image resolution, with performance declining at lower magnifications. Additionally, rare classes such as "dead cells" remain difficult to segment due to data imbalance. Future research will explore using the generated cell embeddings to construct "cell graphs," modeling the spatial interactions within the tumor microenvironment to improve cancer staging and treatment predictions.

Summary updated

BibTeX
@article{horst2023cellvit,
  author = {Fabian Hörst and Moritz Rempe and Lukas Heine and Constantin Seibold and Julius Keyl and Giulia Baldini and Selma Ugurel and Jens Siveke and Barbara Grünwald and Jan Egger and Jens Kleesiek},
  title = {{CellViT: Vision Transformers for Precise Cell Segmentation and Classification}},
  journal = {Medical Image Analysis},
  year = {2023},
  doi = {10.1016/j.media.2024.103143},
}
Figure