Faster R-CNN论文笔记

亮点: 引入 Region Proposal Network(RPN),可以与检测网络共享全图的卷积特征权值,这样基本使得region proposals计算没有消耗(cost-free)。【翻译参考 http://blog.csdn.net/mw_mustwin/article/details/53039338

个人想法:为什么说共享卷积特征权值之后达到了cost free呢,是因为Anchor部分和特征提取是同步进行的,一个给出框一个给出图,框框一圈起来就可以直接进行运算了。


RPN是一种全卷积的网络,能够同时预测目标的边界以及对objectness得分。RPN是端到端训练,产生高质量的region proposals用于Fast R-CNN的检测。作者通过 共享卷积特征 进一步将RPN和Fast R-CNN合并成一个网络,使用最近神经网络流行的术语——“attention”机制,RPN组件能够告诉网络看向哪里。对于VGG-16模型,检测系统在GPU上的帧率为5帧(包含所有步骤),同时仅用每张图300个proposals取得了PASCAL VOC2007,2012以及MS COCO数据集的最好检测精度。代码已公开。

1. Introduction
近期 region proposal methods和region-based convolutional neural netwoeks(R-CNNs)在目标检测中的应用比较成功,尽管R-CNNs的计算本质上就expensive,采用across proposals的卷积共享极大地减少了cost。忽略region proposals耗时,改进后应用深度网络的Fast R-CNN基本达到了实时速度,所以porposals的计算时间是当前检测技术的主要瓶颈。(Now, proposals are the  test-time computational bottleneck in state-of-the-art  detection systems.

标注: 

第1、2节介绍,目前的网络挺好,点明问题所在——region proposal算法比较耗时。

第3节分析耗时跟region proposal使用CPU有一定关系,但即使用GPU去生成proposal来省时,依旧忽略了网络结构的特征从而错过可以共享计算的机会。然后 4~5节就是引入并介绍本文提出的算法。

第4节引入了RPN,可以和目前非常好的目标检测网络共享卷积层,从而省去计算proposal的时间。第5节说明了这个想法的由来:作者发现Fast R-CNN网络结构中的卷积特征图不仅可以用于ROI池化层,另外再加一段卷积层还可以用来产生region proposals,RPN的结构就这样出来了,具体如图,左边多出来的部分就是RPN结构。所以RPN是实质是一种全卷积层,端到端训练,专门用于产生regionproposals的任务。


6~7节介绍了一下结构细节的内容,也是文章正文核心的内容。RPN用于产生预测具有大范围尺度以及长宽比变化的region proposals。先前的方法都是通过图像金字塔或者滤波器金字塔的方式来得到Region proposals在尺度以及长宽比上的不同模式,但是本文引入一种称为“anchor”boxes的方法实现,可以视为一种pyramids of regressionreference(回归引用金字塔,意思就是在一个位置同时预测多个不同size的proposal),如图。这种模式不必去列举不同尺寸和长宽比的图像或者滤波器,训练和测试阶段都仅使用一种size的图像即可。为了统一RPN和Fast R-CNN,作者提出了一种训练模式:在region proposal和目标检测两个任务的fine-tuning之间交替进行。这种模式收敛很快并且产生统一的能够在两个之间共享卷积特征的网络结构。 


8~10节介绍了方法的结果以及成绩。在PASCAL VOC上评估,检测精度比Selective Search + Fast R-CNN高,同时解决了Selective search在测试阶段的计算负担。在GPU上即使使用复杂的VGG-16模型,帧率依旧能达到5帧(包括所有步骤),就速度和精度而言,已经达到了实际应用的效果。文章同时也展示了在MS COCO上的结果以及利用MS COCO数据对PASCAL VOC检测结果的改善,代码已公开。

第9、10节交代之前的版本以及本文的方法还被很多其他方法和商业系统引用。

2. Related Work

Object Proposals
关于Object Proposals的文献很多,论文中给出一些方法。

Deep Networks for Object Detection
        R-CNN : 端到端训练CNNs来分类目标,它主要扮演一个分类器,而不去预测目标的边界(除了通过包围盒回归精炼)。其准确度由region proposal module的性能决定。一些论文中提出使用deep networks来预测object bounding boxes.
        OverFeat : 训练一个fully-connected layer来预测box coordinates用来对单个目标的任务进行定位。fully-connected layer接入convolutional layer处理多类目标 
        MultiBox :  从网络的最后一个fully-connected layer (全连接层)同时预测多个class-agnostic boxes生成region proposals, generalizing the“singlebox” fashion of OverFeatThese class-agnostic boxes  are used as proposals for R-CNN.
从最后一个fc层同时预测多个包围盒的网络中生成区域建议,R-CNN就是用的这个。
       另外,卷积的共享计算近来也很热门。主要就是SPPnet, Fast R-CNN。

3. FASTER R-CNN

作者提出自己的目标检测系统:Faster R-CNN, 由两部分组成:  deep fully convolutional network 用来生成propose regions;Fast R-CNN detector .
In Section 3.1 we introduce the designs and properties of the network for region proposal. In Section 3.2 we develop algorithms for training both modules with features shared.
3.1 Region Proposal Networks
RPN:输入任意尺寸图片,输出为一系列rectanglular object proposals,每一个都带有objectness score。作者用了一个全卷积网络模型来处理。作者的目标是能够与Fast R-CNN目标检测网络共享计算,因此假设每个网络都可以共享卷积层。

生成region proposals

如图所示,作者用sliding window在convolutional feature map上滑动,并将每一个sliding window映射到低维特征(ZF 是256d,VGG是512d),然后这些特征又分别被feed into two sibling fully connected  layers—— 一个box-regression layer(reg),一个box-classification layer(cls). 本文用一个全卷积网络(n*n的卷积层+两个并列的1*1卷积层)来对这个过程进行建模

3.1.1 Anchors
每一处sliding window,作者都同时预测了很多个region proposals, proposals最大数目设置为k

reg layer 有4k个输出,即k boxes 的坐标,cls layer的输出为每个proposal 估计是否为object的可能性的 2k scores 。k proposals  are parameterized relative to k reference boxes,which we call anchors.  An anchor is centered at the sliding window  in question, and is associated with a scale and aspect  ratio.
reg层输出4k个值表示proposal的坐标,cls层输出2k个值评估proposal是否为目标的概率。这k个proposals是关于k个reference boxes参数化的,因此称为anchors。anchor以滑动窗口为中心,对应一种特定尺度以及长宽比,默认选取3种尺度和三种长宽比,因此每个滑动位置产生9个anchors。最终总共最多产生W*H*k个anchors(当然会选取得分高的anchors作为proposals的)。

Translation-Invariant Anchors
作者提出该方法的最重要的特性是平移不变性,意思是对于anchors以及与anchors相关的计算proposals的函数而言,具有平移不变性。例:将图像中的目标平移了,依然能计算出对应的平移的proposals,并且在何位置函数都能预测到它。MultiBox用的是K均值方法产生800个anchors,不具有平移不变性。平移不变性还能减小模型的尺寸,MultiBox的全连接输出层是(4+1)*800维,本文卷积输出层是(4+2)*9维(k取9),结果就是本文输出层2.8*10^4个参数,而MultiBox有6.1*10个参数,相差两个量级。考虑特征映射层,也会相差一个量级。

Multi-Scale Anchors as Regression References
将本文的多尺度anchors和图像/滤波器金字塔作比较,并举了例子,来说明本文基于anchor的方法实现多尺度有两个好处:一、省时;二、可以仅使用一张一张图像的卷积特征图(事实上还是省时)。

3.1.2 Loss Function
训练RPNs:对每个anchor设计二进制的分类标签(是/不是 object)
给两种anchors设置 positive label:
(1) the  anchor/anchors with the highest Intersection-overUnion (IoU) overlap with a ground-truth box,
(2) an  anchor that has an IoU overlap higher than 0.7 with any ground-truth box.
作者采用了第一种方式,因为第二种条件可能在某些情况下无法寻找到正样本。
作者对 IoU ratio is lower than 0.3 for all ground-truth boxes的non-positive anchor设置了negative label.
Anchors的正/负不会对训练目标造成影响。

有了以上一些定义,作者用Fast R-CNN 中的multi-task loss minimize an objective function.Loss function for an image is defined as:

i is the index of an anchor in a mini-bach.
p_i is  the predicted probability of anchor i being an object.   当anchor为positive时,the ground-truth label p_i* 为1,否则为0。 
t_i 是一个向量,表示predicted bounding box 的4个参数化的坐标。 t∗ i is that of the  ground-truth box associated with a positive anchor.
分类损失 L_cls 是两个类别的log loss(object vs. not object).对于回归损失,作者使用,R is robust loss function(smooth L_1)。
可以看出,仅当positive anchors(p_i*=1)时,p_i*L_reg means the regression loss is activated.
The outputs of the cls and reg layers consis of {p_i} and {t_i} respectively.
实验设计: 

N_cls = 256 ,N_reg ~ 2400, λ = 10.

bounding box regression,作者采用 parameterizations of the 4 coordinates following:

x\x_a\x*  are for  predicted box\anchor box\ground-truth box(likewise for y,w,h).

作者指出其方法: 用于回归的特征是来自feature maps的同一空间尺度(3*3),考虑不同的尺寸, a set of k bounding-box regressors  are learned.每一个 regressor 都代表一种尺度和一种长宽比, and the k regressors do not share  weights. As such, it is still possible to predict boxes of  various sizes even though the features are of a fixed  size/scale, thanks to the design of anchors.

3.1.3 Training RPNs

使用反向传播和随机梯度下降端对端训练RPN。采用“Fast R-CNN” 采样策略,每个mini-batch由一张包含多个正负anchors的单一图像产生,由于优化loss函数的时候会偏向占主导作用的负样本,所以作者采样的mini-batch正负anchors的比例保持在1:1,随机采样的256个anchors来计算损失函数。
从零均值、标准差为0.01的高斯分布中随机采样 初始化new layers参数,其他layers用  ImageNet classification 的 预训练模型初始化。ZF net的所有层都参与优化\VGG-16从conv3_1向上的层优化,学习速率 : 60k mini-batches 为 0.001,next 20k mini-batches 为 0.0001 on  the PASCAL VOC dataset; momentum : 0.9; a weight decay of 0.0005; uses Caffe.

3.2 Sharing Features for RPN and Fast R-CNN 

learn a unified network composed of RPN and Fast R-CNN with shared convolutional layers.
RPN与Fast R-CNN分别独立训练,然后设计一个技术点用以sharing convolutional layers between the two networks.作者讨论了三种训练方法(for training networks  with features shared ):
(1) Alternating training. 先训练RPN, 然后利用 proposals 训练 Fast R-CNN. 训练好的Fast R-CNN 用来初始化RPN,这个过程是迭代的,本文实验选用了这个方法。
(2) Approximate joint training. RPN与Fast R-CNN网络在训练过程中融合为一个网络。在每个随机梯度下降迭代过程,前向传递产生region proposals并固定,在训练Fast R-CNN检测器时,提前计算好proposals.The  backward propagation takes place as usual, where for  the shared layers the backward propagated signals  from both the RPN loss and the Fast R-CNN loss
are combined.
(3) Non-approximate joint training.(详细见论文)

4-Step Alternating Training
作者采用了 a pragmatic 4-step training algorithm to learn shared  features via alternating optimization.

  1. 训练RPN,由ImageNet-pre-trained model and fine-tune end-to-end for the region proposal task.
  2. 训练一个分离的detection network by Fast R-CNN using the proposals generated by the step-1 RPN.该检测网络也使用以上初始化模型。此时两个网络还未共享卷积层。
  3. 使用detector network to initialize RPN training,先固定共享的卷积层,only fine-tune the layers unique to RPN.现在两个网络共享卷积层,最后保持共享的卷积层固定,fine-tune the unique layers of Fast R-CNN. 如此,每个网络都共享了同样的卷积层从而形成了一个统一的网络。相同的交替训练可以迭代运行多次,不过作者观察到没有明显的提升。









猜你喜欢

转载自blog.csdn.net/github_38657489/article/details/79213434