Skip to content

KCL-BMEIS/Pneumonia-Detection

Repository files navigation

Pneumonia Detection

A deep learning system for detecting pneumonia in chest X-rays using PyTorch.

Project Structure

pneumonia_detection/
├── data/                      # Data directory
│   └── chest_xray/            # X-ray image dataset
│       ├── train/             # Training images
│       ├── val/               # Validation images
│       └── test/              # Test images
├── models/                    # Saved model weights
│   └── pneumonia_model_v1.pth # Pre-trained model weights
├── pneumonia_detection/       # Package source code
|   ├── __init__.py            # Package initialisation
│   ├── dataset.py             # Data loading module
│   ├── paths.py               # Path management utilities
│   ├── pneumonia_net.py       # Model architecture definition
│   └── predict.py             # Prediction script
├── scripts/                   # Additional scripts
│   ├── __init__.py            # Package initialisation
│   ├── test.py                # Script for evaluating the model
│   └── train.py               # Script for training the model
├── tests/                     # Unit tests
│   ├── __init__.py            # Test package initialisation
│   ├── test_dataset.py        # Tests for the dataset module
│   ├── test_paths.py          # Tests for the path management utilities
│   ├── test_pneumonia_net.py  # Tests for the model architecture
│   └── test_system.py         # System tests
├── .gitignore                 # Git ignore file
├── LICENCE                    # Licence file
├── pyproject.toml             # Package configuration
├── README.md                  # Project documentation
├── requirements-dev.txt       # Development dependencies
└── requirements.txt           # Project dependencies

Installation

pip install -e .

Usage

Training

python scripts/train.py

Prediction

Using the installed package:

python -m pneumonia_detection.predict path/to/image.jpeg

Or directly:

predict path/to/image.jpeg

Docker Usage

This guide explains how to build and run the Pneumonia Detection project using Docker.

Building the Docker Image

docker build -t pneumonia-detection .

Running the Docker Container

For predictions using the CLI

To analyze images from your local machine, you need to mount the directory containing the images:

docker run -it --rm -v ./data:/data pneumonia-detection pneumonia_detection.predict /data/image.jpeg

Using GPU support

docker run -it --rm --gpus all -v ./data:/data pneumonia-detection pneumonia_detection.predict /data/image.jpeg

Dataset

This project uses the Chest X-Ray Images (Pneumonia) dataset from Kaggle, which is available under the CC BY 4.0 license.

About

An example Python pneumonia detection project for QMS for SaMD course.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published