资源简介
基于 CNN 的疲劳检测源码-Python
- 模型: CNN;
- drowsiness detection;
- blink detection;
- yawning detection
代码片段和文件信息
from __future__ import absolute_import
from __future__ import print_function
import numpy as np
import os
from keras.utils import plot_model
import cv2
np.random.seed(1337) # for reproducibility
from keras.models import Sequential
from keras.layers.core import Dense Dropout Activation Flatten
from keras.layers.convolutional import Convolution2D MaxPooling2D
from keras.utils import np_utils
from keras.optimizers import SGD Adadelta Adagrad
from six.moves import cPickle as pickle
import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
os.environ[“PATH“] += os.pathsep + ‘C:/Program Files (x86)/Graphviz2.38/bin/‘
pickle_files = [‘open_eyes.pickle‘ ‘closed_eyes.pickle‘]
i = 0
for pickle_file in pickle_files:
with open(pickle_file ‘rb‘) as f:
save = pickle.load(f)
if i == 0:
train_dataset = save[‘train_dataset‘]
train_labels = save[‘train_labels‘]
test_dataset = save[‘test_dataset‘]
test_labels = save[‘test_labels‘]
else:
print(“here“)
train_dataset = np.concatenate((train_dataset save[‘train_dataset‘]))
train_labels = np.concatenate((train_labels save[‘train_labels‘]))
test_dataset = np.concatenate((test_dataset save[‘test_dataset‘]))
test_labels = np.concatenate((test_labels save[‘test_labels‘]))
del save # hint to help gc free up memory
i += 1
print(‘Training set‘ train_dataset.shape train_labels.shape)
print(‘Test set‘ test_dataset.shape test_labels.shape)
batch_size = 30
nb_classes = 1
epochs = 12
X_train = train_dataset
X_train = X_train.reshape((X_train.shape[0] X_train.shape[3]) + X_train.shape[1:3])
Y_train = train_labels
X_test = test_dataset
X_test = X_test.reshape((X_test.shape[0] X_test.shape[3]) + X_test.shape[1:3])
Y_test = test_labels
# print shape of data while model is building
print(“{1} train samples {4} channel{0} {2}x{3}“.format(““ if X_train.shape[1] == 1 else “s“ *X_train.shape))
print(“{1} test samples {4} channel{0} {2}x{3}“.format(““ if X_test.shape[1] == 1 else “s“ *X_test.shape))
# input image dimensions
_ img_channels img_rows img_cols = X_train.shape
# convert class vectors to binary class matrices
# Y_train = np_utils.to_categorical(y_train nb_classes)
# Y_test = np_utils.to_categorical(y_test nb_classes)
model = Sequential()
model.add(Convolution2D(32 (3 3) padding=‘same‘
input_shape=(img_channels img_rows img_cols)data_format=‘channels_first‘))
model.add(Activation(‘relu‘))
model.add(Convolution2D(24 (3 3) data_format=‘channels_first‘))
model.add(Activation(‘relu‘))
model.add(MaxPooling2D(pool_size=(2 2)))
model.add(Dropout(0.25))
model.add(Convolution2D(64 (3 3) padding=‘same‘ data_format=‘channels_first‘))
model.add(Activation(‘relu‘))
model.add(Convolution2D(64 (3 3)))
model.add(Activation(‘relu‘))
model.add(MaxPooling2D(pool_size=(2 2)))
mode
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-21 13:30 DrowsyDriverDetection-master\
文件 5502669 2018-05-19 22:50 DrowsyDriverDetection-master\closed_eyes.pickle
目录 0 2018-05-21 19:08 __MACOSX\
目录 0 2018-05-21 19:08 __MACOSX\DrowsyDriverDetection-master\
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._closed_eyes.pickle
文件 6148 2018-05-21 13:30 DrowsyDriverDetection-master\.DS_Store
文件 120 2018-05-21 13:30 __MACOSX\DrowsyDriverDetection-master\._.DS_Store
文件 1066283 2018-05-19 22:50 DrowsyDriverDetection-master\yawn_mouths.pickle
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._yawn_mouths.pickle
文件 69 2018-05-19 22:50 DrowsyDriverDetection-master\requirements.txt
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._requirements.txt
文件 97341 2018-05-19 22:50 DrowsyDriverDetection-master\model.png
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._model.png
文件 1093 2018-05-19 22:50 DrowsyDriverDetection-master\README.md
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._README.md
文件 570 2018-05-19 22:50 DrowsyDriverDetection-master\test.jpg
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._test.jpg
文件 5682693 2018-05-19 22:50 DrowsyDriverDetection-master\open_eyes.pickle
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._open_eyes.pickle
文件 2807 2018-05-19 22:50 DrowsyDriverDetection-master\eyesPreprocess.py
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._eyesPreprocess.py
文件 24 2018-05-19 22:50 DrowsyDriverDetection-master\.gitignore
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._.gitignore
文件 3756 2018-05-19 22:50 DrowsyDriverDetection-master\eyesCNN.py
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\._eyesCNN.py
目录 0 2018-05-19 22:50 DrowsyDriverDetection-master\Code_archive\
文件 1993 2018-05-19 22:50 DrowsyDriverDetection-master\Code_archive\faceDetect.py
目录 0 2018-05-21 19:08 __MACOSX\DrowsyDriverDetection-master\Code_archive\
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\Code_archive\._faceDetect.py
文件 2970 2018-05-19 22:50 DrowsyDriverDetection-master\Code_archive\eyeDetect.py
文件 212 2018-05-19 22:50 __MACOSX\DrowsyDriverDetection-master\Code_archive\._eyeDetect.py
............此处省略6个文件信息
- 上一篇:python爬取王者荣耀信息.zip
- 下一篇:Python物理学高效计算
相关资源
- opencv for Python官方文档中文版
- OpenCV官方教程中文版for Pythonpdf+自己编
- python + opencv 人脸识别代码(可以跨平
- python利用opencv进行相机标定(教程)
- 图片感兴趣区域ROI获取——鼠标选择
- OpenCV+python手势识别框架和简单
- Practical Python and OpenCV+ Case Study(最新
- OpenCV官方教程中文版--python版本
- 基于树莓派的门禁管理系统
- Python实现跟踪、光流、前景检测
- opencv_python-3.4.5 contrib-cp37-cp37m-win_amd
- opencv-contrib_python-3.4.2.16-cp37-amd64.zip
- OpenCV+3计算机视觉++Python语言实现 高清
- 基于python和pencv的车牌号码识别
- OpenCV3计算机视觉_Python语言实现 _刘波
- OpenCV3计算机视觉Python语言实现源代码
- opencv_python‑3.4.3‑cp37‑cp37m‑win_amd
- opencv_python-3.4.2-cp37-cp37m-win_amd64.whl
- OPENCV入门书籍:opencv3机器视觉Python语
- TensorflowOpenCV实现的CNN车牌识别代码
- opencv_python-3.4.3+contrib-cp35-cp35m-win_amd
- opencv_python-3.2.0-cp36-cp36m-win_amd64.whl25
- OpenCV3 计算机视觉 Python语言实现
- opencv_python-3.4.2.16-cp37-cp37m-win_amd64.wh
- opencv_python-2.4.13.2-cp27-cp27m-win_amd64.wh
- python2环境的opencv库
- opencv_python-3.3.0-cp35-cp35m-win_amd64.whl
- opencv_python-4.1.0.25-cp37-cp37m-win_amd64.wh
- simplecv实用机器视觉+OpenCV-Python-Totur
- opencv_python-4.1.2-cp37-cp37m-win_amd64.whl
评论
共有 条评论