An open API service indexing awesome lists of open source software.

https://github.com/allanotieno254/pneumonia-xray-classification

This project is a Deep Learning-based Pneumonia classification system that allows medical staff to upload chest X-ray images and quickly determine whether a patient shows signs of pneumonia.
https://github.com/allanotieno254/pneumonia-xray-classification

keras machine-learning numpy pandas pil pillow python streamlit streamlit-webapp

Last synced: 3 months ago
JSON representation

This project is a Deep Learning-based Pneumonia classification system that allows medical staff to upload chest X-ray images and quickly determine whether a patient shows signs of pneumonia.

Awesome Lists containing this project

README

          

# Pneumonia Classification Using Chest X-ray Images
![Normal](https://github.com/user-attachments/assets/cf0027a3-7def-4338-a1e3-13038620439a)
![pneumonia](https://github.com/user-attachments/assets/ed288db9-50a4-48de-89be-9547d5c78ac1)

Dataset:https://data.mendeley.com/datasets/rscbjbr9sj/2

## Table of Contents
- [Project Overview](#project-overview)
- [Features](#features)
- [Project Structure](#project-structure)
- [Installation](#installation)
- [Usage](#usage)
- [Model Details](#model-details)
- [Integration into Hospital Systems](#integration-into-hospital-systems)
- [Benefits and Usefulness](#benefits-and-usefulness)
- [License](#license)

---

## Project Overview
This project is a **Deep Learning-based Pneumonia classification system** that allows medical staff to upload chest X-ray images and quickly determine whether a patient shows signs of pneumonia. The system uses a pre-trained Keras model to predict the condition and provides a confidence score for the diagnosis.

The project is built using:
- **Python**
- **Streamlit** for web interface
- **Keras / TensorFlow** for model inference
- **Pillow (PIL)** and **NumPy** for image processing

This tool is designed for **rapid, accurate preliminary screening** in medical facilities, reducing the burden on radiologists and improving response time for patient care.

---

## Features
- Upload a chest X-ray image in multiple formats (`jpeg`, `jpg`, `png`, `dcm`, `tiff`, `bmp`, `gif`)
- Automatic classification of **Pneumonia** (label 0) or **Normal** (label 1)
- Confidence score displayed for each prediction
- Simple, interactive web interface using Streamlit
- Preprocessing steps for consistent image input (resizing, normalization)
- Option to integrate a custom background for branding

---

## Project Structure
```
pneumonia-classification/

├── main.py # Streamlit application
├── util.py # Utility functions: classify images, set background
├── model/
│ ├── keras_model.h5 # Pre-trained pneumonia classification model
│ └── labels.txt # Labels: Pneumonia (0), Normal (1)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
```

---

## Installation
1. **Clone the repository**
```bash
git clone https://github.com/YourUsername/pneumonia-classification.git
cd pneumonia-classification
```

2. **Create and activate a virtual environment**
```bash
python -m venv venv
source venv/bin/activate # Linux / macOS
venv\Scripts\activate # Windows
```

3. **Install dependencies**
```bash
pip install -r requirements.txt
```

4. **Run the Streamlit app**
```bash
streamlit run main.py
```

---

## Usage
1. Open the Streamlit web app.
2. Upload a chest X-ray image using the file uploader.
3. The app will display the uploaded image.
4. Classification result will appear below the image along with the confidence score.

> Example Output:
```
Pneumonia
Score: 0.98
```

---

## Model Details
- **Input Size:** 224x224 pixels
- **Normalization:** [-1, 1] scale
- **Custom Thresholding:** Images are labeled Pneumonia if probability > 0.95, else Normal
- **Output:** Class name (`Pneumonia` or `Normal`) and confidence score

This approach ensures **high accuracy for pneumonia detection** while minimizing false negatives for normal cases.

---

## Integration into Hospital Systems
The system can be integrated into hospital workflows in several ways:

1. **Electronic Medical Records (EMR) Integration:**
- The app can automatically save classification results to patient records for radiologists to review.

2. **Triage Support:**
- Patients showing high-confidence Pneumonia predictions can be prioritized for urgent care.

3. **Remote Diagnostics:**
- Hospitals in rural areas can upload X-rays to this system and receive preliminary screening results before consulting specialists.

4. **Dashboard and Reporting:**
- Aggregate statistics can be generated for hospital administration to monitor pneumonia cases and trends over time.

---

## Benefits and Usefulness
- **Speed:** Provides near-instantaneous preliminary results.
- **Accuracy:** Reduces human error in X-ray interpretation.
- **Accessibility:** Can be used in hospitals without enough radiologists.
- **Cost-effective:** Requires only a standard computer and X-ray images; reduces unnecessary tests.
- **Data-driven decisions:** Helps hospitals track outbreaks, patient load, and optimize resources.

---

## License
This project is licensed under the **MIT License**. See `LICENSE` file for details.