在很多的项目实战中验证分析注意力机制的加入对于模型最终性能的提升发挥着积极正向的作用,在我之前的一些文章里面也做过了一些尝试,这里主要是想基于轻量级的n系列模型来开发构建共享单车检测系统,在模型中加入CBAM模块,以期在轻量化的基础上进一步提升模型的检测性能。首先来看下效果图:

这里数据集的目标对象只有一个就是:bicycle(共享单车)
使用的模型yaml文件如下:
-
#Parameters
-
nc:
1
# number of classes
-
depth_multiple:
0.33
# model depth multiple
-
width_multiple:
0.25
# layer channel multiple
-
anchors:
-
- [
10,
13,
16,
30,
33,
23]
# P3/8
-
- [
30,
61,
62,
45,
59,
119]
# P4/16
-
- [
116,
90,
156,
198,
373,
326]
# P5/32
-
-
-
#Backbone
-
backbone:
-
# [from, number, module, args]
-
[[-
1,
1, Conv, [
64,
6,
2,
2]],
# 0-P1/2
-
[-
1,
1, Conv, [
128,
3,
2]],
# 1-P2/4
-
[-
1,
3, C3, [
128]],
-
[-
1,
1, Conv, [
256,
3,
2]],
# 3-P3/8
-
[-
1,
6, C3, [
256]],
-
[-
1,
1, Conv, [
512,
3,
2]],
# 5-P4/16
-
[-
1,
9, C3, [
512]],
-
[-
1,
1, Conv, [
1024,
3,
2]],
# 7-P5/32
-
[-
1,
3, C3, [
1024]],
-
[-
1,
1, SPPF, [
1024,
5]],
# 9
-
]
-
-
-
#Head
-
head:
-
[[-
1,
1, Conv, [
512,
1,
1]],
-
[-
1,
1, nn.Upsample, [
None,
2,
'nearest']],
-
[[-
1,
6],
1, Concat, [
1]],
# cat backbone P4
-
[-
1,
3, C3, [
512,
False]],
# 13
-
-
[-
1,
1, Conv, [
256,
1,
1]],
-
[-
1,
1, nn.Upsample, [
None,
2,
'nearest']],
-
[[-
1,
4],
1, Concat, [
1]],
# cat backbone P3
-
[-
1,
3, C3, [
256,
False]],
# 17 (P3/8-small)
-
-
[-
1,
1, Conv, [
256,
3,
2]],
-
[[-
1,
14],
1, Concat, [
1]],
# cat head P4
-
[-
1,
3, C3, [
512,
False]],
# 20 (P4/16-medium)
-
-
[-
1,
1, Conv, [
512,
3,
2]],
-
[[-
1,
10],
1, Concat, [
1]],
# cat head P5
-
[-
1,
3, C3, [
1024,
False]],
# 23 (P5/32-large)
-
[-
1,
1, CBAM, [
1024]],
-
-
[[
17,
20,
24],
1, Detect, [nc, anchors]],
# Detect(P3, P4, P5)
-
]

这里在检测头前面加入了CBAM模块,同时最终的层索引号也要加1处理变成了24。
简单看下数据情况:

都是平时比较场景的路边室外的拍摄素材。
VOC格式标注数据文件:

YOLO格式标注数据文件:

默认设定100次epoch计算,我是在CPU模式下面进行训练的,日志输出如下所示:



结果目录数据如下所示:

标签可视化如下:

F1值曲线和PR曲线:

混淆矩阵:

检测实例如下:

后续使用基于专门的界面实现推理可视化如下所示:

上传图像:

推理检测:

转载:https://blog.csdn.net/Together_CZ/article/details/128624135
查看评论