File size: 1,822 Bytes
a3355a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---

title: Pneumonia Detection Assistant
emoji: 🫁
colorFrom: blue
colorTo: red
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: mit
---


# Pneumonia Detection Assistant

A medical AI assistant that analyzes chest X-ray images to detect signs of pneumonia using a Vision Transformer (ViT) model.

## Features

- **Multi-class Classification**: Distinguishes between Normal, Viral Pneumonia, and Bacterial Pneumonia
- **Attention Visualization**: Shows heatmaps highlighting areas the model focuses on for diagnosis
- **User-friendly Interface**: Simple drag-and-drop interface built with Gradio

## Model Details

- **Architecture**: Vision Transformer (ViT) base model fine-tuned on chest X-ray data
- **Base Model**: `google/vit-base-patch16-224-in21k`
- **Dataset**: Chest X-Ray Images (Pneumonia) dataset
- **Classes**: 
  - Normal
  - Pneumonia (Bacterial)
  - Pneumonia (Viral)

## Usage

1. Upload a chest X-ray image (PNG, JPG, or JPEG format)
2. View the classification results with confidence scores
3. Examine the attention heatmap to understand the model's decision-making process

## Medical Disclaimer

⚠️ **IMPORTANT**: This application is for educational and research purposes only. It is NOT a diagnostic tool and should not be used for medical diagnosis. Always consult with qualified healthcare professionals for medical advice and diagnosis.

## Technical Implementation

The model uses:
- **Transformers**: Hugging Face transformers library
- **PyTorch**: Deep learning framework
- **Gradio**: Web interface
- **OpenCV & Matplotlib**: Image processing and visualization

## Example Images

The app includes sample images demonstrating different conditions:
- Normal chest X-ray
- Bacterial pneumonia
- Viral pneumonia