当前位置:网站首页>Inception V3 闭眼检测
Inception V3 闭眼检测
2022-08-09 06:27:00 【Starry-sky(jing)】
一. 模型演示
闭眼检测
闭眼检测准确率高达98%
二.网络设计
网络结构转载来源 : 经典卷积网络之InceptionV3
InceptionV3模型是google系列第三代模型,Inception网络最大的特点是将神经网络层与层之间的卷积运算进行了拓展.
如VGG,AlexNet网络就是一直卷积,ResNet则是引入了残差网络,使得靠前若干层的某一层数据直接跳过多层引入到后面的数据层的输入部分,后面的特征层的内容会有一部分有前面的某一层线性提供.而Inception网络则是采用不同大小的卷积核是的存在不同大小的感受野,最后实现拼接达到不同尺度的特征融合.
三.结构层次
三. 网络优点
存在着这样的结构,利用1x7的卷积和7x1的卷积代替7x7的卷积,这样可以只使用约(1x7 + 7x1) / (7x7) = 28.6%的计算开销;利用1x3的卷积和3x1的卷积代替3x3的卷积,这样可以只使用约(1x3 + 3x1) / (3x3) = 67%的计算开销。
下图利用1x7的卷积和7x1的卷积代替7x7的卷积(这个结构主要在代码中的block2使用)。
下图利用1x3的卷积和3x1的卷积代替3x3的卷积(这个结构主要在代码中的block3使用)。
三.主要代码讲解
闭眼检测功能实现思路如下:
- 用haar级联分类器实现对人脸,左右眼睛的识别
- 读取,处理数据集
- 加载模型,输入数据集,训练
- 验证模型
主要是利用InceptionV3主网络结构作特征,修改网络输出层全链接部分做重新训练具体网络结构代码如下:
def V3Model(classes=2):
# 采用imagenet 作权重
# include_top=False 不采用Inception原始分类,自定义分类
base_model = InceptionV3(weights='imagenet', include_top=False)
# 输出层
x = base_model.output
# 可以使用gap全局池化代替flatten,从参数的对比可以看出,这种改进大大的减少了参数的使用量,避免了过拟合现象。
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)
# 不使用之前训练参数
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%.后期开放源码与模型
边栏推荐
- Harbor Enterprise Mirror Warehouse Construction
- flask创建数据库失败未报错
- 直接用的zip包 缺少很多依赖,pip没有,感觉用anaconda create一个环境会方便点
- DDD 领域驱动设计
- Unity Gobang Game Design and Simple AI(3)
- sql问题解答创建表的语句
- CMake中INSTALL_RPATH与BUILD_RPATH问题
- 正则表达式-判断字符串是否匹配“AABB”模式
- IQ Products CMV Brite Turbo试剂盒的原理
- Cysteine/Galactose/Perylenediimide Functionalized Fe3O4 Fe3O4 Nanomaterials | Scientific Research Reagents
猜你喜欢
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
Xilinx Zynq ZynqMP DNA
qt send mail program
- [email protected]@BSABiS nanoparticles) | dendrimer-stabilized bismuth sulfide nanop"/>
Ferric oxide/bismuth sulfide nanocomposites ([email protected]@BSABiS nanoparticles) | dendrimer-stabilized bismuth sulfide nanop
phpstudy 安装 flarum论坛
redis 运行lua 脚本 出现Invalid argument(s)
深度学习-神经网络原理2
Bismuth sulfide nanorods with CT imaging function | Bismuth sulfide-zinc protoporphyrin composites (PAMAM/Bi2S3 composite nanoparticles)
sql问题解答创建表的语句
网络学习总结
随机推荐
Text String Length Sorting - Online Tool
VS2019常用快捷键
域名批量查询在线工具
db.sqlite3没有“as Data Source“解决方法
剑指offer专项突击版第24天
什么是excel文件保护
【R语言】对文件进行归一化整理到各文件类型文件夹
Unity C# 委托——事件,Action,Func的作用和区别
[GO], arrays and slices
像天才一样思考:如何培养自己的创造力?
Excel受保护的工作表怎么操作?
redis 运行lua 脚本 出现Invalid argument(s)
【Wwise】ArgumentException: The specified path is not of a legal form (empty). About the path reading error in WwiseGlobal
中英文说明书丨CalBioreagents 醛固酮单克隆抗体
pdf加密、找回密码
Unity Gobang Game Design and Simple AI(3)
DevNet: Deviation Aware Networkfor Lane Detection
Likou Brush Question 180
MYSQL Advanced Chapter - Query Interception Analysis, Lock Mechanism, Master-Slave Replication
Qt 学习(三) —— Qt 模块