AI system for malaria detection from blood smear images
Implemented in Rust (Burn) with an Axum inference API and a Yew web UI.
This model predicts:
- Infected vs Uninfected (gating)
- Species: Falciparum, Malariae, Ovale, Vivax (plus an internal Uninfected class)
- Stage presence (multi-label): Ring (R), Trophozoite (T), Schizont (S), Gametocyte (G)
Stage labels are weak (image-level presence inferred from filename tokens) and are treated as presence probabilities.
src/bin/mpidb_prep.rs: crop generation +manifest.csvwritersrc/training.rs: training entry pointsrc/bin/server.rs: inference API (Axum)inference-ui/: web UI (Yew)DEV_GUIDE.md: detailed crop/manifest strategy
- Rust toolchain
- UI:
trunk+ targetwasm32-unknown-unknown
This project trains from a CSV manifest generated by mpidb_prep.
Expected input folders:
- MP-IDB species dataset (infected) (one folder per species):
data/
├── Falciparum/
│ ├── img/...
│ └── gt/...
├── Malariae/
│ ├── img/...
│ └── gt/...
├── Ovale/
│ ├── img/...
│ └── gt/...
└── Vivax/
├── img/...
└── gt/...
- Uninfected negatives:
data/
└── Uninfected/
├── cell_1.png
├── cell_2.png
└── ...
Generate crops + manifest.csv:
cargo run --bin mpidb_prep -- data mpidb_crops 128 25Outputs:
mpidb_crops/<Species>/*.png(infected crops)mpidb_crops/Uninfected/*.png(uninfected crops)mpidb_crops/manifest.csv
Manifest schema:
crop_path,infected,species,stage_r,stage_t,stage_s,stage_g,source_image_id
For a detailed explanation of the cropping strategy and leakage-safe splitting, see:
DEV_GUIDE.md
cargo run --releaseTraining reads the manifest path configured in src/config.rs:
mpidb_crops/manifest.csv
Start the server:
MODEL_PATH=./malaria-model.bin cargo run --bin serverEndpoints:
GET /health→okPOST /predict→multipart/form-datawith fieldimage(orfile)
Example request:
curl -X POST http://localhost:8080/predict -F "image=@./some_image.png"Example response:
{
"infected": true,
"predicted_species": "Falciparum",
"species_probabilities": [0.87, 0.05, 0.03, 0.02, 0.03],
"stage_probabilities": [0.92, 0.15, 0.08, 0.02]
}rustup target add wasm32-unknown-unknown
cargo install trunk
cd inference-ui
trunk serve --openMIT. See LICENSE.
