Faster-Rcnn 论文学习笔记

这半年忙于实习,很久没有写文章了。实习的工作又是深度学习框架的优化,NLP模型性能的优化,所以CV方面看的就越来越少了,现在有时间,把之前的坑补好,将RCNN系列文章写完,也算是对自己知识的一个总结回忆。后续会记录一些GANNLP、以及深度学习框架的东西,希望可以坚持下去。

Faster-RCNN

总览

上一篇写了 Fast-RCNN 算法,相比于 R-CNN 算法,已经大大降低了运行时间,这种基于 region proposal 的算法运行效率的瓶颈变为了候选框的选取上,以往都是选取大量候选框,然后在 feature map 上进行映射,随后再进行回归,确定最终的候选框,这种方式需要花费大量的时间在候选框的回归运算。针对这一点,Faster-RCNN 采用了 Region proposal Network (RPN) ,将候选框的选取也交给网络来做。文章主要创新在两方面:

  1. 提出 Region proposal network,这样只需要将feature map 送入***RPN*** 网络即可得出需要的候选框(object bounds)和目标分数(objectness score)提高了效率;
  2. RPN 网络与 fast-rcnn 网络进行融合为一个网络,并提出了训练方法,可以共用网络卷积提取特征的结果,从而简化计算步骤,进一步提高效率。

Region Proposal Network(RPN)

RPN 输入是一张图片,输出是矩形候选框及对于的目标分数,这中间当然会用到卷积网络进行特征提取,至于如何与 Fast-RCNN 融合为一个网络,共用卷积网络进行特征提取,下一章节再表。

**RPN** 网络总的流程RPN 网络总的流程如上图,其中

conv feature map : 卷积提取特征,需要与 fast-rcnn 进行融合共用;
N * N spatial window : 进行 ROP pooling 时选用的卷积核,得到固定的输出,这里是 256-d 特征值;
1 * 1 conv : 分别为 cls 和 reg 两个task提供特征筛选,这里使用 1*1 的卷积和 fc全连接 是等价的,每个候选框生成 2+4 个值作为 候选框的位置 和 是特定目标的分数。

原文描述如下:

------To generate region proposals, we slide a small network over the convolutional feature map output by the last shared convolutional layer. This small network takes as input an n × n spatial window of the input convolutional feature map. Each sliding window is mapped to a lower-dimensional feature (256-d for ZF and 512-d for VGG, with ReLU [33] following). This feature is fed into two sibling fullyconnected layers—a box-regression layer (reg) and a box-classification layer (cls) .

下面这一句,说明 所有候选框 进行降维时的全连接层的参数是共享的:

------ Note that because the mini-network operates in a sliding-window fashion, the fully-connected layers are shared across all spatial locations. This architecture is naturally implemented with an n×n convolutional layer followed by two sibling 1×1 convolutional layers (for reg and cls, respectively).

  • anchors
    这个翻译为 锚框 吧,作者在每个 sliding-window location 时候,产生了多个候选框,每个位置产生 k(这里为9)个候选框,所有对应上图中会看到有 2k-scores4k-coordinates
    9个 候选框是怎么来的呢,根据 feature map 为每一个候选框提供了一个中心点,然后生成一个候选框,将这个候选框进行大小比例变化,大、中、小共3种,不同方向比例变换,1:1、1:2、2:1 共3种,组合一下,3*3=9。如果 feature map 大小为 H * W,那么总共会产生锚框 H * W * k 个。

锚框示意如下图(将改图所有矩形框中心移到同一点即可):
在这里插入图片描述
对应原文以及引用其他博客内容:
------
------ An anchor is centered at the sliding window in question, and is associated with a scale and aspect ratio (Figure 3, left). By default we use 3 scales and 3 aspect ratios, yielding k = 9 anchors at each sliding position. For a convolutional feature map of a size W ×H (typically ∼2,400), there are WHk anchors in total.

feature map对于anchorbox的生成的贡献就是提供了一个中心点而已,featuremap每个位置上的点,就对应一个anchorbox的中心,然后呢,我知道了这么多中心点,根据base size,scales,aspect ratios就可以算出来一个矩形的长和宽。矩形的中心点就是featuremap上的那个点对应原图上的点。
原文:https://blog.csdn.net/qian99/article/details/79942591

  • Training RPN
    因为目标检测种,图像目标和背景相比较小,所以导致大量的候选框为负类,这里作者训练时强行将正类、负类进行 1:1 的分配,如果正类还是凑不够,那就拿负类凑。
    ------ It is possible to optimize for the loss functions of all anchors, but this will bias towards negative samples as they are dominate. Instead, we randomly sample 256 anchors in an image to compute the loss function of a mini-batch, where the sampled positive and negative anchors have a ratio of up to 1:1. If there are fewer than 128 positive samples in an image, we pad the mini-batch with negative ones.
    在这里插入图片描述

Sharing Features for RPN and Fast R-CNN

因为RPN和Fast-RCNN时单独训练的,且会根据不同的方式进行网络参数更新,如何进行 RPN 和 Fast-RCNN 直接的卷积层共享,作者分析了三种方法,最后采用了 alternating training,就是 “你一次,我一次” 的迭代训练。

  • 3 ways
    • Alternating training
    • Approximate joint training
    • Non-approximate joint training

具体训练时采用了4步训练法:

  • 4-step Alternating Training
    ------In this paper, we adopt a pragmatic 4-step training algorithm to learn shared features via alternating optimization. In the first step, we train the RPN as described in Section 3.1.3. This network is initialized with an ImageNet-pre-trained model and fine-tuned end-to-end for the region proposal task. In the second step, we train a separate detection network by Fast R-CNN using the proposals generated by the step-1 RPN. This detection network is also initialized by the ImageNet-pre-trained model. At this point the two networks do not share convolutional layers. In the third step, we use the detector network to initialize RPN training, but we fix the shared convolutional layers and only fine-tune the layers unique to RPN. Now the two networks share convolutional layers. Finally, keeping the shared convolutional layers fixed, we fine-tune the unique layers of Fast R-CNN.
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值