metadata
title: NEXUS
emoji: π©Ί
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: true
license: cc-by-4.0
tags:
- medgemma
- medical-ai
- hai-def
- maternal-health
- neonatal-care
NEXUS - AI-Powered Maternal-Neonatal Assessment Platform
Non-invasive screening for maternal anemia, neonatal jaundice, and birth asphyxia using Google HAI-DEF models
Overview
NEXUS transforms smartphones into diagnostic screening tools for Community Health Workers in low-resource settings. Using 3 Google HAI-DEF models in a 6-agent clinical workflow, it provides non-invasive assessment for:
- Maternal anemia from conjunctiva images (MedSigLIP)
- Neonatal jaundice from skin images with bilirubin regression (MedSigLIP)
- Birth asphyxia from cry audio analysis (HeAR)
- Clinical synthesis with WHO IMNCI protocol alignment (MedGemma)
HAI-DEF Models
| Model | HuggingFace ID | Purpose |
|---|---|---|
| MedSigLIP | google/medsiglip-448 |
Anemia + jaundice detection, bilirubin regression |
| HeAR | google/hear-pytorch |
Cry audio analysis for birth asphyxia |
| MedGemma 4B | google/medgemma-4b-it |
Clinical reasoning and synthesis |
Architecture
6-Agent Clinical Workflow:
Triage -> Image Analysis (MedSigLIP) -> Audio Analysis (HeAR)
-> WHO Protocol -> Referral Decision -> Clinical Synthesis (MedGemma)
Each agent produces structured reasoning traces for a full audit trail.
Quick Start
Prerequisites
- Python 3.10+
- HuggingFace token (for gated HAI-DEF models)
Setup
# Clone and install
git clone <repo-url>
cd nexus
pip install -r requirements.txt
# Set HuggingFace token (required for MedSigLIP, MedGemma)
export HF_TOKEN=hf_your_token_here
Run the Demo
# Streamlit interactive demo
PYTHONPATH=src streamlit run src/demo/streamlit_app.py
# FastAPI backend
PYTHONPATH=src uvicorn api.main:app --reload
# Run tests
PYTHONPATH=src python -m pytest tests/ -v
Train Models
# Train linear probes (anemia + jaundice classifiers)
PYTHONPATH=src python scripts/training/train_linear_probes.py
# Train bilirubin regression head
PYTHONPATH=src python scripts/training/finetune_bilirubin_regression.py
HuggingFace Spaces
# Local test of HF Spaces entry point
python app.py
Project Structure
nexus/
βββ src/nexus/ # Core platform
β βββ anemia_detector.py # MedSigLIP anemia detection
β βββ jaundice_detector.py # MedSigLIP jaundice + bilirubin regression
β βββ cry_analyzer.py # HeAR cry analysis
β βββ clinical_synthesizer.py # MedGemma clinical synthesis
β βββ agentic_workflow.py # 6-agent workflow engine
β βββ pipeline.py # Unified assessment pipeline
βββ src/demo/streamlit_app.py # Interactive Streamlit demo
βββ api/main.py # FastAPI backend
βββ scripts/
β βββ training/
β β βββ train_linear_probes.py # MedSigLIP embedding classifiers
β β βββ finetune_bilirubin_regression.py # Novel bilirubin regression
β β βββ train_anemia.py # Anemia-specific training
β β βββ train_jaundice.py # Jaundice-specific training
β β βββ train_cry.py # Cry classifier training
β βββ edge/
β βββ quantize_models.py # INT8 quantization
β βββ export_embeddings.py # Pre-computed text embeddings
βββ notebooks/
β βββ 01_anemia_detection.ipynb
β βββ 02_jaundice_detection.ipynb
β βββ 03_cry_analysis.ipynb
β βββ 04_bilirubin_regression.ipynb # Novel task reproducibility
βββ tests/
β βββ test_pipeline.py # Pipeline tests
β βββ test_agentic_workflow.py # Agentic workflow tests (41 tests)
β βββ test_hai_def_integration.py # HAI-DEF model compliance
βββ models/
β βββ linear_probes/ # Trained classifiers + regressor
β βββ edge/ # Quantized models + embeddings
βββ data/
β βββ raw/ # Raw datasets (Eyes-Defy-Anemia, NeoJaundice, CryCeleb)
β βββ protocols/ # WHO IMNCI protocols
βββ submission/
β βββ writeup.md # Competition writeup (3 pages)
β βββ video/ # Demo video script and assets
βββ app.py # HuggingFace Spaces entry point
βββ requirements.txt # Full dependencies
βββ requirements_spaces.txt # HF Spaces minimal dependencies
Key Results
| Task | Method | Performance |
|---|---|---|
| Anemia zero-shot | MedSigLIP (max-similarity, 8 prompts/class) | Screening capability |
| Jaundice classification | MedSigLIP linear probe | 68.9% accuracy |
| Bilirubin regression | MedSigLIP + MLP head | MAE: 2.667 mg/dL, r=0.77 |
| Cry analysis | HeAR + acoustic features | Qualitative assessment |
| Clinical synthesis | MedGemma + WHO IMNCI | Protocol-aligned recommendations |
Novel Task: Bilirubin Regression
Frozen MedSigLIP embeddings -> 2-layer MLP -> continuous bilirubin (mg/dL) prediction. Trained on 2,235 NeoJaundice images with ground truth serum bilirubin. MAE: 2.667 mg/dL, Pearson r: 0.7725 (p < 1e-67)
Edge AI
- INT8 dynamic quantization: 812.6 MB -> 111.2 MB (7.31x compression)
- Pre-computed text embeddings: 12 KB (no text encoder on device)
- Total on-device: ~289 MB
Competition Tracks
- Main Track: Comprehensive maternal-neonatal assessment platform
- Agentic Workflow Prize: 6-agent pipeline with reasoning traces and audit trail
Tests
# All tests
PYTHONPATH=src python -m pytest tests/ -v
# Agentic workflow only (41 tests)
PYTHONPATH=src python -m pytest tests/test_agentic_workflow.py -v
License
Acknowledgments
- Google Health AI Developer Foundations team
- NeoJaundice dataset (Figshare)
- Eyes-Defy-Anemia dataset (Kaggle)
- WHO IMNCI protocol guidelines
Built with Google HAI-DEF for the MedGemma Impact Challenge 2026