开放科学(资源服务)标志码(OSID):
目标检测技术是很多计算机视觉任务的基础,如实例分割[1-3]、图像描述[4-5]、目标跟踪[6]等,并且在工业、安防、视频监控、人脸识别[7]、机器人视觉[8]、自动驾驶[9]等诸多领域有极大的研究价值和应用前景,受到了学者们的广泛关注。当前,目标检测的研究已取得较大进展,检测精度及速度在不断提高。但是,由于尺度变化、旋转、遮挡、光照以及物体的稠密度、角度等不同因素的影响,目标检测的精度仍有较大的提升空间。近年来,基于深度学习的目标检测成为研究热点,卷积神经网络可以快速、准确地从大量样本中学习更通用的特征,并且无需对样品进行预处理,避免了复杂的手工制作和设计。
基于深度学习的目标检测算法大致分为两阶段检测算法和单阶段检测算法两种:一种是包括R-CNN[10]、Fast R-CNN[11]、Faster R-CNN[12]和Pyramid Networks[13]的两阶段检测算法,被称为基于候选区域的目标检测算法,其将目标检测过程分解为候选区域提取、候选区域分类和候选区域坐标修正3个步骤;另一种是包括SSD[14]、RetinaNet[15]和YOLO[16-18]系列的单阶段检测算法,被称为基于回归分析的目标检测算法,其将目标检测问题视为对目标位置和类别信息的回归分析问题,通过一个神经网络模型直接输出检测结果。尽管存在这些不同的检测框架,但无论对于单阶段算法还是两阶段算法,边界框回归都是预测矩形框以对目标对象进行定位的关键步骤。
现有的目标检测算法常用平均绝对误差(Mean Absolute Error,MAE)损失(又称L1范数损失)、均方误差(Mean Square Error,MSE)损失(又称L2范数损失)函数计算边界框位置坐标的回归损失,但是L1、L2范数损失对边界框的尺度具有敏感性,尺度越小的边界框预测偏差对其影响越大,且卷积神经网络在评价边界框的回归效果时使用交并比(Intersection over Union,IoU)作为评价标准,而L1、L2范数损失与IoU之间的优化并非等价。文献[19]提出将IoU作为边界框回归损失函数对检测模型进行优化,但是存在真值框与预测框无交集时优化效果不佳的情况。文献[20]提出一种通用的优化边界框的方式破折号GIoU,解决了在真值框和预测框无交集的情况下将IoU作为边界框损失函数不能反映边界框之间的距离、以及函数梯度为零导致模型无法被优化等问题。文献[21]采用GIoU损失对YOLOv2模型损失函数进行改进,提高了模型对车身焊点的检测精度。文献[22]在YOLOv3网络中引入空间金字塔池化单元,并采用GIoU损失计算坐标损失,在不降低速度的情况下,提高了无人机对罂粟的检测效率。上述损失函数虽然总体上比传统边界框损失函数效果更好,但在某些情况下仍存在收敛效果不佳的问题。
本文提出边界框回归损失算法BR-IoU。将IoU作为边界框回归的损失项,加强损失函数的优化与IoU之间的联系,并添加惩罚项加快真值框与预测框中心点之间的重叠速度,通过使预测框和真值框宽高比保持一致,提升边界框的回归收敛效果。
1 相关工作 1.1 IoU与GIoU交并比(IoU)也被称为Jaccard系数,用于衡量两个边界框重叠面积的相对大小,是2D和3D目标检测中常用的评价标准。IoU具有尺度不变性、非负性和对称性,不仅可以用来确定正负样本,而且还可以反映模型中预测框的检测效果。如图 1所示,A和B为2个重叠的边界框,其Jaccard系数公式如下:
$ {I}_{\mathrm{I}\mathrm{o}\mathrm{U}}(\mathrm{A}, \mathrm{B})=\frac{|\mathrm{A}\bigcap \mathrm{B}|}{|\mathrm{A}\bigcup \mathrm{B}|} $ | (1) |
![]() |
Download:
|
图 1 矩形A、B与最小封闭框C Fig. 1 Rectangle A, B and the smallest enclosed frame C |
将IoU作为边界框回归损失,其损失函数如下:
$ {{I}_{\mathrm{I}\mathrm{o}\mathrm{U}\_}}_{\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}=1-{I}_{\mathrm{I}\mathrm{o}\mathrm{U}} $ | (2) |
虽然IoU作为评价标准具有优势,但是当边框无交集时将IoU作为损失函数会导致无法反映两个边界框彼此之间的距离、损失函数梯度为零不能被优化等问题。如图 2所示,图 2(a)场景预测框的位置相较于图 2(b)场景离真实框更近,但是IoU的值却都为0。
![]() |
Download:
|
图 2 边界框无交集时IoU的比较 Fig. 2 IoU comparison when bounding boxes have no intersection |
基于此,2019年REZATOFGHI等[20]提出的GIoU继承了IoU具有的尺度不变性、非负性和对称性,同时克服了IoU在边界框无交集情况下的不足。令图 1中包含A和B的最小封闭框为C,则GIoU公式如下:
$ {G}_{\mathrm{G}\mathrm{I}\mathrm{o}\mathrm{U}}(\mathrm{A}, \mathrm{B})={I}_{\mathrm{I}\mathrm{o}\mathrm{U}}(\mathrm{A}, \mathrm{B})-\frac{|\mathrm{C}\backslash (\mathrm{A}\bigcup \mathrm{B}\left)\right|}{\left|\mathrm{C}\right|} $ | (3) |
当A、B两个边界框完全重叠时,
$ \underset{\frac{|\mathrm{A}\bigcup \mathrm{B}|}{\left|\mathrm{C}\right|}\to 0}{\mathrm{l}\mathrm{i}\mathrm{m}}{G}_{\mathrm{G}\mathrm{I}\mathrm{O}\mathrm{U}}(\mathrm{A}, \mathrm{B})=-1 $ | (4) |
GIoU取值区间的对称性使其比IoU更能反映边界框的重叠和非重叠情况。本文将GIoU作为边界框回归损失,其损失函数如下:
$ {G}_{\mathrm{G}\mathrm{I}\mathrm{o}\mathrm{U}\_\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}=1-{G}_{\mathrm{G}\mathrm{I}\mathrm{o}\mathrm{U}} $ | (5) |
可以看出,边界框之间的GIoU值越大,
YOLOv3模型是具有代表性的单阶段目标检测算法,其通过缩放、填充将不同尺寸输入图像的大小调整为32的倍数,再分成S×S个非重叠的网格,如图 3所示(S=7)。
![]() |
Download:
|
图 3 输入图像网格示意图 Fig. 3 Grid diagram of input image |
每个网格负责检测中心点位置坐标落入该格的物体,网格中预设有3个边界框和C个类别概率。在边界框预测的5个分量x、y、w、h和置信度中,(x,y)坐标表示边界框的中心点相对于网格单元的位置,(w,h)坐标表示边界框的尺寸,置信度用来判断边界框中存在物体的概率。YOLOv3通过对置信度设定阈值过滤掉低分的边界框,再对剩下的边界框使用非极大值抑制(Non-Maximum Supression,NMS)算法去除冗余边界框,得到预测结果,因此,YOLOv3每个网格有
YOLOv3采用L2范数计算边界框坐标的回归损失,L2范数损失中不同尺寸边界框对其预测框坐标产生偏差的敏感度也不同。相对于大尺寸边界框,尺寸越小的边界框预测偏差对其IoU的影响越大,因此,YOLOv3在边界框位置损失部分乘以系数
$ \begin{array}{l}{L}_{\mathrm{L}\mathrm{o}\mathrm{s}\mathrm{s}}={b}_{\mathrm{b}\mathrm{b}\mathrm{o}\mathrm{x}\_\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}+{c}_{\mathrm{c}\mathrm{o}\mathrm{n}\mathrm{f}\_\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}+{p}_{\mathrm{p}\mathrm{r}\mathrm{o}\mathrm{b}\_\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}=\\ {\lambda }_{\mathrm{c}\mathrm{o}\mathrm{o}\mathrm{r}\mathrm{d}}\sum\limits_{i=0}^{{S}^{2}}\sum\limits_{j=0}^{B}{I}_{ij}^{\mathrm{o}\mathrm{b}\mathrm{j}}(2-{w}_{i}^{j}\times {h}_{i}^{j})\times \\ \left[({x}_{i}^{j}-{\widehat{x}}_{i}^{j}{)}^{2}+({y}_{i}^{j}-{\widehat{y}}_{i}^{j}{)}^{2}+({w}_{i}^{j}-{\widehat{w}}_{i}^{j}{)}^{2}+({h}_{i}^{j}-{\widehat{h}}_{i}^{j}{)}^{2}\right]-\\ \sum\limits_{i=0}^{{S}^{2}}\sum\limits_{j=0}^{B}{I}_{ij}^{\mathrm{o}\mathrm{b}\mathrm{j}}\left[{\widehat{C}}_{i}^{j}\mathrm{l}\mathrm{n}\left({C}_{i}^{j}\right)+(1-{\widehat{C}}_{i}^{j})\mathrm{l}\mathrm{n}(1-{C}_{i}^{j})\right]-\\ {\lambda }_{\mathrm{n}\mathrm{o}\mathrm{b}\mathrm{j}}\sum\limits_{i=0}^{{S}^{2}}\sum\limits_{j=0}^{B}{I}_{ij}^{\mathrm{n}\mathrm{o}\mathrm{o}\mathrm{b}\mathrm{j}}\left[{\widehat{C}}_{i}^{j}\mathrm{l}\mathrm{n}\left({C}_{i}^{j}\right)+(1-{\widehat{C}}_{i}^{j})\mathrm{l}\mathrm{n}(1-{C}_{i}^{j})\right]-\\ \sum\limits_{i=0}^{{s}^{2}}{I}_{ij}^{\mathrm{o}\mathrm{b}\mathrm{j}}\sum\limits_{c\in \mathrm{c}\mathrm{l}\mathrm{a}\mathrm{s}\mathrm{s}\mathrm{e}\mathrm{s}}\left[{\widehat{P}}_{i}^{j}\mathrm{l}\mathrm{n}\left({P}_{i}^{j}\right)+(1-{\widehat{P}}_{i}^{j})\mathrm{l}\mathrm{n}(1-{P}_{i}^{j})\right]\end{array} $ | (6) |
其中:
![]() |
Download:
|
图 4 YOLOv3算法检测过程 Fig. 4 Detection process of YOLOv3 algorithm |
采用L2范数边界框回归损失函数的YOLOv3检测算法通常会出现以下2个问题:
1)如图 5所示,4组边界框角点坐标距离的L2范数损失值相等,但IoU值却不同,这表明L2范数损失不能准确地反映IoU值的变化,与IoU之间不具有强相关性。
![]() |
Download:
|
图 5 L2范数损失值相等时IoU的变化 Fig. 5 Change of IoU when L2 norm loss values are equal |
2)L2范数损失具有尺度敏感性,在算法训练过程中,当两个边界框的IoU值相同时,大尺寸边界框会产生更多的损失值使小尺寸边界框难以被优化,导致算法对小尺寸目标的检测效果不佳。
针对上述问题,本文提出BR-IoU算法,为方便不同边界框损失算法的性能对比,将BR-IoU算法分为BR-IoU-A算法和BR-IoU-B算法。
BR-IoU-A算法将IoU作为边界框回归的损失项,强化与IoU之间的联系,并继承了IoU的尺度不变性,使得不同尺度的边界框在回归过程中获得更均衡的损失优化权重。然后算法在IoU损失项的基础上添加一个惩罚项,通过最小化预测框与真值框中心点围成矩形的面积,加快预测框中心点与真值框中心点的重叠速度。算法的惩罚项使边界框在任何情况下都存在梯度,在边界框无交集的情况下仍然能够反映边界框间的相对距离,为边界框的优化提供移动方向,如图 6所示,D是真值框Bg的中心点
$ {B}_{\mathrm{B}\mathrm{R}-\mathrm{I}\mathrm{o}\mathrm{U}-\mathrm{A}}={I}_{\mathrm{I}\mathrm{o}\mathrm{U}}({\mathrm{B}}^{\mathrm{g}}, \mathrm{B})-\frac{w\times h}{{w}^{\mathrm{c}}\times {h}^{\mathrm{c}}} $ | (7) |
![]() |
Download:
|
图 6 BR-IoU-A算法示意图 Fig. 6 Schematic diagram of BR-IoU-A algorithm |
利用BR-IoU-A算法计算边界框回归损失,损失函数如下:
$ {B}_{\mathrm{B}\mathrm{R}-\mathrm{I}\mathrm{o}\mathrm{U}-\mathrm{A}\_\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}=1-{I}_{\mathrm{I}\mathrm{o}\mathrm{U}}({\mathrm{B}}^{\mathrm{g}}, \mathrm{B})+\frac{w\times h}{{w}^{\mathrm{c}}\times {h}^{\mathrm{c}}} $ | (8) |
BR-IoU-A损失继承了IoU和GIoU损失的优良属性:1)BR-IoU-A损失对边界框的尺度不敏感,具有尺度不变性;2)BR-IoU-A损失在边界框无交集情况下仍然存在损失梯度,可以为边界框的优化提供移动方向;3)当两个边框完全重叠时,
![]() |
Download:
|
图 7 中心点间相对位置比较 Fig. 7 Comparison of relative positions between center points |
图 7(a)图像的检测效果优于图 7(b)图像,BR-IoU-A损失算法通过值的变化来反映这种情况。
算法 BR-IoU-A边界框回归损失算法
输入 预测框B和真实框Bg,坐标分别为
输出
1.确保预测框B中
$ {\widehat{\mathrm{x}}}_{1}=\mathrm{m}\mathrm{i}\mathrm{n}({\mathrm{x}}_{1}, {\mathrm{x}}_{2}) \text{,} {\widehat{\mathrm{x}}}_{2}=\mathrm{m}\mathrm{a}\mathrm{x}({\mathrm{x}}_{1}, {\mathrm{x}}_{2}) $ |
$ {\widehat{\mathrm{y}}}_{1}=\mathrm{m}\mathrm{i}\mathrm{n}({\mathrm{y}}_{1}, {\mathrm{y}}_{2}) \text{,} {\widehat{\mathrm{y}}}_{2}=\mathrm{m}\mathrm{a}\mathrm{x}({\mathrm{y}}_{1}, {\mathrm{y}}_{2}) $ |
$ {\mathrm{A}}^{\mathrm{g}}=({\mathrm{x}}_{2}^{\mathrm{g}}-{\mathrm{x}}_{1}^{\mathrm{g}})\times ({\mathrm{y}}_{2}^{\mathrm{g}}-{\mathrm{y}}_{1}^{\mathrm{g}}) $ |
3.计算预测框B的面积:
$ \mathrm{A}=({\widehat{\mathrm{x}}}_{2}-{\widehat{\mathrm{x}}}_{1})\times ({\widehat{\mathrm{y}}}_{2}-{\widehat{\mathrm{y}}}_{1}) $ |
4.计算预测框B与真值框Bg的重叠面积I:
$ {\mathrm{x}}_{1}^{\mathrm{I}}=\mathrm{m}\mathrm{a}\mathrm{x}({\widehat{\mathrm{x}}}_{1}, {\mathrm{x}}_{1}^{\mathrm{g}}) \text{,} {\mathrm{x}}_{2}^{\mathrm{I}}=\mathrm{m}\mathrm{i}\mathrm{n}({\widehat{\mathrm{x}}}_{2}, {\mathrm{x}}_{2}^{\mathrm{g}}) $ |
$ {\mathrm{y}}_{1}^{\mathrm{I}}=\mathrm{m}\mathrm{a}\mathrm{x}({\widehat{\mathrm{y}}}_{1}, {\mathrm{y}}_{1}^{\mathrm{g}}) \text{,} {\mathrm{y}}_{2}^{\mathrm{I}}=\mathrm{m}\mathrm{i}\mathrm{n}({\widehat{\mathrm{y}}}_{2}, {\mathrm{y}}_{2}^{\mathrm{g}}) $ |
$ \mathrm{I}=\left\{\begin{array}{l}({\mathrm{x}}_{2}^{\mathrm{I}}-{\mathrm{x}}_{1}^{\mathrm{I}})\times ({\mathrm{y}}_{2}^{\mathrm{I}}-{\mathrm{y}}_{1}^{\mathrm{I}})\begin{array}{cc}, {\mathrm{x}}_{2}^{\mathrm{I}} > {\mathrm{x}}_{1}^{\mathrm{I}}, {\mathrm{y}}_{2}^{\mathrm{I}} > {\mathrm{y}}_{1}^{\mathrm{I}}& \end{array}\\ 0, \mathrm{o}\mathrm{t}\mathrm{h}\mathrm{e}\mathrm{r}\mathrm{w}\mathrm{i}\mathrm{s}\mathrm{e}\end{array}\right. $ |
5.
6.求最小封闭框
$ {\mathrm{x}}_{1}^{\mathrm{c}}=\mathrm{m}\mathrm{i}\mathrm{n}({\widehat{\mathrm{x}}}_{1}, {\mathrm{x}}_{1}^{\mathrm{g}}) \text{,} {\mathrm{x}}_{2}^{\mathrm{c}}=\mathrm{m}\mathrm{a}\mathrm{x}({\widehat{\mathrm{x}}}_{2}, {\mathrm{x}}_{2}^{\mathrm{g}}) $ |
$ {\mathrm{y}}_{1}^{\mathrm{c}}=\mathrm{m}\mathrm{i}\mathrm{n}({\widehat{\mathrm{y}}}_{1}, {\mathrm{y}}_{1}^{\mathrm{g}}) \text{,} {\mathrm{y}}_{2}^{\mathrm{c}}=\mathrm{m}\mathrm{a}\mathrm{x}({\widehat{\mathrm{y}}}_{2}, {\mathrm{y}}_{2}^{\mathrm{g}}) $ |
7.计算最小封闭框
$ {\mathrm{w}}^{\mathrm{c}}={\mathrm{x}}_{2}^{\mathrm{c}}-{\mathrm{x}}_{1}^{\mathrm{c}} \text{,} {\mathrm{h}}^{\mathrm{c}}={\mathrm{y}}_{2}^{\mathrm{c}}-{\mathrm{y}}_{1}^{\mathrm{c}} $ |
8.计算预测框
$ \mathrm{b}=\left(\frac{{\widehat{\mathrm{x}}}_{1}+{\widehat{\mathrm{x}}}_{2}}{2}, \frac{{\widehat{\mathrm{y}}}_{1}+{\widehat{\mathrm{y}}}_{2}}{2}\right) \text{,} {\mathrm{b}}^{\mathrm{g}}=\left(\frac{{\mathrm{x}}_{1}^{\mathrm{g}}+{\mathrm{x}}_{2}^{\mathrm{g}}}{2}, \frac{{\mathrm{y}}_{1}^{\mathrm{g}}+{\mathrm{y}}_{2}^{\mathrm{g}}}{2}\right) $ |
9.计算预测框B与真值框Bg中心点围成的矩形框D的坐标:
$ {\mathrm{x}}_{1}^{\mathrm{D}}=\mathrm{m}\mathrm{i}\mathrm{n}\left(\frac{{\widehat{\mathrm{x}}}_{1}+{\widehat{\mathrm{x}}}_{2}}{2}, \frac{{\mathrm{x}}_{1}^{\mathrm{g}}+{\mathrm{x}}_{2}^{\mathrm{g}}}{2}\right) $ |
$ {\mathrm{x}}_{2}^{\mathrm{D}}=\mathrm{m}\mathrm{a}\mathrm{x}\left(\frac{{\widehat{\mathrm{x}}}_{1}+{\widehat{\mathrm{x}}}_{2}}{2}, \frac{{\mathrm{x}}_{1}^{\mathrm{g}}+{\mathrm{x}}_{2}^{\mathrm{g}}}{2}\right) $ |
$ {\mathrm{y}}_{1}^{\mathrm{D}}=\mathrm{m}\mathrm{i}\mathrm{n}\left(\frac{{\widehat{\mathrm{y}}}_{1}+{\widehat{\mathrm{y}}}_{2}}{2}, \frac{{\mathrm{y}}_{1}^{\mathrm{g}}+{\mathrm{y}}_{2}^{\mathrm{g}}}{2}\right) $ |
$ {\mathrm{y}}_{2}^{\mathrm{D}}=\mathrm{m}\mathrm{a}\mathrm{x}\left(\frac{{\widehat{\mathrm{y}}}_{1}+{\widehat{\mathrm{y}}}_{2}}{2}, \frac{{\mathrm{y}}_{1}^{\mathrm{g}}+{\mathrm{y}}_{2}^{\mathrm{g}}}{2}\right) $ |
10.计算矩形框D的宽和高:
$ \mathrm{w}={\mathrm{x}}_{2}^{\mathrm{D}}-{\mathrm{x}}_{1}^{\mathrm{D}} \text{,} \mathrm{h}={\mathrm{y}}_{2}^{\mathrm{D}}-{\mathrm{y}}_{1}^{\mathrm{D}} $ |
11.
在BR-IoU-A算法中,
![]() |
Download:
|
图 8 预测框不同宽高比下的检测效果对比 Fig. 8 Comparison of detection effects under different aspect ratios of predicted bounding boxes |
图 8(a)预测框的宽高比值相较于图 8(b)预测框更接近真实框,预测效果更好,但BR-IoU-A值却相同。因此,本文在BR-IoU-A的基础上,结合预测框与真值框之间宽高比的一致性提出BR-IoU-B损失算法,计算公式如下:
$ B _{{\rm{BR-IoU-B}}} = B _{{\rm{BR-IoU-A}}} -V\times C $ | (9) |
其中,参数V使预测框宽高比与真值框的保持一致,C是V的平衡参数,当两个边界框无交集或IoU值较低时,使边界框之间的重叠因子在回归过程中获得较高优先级,从而加快边界框回归的收敛速度。
$ V={\left(\frac{{w}^{\mathrm{g}}}{{h}^{\mathrm{g}}+{w}^{\mathrm{g}}}-\frac{{w}^{\mathrm{p}}}{{h}^{\mathrm{p}}+{w}^{\mathrm{p}}}\right)}^{2} $ |
$ C=\frac{V}{(1-{I}_{\mathrm{I}\mathrm{O}\mathrm{U}})+V} $ | (10) |
其中:
$ B _{{\rm{BR-IoU-B_loss}}} = 1- B _{{\rm{BR-IoU-A_loss}}} +V\times C $ | (11) |
使用BR-IoU边界框回归损失算法对YOLOv3模型进行改进,改进后的损失函数如下:
$ \begin{array}{l}{L}_{\mathrm{L}\mathrm{o}\mathrm{s}\mathrm{s}}={b}_{\mathrm{b}\mathrm{b}\mathrm{o}\mathrm{x}\_\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}+{c}_{\mathrm{c}\mathrm{o}\mathrm{n}\mathrm{f}\_\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}+{p}_{\mathrm{p}\mathrm{r}\mathrm{o}\mathrm{b}\_\mathrm{l}\mathrm{o}\mathrm{s}\mathrm{s}}=\\ {\lambda }_{\mathrm{c}\mathrm{o}\mathrm{o}\mathrm{r}\mathrm{d}}\sum\limits_{i=0}^{{S}^{2}}\sum\limits_{j=0}^{B}{I}_{ij}^{\mathrm{o}\mathrm{b}\mathrm{j}}(2-{w}_{i}^{j}\times {h}_{i}^{j})\times (1-{B}_{\mathrm{B}\mathrm{R}‒\mathrm{I}\mathrm{o}\mathrm{U}})-\\ \sum\limits_{i=0}^{{S}^{2}}\sum\limits_{j=0}^{B}{I}_{ij}^{\mathrm{o}\mathrm{b}\mathrm{j}}\left[{\widehat{C}}_{i}^{j}\mathrm{l}\mathrm{n}\left({C}_{i}^{j}\right)+(1-{\widehat{C}}_{i}^{j})\mathrm{l}\mathrm{n}(1-{C}_{i}^{j})\right]-\\ {\lambda }_{\mathrm{n}\mathrm{o}\mathrm{b}\mathrm{j}}\sum\limits_{i=0}^{{S}^{2}}\sum\limits_{j=0}^{B}{I}_{ij}^{\mathrm{n}\mathrm{o}\mathrm{o}\mathrm{b}\mathrm{j}}\left[{\widehat{C}}_{i}^{j}\mathrm{l}\mathrm{n}\left({C}_{i}^{j}\right)+(1-{\widehat{C}}_{i}^{j})\mathrm{l}\mathrm{n}(1-{C}_{i}^{j})\right]-\\ \sum\limits_{i=0}^{{s}^{2}}{I}_{ij}^{\mathrm{o}\mathrm{b}\mathrm{j}}\sum\limits_{c\in \mathrm{c}\mathrm{l}\mathrm{a}\mathrm{s}\mathrm{s}\mathrm{e}\mathrm{s}}\left[{\widehat{P}}_{i}^{j}\mathrm{l}\mathrm{n}\left({P}_{i}^{j}\right)+(1-{\widehat{P}}_{i}^{j})\mathrm{l}\mathrm{n}(1-{P}_{i}^{j})\right]\end{array} $ | (12) |
本文实验模型基于Tensorflow1.13.1框架,编程语言为python3.7,实验操作系统为Ubuntu16.04,GPU型号为NVIDIA Tesla P40,CUDA版本为10.0。为了验证BR-IoU算法的实际性能,将原始YOLOv3的边界框回归损失部分分别替换成GIoU损失算法(简称G-YOLO)、BR-IoU-A损失算法(简称BR-YOLO-A)、BR-IoU-B损失算法(简称BR-YOLO-B)。在PASCAL VOC 2007+2012数据集和COCO 2014数据集上进行模型评测和对比实验。
在算法训练过程中,为了增强模型性能,对数据集中的原始图像进行数据增强操作,通过图像随机裁剪、旋转、平移、颜色变化等方法,增加图像的多样性,使神经网络具有更强的泛化效果,提高模型鲁棒性。此外,为检测不同尺度图像中包含的不同尺度和形状的目标,在每个检测层中设定不同尺度的先验框与真实标签进行匹配。网络输入大小为416×416,模型参数更新方式为Adam,初始学习率为0.000 1,权重衰减设置为0.000 5。对于VOC和COCO数据集,模型加载预训练权重来完成初始化,令其他没有预训练权重的部分在训练过程中自适应微调参数,然后训练整个模型。为了在训练过程中使模型稳定,算法为模型训练设置两个轮次迭代的热身阶段。实验采用平均精度(Average Precision,AP)反映每一类目标的检测效果,平均精度是从准确率和召回率两个方面来衡量检测算法的准确性,可以直观地表现模型对单个类别的检测效果;采用平均精度均值(mean Average Precision,mAP)来衡量多类目标的平均检测精度,mAP值越高,模型在全部类别中综合性能越高。
3.1 在PASCAL VOC数据集上的对比实验PASCAL VOC 2007+2012训练集共包含16 551张图像、40 058个样本框,分为4个大类和20个小类。VOC 2007测试集包含4 952张图像、12 032个样本框。PASCAL VOC通过计算数据集IoU=0.5时的mAP对模型进行评价。该组实验在PASCAL VOC数据集上的训练迭代次数为100轮,测试集上的mAP及各类别目标的AP检测结果如图 9和表 1所示。
![]() |
Download:
|
图 9 PASCAL VOC数据集上不同算法的AP对比 Fig. 9 AP comparison of different algorithms on PASCAL VOC data set |
![]() |
下载CSV 表 1 PASCAL VOC数据集上不同算法的性能对比 Table 1 Performance comparison of different algorithms on PASCAL VOC data set |
实验结果表明,在不影响模型检测速度的情况下,BR-YOLO-B算法的mAP高出原YOLOv3算法2.54个百分点,高出G-YOLO算法1.51个百分点。
3.2 在COCO数据集上的对比实验COCO 2014训练集共包含82 783张图像,分为80个类别。从验证集中选取5 000张图像作为测试集对模型进行评价。COCO数据集将IoU在[0.5∶0.95]区间内,步长为0.05的10个取值分别计算mAP并取平均值作为检测模型的评价结果,相比VOC数据集,COCO数据集的多IoU评价标准对检测算法的要求更高,更能反映检测算法的综合性能。该组实验在COCO 2014数据集上的迭代次数为120轮,实验结果如图 10和表 2所示。可以看出,后3种模型相对YOLOv3的检测效果均有所提高,这得益于BR-IoU-A损失算法相比L2损失算法对不同尺度边界框的回归优化更均衡,并且与评价指标IoU之间的优化更加密切,模型BR-YOLO-A算法的mAP对比YOLOv3提高了1.63个百分点。此外,由于BR-IoU-B算法进一步对预测框与真值框之间宽高比的一致性进行优化,因此BR-YOLO-B算法的mAP比YOLOv3提高了2.07个百分点。
![]() |
Download:
|
图 10 PASCAL VOC数据集上的检测效果对比 Fig. 10 Comparison of detection effects on PASCAL VOC data set |
![]() |
下载CSV 表 2 COCO 2014数据集上不同算法的mAP对比 Table 2 mAP comparison of different algorithms on COCO 2014 data set |
表 3所示为4种检测算法的空间与时间复杂度比较结果,其中时间复杂度为模型检测每张图像所需要的时间。由于模型的骨干网络都为Darknet53,因此4种算法的网络参数数量基本相同,约为236×106。由表 3可以看出,相比YOLOv3算法,BR-YOLO-A和BR-YOLO-B算法检测速度更快。
![]() |
下载CSV 表 3 不同算法的时空间复杂度对比 Table 3 Time and space complexity comparison of different algorithms |
针对YOLOv3的L2范数边界框回归损失函数对边界框的尺度敏感,以及与算法检测效果的评价标准IoU之间相关性不强等问题,本文提出BR-IoU算法,通过将IoU作为损失项强化边界框回归与算法评估标准的相关性,最小化真值框和预测框中心点形成矩形的面积,同时提高预测框与真值框之间宽高比的一致性,以加强边界框的回归收敛性能。实验结果表明,BR-IoU能够有效提高YOLOv3算法的检测精度和检测速度。下一步将结合本文算法设计思想对其他目标检测算法的边界框回归损失函数进行改进,在不影响检测速度的情况下达到更高的检测精度。
[1] |
HARIHARAN B, ARBELAEZ P, GIRSHICK R, et al. Simultaneous detection and segmentation[C]//Proceedings of European Conference on Computer Vision. Berlin, Germany: Springer, 2014: 297-312.
|
[2] |
DAI J F, HE K M, SUN J. Instance-aware semantic segmentation via multi-task network cascades[C]//Proceedings of IEEE Conference on Computer Vision and Pattern Recognition. Washington D.C., USA: IEEE Press, 2016: 3150-3158.
|
[3] |
HE K, GKIOXARI G, DOLLAR P, et al. Mask R-CNN[C]//Proceedings of IEEE International Conference on Computer Vision. Washington D.C., USA: IEEE Press, 2017: 2980-2988.
|
[4] |
KARPATHY A, FEI-FEI L. Deep visual-semantic alignments for generating image descriptions[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017, 39(4): 664-676. DOI:10.1109/TPAMI.2016.2598339 |
[5] |
WU Q, SHEN C, WANG P, et al. Image captioning and visual question answering based on attributes and external knowledge[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2018, 40(6): 1367-1381. DOI:10.1109/TPAMI.2017.2708709 |
[6] |
KANG K, LI H S, YAN J J, et al. T-CNN: tubelets with convolutional neural networks for object detection from videos[J]. IEEE Transactions on Circuits and Systems for Video Technology, 2018, 28(10): 2896-2907. DOI:10.1109/TCSVT.2017.2736553 |
[7] |
DENG J, GUO J, XUE N, et al. ArcFace: additive angular margin loss for deep face recognition[C]//Proceedings of IEEE Conference on Computer Vision and Pattern Recognition. Washington D.C., USA: IEEE Press, 2019: 4685-4694.
|
[8] |
崔坤坤, 樊绍胜. 基于动态双窗口的机器人视觉导航与特征识别方法[J]. 计算机工程, 2020, 46(9): 313-320. CUI K K, FAN S S. Visual navigation and feature recognition method of robot based on dynamic double windows[J]. Computer Engineering, 2020, 46(9): 313-320. (in Chinese) |
[9] |
CHEN X Z, MA H M, WAN J, et al. Multi-view 3d object detection network for autonomous driving[C]//Proceedings of IEEE Conference on Computer Vision and Pattern Recognition. Washington D.C., USA: IEEE Press, 2017: 6526-6534.
|
[10] |
GIRSHICK R, DONAHUE J, DARRELL T, et al. Rich feature hierarchies for accurate object detection and semantic segmentation[C]//Proceedings of IEEE Conference on Computer Vision and Pattern Recognition. Washington D.C., USA: IEEE Press, 2014: 580-587.
|
[11] |
GIRSHICK R. Fast R-CNN[C]//Proceedings of IEEE International Conference on Computer Vision. Washington D.C., USA: IEEE Press, 2015: 1440-1448.
|
[12] |
REN S, HE K, GIRSHICK R, et al. Faster R-CNN: towards real-time object detection with region proposal networks[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017, 39(6): 1137-1149. DOI:10.1109/TPAMI.2016.2577031 |
[13] |
LIN T, DOLLAR P, GIRSHICK R, et al. Feature pyramid networks for object detection[C]//Proceedings of IEEE Conference on Computer Vision and Pattern Recognition. Washington D.C., USA: IEEE Press, 2017: 936-944.
|
[14] |
LIU W, ANGUELOV D, ERHAN D, et al. SSD: single shot multibox detector[C]//Proceedings of European Conference on Computer Vision. [S. l. ]: Eurographics Association Press, 2016: 21-37.
|
[15] |
LIN T, GOYAL P, GIRSHICK R, et al. Focal loss for dense object detection[C]//Proceedings of IEEE International Conference on Computer Vision. Washington D.C., USA: IEEE Press, 2017: 2999-3007.
|
[16] |
REDMON J, DIVVALA S, GIRSHICK R, et al. You only look once: unified, real-time object detection[C]//Proceedings of IEEE Conference on Computer Vision and Pattern Recognition. Washington D.C., USA: IEEE Press, 2016: 779-788.
|
[17] |
REDMON J, FARHADI A. YOLO9000: better, faster, stronger[C]//Proceedings of IEEE Conference on Computer Vision and Pattern Recognition. Washington D.C., USA: IEEE Press, 2017: 6517-6525.
|
[18] |
REDMON J, FARHADI A. YOLOv3: an incremental improvement[EB/OL]. [2019-11-02]. https://arxiv.org/abs/1804.02767.
|
[19] |
YU J H, JIANG Y N, WANG Z Y, et al. Unitbox: an advanced object detection network[C]//Proceedings of the 24th ACM International Conference on Multimedia. New York, USA: ACM Press, 2016: 516-520.
|
[20] |
REZATOFIGHI H, TSOI N, GWAK J, et al. Generalized intersection over union: a metric and a loss for bounding box regression[C]//Proceedings of IEEE Conference on Computer Vision and Pattern Recognition. Washington D.C., USA: IEEE Press, 2019: 658-666.
|
[21] |
何智成, 王振兴. 基于改进YOLOv2的白车身焊点检测方法[J]. 计算机工程, 2020, 46(11): 246-254. HE Z C, WANG Z X. Welding spot detection method for body in white based on improved YOLOv2[J]. Computer Engineering, 2020, 46(11): 246-254. (in Chinese) |
[22] |
ZHOU J, TIAN Y C, YUAN C, et al. Improved UAV opium poppy detection using an updated YOLOv3 model[J]. Sensors, 2019, 19(22): 4851. DOI:10.3390/s19224851 |