深度学习论文笔记:Faster R-CNN

Abstract

  • Region Proposal的计算是基于Region Proposal算法来假设物体位置的物体检测网络比如:SPPnet, Fast R-CNN运行时间的瓶颈。
  • Faster R-CNN引入了Region Proposal Network(RPN)来和检测网络共享整个图片的卷积网络特征,因此使得region proposal几乎是cost free的。
  • RPN->预测物体边界(object bounds)和在每一位置的分数(objectness score)
  • 通过在一个网络中共享RPN和Fast R-CNN的卷积特征来融合两者——使用“attention”机制。
  • 300 proposals pre image.

Introduction

  • RP是当前许多先进检测系统的瓶颈。
  • Region proposal methods:
    • Selective Search: one of the most popular method
    • EdgeBoxes: trade off between proposal quality and speed.
    • region proposal这一步依旧和检测网络花费同样多的时间。
  • Fast R-CNN生成的feature map 也能用来生成RP。在这些卷积特征之上我们通过这样的方式构建RPN:通过添加几个额外的卷积层来模拟一个regular grid上每一个位置的regress region bounds和objectness scores。所以RPN也是一种fully convolutional network(FCN),从而可以端到端训练来产生detection proposals。
  • anchor boxes:references at multiple scales and aspect ratios. 我们的方法可以看成pyramid of regression reference,从而避免枚举多尺寸、多横纵比的images或者filters
  • R-CNN主要是一个分类器,他不能预测object bounds,他的准确性依赖于Region proposal模块的表现

Faster R-CNN

  • 由两个模块组成:
    • 第一个模块:A deep fuuly convolutional network that proposes regions,用来proposes regions.
    • 第二个模块:Fast R-CNN检测器,使用第一模块提出的regions。
  • Attention mechanisms:RPN module告诉Fast R-CNN module 往哪里看(where to look)

Region Proposal Networks

  • 输入:一张任意尺寸的图片。

  • 输出:一组矩形object proposal,每个proposal都有一个score。

  • 是一个fully convolutional network(FCN),由于我们需要在RPN和Fast RCNN之间共享权值,所以我们假设两个网络共享一组共同的卷积层

  • 为了生成region proposals,我们在最后一层共享卷积层输出的feature map上滑动一个微型网络。这个微型网络将输入的feature map上的nxn的空间窗口作为输入。每一个滑动窗口被映射为一个低维特征(ZF: 256-d, VGG: 512-d, 之后跟着ReLU层)。这些特征然后被送到两个sibling全连接层中——一个box-regression(reg)层一个box-classification(cls)层。

  • 注意:因为微型网络以滑动窗口方式操作,所以完全连接层在所有空间位置上共享。 这种结构自然地通过一个n×n卷积层,后面是两个同级1×1卷积层(分别用于rpn_reg和rpn_cls)来实现。

  • 生成region proposal的思路:

  • rpn网络结构定义如下:

Anchors

  • 假设每个位置最大可能的proposal的数量为k,在每个sliding-window位置,同时预测几个RP:
    • reg layer:有4k个输出
    • cls layer:有2k个输出,指出该每一个proposal是否是object,estimate probability of object or not object for each proposal
  • k个proposal相对于k个参考框(reference boxes)而参数化,我们将参考框称为anchor
  • 一个anchor位于sliding window的中间,同时关联着一个scale和aspect ration。
Translation-Invariant Anchors(平移不变性)
  • 如果移动了一张图像中的一个物体,这proposal应该也移动了,而且相同的函数可以预测出热议未知的proposal。MultiBox不具备如此功能
  • 平移不变性可以减少模型大小。
Multi-Scale Anchor as Regression References
  • Two popular ways for multi-scale predictions:
    • 第一种:based on image/feature pyramids, 如:DPM and CNN-based methods。图像被resized成不同尺寸,然后为每一种尺寸计算feature maps(HOG或者deep convolutional features)。这种方法比较费时
    • 第二种:use sliding windows of multiple scales (and/or aspect ratios) on the feature maps.——filters金字塔。第二种方法经常和第一种方法联合使用
  • 本论文的方法:anchor金字塔——more cost-efficient,只依靠单尺寸的图像和feature map。
  • The design of multiscale anchors is a key component for sharing features without extra cost for addressing scales.

