How to Get Started with CellViT: Vision Transformers for Precise Cell Segmentation and Classification

Mar 12, 2022 | Educational

CellViT is an innovative deep learning-based tool that automates the segmentation and classification of cell nuclei in digitized tissue samples. This guide aims to provide step-by-step instructions on setting up and using CellViT effectively. Let’s dive into the world of CellViT!

Key Features

  • State-of-the-Art Performance in nuclei instance segmentation.
  • Utilizes Vision Transformer (ViT) encoders for enhanced performance.
  • Employs a U-Net architecture for efficient segmentation.
  • Fast inference results with large patch sizes for Whole Slide Images (WSI).

Installation

To install CellViT, follow these steps:

  1. Clone the repository:
  2. git clone https://github.com/TIO-IKIM/CellViT.git
  3. Create a conda environment with Python 3.9.7 version:
  4. conda env create -f environment.yml
  5. Activate the environment:
  6. conda activate cellvit_env
  7. Install torch (version 2.0) for your system:
  8. Refer to PyTorch Installation Guide for the appropriate version.

  9. Install optional dependencies for performance optimizations:
  10. pip install -r optional_dependencies.txt

How to Use CellViT

Once you have installed CellViT, you can start utilizing its functionalities for training and inference. Here’s how:

Project Structure

The project is organized as follows:

  • cell_segmentation: For training and inference files
  • datasets: Contains datasets for PyTorch
  • configs: Configuration and example files
  • models: Machine Learning models and encoders

Training the Model

Use the command line interface (CLI) to train the CellViT model:

python3 cell_segmentation/run_cellvit.py --config 

Replace with your configurations to start the training process.

Dataset Preparation

It is crucial to follow the customized dataset structures as described in the PanNuke documentation.

Running Inference

Run inference on cell detection using the appropriate command:

python3 cell_segmentation/inference/cell_detection.py --model  --wsi_path 

Visualization

You can visualize the results using tools like QuPath.

Troubleshooting

If you encounter issues during setup or usage:

  • Error: cannot import name CuImage from cucim: Uninstall the previous version with pip uninstall cupy-cuda117 and use conda to install.
  • Error resolving packages: Comment out problematic packages in your environment.yml file as stated in the documentation.
  • Pydantic Validation Errors: Install the specified version with pip install pydantic==1.10.4.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox