基于迁移学习的睡意检测报警系统

 摘要

        驾驶员的困倦和疲劳是道路事故的重要原因之一,每年它们都会导致出现车祸,造成人员死亡。在本文中,本文基于迁移学习使用MobileNet模型训练了基于人脸的闭眼检测算法,迁移学习模型MobileNet在训练集上的准确率约为99%,测试集上的准确率为96%。接着结合flask系统开发技术设计实现了睡意检测报警系统(Web应用程序),该系统可以点击打开笔记本电脑自带的摄像头,如果测试中的人脸出现闭眼5s以上,则会发出警报声响。

一、基于迁移学习的MobileNet模型训练

数据集:该数据集为二分类的人脸闭眼与否的图像。

 模型实现代码:

model=tf.keras.applications.mobilenet.MobileNet()
model.summary()

model_input = model.layers[0].input
model_output = model.layers[-4].output  # removing last 3 layers of MobileNet as they have lot of params
flat_layer=layers.Flatten()(model_output)                                       #flatten layer after convolution operation
final_output=layers.Dense(1)(flat_layer)                                        #dense/fully connected layer for deep learning
final_output=layers.Activation('sigmoid')(final_output)                         #activation layer for output
my_model = keras.Model(inputs=model_input, outputs=final_output)  # initilization of our Transfer Learning model
my_model.summary()

my_model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])          #compilation
final_model=my_model.fit(X,y,epochs=10,validation_split=0.2)                              #fitting model having 20% validation data for 10 epochs

测试结果如下:

基于迁移学习的睡意检测报警系统_第1张图片

基于迁移学习的睡意检测报警系统_第2张图片

二、基于flask的web系统应用实现

 点击打开相机:在系统界面上出现和下面类似的界面,当出现闭眼状态时,系统便会发出警报声。 

完整代码请查看博主主页联系方式,并进行索要。

你可能感兴趣的:(卷积神经网络(CNN),系统应用,图像处理,迁移学习,驾驶员的困倦疲劳检测,困倦疲劳检测,视觉检测)