Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
November 15, 2023 17:28
June 5, 2023 12:13
November 15, 2023 14:28
July 13, 2023 14:09
November 15, 2023 17:53
August 20, 2023 18:30
November 14, 2023 17:46
April 15, 2021 11:18
March 18, 2021 17:20
August 18, 2021 07:05
August 26, 2023 16:45
August 31, 2023 15:49
March 21, 2023 20:06

Cell Detection

Downloads Test PyPI Documentation Status DOI

⭐ Showcase

NeurIPS 22 Cell Segmentation Competition


Nuclei of U2OS cells in a chemical screen

bbbc039 (CC0)

P. vivax (malaria) infected human blood

bbbc041 (CC BY-NC-SA 3.0)

πŸ›  Install

Make sure you have PyTorch installed.


pip install -U celldetection


pip install git+

πŸ’Ύ Trained models

model = cd.fetch_model(model_name, check_hash=True)
model name training data link
ginoro_CpnResNeXt101UNet-fbe875f1a3e5ce2c BBBC039, BBBC038, Omnipose, Cellpose, Sartorius - Cell Instance Segmentation, Livecell, NeurIPS 22 CellSeg Challenge πŸ”—
Run a demo with a pretrained model
import torch, cv2, celldetection as cd
from import coins
from matplotlib import pyplot as plt

# Load pretrained model
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = cd.fetch_model('ginoro_CpnResNeXt101UNet-fbe875f1a3e5ce2c', check_hash=True).to(device)

# Load input
img = coins()
img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
print(img.dtype, img.shape, (img.min(), img.max()))

# Run model
with torch.no_grad():
    x = cd.to_tensor(img, transpose=True, device=device, dtype=torch.float32)
    x = x / 255  # ensure 0..1 range
    x = x[None]  # add batch dimension: Tensor[3, h, w] -> Tensor[1, 3, h, w]
    y = model(x)

# Show results for each batch item
contours = y['contours']
for n in range(len(x)):
    cd.imshow_row(x[n], x[n], figsize=(16, 9), titles=('input', 'contours'))

πŸ”¬ Architectures

import celldetection as cd
Contour Proposal Networks
PyTorch Image Models (timm)

Also have a look at Timm Documentation.

import timm

timm.list_models(filter='*')  # explore available models
Segmentation Models PyTorch (smp)
import segmentation_models_pytorch as smp

smp.encoders.get_encoder_names()  # explore available models
encoder = cd.models.SmpEncoder(encoder_name='mit_b5', pretrained='imagenet')

Find a list of Smp Encoders in the smp documentation.

# U-Nets are available in 2D and 3D
import celldetection as cd

model = cd.models.ResNeXt50UNet(in_channels=3, out_channels=1, nd=3)
# Many MA-Nets are available in 2D and 3D
import celldetection as cd

encoder = cd.models.ConvNeXtSmall(in_channels=3, nd=3)
model = cd.models.MaNet(encoder, out_channels=1, nd=3)
Feature Pyramid Networks
ConvNeXt Networks
# ConvNeXt Networks are available in 2D and 3D
import celldetection as cd

model = cd.models.ConvNeXtSmall(in_channels=3, nd=3)
Residual Networks
# Residual Networks are available in 2D and 3D
import celldetection as cd

model = cd.models.ResNet50(in_channels=3, nd=3)
Mobile Networks

🐳 Docker

Find us on Docker Hub:

You can pull the latest version of celldetection via:

docker pull ericup/celldetection:latest
CPN inference via Docker with GPU
docker run --rm \
  -v $PWD/docker/outputs:/outputs/ \
  -v $PWD/docker/inputs/:/inputs/ \
  -v $PWD/docker/models/:/models/ \
  --gpus="device=0" \
  celldetection:latest /bin/bash -c \
  "python --tile_size=1024 --stride=768 --precision=32-true"
CPN inference via Docker with CPU
docker run --rm \
  -v $PWD/docker/outputs:/outputs/ \
  -v $PWD/docker/inputs/:/inputs/ \
  -v $PWD/docker/models/:/models/ \
  celldetection:latest /bin/bash -c \
  "python --tile_size=1024 --stride=768 --precision=32-true --accelerator=cpu"


You can also pull our Docker images for the use with Apptainer (formerly Singularity) with this command:

apptainer pull --dir . --disable-cache docker://ericup/celldetection:latest

πŸ€— Hugging Face Spaces

Find us on Hugging Face and upload your own images for segmentation:

Hugging Face API


import requests

response ="", json={
    "data": [

data = response["data"]


const response = await fetch("", {
    method: "POST",
    headers: {"Content-Type": "application/json"},
    body: JSON.stringify({
        data: [

const data = await response.json();

πŸ§‘β€πŸ’» Napari Plugin

Find our Napari Plugin here:
Find out more about Napari here: bbbc039 You can install it via pip:

pip install git+

πŸ† Awards

πŸ“ Citing

If you find this work useful, please consider giving a star ⭐️ and citation:

    title = {Contour proposal networks for biomedical instance segmentation},
    journal = {Medical Image Analysis},
    volume = {77},
    pages = {102371},
    year = {2022},
    issn = {1361-8415},
    doi = {},
    url = {},
    author = {Eric Upschulte and Stefan Harmeling and Katrin Amunts and Timo Dickscheid},
    keywords = {Cell detection, Cell segmentation, Object detection, CPN},

πŸ”— Links

πŸ§‘β€πŸ”¬ Thanks!

Stargazers repo roster for @FZJ-INM1-BDA/celldetection Forkers repo roster for @FZJ-INM1-BDA/celldetection