Chest X-Ray Pneumonia Detector
Transfer learning AI classifying chest X-rays as PNEUMONIA or NORMAL with 86.22% accuracy — deployed live on Render.com, built in 4 days.
86.22%
Test Accuracy
+48pp
vs Baseline CNN
5,216
X-rays Trained
4 Days
Build to Deploy
The Problem
Pneumonia kills 2.5M+ people worldwide every year. Radiologist shortages in developing regions leave chest X-ray backlogs that delay diagnosis by days or weeks. An automated screening tool that flags high-risk scans for urgent review could save lives — especially given the severe class imbalance (74% pneumonia cases) in real-world data.
The Solution
Fine-tuned ResNet18 (pre-trained on 14M ImageNet images) on 5,216 chest X-rays at 150×150 resolution. All backbone layers were frozen — only the final Linear(512,1) layer (513 weights) was trained, making it fast and efficient. Data augmentation (RandomHorizontalFlip, RandomRotation ±10°, ColorJitter brightness & contrast) and weighted BCEWithLogitsLoss corrected the 74:26 class imbalance. Trained with Adam lr=0.001 for 10 epochs on Kaggle T4 GPU. The 43MB model file is served via Flask on Render.com — upload an X-ray, get PNEUMONIA/NORMAL in under 200ms.
Results & Metrics
- 86.22% test accuracy — 48 percentage points above the 37.5% baseline CNN trained from scratch
- Baseline 3-layer CNN achieved only 37.5% with severe overfitting — transfer learning is the decisive factor
- 74:26 class imbalance (pneumonia vs normal) handled with weighted BCEWithLogitsLoss
- Only 513 parameters trained — final FC layer only; all 14M+ backbone weights frozen
- 43MB model deployed live on Render.com via Flask — inference under 200ms per image
- Entire project — data prep, training, deployment — completed in 4 days