当前位置:网站首页>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
边栏推荐
- 推进产教融合 赋能教育创新发展 | 华云数据荣获“企业贡献奖”
- static静态关键字和继承
- io.lettuce.core。RedisCommandTimeoutException命令超时
- Distributed id generator implementation
- Leetcode 70 stairs issues (Fibonacci number)
- IQ Products CMV Brite Turbo试剂盒的原理
- TCP segment of a reassembled PDU
- 中英文说明书丨TRC 交替醇(Catalogue NumberA575760)
- How to find package information and pin definitions for NXP S32K1xx series microcontrollers
- 中英文说明书丨CalBioreagents 醛固酮单克隆抗体
猜你喜欢
随机推荐
集合内之部原理总结
运放-运算放大器经典应用电路大全-应用电路大全
jvm线程状态
先序遍历,中序遍历,后序遍历,层序遍历
APP商品详情源数据接口(淘宝/京东/拼多多/苏宁/抖音等平台详情数据分析接口)代码对接教程
使用百度EasyDL实现智能垃圾箱
SIGINT,SIGKILL,SIGTERM信号区别,各类信号总结
mysql 总结
Service
报错:flask: TypeError: ‘function‘ object is not iterable
电学知识的疑问
IQ Products巨细胞病毒CMV感染检测试剂盒的特征和应用
Error: flask: TypeError: 'function' object is not iterable
ByteDance Interview Questions: Mirror Binary Tree 2020
安装flask
输入框最前面添加放大镜&&background-image和background-color冲突问题
单例 DCL(double check lock) 饱汉模式和饿汉模式
The Integer thread safe
PDF不能打印和复制的问题如何解决?
Singleton DCL (double check the lock) full han mode and the hungry