Welcome to the Lung Nodule Detection System, an advanced deep learning-based framework for detecting and classifying pulmonary nodules in CT scans. This system leverages the 3D Dual Path Network (DPN) architecture, inspired by the DeepLung framework detailed in "DeepLung: Deep 3D Dual Path Nets for Automated Pulmonary Nodule Detection and Classification".
This repository provides a comprehensive pipeline for automating lung nodule detection and classification, encompassing:
- Nodule Detection π: Using a 3D Faster R-CNN with dual path blocks for identifying lung nodules in CT scans.
- Nodule Classification π¬: Leveraging a 3D DPN combined with Gradient Boosting Machines (GBM) for malignancy prediction.
β
3D Dual Path Networks: Combines residual learning and dense connections for efficient feature extraction.
β
Modular Codebase: Clean structure for preprocessing, model loading, and inference.
β
Web Application: Flask-based UI for uploading scans and viewing predictions.
β
Monitoring & Observability: Prometheus and Grafana for performance tracking.
β
Containerization: Dockerized deployment for consistent runtime environments.
β
Comprehensive Testing: Includes unit and integration tests for reliability.
π lung-nodule-detection/
βββ π app/ # Main application code
β βββ π static/ # Static assets (CSS, JS)
β βββ π templates/ # HTML templates for web UI
β βββ π models/ # Trained model storage
β βββ π utils/ # Utility scripts (preprocessing, inference)
β βββ π monitoring/ # Monitoring and metrics
β βββ π __init__.py # Flask app initialization
β βββ π routes.py # API routes and logic
βββ π tests/ # Unit and integration tests
βββ π requirements.txt # Python dependencies
βββ π Dockerfile # Container definition
βββ π docker-compose.yml # Multi-service orchestration
βββ π Makefile # Automation commands
βββ π README.md # Project documentation
# Create project directory and virtual environment
mkdir lung-nodule-detection
cd lung-nodule-detection
python -m venv venv
source venv/bin/activate
pip install flask torch torchvision numpy pandas matplotlib scikit-image scipy opencv-python prometheus-client gunicorn flask-wtf flask-cors
pip install -U mlflow tensorboard pytest pytest-cov
pip freeze > requirements.txt
- Utility to load the 3D DPN model from
.pth
files. - Ensures compatibility with the model architecture.
- Steps include:
- Normalization: Adjust pixel intensity to a standard scale.
- Resizing: Ensure input dimensions match the model's expected size.
- Dimensionality Addition: Add batch and channel dimensions.
- Run predictions on preprocessed scans to classify nodules as benign or malignant.
- File Uploads: Upload
.raw
CT scan files for analysis. - Results Visualization: View predictions, confidence levels, and download detailed reports.
- Metrics Tracked:
- Total inference requests.
- Inference duration and errors.
- Active requests and model load time.
- Dashboards: Visualize system performance and application health.
- Dockerfile: Encapsulates the application and dependencies.
- docker-compose.yml: Orchestrates multi-container setups (web app, Prometheus, Grafana).
- Verify preprocessing utilities and model loading.
- Validate API endpoints and end-to-end workflows.
git clone https://github.com/dhou22/Lung-Nodule-Detection.git
cd lung-nodule-detection
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Start the Flask application
python app/__init__.py
Visit the web app at http://localhost:5000.
pytest tests/
docker-compose up --build
- Web App: http://localhost:5000
- Monitoring Dashboard: http://localhost:3000
Method | Endpoint | Description |
---|---|---|
GET | /health |
Check API status |
POST | /upload |
Upload CT scan for prediction |
GET | /report/<id> |
Download prediction report |
Command | Description |
---|---|
make install |
Install dependencies |
make test |
Run unit tests |
make run |
Start Flask app |
make docker-build |
Build Docker image |
make docker-run |
Run Docker container |
make monitor |
Start monitoring services |
- Accuracy: Achieves radiologist-level detection rates.
- Efficiency: Optimized for high-resolution CT scans with reduced computational overhead.
Licensed under MIT License.
Β© 2025 Dhouha Meliane
Email: [email protected]