HMH-1-Cell: 20-class single-cell classifier + cell detector
Two-stage ONNX pipeline for microscopy images:
- Detector
detector_yolo11s_seg.onnxβ YOLO11s-seg, 640Γ640 input, finds cells (one classcell). - Classifier
model.onnxβ ResNet18, 128Γ128 input, predicts one of 20 cell types.
Everything runs on CPU with onnxruntime; no PyTorch required.
Classes (20)
| Group | Classes |
|---|---|
| Cell lines (8) | A172, BT474, BV2, Huh7, MCF7, SHSY5Y, SKOV3, SkBr3 |
| Blood (8) | basophil, eosinophil, erythroblast, immature granulocyte, lymphocyte, monocyte, neutrophil, platelet |
| Immune (2) | T cell, NK cell |
| Malaria (2) | parasitized RBC, uninfected RBC |
Chinese names and domain labels are in classes.json.
Metrics
Classifier, held-out test set (29,668 images):
| Metric | Value |
|---|---|
| top-1 | 94.04% |
| top-5 | 99.56% |
| blood domain | 99.01% |
| malaria domain | 96.88% |
| cell-line domain | 93.93% |
| immune domain (T/NK) | 82.75% |
Detector, LIVECell test images (2,568 GT boxes, conf 0.25): recall 0.813, precision 0.781, F1 0.797.
Training curves and confusion matrix are in the project repository (not uploaded here).
Usage
import json, numpy as np, onnxruntime as ort
from PIL import Image
cls = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
meta = json.load(open("classes.json", encoding="utf-8"))
classes = meta["classes"]
im = Image.open("sample_cell.jpg").convert("RGB").resize((128, 128))
x = np.asarray(im, dtype=np.float32) / 255.0
x = x.transpose(2, 0, 1)[None]
x = (x - np.array([0.485, 0.456, 0.406])[None, :, None, None]) / np.array([0.229, 0.224, 0.225])[None, :, None, None]
logits = cls.run(None, {cls.get_inputs()[0].name: x})[0][0]
prob = np.exp(logits - logits.max()) / np.exp(logits - logits.max()).sum()
k = int(prob.argmax())
print(classes[k]["name_cn"], float(prob[k]))
For full images (detect β crop β classify), see inference_example.py.
Calibration note: the shipped app marks predictions with max_prob < 0.45 as "unknown" instead of forcing a class.
Training data
| Dataset | Used for | License |
|---|---|---|
| LIVECell | 8 cell lines, detector training | CC BY-NC 4.0 |
| BloodMNIST (MedMNIST v2) | 8 blood cell types | CC BY 4.0 |
| Deepcell brightfield immune cells | T cells, NK cells | CC BY 4.0 |
| Malaria Cell Images (NIH/Kaggle, dpdl mirror) | parasitized / uninfected RBC | CC BY 4.0 |
| BBBC038, BBBC039 | detector training | CC0 |
Limitations
- Trained on phase-contrast / brightfield microscopy; fluorescence and stained histology will degrade.
- Closed set: cells outside the 20 classes are forced to the nearest class (the app uses a 0.45 confidence threshold to reject).
- HeLa is not included: the HeLa images available were fluorescence nuclei, which do not transfer to phase-contrast HeLa.
- T vs NK is the weakest pair (~17% mutual confusion).
- Detection precision ~0.78 on dense fields; very large images (>2000 px) use tiled inference.
License
CC BY-NC 4.0 β non-commercial use only, because the 8 cell-line classes derive from LIVECell (CC BY-NC 4.0). Attribution required.
Citation
If you use this model, please cite the underlying datasets:
- Edlund et al., LIVECell β A large-scale dataset for label-free live cell segmentation, Nature Methods 2021.
- Yang et al., MedMNIST v2, Scientific Data 2023.
- Deepcell brightfield immune cells, Allen Institute.
- Rajaraman et al., Performance evaluation of deep neural ensembles toward malaria parasite detection, PeerJ 2019.