当前位置:网站首页>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
边栏推荐
- After the VB.net program is closed, the background is still connected to SQL
- Service
- XxlJobConfig分布式定时器任务管理XxlJob配置类,替代
- Integer 线程安全的
- Error: flask: TypeError: 'function' object is not iterable
- crc计算
- 工控设备的系统如何进行加固
- APP product source data interface (taobao, jingdong/spelling/suning/trill platform details a lot data analysis interface) code and docking tutorial
- Leetcode 70 stairs issues (Fibonacci number)
- Unity Gobang Game Design and Simple AI(3)
猜你喜欢
推进产教融合 赋能教育创新发展 | 华云数据荣获“企业贡献奖”
ByteDance Interview Questions: Mirror Binary Tree 2020
workbench 数据导出
使用百度EasyDL实现智能垃圾箱
The solution that does not work and does not take effect after VScode installs ESlint
Flask failed to create database without error
The JVM thread state
2022-08-08: Given an array arr, it represents the height of the missiles that will appear in order from morning to night.When the cannon shoots missiles, once the cannon is set to shoot at a certain h
95后,刚工作2-3年就年薪50W+ ,才发现打败我们的,从来不是年龄···
db.sqlite3没有“as Data Source“解决方法
随机推荐
Go lang1.18入门精炼教程——第一章:环境搭建
锁执行的过程
Gao Zelong, a famous digital collection expert and founder of the Digital Collection Conference, was interviewed by China Entrepreneur Magazine
AD画PCB板教程 20分钟讲清楚操作流程 铺铜 网络标号
Built-in macros in C language (define log macros)
The singleton pattern
分布式id 生成器实现
Fragments
leetcode 之 零移位
APP product source data interface (taobao, jingdong/spelling/suning/trill platform details a lot data analysis interface) code and docking tutorial
逆向工程
Remember a nest.js route that matches all the path problems that follow
移远EC20 4G模块拨号相关
mysql summary
io.lettuce.core。RedisCommandTimeoutException命令超时
P7阿里面试题2020.07 之滑动窗算法(阿里云面试)
Unity Gobang Game Design and Simple AI(3)
.NET高级技术
抗菌药物丨Toronto Research Chemicals 天冬酰胺D
uniapp实现防抖搜索