针对目标检测算法中深度卷积网络提取特征图关联性不足导致的检测精度下降问题,提出一种基于群体感受野模块(Receptive Field Block, RFB)与坐标注意力(Coordinate Attention, CA)的改进SSD目标检测算法。使用深层特征提取网络ResNet50作为主干网络,并在卷积层结构中添加坐标注意力模块,捕获方向和位置感知的信息;为充分利用不同特征图之间的关联信息,在特征提取与预测中采用反卷积与上采样等方式,融合低层位置特征和高层语义信息。同时在网络结构中引入多尺度卷积核与空洞卷积的RFB模块,以提高感受野的方式提高网络的特征提取能力。实验表明:该算法在PASCAL VOC 2007数据集上的mAP为78.08%,相较于传统的SSD算法检测能力得到了显著提升。 Aiming at the problem of insufficient correlation of feature map extracted by deep convolutional network in object detection algorithm, an improved SSD object detection algorithm based on Receptive Field Block and Coordinate Attention is proposed. The deep feature extraction network ResNet50 is used as the backbone network, and a coordinate attention module is added to the convolutional layer structure to capture the information of direction and location awareness. In order to make full use of the association information between different feature maps, deconvolution and upsampling are used in feature extraction and prediction to integrate low-level location features and high-level semantic information. At the same time, the RFB module of multi-scale convolution kernel and hole convolution is introduced in the network structure to improve the feature extraction ability of the network by improving the receptive field. Experiments show that the mAP of the algorithm on the PASCAL VOC 2007 dataset is 78.08%, which is significantly improved compared with the traditional SSD algorithm.
针对目标检测算法中深度卷积网络提取特征图关联性不足导致的检测精度下降问题,提出一种基于群体感受野模块(Receptive Field Block, RFB)与坐标注意力(Coordinate Attention, CA)的改进SSD目标检测算法。使用深层特征提取网络ResNet50作为主干网络,并在卷积层结构中添加坐标注意力模块,捕获方向和位置感知的信息;为充分利用不同特征图之间的关联信息,在特征提取与预测中采用反卷积与上采样等方式,融合低层位置特征和高层语义信息。同时在网络结构中引入多尺度卷积核与空洞卷积的RFB模块,以提高感受野的方式提高网络的特征提取能力。实验表明:该算法在PASCAL VOC 2007数据集上的mAP为78.08%,相较于传统的SSD算法检测能力得到了显著提升。
目标检测,单阶多层检测器,RFB模块,坐标注意力
Zhiqing Wang
School of Computer Science, Nanjing University of Posts and Telecommunications, Nanjing Jiangsu
Received: Aug. 15th, 2023; accepted: Oct. 7th, 2023; published: Oct. 18th, 2023
Aiming at the problem of insufficient correlation of feature map extracted by deep convolutional network in object detection algorithm, an improved SSD object detection algorithm based on Receptive Field Block and Coordinate Attention is proposed. The deep feature extraction network ResNet50 is used as the backbone network, and a coordinate attention module is added to the convolutional layer structure to capture the information of direction and location awareness. In order to make full use of the association information between different feature maps, deconvolution and upsampling are used in feature extraction and prediction to integrate low-level location features and high-level semantic information. At the same time, the RFB module of multi-scale convolution kernel and hole convolution is introduced in the network structure to improve the feature extraction ability of the network by improving the receptive field. Experiments show that the mAP of the algorithm on the PASCAL VOC 2007 dataset is 78.08%, which is significantly improved compared with the traditional SSD algorithm.
Keywords:Object Detection, Single-Stage Multilayer Detector, RFB Module, Coordinate Attention
Copyright © 2023 by author(s) and beplay安卓登录
This work is licensed under the Creative Commons Attribution International License (CC BY 4.0).
http://creativecommons.org/licenses/by/4.0/
目标检测作为计算机视觉的一项基本任务,也是计算机视觉领域中研究热点之一,在无人驾驶、智能视频监控、生物检测等方面有着广泛的应用。随着基于深度学习目标检测算法的研究与发展,其主要检测算法可以划分成两类:基于候选区域的双阶段目标检测算法和基于回归分析的单阶段目标检测算法 [
SSD算法对小目标检测性能不佳,主要原因有:特征信息少,正负样本不平衡、数据集不完备以及锚框设计难等 [
本文基于传统SSD算法的不足,设计了一种基于群体感受野模块与坐标注意力机制的改进SSD目标检测算法。在前两层较浅预测特征图后添加RFB模块,增加感受野。并在ResNet50网络中引入坐标注意力机制,不仅获取通道间信息,还考虑了方向相关的位置信息,有效地提升模型的准确率。比较实验结果,改进后的SSD算法检测精度有明显提升。
基于群体感受野模块与坐标注意力的改进SSD目标检测算法结构如图1所示。网络架构设计遵循的主要原则是在主干网络中降低特征信息损失,采用ResNet50 [
在主干网络提取出来的(38, 38)、(19, 19)和(10, 10)特征层后,考虑通道之间远程依赖关系,经过坐标注意力模块进行编码。为增强信息表达能力,将深层特征层与浅层特征层进行有效信息融合,(19, 19)和(10, 10)尺寸特征层采用线性插值方式将其放大到(38, 38)尺寸,并进行Concat方式融合。同时为改善网络的梯度,防止梯度爆炸,实现归一化,采用BN层处理。在生成预测特征层上,采用反卷积方式再次进行特征融合 [
图1. 基于RFB与注意力机制的SSD目标检测算法
坐标注意力模块 [
具体来说,输入的特征图为X,大小为 C × H × W 的特征图,其高和宽为H和W,高度为 的第c个通道的输出 z c h ( h ) 为:
z c h ( h ) = 1 W ∑ i = 0 W − 1 x c ( h , i ) (1)
式中 x c ( h , i ) 为第i行特征向量。
宽度w的第c个通道的输出 z c w ( w ) 为:
z c w ( w ) = 1 H ∑ j = 0 H − 1 x c ( j , w ) (2)
式中 x c ( j , w ) 为第j列特征向量。
通过上述操作可以获得全局感受野和位置信息。拼接两个输出结果后,再使用1 × 1卷积操作可以得到空间信息经过编码后的中间特征图F。
F = δ ( F 1 ( [ z h , z w ] ) ) (3)
式中 z h 为所有高度为h的通道的输出; z w 为所有宽度为w的通道的输出; [ z h , z w ] 为特征图在垂直和水平方向上的拼接;F1为卷积操作; δ 为非线性激活函数。
然后将F切分为2个单独的张量,再分别利用1 × 1卷积变换成X相同的通道数,最后利用Sigmoid激活函数得到注意力权重 g h 和 g w 。
输入特征图X的第c通道上高度为i宽度为j的特征 x c ( i , j ) 经过坐标注意力模块后的输出 y c ( i , j ) 为:
y c ( i , j ) = x c ( i , j ) × g c h ( i ) × g c w ( j ) (4)
式中: g c h ( i ) 表示第c通道上高度为i的水平注意力权重, g c w ( j ) 表示第c通道上宽度为j的水平注意力权重。
图2. 坐标注意力模块
RFB模块 [
图3. RFB模块
本文采用的RFB模块的两种结构如图3所示,由多分支卷积结构和空洞卷积构成。先用一个1 × 1的卷积减少通道数,再加上一个3 × 3的卷积,RFB_a模块第1个分支为一个空洞率为3的3 × 3空洞卷积,第2个分支先经过一个3 × 3的普通卷积,再经过一个空洞率为3的3 × 3空洞卷积,第3个分支首先经过两个3 × 3的卷积,其效果等于一个5 × 5的卷积,之后经过空洞率为5的3 × 3空洞卷积,最后通过Concat通道级联。RFB-b和RFB_a相比主要采用1 × 3和3 × 1卷积层代替3 × 3卷积层,主要增加了模型的非线性特征并减少计算量。
数据集:本文采用公开数据集PASCAL VOC 2007 + 2012进行实验,该数据集总共有20种常见类别,此次实验为扩大训练集数据,合并了VOC 2007和2012的训练集,测试数据为VOC 2007测试集。
评价指标:mAP作为目标检测领域重要评估指标之一,综合考虑了所有的类别以及定位精度等问题,其值越大模型的检测性能越好。计算方法为式1~式3。
P = T P T P + F P , R = T P T P + F N (5)
A P = ∫ 0 1 P ( R ) d R ≈ 1 m ∑ i = 1 m P ( R i ) (6)
m A P = 1 C ∑ i = 1 C A P i (7)
实验平台配置:本实验操作系统为Windows11,具体配置如表1所示。
配置项 | 配置参数 |
---|---|
内存 | 16GB |
显卡(显存) | NVIDIA RTX3060(8GB) |
处理器(CPU) | Intel i5-12490F |
深度学习框架 | Pytorch |
CUDA版本 | 11.7 |
输入图片尺寸 | 300 × 300 |
权重衰减参数 | 0.1 |
batchsize | 16 |
初始学习率 | 0.001 |
MAX_ITER | 120000 |
表1. 实验配置参数
为了验证改进后模型的有效性,本文设置了对照实验:① 标准SSD模型作为实验对照组;② 使用ResNet50作为骨干网络,在特征提取阶段融合不同深度特征图;③ 在实验2的基础上,增加坐标注意力模块;④ 在实验3的基础上,增加RFB模块,同时将19尺寸特征图反卷积操作与上层特征图融合。
4种模型的实验结果平均精度值mAP如表2所示,分析实验结果,在原SSD模型基础上每改进后,mAP值均有提升,其中引入坐标注意力模块和RFB模块后,mAP值分别提升了0.92%和0.85%。实验表明,坐标注意力模块和RFB模块对于传统SSD算法性能的提升有着显著的效果。
模型 | VGG-16 | ResNet50 | CA | RFB | mAP/% |
---|---|---|---|---|---|
SSD | √ | 76.17 | |||
SSD | √ | 76.31 | |||
SSD_CA | √ | √ | 77.23 | ||
SSD_CA_RFB | √ | √ | √ | 78.08 |
表2. PASCAL VOC 2007测试集对比
20种目标类别检测准确率AP如表3所示,绝大部分类别的准确率均有显著提升,其中aeroplane、bird、diningtable和tvmonitor尤为突出,分别提升了4.21%、3.62%、4.45%和4.28%。
种类 | SSD_VGG | SSD_ResNet | SSD_CA | SSD_CA_RFB |
---|---|---|---|---|
aeroplane | 0.7982 | 0.8222 | 0.8270 | 0.8403 |
bicycle | 0.8386 | 0.8649 | 0.8522 | 0.8552 |
bird | 0.7438 | 0.7885 | 0.7827 | 0.7800 |
boat | 0.7000 | 0.6732 | 0.6987 | 0.6924 |
bottle | 0.5122 | 0.4871 | 0.5008 | 0.5087 |
bus | 0.8443 | 0.8534 | 0.8295 | 0.8573 |
car | 0.8579 | 0.8574 | 0.8613 | 0.8597 |
cat | 0.8693 | 0.8752 | 0.8713 | 0.8773 |
chair | 0.6062 | 0.6095 | 0.6019 | 0.5936 |
cow | 0.8097 | 0.7964 | 0.8372 | 0.8237 |
diningtable | 0.7282 | 0.7489 | 0.7665 | 0.7727 |
dog | 0.8349 | 0.8627 | 0.8686 | 0.8602 |
horse | 0.8596 | 0.8529 | 0.8741 | 0.8765 |
motorbike | 0.8252 | 0.8579 | 0.8535 | 0.8567 |
person | 0.7871 | 0.7774 | 0.7839 | 0.7847 |
pottedplant | 0.4920 | 0.5217 | 0.5177 | 0.5224 |
sheep | 0.7316 | 0.7656 | 0.8153 | 0.7852 |
sofa | 0.7979 | 0.7781 | 0.8029 | 0.8117 |
train | 0.8503 | 0.8672 | 0.8524 | 0.8672 |
tvmonitor | 0.7480 | 0.7942 | 0.7816 | 0.7908 |
表3. 20种类别不同算法测试结果
VOC2007测试集数据有4952张,测试阶段通过单张批量测试得到分类损失、定位损失及总损失,以传统SSD算法作为基线模型,对比每个组件对模型的检测性能的作用,本文模型的总损失值最低且收敛速度略优于原模型,表明了本文模型能有效降低分类定位损失,提升算法的检测性能。分类损失和回归损失的总损失效果对比如图4所示。
图4. 不同算法loss对比图
本文设计了一种基于群体感受野模块与坐标注意力机制的改进SSD目标检测算法,采用ResNet50网络作为特征提取的骨干网络,并引入轻量级坐标注意力机制,能够同时考虑通道间关系以及长距离的位置信息,利于模型更准确定位目标信息,增强识别能力,且坐标注意力模块轻量灵活仅带来少量的计算消耗。在特征提取阶段通道拼接融合不同深度卷积层输出,丰富预测特征图上下文信息,同时在预测过程中加入RFB模块,通过不同尺寸卷积核的多分支结构和空洞卷积来提高感受野,增强特征提取能力。通过实验验证,叠加各个模块后,算法的检测精确度均有提升。实验表明,改进后目标检测算法在PASCAL VOC数据集上各类别的检测准确率较传统SSD算法有着显著提高,mAP比传统SSD算法提升了1.91%。
国家自然科学基金(61872190);江苏省博士后科研资助计划项目(2020Z058)。
王志青. 基于RFB模块与注意力机制的目标检测算法Object Detection Algorithm Based on RFB Module and Attention Mechanism[J]. 软件工程与应用, 2023, 12(05): 697-704. https://doi.org/10.12677/SEA.2023.125067
https://kns.cnki.net/kcms/detail/11.2127.TP.20230620.1746.002.html, 2023-01-13.
https://doi.org/10.1109/ICCV.2015.169
https://doi.org/10.1109/CVPR.2016.91
https://doi.org/10.48550/arXiv.1701.06659
https://doi.org/10.1609/aaai.v33i01.33019259
https://doi.org/10.1109/CVPR.2018.00062
https://doi.org/10.1109/CVPR.2017.243
https://doi.org/10.1109/CVPR.2016.90
https://doi.org/10.1117/12.2304811
https://doi.org/10.1109/CVPR46437.2021.01350
https://doi.org/10.1007/978-3-030-01252-6_24