pneumonia-detector / README.md
mou11's picture
Update README.md
f627411 verified

A newer version of the Gradio SDK is available: 6.14.0

Upgrade
metadata
title: Pneumonia Detector
emoji: 🫁
colorFrom: purple
colorTo: red
sdk: gradio
sdk_version: 6.12.0
app_file: app.py
pinned: false
license: mit
short_description: Pneumonia detection from chest X-rays using ViT and Grad-CAM

🫁 Pneumonia Detector

Medical AI system for detecting pneumonia from chest X-ray images using Vision Transformer (ViT) with explainable Grad-CAM heatmaps.

Features

  • Upload chest X-ray β€” supports PNG, JPEG
  • AI prediction β€” Normal or Pneumonia with confidence score
  • Grad-CAM heatmap β€” visual explanation showing which regions the model focused on
  • Fast inference β€” runs on CPU or GPU

Model Details

Attribute Value
Architecture Vision Transformer (ViT)
Backbone ViT-B/16
Fine-tuned on Chest X-ray dataset
Accuracy 87%
AUC-ROC 0.98
Input size 224x224 pixels

Training Details

Parameter Value
Dataset Chest X-ray (Pneumonia)
Train/Val/Test split 80/10/10
Epochs 20
Batch size 32
Learning rate 1e-4
Optimizer AdamW
Hardware Kaggle P100 (16GB)
Training time ~3 hours

Performance Metrics

Metric Score
Accuracy 87%
AUC-ROC 0.98
Precision 85%
Recall 89%
F1-Score 87%

Tested on held-out test set of 624 images

How to Use

  1. Upload a chest X-ray image (frontal view preferred)
  2. Click Submit
  3. View prediction + Grad-CAM heatmap

Example Output

Prediction: Pneumonia (confidence: 94%)
Heatmap: Highlights upper right lung region

Technical Stack

  • PyTorch
  • Hugging Face Transformers
  • timm (Vision Models)
  • Grad-CAM
  • Gradio

Run Locally

git clone https://huggingface.co/spaces/mou11/pneumonia-detector
cd pneumonia-detector
pip install -r requirements.txt
python app.py