当前位置:网站首页>Inception V3 Eye Closure Detection
Inception V3 Eye Closure Detection
2022-08-09 06:38:00 【Starry-sky(jing)】
一. 模型演示
闭眼检测
Closed eyes detection accuracy is high98%
二.网络设计
The network structure is reproduced from the source : One of the classic convolutional networksInceptionV3
InceptionV3模型是googleThe third generation model in the series,InceptionThe biggest feature of the network is the expansion of the convolution operation between the layers of the neural network.
如VGG,AlexNetThe network is always convolutional,ResNetThen a residual network is introduced,The data of a certain layer in the first several layers is directly skipped and introduced into the input part of the following data layer,The content of the later feature layer will be partially linearly provided by a previous layer.而InceptionThe network uses convolution kernels of different sizes to have different sizes of receptive fields,Finally, splicing to achieve feature fusion of different scales is achieved.
三.结构层次
三. 网络优点
Such a structure exists,利用1x7的卷积和7x1的卷积代替7x7的卷积,This way you can use only approx(1x7 + 7x1) / (7x7) = 28.6%的计算开销;利用1x3的卷积和3x1的卷积代替3x3的卷积,This way you can use only approx(1x3 + 3x1) / (3x3) = 67%的计算开销.
下图利用1x7的卷积和7x1的卷积代替7x7的卷积(This structure is mostly in the codeblock2使用).
下图利用1x3的卷积和3x1的卷积代替3x3的卷积(This structure is mostly in the codeblock3使用).
三.主要代码讲解
The realization idea of the closed eye detection function is as follows:
- 用haarCascaded classifiers are implemented on human faces,Recognition of left and right eyes
- 读取,处理数据集
- 加载模型,输入数据集,训练
- 验证模型
主要是利用InceptionV3The main network structure is featured,Modify the full link part of the output layer of the network for retraining. The specific network structure code is as follows:
def V3Model(classes=2):
# 采用imagenet as weight
# include_top=False 不采用Inception原始分类,自定义分类
base_model = InceptionV3(weights='imagenet', include_top=False)
# 输出层
x = base_model.output
# 可以使用gap全局池化代替flatten,It can be seen from the comparison of parameters,This improvement greatly reduces the number of parameters used,避免了过拟合现象.
x = GlobalAveragePooling2D()(x)
x = Dense(1024, activation='relu')(x)
x = Dropout(0.5)(x)
y = Dense(classes, activation='softmax')(x)
model = Model(inputs=base_model.input, outputs=y)
# The previous training parameters are not used
for layer in base_model.layers:
layer.trainable = True
model.summary()
return model
部分训练,测试代码
if os.path.exists("data/checkpoints"):
print('-------------load the model-----------------')
model.load_weights("data/checkpoints/model.006-0.040.h5")
model.compile(optimizer='Adam',
loss='categorical_crossentropy', metrics=['accuracy'])
model.fit_generator(train_data, steps_per_epoch=train_data.samples // batchsize,
epochs=50,
validation_data=validation_data,
validation_steps=validation_data.samples // batchsize,
verbose=1,
callbacks=callbacks)
loss, acc = model.evaluate_generator(train_data)
val_loss, val_acc = model.evaluate_generator(validation_data)
print(f"acc:{
acc},loss:{
loss},val_acc:{
val_acc},val_loss:{
val_loss}")
数据集处理
for dirpath, dirname, filename in os.walk(raw_data):
for file in tqdm([f for f in filename if f.endswith('.png')]):
if file.split('_')[4] == '0':
path = '/home/delixus/Desktop/drowsiness_detection/data/train/closed'
if not os.path.exists(path):
os.makedirs(path)
shutil.copy(src=dirpath + '/' + file, dst=path)
elif file.split('_')[4] == '1':
path = '/home/delixus/Desktop/drowsiness_detection/data/train/open'
if not os.path.exists(path): os.makedirs(path)
shutil.copy(src=dirpath + '/' + file, dst=path)
四.源码及模型下载
闭眼检测tensorflow源码,h5训练模型,准确率达98%.Late Open Source and Models
边栏推荐
猜你喜欢
Flask failed to create database without error
中英文说明书丨TRC 交替醇(Catalogue NumberA575760)
jvm线程状态
Go lang1.18入门精炼教程——第一章:环境搭建
Xilinx Zynq ZynqMP DNA
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disab
变压器的工作原理(图解,原理图讲解,一看就懂)
网络学习总结
longest substring without repeating characters
ByteDance Interview Questions: Mirror Binary Tree 2020
随机推荐
无重复的字符的最长子串
VS2019 common shortcut keys
线程池总结
P6阿里机试题之2020 斐波那契数
思维方法 解决问题的能力
Search 1688 product interface by image (item_search_img-search 1688 product by image (Politao interface) code docking tutorial
Distributed id generator implementation
longest substring without repeating characters
Service
CMake中INSTALL_RPATH与BUILD_RPATH问题
中英文说明书丨TRC 交替醇(Catalogue NumberA575760)
数据库中间件-jdbi
The JVM thread state
The singleton pattern
VS2019常用快捷键
static静态关键字和继承
普罗米修斯原理及节点发布
db.sqlite3没有“as Data Source“解决方法
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disab
单例模式