Toxoplasma PV v2 (round 5)
Segments Toxoplasma gondii parasitophorous vacuoles from a parasite stain (anti-Toxoplasma-biotin, or DsRed in the PV lumen). Round 5 — the current promoted PV model, superseding round 2 (Toxoplasma PV v1).
- Architecture: Cellpose-SAM (cpsam_v2)
- Model Zoo key:
toxoplasma_pv_v2
- Checkpoint:
cpsam_v2_toxo_r5
- 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.
pip install spacr
Model Zoo (GUI)
Launch the GUI and open the Model Zoo:
spacr
Find Toxoplasma PV v2 (round 5) 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)
from spacr import model_zoo
entry = next(e for e in model_zoo.catalogue() if e.key == "toxoplasma_pv_v2")
path = model_zoo.install(entry, dest="~/spacr_models")
print(path) # verified local checkpoint
Mask generation
Point spaCR's mask generation at the downloaded checkpoint:
from spacr.core import preprocess_generate_masks
settings = {
"src": "/path/to/images",
"pathogen": "cellpose",
"pathogen_model": str(path), # the checkpoint fetched above
"pathogen_diameter": 12,
}
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
| model |
train |
train obj. |
test |
test obj. |
CV |
F1 @ IoU 0.5 |
AJI |
Dice |
final train loss |
final val loss |
val - train |
best epoch |
| stock cpsam_v2 (no fine-tuning) |
— |
— |
11 |
— |
— |
0.7130 |
0.4260 |
— |
— |
— |
— |
— |
| this model (round 5) |
556 |
not recorded |
619 |
not recorded |
5-fold |
0.8170 ± 0.036 |
0.7144 ± 0.107 |
0.8024 ± 0.118 |
0.0424 |
not recorded |
— |
100 / 100 |
The CV column is the point of this model: scores are the mean ± SD over 5 cross-validation folds covering 619 curated pairs, not a single split, so the spread is a measured quantity rather than an assumption. The stock row is stock Cellpose-SAM on the 11 in-house held-out wells (evaluation/baseline_scores.csv).
| metric |
mean |
SD |
| f1 |
0.8170 |
0.0360 |
| precision |
0.8291 |
0.0528 |
| recall |
0.8091 |
0.0569 |
| aji |
0.7144 |
0.1069 |
| dice |
0.8024 |
0.1176 |
| mAP |
0.5562 |
0.0855 |
Cross-validation replaces a train/validation loss gap as the overfitting check: a model that had memorised its training data would not hold F1 0.817 ± 0.036 across five folds. Only training loss was recorded for this run, so there is no validation loss curve to plot.
Training data
556 curated training images of Toxoplasma tachyzoite parasitophorous vacuoles,
stained with goat anti-Toxoplasma-biotin or expressing DsRed in the PV lumen (RH and ME49),
accumulated over five rounds of curation. 100 epochs from stock cpsam_v2, AdamW,
lr 1e-5, weight decay 0.1. Cross-validation folds are in training/folds.csv.
Files in this repository
| path |
what |
cpsam_v2_toxo_r5 |
the checkpoint |
training/final_report.json |
run configuration and summary |
training/final_losses.csv |
per-epoch losses |
training/folds.csv |
the 5 cross-validation folds |
training/train.log |
full training log |
evaluation/cv_aggregate.json |
5-fold aggregate, overall and per dataset |
evaluation/cv_final_holdout.csv |
per-fold held-out scores |
evaluation/baseline_scores.csv |
scores against stock cpsam and earlier rounds |
Limitations
- Accuracy falls above IoU 0.8 — suited to counting and area rather than precise morphometry.
- Per-dataset variance is real: F1 ranges from ~0.74 to ~0.93 depending on the screen.
- Trained on RH and ME49 tachyzoites; other strains and bradyzoites are untested.
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