BioMedCLIP-Distilled DenseNet-121 for Pulmonary Tuberculosis Conformal Triage
This repository contains the flagship lightweight distilled model developed for clinical pulmonary tuberculosis (TB) screening on chest radiographs (CXRs).
Key Architectural & Clinical Specifications
- Student Backbone: DenseNet-121 (7.74M parameters)
- Teacher Foundation Model: Microsoft BioMedCLIP (ViT-B/16, 86.4M parameters)
- Distillation Loss: Tri-Loss Formulation (Hard Label CE + Soft Text KL + Visual Feature Latent Alignment)
- Quantized / Native Formats:
tb_conformal_distilled_v11.onnx(26.90 MB, ONNX Opset 17)tb_conformal_distilled_v11.pth(30.15 MB, PyTorch checkpoint)
- Edge CPU Telemetry:
- ONNX Runtime CPU Latency: 77.5 ms / CXR (12.90 FPS)
- PyTorch CPU Latency: 414.7 ms / CXR
- Speedup: 5.35x on pure edge CPU
- External Multi-Cohort AUROC Performance (DeLong Significance p < 0.0001):
- India Solan Cohort (N=1,400): 0.9292 (95% CI: 0.9157 - 0.9427)
- India NITRD Cohort (N=1,400): 0.9347 (95% CI: 0.9218 - 0.9477)
- Pakistan High-Shift Cohort (N=641): 0.9065 (95% CI: 0.8837 - 0.9293)
- South Asia Pooled (N=3,441): 0.9147 (95% CI: 0.9052 - 0.9242)
- WHO CAD TPP Compliance:
- Exceeds WHO target (>=90% sensitivity, >=70% specificity) across all evaluation cohorts.
Python Quickstart (ONNX Runtime)
import numpy as np
import onnxruntime as ort
from PIL import Image
# 1. Load ONNX Session
session = ort.InferenceSession("tb_conformal_distilled_v11.onnx", providers=["CPUExecutionProvider"])
# 2. Preprocess Chest Radiograph (224x224, ImageNet normalization)
img = Image.open("cxr_sample.jpg").convert("RGB").resize((224, 224))
arr = np.array(img).astype(np.float32) / 255.0
mean = np.array([0.485, 0.456, 0.406], dtype=np.float32)
std = np.array([0.229, 0.224, 0.225], dtype=np.float32)
arr = ((arr - mean) / std).transpose(2, 0, 1)[np.newaxis, ...]
# 3. Execute Inference
ort_inputs = {session.get_inputs()[0].name: arr}
logits = session.run(None, ort_inputs)[0]
probs = np.exp(logits) / np.sum(np.exp(logits), axis=-1, keepdims=True)
p_tb = probs[0, 1]
print(f"P(Tuberculosis): {p_tb:.4f}")
Investigational Medical Device Notice
This model is an investigational Clinical Decision Support prototype under FDA 21 CFR 820, EU MDR 2017/745, and Indonesian Health Law (UU Kesehatan No 17/2023). It is not an autonomous primary diagnostic tool. All outputs must be interpreted and validated by a licensed physician or radiologist.