This project is focused on the early detection of pneumonia from chest X-ray images and uses a Generative Adversarial Network (GAN) model for the generation of realistic synthetic pneumonia images to augment training data. Early detection of pneumonia can help healthcare providers offer timely treatments, improving patient outcomes and potentially saving lives. The detection system is deployed as a web application using Flask.
- Pneumonia Detection Model: A deep learning model that classifies chest X-ray images as either "Pneumonia" or "Normal."
- GAN Image Generation: A GAN model trained to generate realistic pneumonia images, helping to augment training data and improve model performance.
- Web Application: The model is deployed using Flask, providing an interactive web interface for uploading images and receiving real-time predictions.
- Business Value
- Model Overview
- Exploratory Data Analysis (EDA)
- Model Performance
- Web Application
- Setup Instructions
- Future Enhancements
Pneumonia is a life-threatening illness that affects over 450 million people globally each year. The early detection of pneumonia is critical for administering timely medical interventions, especially in children under five and the elderly. Implementing a GAN-based pneumonia image generation system helps in:
- Improving Data Quality: GAN-generated images can enhance training datasets, addressing data imbalance between pneumonia and normal cases.
- Enhancing Model Performance: By augmenting the dataset with synthetic pneumonia images, the model can better generalize, leading to more accurate predictions in real-world scenarios.
- Supporting Healthcare Systems: Such a system reduces diagnostic errors and assists healthcare providers in making more accurate, data-driven decisions.
The detection model is a convolutional neural network (CNN) trained to classify chest X-ray images into two categories: Pneumonia and Normal. It takes a chest X-ray image as input and outputs the probability of the image belonging to either class.
- Input: X-ray images resized to (224x224).
- Output: Prediction of "Pneumonia" or "Normal."
- Libraries: TensorFlow, Keras.
The Generative Adversarial Network (GAN) is used to generate synthetic pneumonia images. This is particularly useful for improving the detection model’s performance by augmenting the dataset with more pneumonia images.
- Generator: Creates realistic pneumonia images from noise.
- Discriminator: Evaluates whether the generated images are real or synthetic.
- Purpose: To alleviate class imbalance in the dataset and improve model generalization.
Exploratory Data Analysis was conducted to understand the dataset better. Visualizations such as class distributions, image quality, and correlation analyses were performed to ensure balanced and clean data for model training.
The performance of the pneumonia detection model is evaluated using the following metrics:
The GAN model is evaluated based on its ability to generate realistic and diverse pneumonia images that can fool the discriminator while improving classification model performance.
The project includes a Flask-based web application that allows users to upload chest X-ray images and receive predictions on whether the patient has pneumonia or not.
- Python 3.x
- TensorFlow and Keras
- Flask
- OpenCV
- Numpy
- Pickle
-
Clone the repository:
git clone https://github.com/your-repo/pneumonia-gan-detection.git cd pneumonia-gan-detection
-
Install required dependencies:
pip install -r requirements.txt
-
Download or place the trained models (
detection_model.h5
andgan_model.h5
) in themodel/
directory. -
Run the Flask web application:
python app.py
-
Access the web application by opening a browser and navigating to
http://127.0.0.1:5000/
.
- GAN Image Integration: Automatically enhance uploaded X-ray images using the GAN model.
- Deployment on Cloud: Deploy the app on a cloud platform such as AWS or Google Cloud for real-time access.
- Model Optimization: Experiment with more advanced architectures to further improve detection accuracy.
- Multi-class Classification: Expand the model to detect other lung diseases like tuberculosis or COVID-19.
This project is licensed under the MIT License. See the LICENSE file for more details.