KatoLens v1.0
Open Kato-Katz helminth-egg detector: 5-seed YOLO11s ensemble · OpenVINO CPU inference · frozen benchmark · honest safety analysis.
⚠️ RESEARCH USE ONLY — NOT A MEDICAL DEVICE — NOT FOR DIAGNOSIS
KatoLens must not be used for diagnosis, treatment, or mass-drug-administration decisions, and has no clinical validation. It has no "other species" class: 54.5 % (95 % CI 47.6–61.3) of non-target eggs (Taenia, Fasciola) in our held-out test were reported as S. mansoni. A positive S. mansoni count is never a confirmed infection. Egg-free fields still produce false positives. See Limitations.
🧪 Try it: python app.py (local Gradio demo; a hosted Space is not available yet) · 📄 White paper: paper/katolens_whitepaper.pdf · 🏷️ Version: v1.0 (git tag v1.0)
Model summary
| Property | Value |
|---|---|
| Model | KatoLens v1.0 — 5 × YOLO11s (COCO init), weighted-box fusion (IoU 0.55) + rot180 test-time augmentation |
| Task | Detect and classify helminth eggs in single Kato-Katz field-of-view images |
| Classes | Ascaris lumbricoides, Trichuris trichiura, hookworm, Schistosoma mansoni (4; no "other") |
| Input scale | Resampled to 1.0 µm/px, 640 px tiles, 240 px overlap (pixel size must be known) |
| Outputs | Boxes, per-species counts, EPG (eggs × 24 for the 41.7 mg template), WHO intensity class |
| Parameters | ≈ 9.4 M per member (5 members) · weights 19 MB each (.pt) · OpenVINO FP32 export |
| Speed | ≈ 1.5–4 s per 1280×720 field on a modern server CPU with TTA (5 models × 2 passes); 5–30 s on laptops |
| Training cost | US$1.93 of rented RTX 4090 time for all five members |
| Licence | CC BY-NC-SA 4.0 (weights and card). Code depends on Ultralytics (AGPL-3.0). See NOTICE.md |
| Author | Ahmad Sandid (independent) · ahmadsandid.com · questions/issues: Community tab of this repo |
Quick start
git lfs install
git clone https://huggingface.co/ahmadaccino/katolens && cd katolens
python -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
# one or several fields of ONE smear (counts are summed; EPG = total eggs x 24)
python -m katolens --models openvino --um-per-px 0.93 examples/p3_ascaris.jpg --out out/
from PIL import Image
from katolens import KatoLens, annotate, summarize
kl = KatoLens("openvino") # 5 OpenVINO FP32 models (CPU). backend="torch" + "weights" for the .pt files
im = Image.open("examples/p3_s_mansoni_good.jpg")
det = kl.detect(im, um_per_px=0.93) # boxes (input pixels), scores, classes 0..3, operating-point thresholds applied
print(summarize([det])) # counts, EPG, WHO class per species
annotate(im, det).save("pred.png")
Gradio demo (local): pip install -r requirements-app.txt && python app.py.
Pixel size matters. Images are rescaled to 1.0 µm/px, so pass --um-per-px for your scanner. Known sizes are looked up automatically (1280×720 → 0.93 µm/px, 1640×1232 → 0.262, 2028×1520 → 0.62). An unknown size without a value is assumed to be 1.0 µm/px and the output is unreliable.
EPG caveat. One field covers ≈ 0.8 mm² of a ≈ 400 mm² smear (our assumption); EPG and WHO class are only meaningful if the fields you pass cover the whole smear.
Intended use
Direct uses (research): benchmarking automated Kato-Katz reading; annotation triage; method comparison; teaching about detector failure modes.
Out of scope: any clinical, diagnostic, treatment, screening or MDA decision; patient-level reporting; species identification of eggs outside the four classes; images from scanners or stains not validated (the external-scanner score is lower and highly uncertain); wet-mount or concentration-technique images (not Kato-Katz); commercial use.
Evaluation
Protocol (details in the white paper): PEDB-v1 is a frozen test benchmark whose manifest and image hashes are locked; it was scored once for this release. The primary endpoint (macro AP50 over four classes, IoU 0.5) and the gates were fixed before results. CIs are 95 % cluster-bootstrap over slides (B = 1000). Operating points are fixed (katolens/operating_point.json); they were not tuned on the test set.
Headline (3,503 fields, 160 slide units; AP50 %)
| Model | macro AP50 [95% CI] | A. lumb. | T. trich. | Hookworm | S. mansoni | FP / 1000 egg-free fields (mean of 4) |
|---|---|---|---|---|---|---|
| single model (mean of 5 seeds) | 94.3 | 97.3 | 96.0 | 93.9 | 89.9 | 54 |
| 5-seed ensemble | 95.9 [93.8, 96.9] | 97.9 | 96.8 | 95.7 | 93.0 | 42 |
| KatoLens (ensemble + rot180) | 96.0 [94.1, 97.0] | 98.0 | 96.7 | 96.0 | 93.2 | 41 |
Hookworm has only 143 test eggs from few scans (CI ≈ ±4.5 pt). Full tables, PR curves and per-scope results: white paper and results/katolens_v1_metrics.json.
| Scope (macro AP50 %) | KatoLens |
|---|---|
| P3.0 fold 4 (slide-disjoint; closest to published P3.0 setups) | 96.4 |
| Higgins bright-field | 95.0 |
| Unseen device (Raspberry-Pi microscope) | 96.3 |
| External scanner (UFMG, 66 images, S. mansoni only) | 90.5 [80.4, 99.3] |
What actually drives the gain (controlled, paired, headline tier)
- Ensemble of 5 seeds vs a single seed: +1.36 pt [0.89, 1.87]. rot180 TTA on top of the ensemble: +0.11 [−0.01, 0.34]. Full-data models vs the 5 CV-fold ensemble: +0.36 [−0.13, 0.88].
- On the development benchmark the ensemble idea gave +1.11 pt [0.80, 1.59] and did not meet our pre-registered +2.0 pt gate; this release is a "best shippable build", not a gate pass.
- The +1.43 pt over our previous internal build bundles a resolution change, more data and ensembling — not a controlled ablation.
Comparison with the literature
Ward et al. (2026, PLOS NTD) report 5-fold CV AP of 97.1 / 94.8 / 91.4 / 89.2 (Asc / Tri / Hook / Sm) for their platform. On P3.0 fold 4 we measure 98.3 / 97.1 / 96.0 / 94.1, but the settings are not comparable (one split vs a 5-fold mean, extra training data, an ensemble with TTA, different operating-point selection). We make no state-of-the-art claim.
Limitations and risks
- Non-target species → S. mansoni. No "other" class; 54.5 % [47.6, 61.3] of 244 Taenia/Fasciola eggs were reported as S. mansoni (no better than development models, 52–53 %). Wrong species implies wrong drug.
- False positives on egg-free fields: about 77 / 49 / 1 / 36 per 1,000 egg-free fields (Asc / Tri / Hook / Sm; headline tier); about 90 per 1,000 (all classes) on 22 held-out egg-free slides, concentrated in a few slides (debris, plant material; some may be unlabelled eggs).
- Out-of-distribution hookworm scans: blurry or strongly colour-cast scans can have hookworm eggs called A. lumbricoides (two scans cost 1.8 pt of development macro AP50). Only ≈ 410 hookworm eggs were used in training, all from one scanner family.
- Domain: trained on AI4NTD P3.0, Higgins bright-field and small extras. Other scanners/stains are unvalidated; the external score is lower (90.5 %) and uncertain.
- No patient-level validation: not validated for whole-smear EPG calibration, low-intensity infection, or any field decision. No comparison with human readers was made.
- Label noise in public data (e.g., unlabelled eggs in "egg-free" fields) affects both training and measured FP rates. Some Higgins slide identifiers were only partly recoverable, so slide leakage within that source cannot be fully excluded (test integrity is enforced by file hash).
- Licensing uncertainty about training data without a stated licence (see below). No legal review.
Negative results (so you don't repeat them)
Per-slide scale correction, extra data from wet-mount Chula-ParasiteEgg-11 (0 % hookworm transfer), post-processing grids (≤ +0.4 pt), test-time colour normalisation, YOLO11m instead of 11s (−0.3 pt), longer schedule (≤ +0.5 pt predicted), more seeds (saturates ≈ +1.7 pt). Details in the paper.
Training data
Trained on 15,977 fields of view (37,460 / 5,956 / 410 / 2,918 boxes of Asc / Tri / Hook / Sm). No dataset images or labels are redistributed here.
| Source | Fields | Role | Licence found |
|---|---|---|---|
| AI4NTD KK2.0 P3.0 (Ward et al., Kaggle) | 7,308 | train (scan groups 0–3) | CC BY-SA 4.0 |
| Higgins Helminth Image Dataset (Univ. of Glasgow) | 6,903 | train (bright-field incl. egg-free fields) | none stated (Kaggle "Unknown") |
| LIDS schistossoma-eggs | 1,151 | train (S. mansoni, empty fields) | none stated |
| ParasitoBank | 615 | train (negatives) | CC BY 4.0 |
Evaluation-only: AI4NTD P1.5 v2 + OOD (CC BY-NC-SA 4.0), UFMG KK (CC BY 4.0), Zenodo STH/SCH set (CC BY 4.0). Full list, DOIs and caveats: NOTICE.md.
Training procedure
YOLO11s (Ultralytics 8.4.219), COCO init, 16 epochs, batch 16, microscopy augmentation pipeline (albumentations 2.0.8: dihedral flips/90° rotations, blur, illumination, colour-temperature, noise, JPEG jitter) plus Ultralytics mosaic/flips/±25 % zoom/HSV jitter, last checkpoint, five seeds on all development data. Tiles 640 px / overlap 240 px at 1.0 µm/px. One seed was resumed from a checkpoint after a CUDA out-of-memory event (same recipe). Operating points = mean of per-class max-F1 thresholds chosen on the validation split of each of five cross-validation fold ensembles (the release models have no clean validation split).
Files
README.md LICENSE NOTICE.md config.json requirements.txt requirements-app.txt
app.py Gradio demo
katolens/ inference package (python -m katolens) + operating_point.json
weights/katolens_v1_s{0-4}.pt PyTorch checkpoints
openvino/katolens_v1_s{0-4}_openvino_model/ OpenVINO FP32 exports (CPU inference)
examples/ 7 attributed example fields (+ ATTRIBUTION.md)
results/katolens_v1_metrics.json frozen-benchmark metrics with CIs
paper/katolens_whitepaper.pdf white paper
export_openvino.py
Integrity (sha256 of the published .pt files)
028b84a490f625c1da7d3c2c6c56492cac18a15b99eb00fe0aa2d1e0f8e9da18 weights/katolens_v1_s0.pt
858decf76506ef1c145cd26b5b69bd534575b28a2f3022f5dd74c38fe26da4f4 weights/katolens_v1_s1.pt
170a97b378ec7cd0844c9267eff6036a60b7db0da4a9703afad2b5c1815fd6f4 weights/katolens_v1_s2.pt
aa6449e416973d42b7431b98b5e9bf9c0513ad6771fedaac5bc35d89fce4c689 weights/katolens_v1_s3.pt
395c639dd4e629abd9a67e55ecac788111b686d9be36ce209c1bafa7f6ee6728 weights/katolens_v1_s4.pt
These are the benchmarked training checkpoints (last.pt, seeds 0-4) re-saved without training-time objects (augmentation pipeline, data paths) so they load with a plain pip install ultralytics; the weights are unchanged and the outputs match the benchmarked checkpoints (verified: identical detections and scores to 3 decimals).
Original training-checkpoint hashes (kept privately, for traceability): d7232638...45dd, f71a9163...93a8, f0395dcd...5e84, 3eca0171...f2c7, d35eacc2...2038.
Versioning
- v1.0 (2026-11-27): first release. The
v1.0git tag is immutable; later improvements will be taggedv1.x/v2.0and described here. Benchmark: PEDB-v1 (frozen). Any change to the benchmark is a new benchmark version, never an edit.
Citation
@misc{sandid2026katolens,
author = {Sandid, Ahmad},
title = {{KatoLens} v1.0: an open ensemble detector for helminth eggs in {Kato-Katz} images, with a frozen benchmark, pre-registered gates, and a safety analysis},
year = {2026},
howpublished = {Hugging Face model repository},
url = {https://huggingface.co/ahmadaccino/katolens},
note = {Research use only. arXiv link to be added.}
}
Please also cite the data sources you rely on: Ward et al. 2022 (doi:10.1371/journal.pntd.0010500), Mohammed et al. 2025 (doi:10.1371/journal.pntd.0013234), Ward et al. 2026 (doi:10.1371/journal.pntd.0013432), and the Ultralytics framework.
Acknowledgements
The AI4NTD group, the Schistoscope team, O. Higgins, the UFMG, LIDS-UNICAMP and ParasitoBank authors, and Ultralytics.