Loss Function

  • 为了训练RPN,我们给每个anchor设置了一个二元标签(是物体或者不是物体)

  • 两类anchor是有正标签(is object)的:

    • anchor/anchors with highest IoU overlap with a ground-truth box。
    • an anchor that has IoU overlap higher than 0.7 with any ground-truth box.
    • 第二种方法更好检测正样本,在第二种情况下如果找不到正样本,那么使用第一种。
  • 如果一个anchor和任何ground-truth boxes的IoU值小于0.3,那么该anchor为负标签

  • 非正非负样本对training objective没有用。

  • Loss Function:

    $N{cls}=256,N{reg}=256*9=2304,\lambda=10$,这样两个loss就可以权重基本相当了。

  • Bounding box regression

    这个可以考虑为从anchor box回归到附近的ground truth box。

  • 和R-CNN和Fast R-CNN的bounding box regression方法不同的是:

    • 前两种的回归是在从任意大小RoI中提取的特征进行回归的,所以regression weights在所有尺寸中共享
    • 在我们的方法中,用于回归的特征都是同一个3x3的空间特征。考虑到变化的尺寸,有k个不同的bounding boxe回归器去学习,每一个回归器负责去学习一个尺寸一个衡重比的anchor。所以k个回归器是不共享权值的。所以得益于anchor的设计,即使特征规定,我们依旧可以去预测不同尺寸的box。

Training RPNs

  • image-centric sampling strategy
  • mini-batch: arises from a single image that contains many positive and negative example anchors.
  • 随机在一张图片中采样256个anchors来计算一个mini-batch的loss function。正负anchors = 1:1.
  • all new layers的权值初始化:高斯分布$(\mu = 0, \sigma = 0.01)$,all other layers(比如共享卷积层)用ImageNet来权值初始化。用ZF net来进行进行微调
  • 学习率:0.001(60k)->0.0001(20k)
  • 动量:0.9
  • weight decay: 0.0005

Sharing Feature for RPN and Fast R-CNN

  • sharing convolutional layers between the two networks, rather than learning two separate networks

  • 三种特征共享的方法:

    • Alternating training:迭代,先训练PRN,然后用proposal去训练Fast R-CNN。被Fast R-CNN微调的网络然后用来初始化PRN,以此迭代。本论文所有的实现都是使用该方法。

    • Approximate joint training:

      RPN和Fast R-CNN融合到一个网络中进行训练。在每次SGD迭代过程中:

      • 前向传递:RPN产生region proposals,这些proposals被当做固定的、提前计算好的proposal来训练Fast R-CNN检测器。
      • 反向传递:对于共享层来说,来自RPN的loss和Fast R-CNN的loss结合.
      • 但是这种方法不考虑Bounding Boxes,忽略了proposal boxes的坐标也是网络的输出。所以这种方法叫做approximate
    • Non-approximate joint training: 考虑Bounding Boxes。

  • 4-step Alternating Training:

    • Step 1: train the RPN, initialized with an ImageNet-pre-trained model and fine-tuned end-to-end for the region proposal task.
    • Step 2: train a separate detection network by Fast R-CNN using the proposals generated by the step-1 RPN. 同样使用ImageNet-pre-trained model来初始化。此时两个网络并没有共享卷积层。
    • Step 3: use the detector network to initialize RPN training but we fix the shared convolutional layers and only fine-tune the layers unique to RPN. 现在两个网络共享卷积层
    • Step 4: keeping the shared convolutional layers fixed, we fine-tune the unique layers of Fast R-CNN.

Implementation Details

  • Multi-scale与speed-accuracy之间的trade-off
  • To reduce redundancy, we adopt non-maximum suppression (NMS) on the proposal regions based on their cls scores.