This project implements a deep learning model to detect pneumonia from chest X-ray images. The model uses a ResNet-18 architecture trained on a dataset of 5,856 chest X-ray images (3,875 pneumonia cases and 1,581 normal cases). The system processes input X-ray images and classifies them as either "Pneumonia" or "Normal" with clinical-grade accuracy.
Dataset Source:
Chest X-Ray Images (Pneumonia) on Kaggle
The ResNet-18 model was trained with the following key parameters:
- Input Size: 224x224 pixels (3-channel RGB)
- Data Augmentation: Random rotations, flips, and normalization
- Loss Function: Cross-Entropy Loss
- Optimizer: Adam (Learning Rate = 0.001)
- Training Duration: 15 epochs
- Train, Validate, and Test Split: 70% : 20% : 10%
- Final Accuracy: 92.3% on test set
The trained model (pneumonia_model.pth) is included in the model/ directory.
- Python 3.12+
- Pipenv
- Docker (optional)
- Clone the repository:
git clone https://github.com/garlicdoggoe/pneumonia-detection.git
cd pneumonia-detector
- Install dependencies using Pipenv:
pip install pipenv
pipenv install
- Activate virtual environment:
pipenv shell
- Build the Docker image:
docker build -t pneumonia-detector .
- Run the container:
docker run -d -p 5000:5000 --name pneumonia-container pneumonia-detector
- Access the web interface at:
http://localhost:5000
- Start the Flask application:
python app/app.py
- Open web browser and navigate to:
http://localhost:5000
-
Upload a chest X-ray image (JPEG/PNG format)
-
Get instant prediction result (Pneumonia/Normal)
- Flask (Web framework)
- PyTorch (Deep learning)
- TorchVision (Image transformations)
- Pillow (Image processing)
- Gunicorn (Production server)

