A deep learning system for detecting pneumonia in chest X-rays using PyTorch.
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
pip install -e .
python scripts/train.py
Using the installed package:
python -m pneumonia_detection.predict path/to/image.jpeg
Or directly:
predict path/to/image.jpeg
This guide explains how to build and run the Pneumonia Detection project using Docker.
docker build -t pneumonia-detection .
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
docker run -it --rm --gpus all -v ./data:/data pneumonia-detection pneumonia_detection.predict /data/image.jpeg
This project uses the Chest X-Ray Images (Pneumonia) dataset from Kaggle, which is available under the CC BY 4.0 license.