Skip to content
/ LKCell Public

[arXiv '24] Efficient Cell Nuclei Instance Segmentation with Large Convolution Kernels

License

Notifications You must be signed in to change notification settings

hustvl/LKCell

Repository files navigation

LKCell🔬

Efficient Cell Nuclei Instance Segmentation with Large Convolution Kernels

Paper Python 3.9.7 license authors HuggingFace

PWC

Ziwei Cui 1*, Jingfeng Yao 1*, Lunbin Zeng 1, Juan Yang 2, Wenyu Liu 1, Xinggang Wang 1,📧

1 School of Electronic Information and Communications, Huazhong University of Science and Technology
2 Department of Cardiology, Huanggang Central Hospital

(* equal contribution, 📧 corresponding author)

Key FeaturesInstallationUsageTrainingInferenceCitation


Key Features

Click and try LKCell on our 🤗 Hugging Face Space!

This repository contains the code implementation of LKCell, a deep learning-based method for automated instance segmentation of cell nuclei in digitized tissue samples. LKCell utilizes an architecture based on large convolutional kernels and achieves state-of-the-art performance on the PanNuke dataset, a challenging nuclei instance segmentation benchmark.

Installation

git clone https://github.com/hustvl/LKCell.git
conda create -n lkcell
conda activate lkcell
pip install -r requirements.txt

Note: (1) preferred torch version is 2.0; (2) If you find problem in installing depthwise-conv2d-implicit-gemm==0.0.0 , please follow the instruction in here.

Project Structure

We are currently using the following folder structure:

├── base_ml               # Basic Machine Learning Code: Trainer, Experiment, ...
├── cell_segmentation     # Cell Segmentation training and inference files
│   ├── datasets          # Datasets (PyTorch)
│   ├── experiments       # Specific Experiment Code for different experiments
│   ├── inference         # Inference code for experiment statistics and plots
│   ├── trainer           # Trainer functions to train networks
│   ├── utils             # Utils code
│   └── run_cellvit.py    # Run file to start an experiment
├── config                # Python configuration file for global Python settings            
├── docs                  # Documentation files (in addition to this main README.md
├── models                # Machine Learning Models (PyTorch implementations)
│   └── segmentation      # LKCell Code
├── datamodel             # Code of dataclass :Graph Data , WSI object , ...
├── preprocessing         # Code of preprocessing : Encoding , Patch Extraction , ...

Training

Dataset preparation

We use a customized dataset structure for the PanNuke and the MoNuSeg dataset. The dataset structures are explained in pannuke.md and monuseg.md documentation files. We also provide preparation scripts in the cell_segmentation/datasets/ folder.

Training script

The CLI for a ML-experiment to train the LKCell-Network is as follows (here the run_cellvit.py script is used):

usage: run_cellvit.py [-h] --config CONFIG [--gpu GPU] [--sweep | --agent AGENT | --checkpoint CHECKPOINT]
Start an experiment with given configuration file.

python ./cell_segmentation/run_cellvit.py  --config ./config.yaml

The important file is the configuration file, in which all paths are set, the model configuration is given and the hyperparameters or sweeps are defined.

Pre-trained UnirepLKNet models for training initialization can be downloaded from Google Drive: UnirepLKNet-Models.

Evaluation

In our paper, we did not (!) use early stopping, but rather train all models for 100 to eliminate selection bias but have the largest possible database for training. Therefore, evaluation neeeds to be performed with the latest_checkpoint.pth model and not the best early stopping model. We provide a script to create evaluation results: inference_cellvit_experiment.py for PanNuke and inference_cellvit_monuseg.py for MoNuSeg.

Inference

Model checkpoints can be downloaded here, You can choose to download from Google Drive or HuggingFace :

You can click 🤗 Hugging Face Space to quickly perform model inference.

Acknowledgement

This project is built upon CellViT and UniRepLKNet. Thanks for these awesome repos!

Citation

@misc{cui2024lkcellefficientcellnuclei,
      title={LKCell: Efficient Cell Nuclei Instance Segmentation with Large Convolution Kernels}, 
      author={Ziwei Cui and Jingfeng Yao and Lunbin Zeng and Juan Yang and Wenyu Liu and Xinggang Wang},
      year={2024},
      eprint={2407.18054},
      archivePrefix={arXiv},
      primaryClass={eess.IV},
      url={https://arxiv.org/abs/2407.18054}, 
}

About

[arXiv '24] Efficient Cell Nuclei Instance Segmentation with Large Convolution Kernels

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages