This model is designed to detect driver drowsiness from facial images using a CNN architecture.
1import tensorflow as tf
2import cv2
3import numpy as np
4
5# Load model
6model = tf.keras.models.load_model('drowsiness_model.h5')
7
8# Preprocess image
9img = cv2.imread('face.jpg')
10img = cv2.resize(img, (64, 64))
11img = img / 255.0
12img = np.expand_dims(img, axis=0)
13
14# Make prediction
15prediction = model.predict(img)
16is_drowsy = prediction[0][0] > 0.5
This model is released under the MIT License.