π Deep Learning for Safer Roads π Exploring CNN-Based and YOLOv11 Driver Drowsiness Detection π€
As part of my journey through a Deep Learning course, I developed this project to explore how artificial intelligence can contribute to making our roads safer. I focused on the challenge of driver drowsiness detection, a crucial issue given how many accidents are caused by fatigue every year. π₯π The idea of using deep learning to potentially save lives made this an incredibly motivating and meaningful project to work on. β€οΈβπ₯
Throughout the process, I experimented with two powerful approaches: a CNN-based model with Transfer Learning for image classification π§ πΌοΈ, and YOLOv8, a real-time object detection model integrated through Roboflow βοΈπ―. This allowed me to explore both accuracy-focused models and those designed for real-time inference, gaining a clearer understanding of their strengths, limitations, and real-world applications. β±οΈπ
Working on this project helped me strengthen my grasp of key deep learning concepts, from feature extraction and model fine-tuning to evaluating metrics like precision, recall, and F1-score. π I also encountered important practical lessonsβlike how to handle imbalanced data, optimize for performance, and think critically about what it means to deploy AI in real-life, safety-critical situations. π§ͺ
I extend my gratitude to the creators of the Driver Drowsiness Dataset (DDD) for providing a high-quality dataset that has been instrumental in training and evaluating our deep learning model for driver drowsiness detection.
The dataset, derived from the Real-Life Drowsiness Dataset, offers a diverse collection of over 41,790 labeled images, carefully preprocessed to focus on the driverβs facial region. The effort in extracting, annotating, and sharing this dataset greatly contributes to research and development in road safety and accident prevention through deep learning techniques.
For more details and citation, please refer to the original dataset:
Driver Drowsiness Dataset (DDD) on Kaggle
A special thank you to Esraa Meslam Sayed for the invaluable inspiration provided through his project, Driver Drowsiness Detectionππ΄(CNN ||MobileNetV2). His work laid the foundation for the development of this model and greatly influenced the approach taken in this project. The insights and techniques explored in his work served as a key resource, helping to guide the creation of an effective and robust diabetes prediction model. We truly appreciate the effort and dedication put into his research and contributions to the data science community
π I would like to extend my heartfelt gratitude to Santiago HernΓ‘ndez, an expert in Cybersecurity and Artificial Intelligence. His incredible course on Deep Learning, available at Udemy, was instrumental in shaping the development of this project. The insights and techniques learned from his course were crucial in crafting the neural network architecture used in this classifier.
This project, Deep Learning for Safer Roads, is an educational and experimental exploration of deep learning models for detecting driver drowsiness. The primary goal of this work is to investigate the effectiveness of CNN-based models with Transfer Learning and YOLOv8 for real-time driver monitoring and fatigue detection.
The models and methods explored in this notebook are intended for learning and research purposes only
This repository is open for educational purposes and encourages further experimentation and development.
If you found this project intriguing, I invite you to check out my other AI and machine learning initiatives, where I tackle real-world challenges across various domains:
-
π Advanced Classification of Disaster-Related Tweets Using Deep Learning π¨
Uncover how social media responds to crises in real time using deep learning to classify tweets related to disasters. -
π° Fighting Misinformation: Source-Based Fake News Classification π΅οΈββοΈ
Combat misinformation by classifying news articles as real or fake based on their source using machine learning techniques. -
π‘οΈ IoT Network Malware Classifier with Deep Learning Neural Network Architecture π
Detect malware in IoT network traffic using Deep Learning Neural Networks, offering proactive cybersecurity solutions. -
π§ Spam Email Classification using LSTM π€
Classify emails as spam or legitimate using a Bi-directional LSTM model, implementing NLP techniques like tokenization and stopword removal. -
π³ Fraud Detection Model with Deep Neural Networks (DNN)
Detect fraudulent transactions in financial data with Deep Neural Networks, addressing imbalanced datasets and offering scalable solutions. -
π§ π AI-Powered Brain Tumor Classification
Classify brain tumors from MRI scans using Deep Learning, CNNs, and Transfer Learning for fast and accurate diagnostics. -
ππ Predicting Diabetes Diagnosis Using Machine Learning
Create a machine learning model to predict the likelihood of diabetes using medical data, helping with early diagnosis. -
ππ LLM Fine-Tuning and Evaluation
Fine-tune large language models like FLAN-T5, TinyLLAMA, and Aguila7B for various NLP tasks, including summarization and question answering. -
π° Headline Generation Models: LSTM vs. Transformers
Compare LSTM and Transformer models for generating contextually relevant headlines, leveraging their strengths in sequence modeling. -
π©Ίπ» Breast Cancer Diagnosis with MLP
Automate breast cancer diagnosis using a Multi-Layer Perceptron (MLP) model to classify tumors as benign or malignant based on biopsy data. -
Deep Learning for Safer Roads π Exploring CNN-Based and YOLOv11 Driver Drowsiness Detection π€ Comparing driver drowsiness detection with CNN + MobileNetV2 vs YOLOv11 for real-time accuracy and efficiency π§ π. Exploring both deep learning models to prevent fatigue-related accidents π΄π‘.
Driver fatigue is a major cause of road accidents worldwide π΄. Detecting drowsy driving in real-time is crucial for preventing accidents and ensuring road safety. This project leverages the Driver Drowsiness Dataset (DDD), a collection of images of drivers in Drowsy and Non-Drowsy states, to build two different models aimed at real-time detection of drowsiness. π
CNNs are at the heart of modern image recognition and excel at learning spatial hierarchies of image data. For this task, we use MobileNetV2, a lightweight and efficient CNN architecture thatβs ideal for real-time applications in vehicles. π
- Why CNNs?
β Efficient at detecting drowsiness through facial state recognition.
β Works great on smaller datasets.
β Uses pre-trained models to speed up the process. ποΈ
YOLOv8 is a state-of-the-art object detection model designed for speed and accuracy. Paired with Roboflow, YOLOv8 becomes even more powerful by streamlining the dataset preparation and deployment process. π
- Why YOLOv8?
β Super fast, making it perfect for real-time applications. β±οΈ
β Capable of localizing and detecting multiple objects in a single frame.
β Roboflow integration simplifies dataset annotation and augmentation. π
The Driver Drowsiness Dataset (DDD) is the foundation for training both models. Hereβs what you need to know about the data:
- Image Format: RGB images with facial features of drivers.
- Classes:
Drowsy
vs.Non-Drowsy
. - Resolution: 227 x 227 pixels, optimized for deep learning tasks.
- Size: 41,790+ labeled images.
- File Size: ~2.32 GB of drowsiness-related data!
- Evaluate the two modelsβCNN-based transfer learning and YOLOv8 with Roboflowβfor detecting drowsy drivers.
- Compare their performance using metrics like accuracy, precision, recall, and F1-score.
- Optimize the models for real-time deployment in vehicles.
We break the project into several stages:
- Normalize pixel values.
- Augment data to improve generalization.
- Split the dataset into training, validation, and testing sets.
- Train CNN models with MobileNetV2 for transfer learning.
- Train YOLOv8 using Roboflow for real-time object detection.
- Compare performance using key metrics.
- Assess real-time feasibility for vehicle deployment.
- Simulate real-world conditions and evaluate model responsiveness.
This project aims to reduce road accidents by detecting driver fatigue using AI. Through deep learning, we can proactively detect when a driver is drowsy, preventing potential accidents before they happen. Safer roads lead to lives saved. π
This approach uses pre-trained CNNs (e.g., MobileNetV2) to classify driver states as drowsy or non-drowsy based on facial images.
-
Pros:
- Quick setup.
- Works well with smaller datasets.
- Pre-trained models speed up training.
-
Cons:
- No object localization.
- Limited real-time suitability due to preprocessing.
- May struggle with high-resolution data.
YOLOv8 excels at detecting and localizing objects (e.g., faces, eyes) in real-time, especially when paired with Roboflow.
-
Pros:
- Perfect for real-time detection.
- Detects and localizes multiple objects at once.
- Simplified data preparation via Roboflow.
-
Cons:
- Resource-heavy, requiring powerful hardware.
- Higher complexity in setup and fine-tuning.
- Time-intensive annotations for accurate detection.
Aspect | CNN + Transfer Learning | YOLOv8 + Roboflow |
---|---|---|
Primary Goal | Classification (Drowsy vs. Non-Drowsy) | Real-Time Detection and Localization |
Real-Time Suitability | Limited (Preprocessing adds latency) | Optimized for real-time applications |
Ease of Use | Beginner-friendly, quick setup | More complex, streamlined with Roboflow |
Dataset Needs | Small to moderate datasets | Detailed annotations, larger datasets |
Performance Focus | Classification Accuracy | Speed + Detection Accuracy |
Hardware Requirements | Moderate (CPUs or mid-tier GPUs) | High (Powerful GPUs recommended) |
When integrating the drowsiness detection model into a mobile application, we need to consider specific factors such as real-time performance, model size, and resource limitations. Let's explore the strengths of each approach and decide which one fits best for mobile deployment with TensorFlow Lite or YOLOv8.
If you're building a mobile app where speed and efficiency are critical, CNN-based models like MobileNetV2 are a great option.
-
Why use CNN + Transfer Learning for Mobile?
- ποΈ Lightweight and fast: MobileNetV2 is designed for resource-constrained environments, making it perfect for real-time mobile applications.
- π Smaller model size: Using TensorFlow Lite, the model can be deployed as a compact version to the mobile device.
- β‘ Real-time performance: MobileNetV2 ensures real-time drowsiness detection even on devices with lower processing power.
-
When should you use it?
- You have limited hardware resources (e.g., mobile devices with moderate performance).
- You need a lightweight and fast model that works efficiently with TensorFlow Lite.
- You donβt need object localization or detecting multiple features within the image.
YOLOv8 excels in object detection and is ideal if your mobile app requires real-time detection and localization of features like faces or eyes.
-
Why use YOLOv8 for Mobile?
- β‘ High-speed detection: YOLOv8 is optimized for real-time processing, making it perfect for mobile apps that need fast response times.
- π οΈ Advanced localization: YOLOv8 can detect and localize facial features, offering more detailed insights into the driverβs state.
- ποΈββοΈ Better for powerful devices: If youβre targeting high-end devices with robust processing power, YOLOv8 will deliver optimal performance.
-
When should you use it?
- Your mobile app needs to detect multiple objects or localize faces/eyes.
- You have access to high-performance hardware on the device (e.g., high-end smartphones).
- You need a complete detection and classification system in a single pipeline.
-
Go for CNN + Transfer Learning (MobileNetV2) if:
- You need a lightweight model that runs efficiently on mobile devices with limited computational power.
- You're aiming for real-time performance with a fast deployment using TensorFlow Lite.
-
Go for YOLOv11 with Roboflow if:
- You need advanced object detection and localization (e.g., detecting faces or eyes).
- Your app will run on high-performance mobile devices that can handle the increased computational load.
- You want an end-to-end system that seamlessly combines real-time detection and classification.
Both models have their strengths, and the best choice will depend on the specific needs of your mobile app. If you're looking for a lightweight and efficient model for real-time performance, MobileNetV2 is the way to go. However, if your focus is on advanced detection and localization with high-end hardware, YOLOv8 will offer the performance you need for a powerful real-time solution. π
Both models are powerful tools for driver drowsiness detection, and each offers unique benefits. The choice of approach depends on your specific goals, dataset, and available resources.
- How to train a YOLOv8 classification model
- Real time object detection in android with yolov11
- Transfer learning
- Dataset
This project, Deep Learning for Safer Roads, is an educational and experimental exploration of deep learning models for detecting driver drowsiness. The primary goal of this work is to investigate the effectiveness of CNN-based models with Transfer Learning and YOLOv8 for real-time driver monitoring and fatigue detection.
The models and methods explored in this notebook are intended for learning and research purposes only
This repository is open for educational purposes and encourages further experimentation and development.
A huge thank you to Ismail Nasri for providing the dataset that made this project possible! π The dataset can be found on Kaggle. Your contribution is greatly appreciated! π
A special thank you to Esraa Meslam Sayed for the invaluable inspiration provided through his project, Driver Drowsiness Detectionππ΄(CNN ||MobileNetV2). His work laid the foundation for the development of this model and greatly influenced the approach taken in this project. The insights and techniques explored in his work served as a key resource, helping to guide the creation of an effective and robust diabetes prediction model. We truly appreciate the effort and dedication put into his research and contributions to the data science community
π I would like to extend my heartfelt gratitude to Santiago HernΓ‘ndez, an expert in Cybersecurity and Artificial Intelligence. His incredible course on Deep Learning, available at Udemy, was instrumental in shaping the development of this project. The insights and techniques learned from his course were crucial in crafting the neural network architecture used in this classifier
Contributions to this project are highly encouraged! If you're interested in adding new features, resolving bugs, or enhancing the project's functionality, please feel free to submit pull requests.
this project is developed and maintained by Sergio SΓ‘nchez SΓ‘nchez (Dream Software). Special thanks to the open-source community and the contributors who have made this project possible. If you have any questions, feedback, or suggestions, feel free to reach out at dreamsoftware92@gmail.com.
This project is licensed under the Apache License 2.0, a permissive open-source software license that allows developers to freely use, modify, and distribute the software. π This includes both personal and commercial use, with some conditions for distribution and modification. π
Key terms of the Apache License 2.0:
- You are allowed to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software. π»
- If you modify and distribute the software, you must include the original copyright notice, provide a copy of the Apache 2.0 license, and indicate any modifications made. π
- You are not allowed to use the name of the project or its contributors to promote derived works without permission. β
- The software is provided "as is," without any warranties, express or implied. π«π‘οΈ
Please see the full license text below for more detailed terms.
Apache License Version 2.0, January 2005 http://www.apache.org/licenses/
Copyright (c) 2025 Dream software - Sergio SΓ‘nchez
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.