| --- |
| 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 |