【Libra R-CNN】《Libra R-CNN: Towards Balanced Learning for Object Detection》

在这里插入图片描述

CVPR-2019


1 Background and Motivation

相较于 model architectures,training process 往往被人忽视,在目标检测任务中,它同样至关重要:

无论 one-stage 还是 two-stage,训练策略都如下:

  • sampling regions
  • extracting features
  • jointly recognizing the categories and refining the locations under the guidance of a standard multi-task objective function

这样会带来三个疑问:

  • whether the selected region samples are representative(sample level)
  • whether the extracted visual features are fully utilized(feature level)
  • whether the designed objective function is optimal(objective level)

更具体的说:
在这里插入图片描述
a)贡献度小的 easy sample 占了大多数,贡献度大的 hard sample 占少数

OHEM 进行了改进,但是 sensitive to noise labels and incurring considerable memory and computing costs. Focal loss 适用于 one-stage,two-stage 中效果会被 second stage 冲刷弱化

b)low-level 和 high-level 的特征的 integrate 不是最优,还有改进空间

FPN 或者 PANet 都是 focus more on adjacent resolution but less on others,

The semantic information contained in non-adjacent levels would be diluted once per fusion during the information flow.(这句话写的真棒)

c)目标函数的 imbalance

If they are not properly balanced, one goal may be compromised, leading to suboptimal performance overall.


为了缓解上面三个问题,作者提出了相应的三种解决办法:

  • IoU-balanced sampling
  • balanced feature pyramid
  • balanced L1 loss

模型命名为 Libra R-CNN(天秤座)

在这里插入图片描述

2 Advantages / Contributions

  • systematically revisit the training process of detectors,并提出了 sample 、feature、objective 三个 level 的 imbalance 问题

  • 提出 Libra R-CNN detectors 来缓解 sample 、feature、objective 的 imbalance 问题

  • significant improvements over state-of-the-art detectors

3 Method

在这里插入图片描述

3.1. IoU balanced Sampling

Is the overlap between a training sample and its corresponding ground truth associated with its difficulty?
在这里插入图片描述
训练 RPN 时,小于 0.5 是负样本,上图中间橙色的真实的难负样本的百分比分布,可以看出难负样本并不是均匀分布的!所有 0-0.5 区间内,难负样本的数量分布是不均匀的

上图可以看出,random sample 由于分布和真实的不匹配,会导致采样过程中,极小阈值的难负样本过采样(eg 0-0.05),大一些的阈值范围内,欠采样,这样会导致在采样的过程中遗漏部分难负样本!

作者的改进,原来要从 M 个 candidates 采集 N 个 negative samples,随机采样下,每个样本被抽到的概率是
在这里插入图片描述
为了提升难样本被抽到的概率,作者将 M 分为 K 组,然后在每组中均匀采样,每组样本被采集的概率是
在这里插入图片描述
the performance is not sensitive to K,

这样处理后,就如上图的绿色分布,总之目的就是为了逼近真实的分布,改进是把随机采样改成分层采样(参考:2019CVPR Libra RCNN目标检测算法(特征融合))!因为每个区间难负样本的分布不一样,分区间,然后每个区间均匀采样能保证更大的覆盖率(以前生物课本上学的分层采样,回想一下就好理解了)

3.2. Balanced Feature Pyramid

在这里插入图片描述
1)Obtaining balanced semantic features

先 4 合 1 成一个分辨率,差值或者 max pooling
在这里插入图片描述
non-parametric method

2)Refining balanced semantic features

Gaussian non-local attention 来 enhance the integrated features,用卷积也差不多,non-local 稳定一些

最后再和原特征相加(identity),增强原特征

3.3. Balanced L1 Loss

我们的目标函数如下:
在这里插入图片描述
为了平衡两个不同任务的损失,可以调整参数 λ \lambda

然而 owing to the unbounded regression targets, directly raising the weight of localization loss will make the model more sensitive to outliers.

作者定义 loss greater than or equal to 1.0 的样本为outliers,其它样本为 inliers

  • outliers 能看成是 hard samples

  • inliers 可以看成 easy samples

我们先看看原版的 Smooth L1 loss

这里写图片描述 这里写图片描述

有个拐点,来 separate inliers from outliners,clip the large gradients produced
by outliers with a maximum value of 1.0
(原来是这样)


To be more specific, inliers only contribute 30% gradients average per sample compared with outliers.

为了秉持中庸之道,提升 inliers sample 的梯度,作者对 smooth L1 进行了改进,先看下图
在这里插入图片描述
改进前的是红色的虚线,左边梯度,右边 loss(对应我上面画的 loss 图),拐点是 1.0!

公式改进如下

在这里插入图片描述
原来目标函数的梯度应该是 x x ,现在变成 a l n ( b x + 1 ) aln(b|x|+1) ,也就是线性增长变成了对数增长, α \alpha 越小,inliers 的梯度增加的幅度越大

所以,对应的 loss 为
在这里插入图片描述
求下导数就是上面的梯度公式了,其中
在这里插入图片描述

作者实验中 α \alpha 设计成 0.5, γ \gamma 设计成 1.5

4 Experiments

4.1 Datasets

COCO data

  • train-2017 train
  • val-2017 ablation results
  • test-dev test

4.2 Main Results

1)华山论剑
在这里插入图片描述
在这里插入图片描述
table 3 可以看出,更先进的主干网络带来的提升,不如作者提出的 IoU balanced sampling

4.3 Ablation Experiments

在这里插入图片描述
没有能看到更多的组合

1)IoU-balanced Sampling
在这里插入图片描述
文章中关于正样本的处理写了如下描述
在这里插入图片描述
也就是对正样本的采样也从随机采样变成了分层采样,从图 6 中可以看出,更多的 hard negative sample 被捕捉到(正样本被负样本盖住了,看不出来具体改变)

在这里插入图片描述
sampling equal number of positive samples for each ground truth,叫做 Pos Balance,因为正样本本来就少(所有样本中大于阈值的数量本来就很少),在大于阈值的范围内随机采样基本也可以采集到大部分,所以提升不是很明显!

对组数并不敏感,2,3,5 差别不大,as long as the hard negatives are more likely selected.

2)Balanced Feature Pyramid
在这里插入图片描述

3)Balanced L1 Loss

balanced L1 loss 的提升主要来自于 AP75,说明大大的提升了定位能力

在这里插入图片描述
注意到 loss weight = 2.0 时,效果反而下降了,作者给出了如下解释

These results show that the outliers bring negative influence on the training process, and leave the potential of model architecture from being fully exploited.

5 Conclusion(own)

  • 随机采样到分层采样改进难负样本的 sampling,正样本的选取也进行了同样操作
  • Smooth L1 loss 拐点设计原来这么讲究(outlier,inlier),让我更深刻理解到了调分类定位 loss 的系数本质上是在调什么!一切要从 loss 和 梯度源头思考!!!
  • 定量的给出了 hard negative 的重要性,666
  • FPN 改进的时候,“影分身”实现细节论文中还真看不出,感谢 2019CVPR Libra RCNN目标检测算法(特征融合)