Multi-Resolution YOLOv8 Ensemble for Automated Road Damage Detection
Overview β’ Features β’ Installation β’ Quick Start β’ Results β’ Architecture β’ Documentation
This project implements a cutting-edge multi-resolution YOLOv8 ensemble system for automated road damage detection. By leveraging multiple YOLOv8 models trained at different resolutions and fused using Weighted Boxes Fusion (WBF), the system achieves state-of-the-art performance on the RDD2022 dataset with an ensemble mAP@50 of 66.18%.
The system is designed for real-world deployment in infrastructure monitoring, automated damage assessment, and road maintenance planning. It includes both training pipelines and production-ready inference interfaces (Flask API and Gradio UI).
-
Multi-Resolution Ensemble Architecture: Combines YOLOv8 models at different input resolutions for optimal accuracy
- YOLOv8n @ 640Γ640: Real-time inference (~15ms)
- YOLOv8s @ 640Γ640: Balanced performance (~20ms)
- YOLOv8s @ 1024Γ1024: High-accuracy detection (~50ms)
-
Advanced Fusion Strategy: Weighted Boxes Fusion (WBF) intelligently combines predictions from all models
-
Comprehensive Training Pipeline:
- EDA and data analysis notebooks
- Hyperparameter tuning workflows
- Training scripts with configurable parameters
- Model evaluation and benchmarking
-
Production Deployment Options:
- RESTful Flask API for backend integration
- Interactive Gradio web interface for manual testing
- Containerized deployment support
-
Robust Inference Engine:
- Batch processing capabilities
- Configurable confidence thresholds
- Multi-format output (JSON, images with annotations)
- GPU and CPU support
| Model | Resolution | mAP@50 | Parameters | Inference Time |
|---|---|---|---|---|
| YOLOv8n | 640Γ640 | 60.01% | 3.2M | ~15ms |
| YOLOv8s | 640Γ640 | 63.43% | 11.2M | ~20ms |
| YOLOv8s | 1024Γ1024 | 63.68% | 11.2M | ~50ms |
| Ensemble (WBF) | Multi | 66.18% β | - | ~85ms |
Key Metrics (Ensemble):
- Precision: High confidence in predictions
- Recall: Robust detection of various damage types
- F1-Score: Balanced performance across all classes
- Per-class performance available in
results/metrics/
- Python 3.9 or higher
- CUDA 11.8+ (recommended for GPU acceleration)
- 8GB+ RAM (16GB+ recommended for training)
- Git
# 1. Clone the repository
git clone https://github.com/Cyril-36/Automated-Road-Damage-Detection.git
cd Automated-Road-Damage-Detection
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\\Scripts\\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Install PyTorch (with CUDA support)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118Core Libraries:
torch>=2.0.0: Deep learning frameworkultralytics>=8.0.0: YOLOv8 implementationopencv-python>=4.8.0: Computer vision operations
Ensemble Fusion:
ensemble-boxes>=1.0.9: Weighted Boxes Fusion
Utilities:
numpy,pandas,matplotlib,seaborn,plotly: Data processing and visualizationFlask,Flask-CORS,gradio: Web interfacesalbumentations: Data augmentation
from src.inference import RoadDamageDetector
# Initialize the detector
detector = RoadDamageDetector(
model_paths=[
'models/yolov8n_640.pt',
'models/yolov8s_640.pt',
'models/yolov8s_1024.pt'
],
conf_threshold=0.5
)
# Run detection
results = detector.detect('path/to/image.jpg')
# Visualize results
detector.visualize(results, save_path='output.jpg')images = ['image1.jpg', 'image2.jpg', 'image3.jpg']
results = detector.detect_batch(images)
detector.export_results(results, format='json', output_path='results.json')python deployment/gradio_app.py
# Visit http://localhost:7860 in your browserpython deployment/app.py
# API available at http://localhost:5000
# Example request:
curl -X POST -F "image=@image.jpg" http://localhost:5000/predictAutomated-Road-Damage-Detection/
βββ Notebooks/ # Jupyter notebooks for analysis and training
β βββ EDA-RDD.ipynb
β βββ baseline-rdd2022.ipynb
β βββ TuningRDD22.ipynb
β βββ Model_Evaluation.ipynb
βββ src/ # Source code
β βββ inference.py
β βββ ensemble.py
β βββ wbf.py
βββ deployment/ # Production deployment
β βββ app.py
β βββ gradio_app.py
βββ models/ # Trained model weights
β βββ yolov8n_640.pt
β βββ yolov8s_640.pt
β βββ yolov8s_1024.pt
βββ config/ # Configuration files
β βββ model_config.yaml
βββ data/ # Dataset directory
β βββ RDD2022/
βββ docs/ # Additional documentation
βββ scripts/ # Utility scripts
βββ results/ # Training and evaluation results
βββ requirements.txt
βββ LICENSE
βββ README.md
This project uses the RDD2022 Road Damage Detection 2022 dataset.
- Download from the official RDD2022 repository
- Extract and organize into the project:
mkdir -p data/RDD2022/{train,test}/{images,labels}
cp -r /path/to/RDD2022/train/images data/RDD2022/train/
cp -r /path/to/RDD2022/train/labels data/RDD2022/train/
cp -r /path/to/RDD2022/test/images data/RDD2022/test/
cp -r /path/to/RDD2022/test/labels data/RDD2022/test/python scripts/train.py --config config/model_config.yamlEdit config/model_config.yaml:
models:
yolov8n:
resolution: 640
epochs: 100
batch_size: 16
learning_rate: 0.001
yolov8s:
resolution: 640
epochs: 100
batch_size: 16
learning_rate: 0.001
yolov8s_large:
resolution: 1024
epochs: 100
batch_size: 8
learning_rate: 0.0005
ensemble:
weights: [1.0, 1.5, 2.0]
iou_threshold: 0.5
confidence_threshold: 0.5INPUT IMAGE
β
βββ YOLOv8n (640Γ640) β Predictions 1
βββ YOLOv8s (640Γ640) β Predictions 2
βββ YOLOv8s (1024Γ1024) β Predictions 3
β
Weighted Boxes Fusion (WBF)
β
FINAL ENSEMBLE PREDICTIONS
β
Output: Bounding Boxes + Classes + Confidence Scores
- Cluster overlapping boxes (IoU threshold: 0.5)
- Calculate weighted coordinates:
(b1*w1 + b2*w2 + b3*w3) / (w1 + w2 + w3) - Average confidence:
(c1 + c2 + c3) / 3 - Select ensemble class from majority vote
# Build Docker image
docker build -t road-damage-detector .
# Run container
docker run -p 5000:5000 road-damage-detectorFROM pytorch/pytorch:2.0-cuda11.8-runtime-ubuntu22.04
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python", "deployment/app.py"]Detailed metrics for each damage class:
- D00: Longitudinal Cracks
- D10: Transverse Cracks
- D20: Alligator Cracks
- D40: Potholes
- D50: White Paint Lines
See results/metrics/ for detailed analysis including:
- Confusion matrices
- Precision-Recall curves
- Training curves
- Per-class comparisons
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/improvement - Make your changes and commit:
git commit -am 'Add improvement' - Push to the branch:
git push origin feature/improvement - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Dataset: Thanks to the RDD2022 dataset creators
- Framework: Ultralytics team for the excellent YOLOv8 implementation
- Community: All contributors who support this project
- Issues: Open an issue on GitHub
- Email: cyrilchaitanya@gmail.com
- Documentation: Check the
docs/folder for detailed guides
- Add real-time video stream processing
- Implement MLOps pipeline (DVC, CML)
- Add model quantization for edge deployment
- Integrate with cloud platforms (AWS, GCP, Azure)
- Create mobile app for road assessment
- Add damage severity classification
Made with β€οΈ by Cyril Chaitanya Pudota
β If this project helps you, please consider giving it a star!