MobileNetV2 pediatric chest X-ray classification
ImageNet V2 MobileNetV2 fine-tuned for NORMAL (0) and PNEUMONIA (1). The final model was retrained on all cleaned images from the original train, test, and validation folders. It has no independent test evaluation.
Data and attribution
Kaggle dataset. Kermany D, Goldbaum M, Cai W et al. Identifying Medical Diagnoses and Treatable Diseases by Image-Based Deep Learning. Cell (2018), 172(5):1122-1131. https://doi.org/10.1016/j.cell.2018.02.010 Source data, CC BY 4.0. Latest original release specifies research use. Dataset attribution does not assert a separate weight license.
Unreadable, tiny, constant, exact duplicate images and contradictory duplicate labels were excluded; see cleaning_report.json. No source images are redistributed here. Filename-derived patient groups were used for internal selection. These identifiers are imperfect and near-duplicate or undocumented patient overlap may remain.
Training and evaluation
FP16 DDP, AdamW, class-weighted cross entropy, warmup/cosine schedule, and frozen
BatchNorm running statistics. See training_config.json, environment.json and training.py.
Deterministic resized uint8 pixels are cached locally. Random affine and
brightness/contrast augmentation and normalization run in batches on GPU.
Training augmentation is not bitwise identical to PIL; inference preprocessing
is unchanged. Epoch histories record input, GPU-stream and validation timings.
The best internal validation ROC-AUC selected the duration of a fresh all-data refit.
selection_model.safetensors is the checkpoint associated with selection_metrics.json.
Those are selection scores, not unbiased test scores, and do not evaluate model.safetensors.
Confusion matrices use rows=true, columns=predicted, class order NORMAL/PNEUMONIA.
Usage
Download config.json, model.safetensors and inference.py from this repository. Install torch, torchvision, Pillow and safetensors (recorded versions in environment.json).
from inference import load_model, predict
model, config = load_model("path/to/downloaded/folder")
print(predict("example.jpeg", model, config))
config.json defines RGB conversion, aspect-preserving padding, normalization and
the fixed 0.5 threshold. Softmax outputs are not clinically calibrated probabilities.
Limitations
Research only; not a clinical diagnostic device. The source images are from young children at one center. Performance across hospitals, adults and other diseases is unknown. External patient-independent evaluation is required before any clinical use.
Run results
All-data refit: {"epochs": 12, "images": 5824}
Internal selection checkpoint only:
{
"roc_auc": 0.9974606700757258,
"average_precision": 0.9990594420226382,
"accuracy": 0.9811783960720131,
"balanced_accuracy": 0.9831852348618213,
"f1": 0.9872008903728436,
"sensitivity": 0.9790286975717439,
"specificity": 0.9873417721518988,
"confusion_matrix": [
[
312,
4
],
[
19,
887
]
],
"threshold": 0.5,
"best_epoch": 12,
"evaluation_scope": "Internal selection validation only; not an independent test and not an evaluation of final refit weights."
}