This repository contains my research and development work on Deep Learning for Explainable Traffic Anomaly Detection in Dhaka. The project introduces a Multi-Stage Traffic Anomaly Analysis Framework for identifying and analyzing urban traffic congestion, particularly in Dhaka. Originally utilizing Faster R-CNN and DBSCAN, it has been upgraded to state-of-the-art YOLOv9e and YOLOv10l models for enhanced accuracy and efficiency. By integrating object detection, congestion analysis, and explainable AI techniques, TCRD provides actionable insights to improve urban traffic management and planning.
faster-r-cnn/dhaka-vehicle-detection-faster-r-cnn.ipynb
: Notebook for training the Faster R-CNN model to detect vehicles and people.region_detection_with_dbscan/congested-region-detection-using-dbscan.ipynb
: Notebook for detecting congested regions using DBSCAN based on the output from the Faster R-CNN model.final-tcrd-framework.ipynb
: Core implementation of the Multi-Stage Traffic Anomaly Analysis Framework (TCRD) utilizing the YOLOv10l model.yolov9e/tcd_v9_version2_e50.ipynb
: Notebook for training YOLOv9e for traffic congestion detection.yolov10l/YOLOv10_120E.ipynb
: Notebook for training YOLOv10l for advanced traffic anomaly detection.Kaggle is recommended for its GPU support and storage capabilities. The training and detection notebooks are designed for seamless execution in Kaggle.
dhaka-vehicle-detection-faster-r-cnn.ipynb
yolov9e/tcd_v9_version2_e50.ipynb
yolov9e/detect/yolov9e_ppe_css_50_epochs
yolov9e/detect/yolov9e_ppe_css_50_epochs/weights
yolov10l/YOLOv10_120E.ipynb
yolov10l/detect
yolov10l/detect/weights
The datasets focus on a congested urban environment with the following object classes:
Clustering methods were used with the Faster R-CNN model to test if congestion could be detected thoroughly.
DBSCAN Parameters:
Example Output:
{
"vehicle_count": 23,
"people_count": 4,
"congested_regions": [[175.94656, 123.34937, 375.40375, 415.21686]],
"congestion_count": 1,
"people_in_congested_areas": 0
}
As a matter of fact, congestion region detection was not thorough enough with the DBSCAN clustering method alone, as we can see in the output image. Therefore, new detection methods were needed for accuracy and clearer visualization.
The project workflow is outlined in the following diagram:
The core implementation of the TCRD framework is in the file: final-tcrd-framework.ipynb
. This file integrates the trained YOLOv10l model for:
Object Detection:
Blue Bounding Boxes:
Masked Local Regions:
Explainability with Eigen-CAM:
Now the Congestion Regions are more accurate and can be differentiated more clearly. They are even classified with detailed analysis and visualization.
best.pt
from Google Drive.yolov10-models/weights/
.tcd-yolov10-models
dataset.final-tcrd-framework.ipynb
to your Kaggle workspace.Contributions to this repository are welcome! Potential improvements include:
The TCRD framework aims to:
This work seeks to contribute to smarter, more sustainable cities.