A deep learning-based road damage detection system using YOLOv7, trained on the multi-national RDD2022 dataset. This project achieves 63.85% mAP@0.5 and 31.65% mAP@0.5:0.95 in detecting 4 types of road damage across images from 7 countries.
- Overview
- Features
- Dataset
- Model Performance
- Installation
- Project Structure
- Usage
- Results
- References
- License
This project implements an automated road damage detection system using YOLOv7 object detection architecture. The system can identify and classify 4 types of road damage:
| Class | Description | Example Count |
|---|---|---|
| D00 | Longitudinal Crack | 1,201 labels |
| D10 | Transverse Crack | 611 labels |
| D20 | Alligator Crack | 529 labels |
| D40 | Pothole | 375 labels |
The model is trained on 21,983 images from 7 countries and validated on 1,189 images from the RDD2022 dataset.
- Multi-country generalization - Trained on diverse road conditions from China, Czech Republic, India, Japan, Norway, and United States
- Ensemble inference - Combines predictions from two models trained at different resolutions (640×640 and 512×512)
- Interactive web interface - Gradio-based UI for easy testing and demonstration
- Custom YOLOv7 architecture - Optimized for road damage detection with 37.2M parameters
- Transfer learning - Initialized from pre-trained YOLOv7 weights for faster convergence
- Comprehensive logging - TensorBoard integration for training monitoring
Dataset: RDD2022 - The multi-national Road Damage Dataset
| Country | Training Images | Image Size | Notes |
|---|---|---|---|
| China (Drone) | 482 | 512×512 | Aerial imagery |
| China (MotorBike) | 43 | 512×512 | Ground-level |
| Czech Republic | 1,757 | 600×600 | - |
| India | 4,483 | 720×720 | Largest subset |
| Japan | 2,606 | 600×600, 1080×1080 | Mixed resolutions |
| Norway | 5,247 | 3643-4040×2035-2044 | High-resolution |
| United States | 0 | - | Test set only |
| Total | 21,983 | - | 50,879 labels |
Training: 100 epochs | Batch Size: 10 | GPU: NVIDIA RTX 4060 Laptop
| Metric | Value |
|---|---|
| mAP@0.5 | 63.85% |
| mAP@0.5:0.95 | 31.65% |
| Precision | 68.67% |
| Recall | 57.49% |
| Parameters | 37.2M |
| Training Time | ~28 hours |
| Class | Precision | Recall | mAP@0.5 | mAP@0.5:0.95 |
|---|---|---|---|---|
| D00 | 66.3% | 63.5% | 66.6% | 36.0% |
| D10 | 68.6% | 53.2% | 61.3% | 29.5% |
| D20 | 71.7% | 61.2% | 69.6% | 36.7% |
| D40 | 68.1% | 52.0% | 58.0% | 24.4% |
- Python 3.7 - 3.12
- CUDA 11.8+ (for GPU acceleration)
- Conda (recommended)
git clone https://github.com/WongKinYiu/yolov7.git
cd yolov7IMPORTANT: Replace the default YOLOv7 files with custom configurations from this project:
- Copy
DetectingRoadDamage/folders_to_replace/training→ Replaceyolov7/cfg/training - Copy
DetectingRoadDamage/folders_to_replace/data→ Replaceyolov7/data
pip install -r requirements.txtKey Dependencies:
torch>=1.7.0
torchvision>=0.8.1
opencv-python>=4.1.1
numpy>=1.18.5,<1.24.0
matplotlib>=3.2.2
tensorboard>=2.4.1
gradio==5.29.0
pillow>=7.1.2
tqdm
scipy
seaborn
If you encounter KMP_DUPLICATE_LIB_OK errors on Windows:
# Option 1: Conda environment variable
conda env config vars set KMP_DUPLICATE_LIB_OK=TRUE
conda deactivate
conda activate base # or your environment name
# Option 2: Set system environment variable
set KMP_DUPLICATE_LIB_OK=TRUE- Download RDD2022 dataset from Figshare
- Extract to your preferred location (e.g.,
F:/RoadDamageDetection/Datasets/RDD2022/) - Update paths in
data/crdd22.yaml:
train: /path/to/RDD2022/images/train
val: /path/to/RDD2022/images/val
nc: 4
names: ['D00', 'D10', 'D20', 'D40']Download YOLOv7 pre-trained weights:
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7_training.ptCRITICAL: Before starting training, you MUST run these notebooks to prepare the dataset:
Run CheckSizes.ipynb to verify image dimensions and XML annotation consistency:
jupyter notebook CheckSizes.ipynbPurpose:
- Validates image dimensions match XML annotations
- Identifies square vs. non-square images
- Detects resolution inconsistencies across countries
- Ensures dataset integrity before training
Run Local_YOLOv7_DataConversion.ipynb to convert RDD2022 annotations to YOLOv7 format:
jupyter notebook Local_YOLOv7_DataConversion.ipynbPurpose:
- Converts XML annotations to YOLO txt format
- Normalizes bounding box coordinates
- Creates proper train/val splits
- Organizes images and labels in YOLOv7 structure
Expected Output:
RDD2022/
├── images/
│ ├── train/
│ └── val/
└── labels/
├── train/
└── val/
WARNING: Skipping these steps will result in training failures or incorrect annotations!
DetectingRoadDamage/
├── yolov7/ # YOLOv7 implementation (~7.5GB - NOT included)
├── folders_to_replace/ # Trained model weights
│ ├── training # Custom model configurations [REPLACE yolov7/cfg/training]
│ └── data # Dataset configurations [REPLACE yolov7/data]
├── test_images/ # Sample test images
├── index.ipynb # Ensemble inference + Gradio demo
├── CheckSizes.ipynb # [REQUIRED] Dataset validation utilities
├── Local_YOLOv7_DataConversion.ipynb # [REQUIRED] Dataset format conversion
├── Directory_Structure_CRDDC_RDD2022.txt # Dataset structure reference
├── commands to run.txt # Training command reference
├── yolov7all6-log.txt # Complete training logs
├── Documentation/
│ ├── PathFinders-Final Report.pdf
│ └── results_yolov7all6.txt
└── images/ # Visualization results
cd yolov7
python train.py --workers 8 --device 0 --batch-size 10 \
--data data/crdd22.yaml \
--img 640 640 \
--cfg cfg/training/yolov7-custom.yaml \
--weights yolov7_training.pt \
--name yolov7all6 \
--hyp data/hyp.scratch.p5.custom.yaml \
--epoch 100python train.py --workers 8 --device 0 --batch-size 10 \
--data data/crdd22.yaml \
--img 512 512 \
--cfg cfg/training/yolov7-custom.yaml \
--weights yolov7_training.pt \
--name yolov7all61 \
--hyp data/hyp.scratch.p5.custom.yaml \
--epoch 200cd yolov7
python -m tensorboard.main --logdir runs/trainThen open your browser to http://localhost:6006
python train.py --resumepython detect.py \
--weights runs/train/yolov7all6/weights/best.pt \
--conf 0.10 \
--img 640 \
--source /path/to/test_images \
--save-confpython detect.py \
--weights runs/train/yolov7all61/weights/best.pt \
--conf 0.25 \
--img 512 \
--source /path/to/test_images \
--save-confParameters:
--weights: Path to trained model weights--conf: Confidence threshold (0.0-1.0)--img: Input image size--source: Path to images, videos, or folder--save-conf: Save confidence scores
The project includes an interactive Gradio web interface for ensemble inference using both trained models.
jupyter notebook index.ipynbOr run directly in Google Colab:
- Upload
index.ipynbto Colab - Mount Google Drive or upload weights
- Run all cells
- Access the Gradio interface
- Upload single or multiple images
- Adjustable confidence threshold (0.1 - 0.9)
- Ensemble prediction from both models
- Visual bounding boxes with class labels
- Gallery view for batch results
The demo combines predictions from:
- yolov7all6.pt (640×640 resolution)
- yolov7all61.pt (512×512 resolution)
Predictions are merged using Non-Maximum Suppression (NMS) for improved accuracy.
| Epoch | Box Loss | Obj Loss | Cls Loss | mAP@0.5 | mAP@0.5:0.95 |
|---|---|---|---|---|---|
| 0 | 0.0639 | 0.01289 | 0.01437 | 25.06% | 9.10% |
| 10 | 0.04682 | 0.0118 | 0.00574 | 46.34% | 19.94% |
| 50 | 0.04147 | 0.01102 | 0.00391 | 60.16% | 28.92% |
| 90 | 0.03702 | 0.01007 | 0.00250 | 63.25% | 31.20% |
| 99 | 0.03639 | 0.00985 | 0.00235 | 63.85% | 31.65% |
Place your sample detection images in the images/ folder to showcase results.
| File | Description |
|---|---|
index.ipynb |
Ensemble inference pipeline + Gradio UI |
CheckSizes.ipynb |
[REQUIRED] Dataset validation and image size analysis |
Local_YOLOv7_DataConversion.ipynb |
[REQUIRED] Convert RDD2022 XML to YOLO format |
Directory_Structure_CRDDC_RDD2022.txt |
Expected dataset folder structure reference |
cfg/training/yolov7-custom.yaml |
Custom YOLOv7 architecture (4 classes) |
data/crdd22.yaml |
RDD2022 dataset configuration |
data/hyp.scratch.p5.custom.yaml |
Custom training hyperparameters |
yolov7all6-log.txt |
Complete training logs for Model 1 (100 epochs) |
yolov7all61-log.txt |
Complete training logs for Model 2 (200 epochs) |
commands to run.txt |
All training/inference commands used |
# Reduce batch size
python train.py --batch-size 4 ... # Instead of 10set KMP_DUPLICATE_LIB_OK=TRUEMake sure to use the correct --img parameter:
- Model 1 (yolov7all6):
--img 640 - Model 2 (yolov7all61):
--img 512
Download pre-trained weights:
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7_training.pt@data{RDD2022,
author = {Arya, Deeksha and Maeda, Hiroya and Ghosh, Sanjay Kumar and others},
title = {RDD2022: The multi-national Road Damage Dataset},
year = {2022},
publisher = {figshare},
doi = {10.6084/m9.figshare.21431547}
}@article{wang2022yolov7,
title={{YOLOv7}: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors},
author={Wang, Chien-Yao and Bochkovskiy, Alexey and Liao, Hong-Yuan Mark},
journal={arXiv preprint arXiv:2207.02696},
year={2022}
}- Repository: mdptlab/roaddamagedetector2022
- YOLOv7 Implementation: WongKinYiu/yolov7
This project is based on YOLOv7 (GPL-3.0 License) and the RDD2022 dataset. Please refer to the original repositories for licensing information.
Team: PathFinders
Institution: Texas A&M University - Corpus Christi
Course: Capstone Project
- YOLOv7 team for the excellent object detection framework
- RDD2022 dataset creators for the comprehensive road damage dataset
- Original roaddamagedetector2022 project for inspiration and guidance
Last Updated: November 2025