Digital pathology research toolkit

See how TB AFB candidate detection works

Use the simulated microscopy field below to see how a confidence threshold changes which candidate boxes are displayed.

Research use only. The demo uses simulated detections. Run the Python application locally to review your own images.

Try the detection demo

Set a confidence threshold and run the demo to see which simulated detections are retained.

Controls

Synthetic Ziehl-Neelsen fieldReady
Retained candidates0
Highest score—
Threshold0.60
OutputExpert review
1
Load imageMicroscopy field selected
2
Tile fieldRegions prepared for inference
3
Detect candidatesIllustrative scores generated
4
Post-processThreshold + overlap filtering
5
ReviewCandidate boxes presented

Implementation workflow

How the repository processes images

The website mirrors the actual code paths without pretending that GitHub Pages can execute the server-side model.

01

Image / WSI loading

Raster images use OpenCV. Supported whole-slide formats use OpenSlide for level-aware access.

data/wsi_loader.py
02

Tiling

Large slides are divided into bounded tiles so inference can run at manageable spatial and memory scales.

01_extract_tiles.py
03

Candidate detection

An AFB-trained YOLO checkpoint can score candidate bacilli. The local web app labels heuristic fallback explicitly.

models/yolo_detector.py
04

Post-processing

Detections are filtered by confidence, class, morphology, and overlap before being translated to slide coordinates.

inference/postprocessor.py
05

Human review

Candidate boxes remain research outputs for expert review, annotation, correction, and downstream validation.

static/annotate.html

Architecture

Running the toolkit locally

GitHub Pages hosts this static demonstration because it is HTML, CSS, JavaScript, and Canvas only. The actual detection application stays local/server-side because it depends on PyTorch, Ultralytics, native OpenSlide libraries, model checkpoints, local files, and potentially very large WSIs.

See the repository README for installation and example commands.

Public websiteGitHub PagesInteractive explanation, synthetic demonstration, architecture, limitations
↓
Local applicationFastAPI + browser UIRaster upload, annotation, reporting, WSI tile serving
↓
Research computePyTorch + Ultralytics + OpenSlideTraining, model inference, WSI traversal, candidate post-processing

Validation boundary

Candidate detection is not a TB diagnosis

The repository intentionally separates model-generated candidates from smear grading. Candidate counts are not automatically converted into a WHO/IUATLD grade. The grading utility is intended for confirmed microscopy counts with an appropriate examined-field protocol.

Local setup

Install the research toolkit

For annotation and training, install the local toolkit. To try a ready-to-run AFB checkpoint, visit the Pretrained AFB Detection Model.

Open repository