二话不说,首先看下跑通代码的效果图如下://采用visdom可视化工具
从图中可以看到图片中的三个目标对象都是可以检测出来的
对应的模型如下 refer to zhihu(侵权删)
经过R-CNN和Fast RCNN的积淀,Ross B. Girshick在2016年提出了新的Faster RCNN,由图可以看到分为4个主要内容:
- Conv layers。作为一种CNN网络目标检测方法,Faster RCNN首先使用一组基础的conv+relu(线性整流函数)+pooling层提取image的feature maps。该feature maps被共享用于后续RPN层和全连接层。
- Region Proposal Networks。RPN网络用于生成region proposals。该层通过softmax(映射成为(0,1)的值)判断anchors属于positive或者negative,再利用bounding box regression修正anchors获得精确的proposals。
- Roi Pooling。该层收集输入的feature maps和proposals,综合这些信息后提取proposal feature maps,送入后续全连接层判定目标类别。
- Classification。利用proposal feature maps计算proposal的类别,同时再次bounding box regression获得检测框最终的精确位置。
关于FasterRCNN这个类
首先,开发注释里谈到了Faster R-CNN的三个层次:
- Feature extraction: Images are taken and their feature maps are calculated.
- Region Proposal Networks: Given the feature maps calculated in the previous stage, produce set of RoIs around objects.
- Localization and Classification Heads: Using feature maps that belong to the proposed RoIs, classify the categories of the objects in the RoIs and improve localizations.
这三个层次分别对应callable的三个nn.module的模块
关于nn.module link
- 一般把网络中具有可学习参数的层放在构造函数中。
- 不具有可学习参数的层(如ReLU)可放在构造函数中,也可不放在构造函数中
- 只要在nn.Module中定义了forward函数,backward函数就会被自动实现(利用Autograd)
- 关于类中用到的nn.Module的三个callable——rpn、head、feature(即extractor和classifier)
- FasterRCNNVGG16对FasterRCNN的继承
- 关于rpn:
- RegionProposalNetwork: