pneumonia-detector / README.md
mou11's picture
Update README.md
9575f2c verified
---
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
![Python](https://img.shields.io/badge/Python-3.10-blue)
![ViT](https://img.shields.io/badge/ViT-Base%20Patch16%20224-green)
![PyTorch](https://img.shields.io/badge/PyTorch-2.0-red)
![HuggingFace](https://img.shields.io/badge/HuggingFace-Spaces-yellow)
## 🎯 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