CoolFace
Modelpublic

einarolafsson/cross-channel-nuclei-from-cellmask-cpsam

sourceHugging Facemitupdated 9d agoView on Hugging Face
0likes
Model Card

Cross-channel nuclei-from-cellmask (Cellpose-SAM)

Segments nuclei from the host cell mask channel alone — no nuclear stain required. A cross-channel model: it is given the cell image and predicts where the nuclei are, freeing the DAPI/Hoechst channel for another marker.

  • —Architecture: Cellpose-SAM (cpsam_v2)
  • —Model Zoo key: nuclei_from_cellmask_v1
  • —Checkpoint: nuclei_from_cellmask
  • —Trained by: einarolafsson

Use it in spaCR

This model is distributed through the spaCR Model Zoo. spaCR is an open-source package for spatial phenotype analysis of CRISPR screens and microscopy images.

bash
pip install spacr

Model Zoo (GUI)

Launch the GUI and open the Model Zoo:

bash
spacr

Find Cross-channel nuclei-from-cellmask (Cellpose-SAM) in the model list and press Download. The Model Zoo verifies the checkpoint's SHA-256 after download, so a truncated or substituted file is rejected rather than silently used.

Model Zoo (Python)

python
from spacr import model_zoo

entry = next(e for e in model_zoo.catalogue() if e.key == "nuclei_from_cellmask_v1")
path  = model_zoo.install(entry, dest="~/spacr_models")
print(path)   # verified local checkpoint

Mask generation

Point spaCR's mask generation at the downloaded checkpoint:

python
from spacr.core import preprocess_generate_masks

settings = {
    "src": "/path/to/images",
    "nucleus": "cellpose",
    "nucleus_model": str(path),     # the checkpoint fetched above
    "nucleus_diameter": 20,
}
preprocess_generate_masks(settings)

In the GUI the same thing is under Make masks — choose the downloaded model in the Cellpose model field for the relevant object.

API: :func:spacr.core.preprocess_generate_masks, :func:spacr.spacr_cellpose.generate_masks_from_imgs

Performance

modeltraintrain obj.testtest obj.CVF1 @ IoU 0.5AJIDicefinal train lossfinal val lossval - trainbest epoch
stock cpsam_v2 (no fine-tuning)——45342487—0.20090.28560.4493————
this model—not recorded45342487no (single well-grouped split)0.88810.79160.8774———best / 100

Scored on a well-grouped held-out split — no well appears in both train and test.

Per host cell line:

hostnF1AJI
HFF1570.93230.7462
HeLa1470.85960.8799
THP11490.86100.7524

Objects are reference (ground-truth) objects. Training-set object counts and the per-epoch history were not preserved for this run, so the loss columns and training curves are unavailable.

Training data

Well-grouped split shared with the other cross-channel models, so no well leaks across train and test. 100 epochs from stock cpsam_v2, AdamW, lr 1e-5, weight decay 0.1.

Environment

cellpose (training)4.2.1.1
cellpose (scoring)4.0.9
GPUNVIDIA GeForce RTX 3090 Ti
base weightscpsam_v2

Files in this repository

pathwhat
checkpoints/nuclei_from_cellmaskdata
checkpoints/nuclei_from_cellmask_epoch_0010data
checkpoints/nuclei_from_cellmask_epoch_0020data
checkpoints/nuclei_from_cellmask_epoch_0030data
checkpoints/nuclei_from_cellmask_epoch_0040data
checkpoints/nuclei_from_cellmask_epoch_0050data
checkpoints/nuclei_from_cellmask_epoch_0060data
checkpoints/nuclei_from_cellmask_epoch_0070data
checkpoints/nuclei_from_cellmask_epoch_0080data
checkpoints/nuclei_from_cellmask_epoch_0090data
qc/best_matched_ious.csvdata
qc/best_perimage.csvdata
qc/best_perimage_periou.csvdata
qc/best_periou.csvdata
qc/best_summary.jsondata
qc/comparison_vs_stock.csvdata
qc/final_matched_ious.csvdata
qc/final_perimage.csvdata
qc/final_perimage_periou.csvdata
qc/final_periou.csvdata
qc/final_summary.jsondata
qc/stock_cpsam_v2_matched_ious.csvdata
qc/stock_cpsam_v2_perimage.csvdata
qc/stock_cpsam_v2_perimage_periou.csvdata
qc/stock_cpsam_v2_periou.csvdata
qc/stock_cpsam_v2_summary.jsondata
training/best_perimage.csvtraining metrics
training/loss_per_epoch.csvtraining metrics
training/metrics.csvtraining metrics
training/nuclei_from_cellmask_training_curves.pdftraining metrics
training/nuclei_from_cellmask_training_curves.pngtraining metrics
training/report.jsontraining metrics
training/scores/best_matched_ious.csvtraining metrics
training/scores/best_perimage.csvtraining metrics
training/scores/best_perimage_periou.csvtraining metrics
training/scores/best_periou.csvtraining metrics
training/scores/comparison_vs_stock.csvtraining metrics
training/scores/final_matched_ious.csvtraining metrics
training/scores/final_perimage.csvtraining metrics
training/scores/final_perimage_periou.csvtraining metrics
training/scores/final_periou.csvtraining metrics
training/scores/stock_cpsam_v2_matched_ious.csvtraining metrics
training/scores/stock_cpsam_v2_perimage.csvtraining metrics
training/scores/stock_cpsam_v2_perimage_periou.csvtraining metrics
training/scores/stock_cpsam_v2_periou.csvtraining metrics
weights/nuclei_from_cellmaskdata
weights/nuclei_from_cellmask_bestdata

Limitations

  • —The held-out split is used for checkpoint selection, so it is validation data rather than a fully independent test set.
  • —Targets are automatic reference labels rather than hand-drawn ground truth.
  • —Predicts nuclei positions from cell morphology — expect degraded accuracy on unusual or highly confluent morphologies.

Links

  • —spaCR on GitHub: https://github.com/EinarOlafsson/spacr
  • —Model Zoo API: spacr.model_zoo — catalogue(), install(), fetch(), verify()
  • —Mask generation API: spacr.core.preprocess_generate_masks
  • —Issues and questions: https://github.com/EinarOlafsson/spacr/issues