CellPilot / SAMHI /README.md
philippendres's picture
Upload folder using huggingface_hub
907462b verified
|
Raw
History Blame Contribute Delete
3.44 kB

A newer version of the Gradio SDK is available: 6.20.0

Upgrade

SAMHI

This repository contains the code of SAMHI, a deep learning-based method for the automatic and interactive segmentation of cells and glands in histological images. SAMHI uses SAM and CellViT and is fine-tuned on large-scale segmentation datasets of histological images. Model

Key Features

  • Automatic Segmentation: SAMHI allows users to automatically segment cells in histological images.
  • Interactive Segmentation: SAMHI allows users to interactively segment cells and glands in histological images.

Setup

  1. Clone the repository with: git clone https://github.com/philippendres/SAMHI.git
  2. Create a new conda environment with the provided environment.yml file:
    conda env create -f environment.yml
    conda activate histo3.10
    
  3. Install the resources:
    cd resources
    cd CellViT
    git submodule init
    git submodule update
    pip install -e .
    cd ..
    cd SimpleClick
    git submodule init
    git submodule update
    pip install -e .
    cd ..
    cd ..
    
  4. Install our package:
    pip install -e .
    
    • For inference: Download the weights of the SAMHI model and the CellViT model: SAMHI, CellViT
    • For training: Download the weights of the SAM model: SAM
    • For model comparisons: Download the weights of the SimpleClick and the MedSAM model: SimpleClick, MedSAM

Usage

App

Run the gradio webapplication with the following command:

python app.py --model_dir <model_dir> --model_name <model_name> --cellvit_model <cellvit_model>

The app has the following arguments:

  • model_dir: The directory where the SAMHI and the CellViT model are stored.
  • model_name: The name of the SAMHI model.
  • cellvit_model: The name of the CellViT model.

The command above will generate a link to a webapplication where you can upload your own images and segment them with SAMHI. The app will look like this: App The app has the following features:

  • Upload Image: Upload your own image to segment in the upper left corner.
  • Auto Segment: Automatically segment the uploaded image with SAMHI.
  • Add Mask: Interactively add a mask with SAMHI by drawing points and bounding boxes on the image.
  • Refine Mask: Refine an existing mask by drawing points and bounding boxes on the image.
  • Remove Mask: Remove an existing mask by clicking on it.
  • Move the Image: Move the image with the arrow symbols.
  • Zoom the Image: Zoom the image with the zoom bar.