--- title: MedicalClassifier emoji: ๐Ÿ“š colorFrom: blue colorTo: green sdk: gradio sdk_version: 6.26.0 python_version: '3.13' app_file: app.py pinned: false license: apache-2.0 short_description: Pneumonia classifier student lab models: - therayelab/pneumoniamnist-resnet18 datasets: - galilai-group/medmnist --- # MedicalClassifier ยท Student Lab Educational Gradio demo: upload a teaching image, guess a hidden test label, and evaluate all 624 official PneumoniaMNIST test images with a confusion matrix, sensitivity, specificity, precision, mistake gallery and CSV export. **Not for diagnosis or treatment. Do not upload identifiable patient images.** Softmax scores are not calibrated clinical probabilities. Uploaded-image provenance is unknown. ## Run locally ```sh python -m venv .venv # Activate the environment for your operating system. python -m pip install -r requirements.txt python app.py ``` Model and dataset download on first use. CPU is sufficient; first benchmark may take a minute. Inference is cached in memory, and downloads are stored in `.cache/` (override with `APP_CACHE`). No paid inference service is needed. ## Deploy to the existing Space Upload `app.py`, `core.py`, `requirements.txt`, and this `README.md` to `therayelab/MedicalClassifier`. Keep its CPU Basic hardware. Alternatively, sign in locally using `hf auth login` with a token permitted to write to that Space, then run from this directory: ```sh hf upload therayelab/MedicalClassifier . --repo-type space --include app.py --include core.py --include requirements.txt --include README.md ``` Never put a token in the source files. Public model and dataset access needs no Space secret. ## Provenance and limitations Model revision: `a5e0ebebfcf20bee6701e6d528e33c5bf7a33b94`. Inference uses its saved processor and safetensors weights with remote code disabled. IDs 0/1 map to Normal/Pneumonia according to official MedMNIST metadata. The model's training settings name train and validation; this app uses only test. This does not independently establish no prior exposure or duplicate images. The official 28ร—28 archive is downloaded from https://zenodo.org/records/10519652/files/pneumoniamnist.npz?download=1 and checked against MD5 `28209eda62fecd6e6a2d98b1501bb15f`. It is the same archive used by the training dataset loader. No dataset remote code is executed. Test-set threshold changes are teaching experiments, not independent evaluation after threshold optimization. The single-image views use argmax. The model cannot reliably reject non-X-rays or establish clinical validity. New institutions, populations and acquisition methods can change performance. PneumoniaMNIST: CC BY 4.0. Attribution: Yang et al., MedMNIST v2, Scientific Data (2023), https://medmnist.com/. App temporary uploads and CSVs use Gradio cache cleanup, hourly for files at least one hour old. Do not use this public demo to process sensitive patient data.