Computer Vision & Deep Learning Project
This project focuses on building a Drowsiness Detection System using deep learning and computer vision techniques. The system detects early signs of driver drowsiness by analyzing the state of the driver’s eyes in real-time, aiming to improve road safety by alerting drowsy drivers.
Drowsiness is one of the leading causes of road accidents worldwide. Detecting and alerting a drowsy driver on time can prevent potential accidents. This system uses a Convolutional Neural Network (CNN) to classify eye states (open or closed) and uses facial landmarks for precise eye region detection.
The project leverages the MRL Eye Dataset, which contains labeled images of eyes in different states (open or closed). The dataset was divided into training, validation, and testing sets.
train_datagen = ImageDataGenerator(
rescale=1./255,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,
fill_mode='nearest')
Augmentation improved the model’s generalizability, allowing it to handle different angles and lighting conditions.
The CNN model was defined as follows:
The model was compiled using the Adam optimizer with a learning rate of 0.001. The loss function used was binary_crossentropy. Metrics such as accuracy, precision, and recall were tracked during training.
model.compile(optimizer=Adam(learning_rate=0.001),
loss='binary_crossentropy',
metrics=[tf.keras.metrics.BinaryAccuracy(name='accuracy'),
tf.keras.metrics.Precision(name='precision'),
tf.keras.metrics.Recall(name='recall')])
The model was evaluated on both training and testing datasets. The final evaluation yielded the following metrics:
Metric | Training Set | Testing Set |
---|---|---|
Accuracy | 0.98 | 0.95 |
Precision | 0.97 | 0.94 |
Recall | 0.96 | 0.93 |
Loss | 0.10 | 0.15 |
The system captures video input using a webcam, applies Dlib’s face detection and landmark identification, and extracts eye regions. These eye regions are preprocessed and fed into the trained CNN model for prediction. If both eyes are classified as closed, an auditory alert is triggered using the winsound module.
A comparative bar chart between training and testing metrics:
The Drowsiness Detection System leverages deep learning and computer vision to identify drowsiness and alert drivers in real-time. This system can be integrated into vehicles to enhance road safety and prevent accidents caused by drowsiness.
For the complete code and further details, you can visit the GitHub repository.
Interested in collaborating or have any questions? Reach out to me through this form.