InstanSeg

Fast, accurate and portable cell and nucleus segmentation for microscopy images

PyPI Downloads License

InstanSeg is a PyTorch-based instance segmentation pipeline for brightfield and fluorescence microscopy. It segments nuclei and whole cells, and works on multiplexed images with any number of channels.

from instanseg import InstanSeg

instanseg = InstanSeg("brightfield_nuclei")
labels = instanseg.eval("HE_example.tif", save_output=True, save_overlay=True)
Installation

Install InstanSeg from PyPI, with optional extras for extra image formats, GPU support and training.

Installation
Quickstart

Segment your first image in a few lines of Python.

Quickstart
Running inference

Pretrained models, pixel sizes, large and whole slide images, saving results and the command line.

Running inference
API reference

Full reference for the InstanSeg class and utility functions.

API reference

Why InstanSeg?

  • Free and open source, released under the Apache 2.0 license.

  • Fast: often much faster than other cell segmentation methods.

  • Nuclei and whole cells: accurately segments both, in a single model.

  • Channel invariant: runs on multiplexed images with new biomarker panels, without retraining or manual intervention.

  • Portable: the whole model, including postprocessing, compiles to TorchScript. It runs with LibTorch alone, which is how InstanSeg runs directly inside QuPath.

How it works

Overview of the InstanSeg architecture

Overview of the InstanSeg pipeline. See the papers for details.