File size: 2,190 Bytes
192f07d 6ad7154 192f07d 9575f2c 6ad7154 9575f2c 6ad7154 9575f2c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | ---
license: mit
pipeline_tag: image-classification
base_model: google/vit-base-patch16-224
tags:
- medical-ai
- image-classification
- pneumonia
- chest-xray
- gradcam
- vit
---
# π« Pneumonia Detector




## π― Live Demo
π [Try it on Hugging Face Spaces](https://huggingface.co/spaces/mou11/pneumonia-detector)
## π Overview
A medical image classification system that detects pneumonia from chest X-ray images using Vision Transformer (ViT) with Grad-CAM explainability. The model highlights which regions of the X-ray influenced the prediction, making it transparent and trustworthy for medical screening.
## π Results
| Metric | Score |
|--------|-------|
| Overall Accuracy | 87% |
| AUC-ROC | 0.9805 |
| PNEUMONIA Recall | 1.00 |
| NORMAL Precision | 0.99 |
## π Classification Report
| Class | Precision | Recall | F1-Score |
|-------|-----------|--------|----------|
| NORMAL | 0.99 | 0.66 | 0.79 |
| PNEUMONIA | 0.83 | 1.00 | 0.91 |
## β¨ Features
- β
Chest X-ray classification: NORMAL vs PNEUMONIA
- β
Vision Transformer (ViT) fine-tuned on medical images
- β
Grad-CAM heatmap visualization for explainability
- β
Handles class imbalance with weighted loss
- β
Gradio demo for interactive predictions
## ποΈ Architecture
Chest X-Ray Image β Preprocessing (224x224) β ViT Base Patch16 β Fine-tuned Classifier Head β Prediction + Grad-CAM Heatmap
## π οΈ Tech Stack
| Component | Tool |
|-----------|------|
| Model | Google ViT Base Patch16 224 |
| Framework | PyTorch |
| Explainability | Grad-CAM |
| Dataset | Chest X-Ray Images (Pneumonia) β Kaggle |
| UI | Gradio |
| Training | Google Colab T4 GPU |
## π Dataset
- **Source:** [Chest X-Ray Images (Pneumonia)](https://www.kaggle.com/datasets/paultimothymooney/chest-xray-pneumonia)
- **Total Images:** 5,863
- **Classes:** NORMAL (1,341) vs PNEUMONIA (3,875)
- **Split:** Train / Val / Test
## π How to Use
```python |