训练流

caffe版本的训练步骤

  • Step1-RPN.TRAIN
  • Step1-RPN.PROPOSAL
  • Step2-FASTRCNN.TRAIN
  • Step3-RPN.TRAIN
  • Step3-RPN.PROPOSAL
  • Step4-FASTRCNN.TRAIN

到底在学习什么东西?

  • 识别+小分类(是否有物体):RPN

  • 识别方法:CNN特征提取+Bounding-Box回归

  • 回归(学习)什么: 一种平面图形的映射t:PG^\mathbf{t}:\mathbf{P}\to \mathbf{\hat{G}}
    具体来说是把一个proposal(P\mathbf{P})形状变形成一个groundtruth(G^\mathbf{\hat{G}})形状。已知函数形式,学习(求解)该函数的参数

    t={G^x=Pwtx(P)+PxG^y=Phty(P)+PyG^w=Pwexp(tw(P))G^h=Phexp(th(P)) \mathbf{t}=\left\{ \begin{array}{ll} \hat{G}_{x}=P_{w}t_{x}(\mathbf{P})+P_{x} & \textrm{}\\ \hat{G}_{y}=P_{h}t_{y}(\mathbf{P})+P_{y} & \textrm{}\\ \hat{G}_{w}=P_{w}exp(t_{w}(\mathbf{P})) & \textrm{}\\ \hat{G}_{h}=P_{h}exp(t_{h}(\mathbf{P})) & \textrm{}\\ \end{array} \right.

对于每一个 t=wTϕ(Pi)t_{*}=\mathbf{w}_{*}^{T}\phi(\mathbf{P}^i)
w=arg minw^iN(tiw^Tϕ(Pi))2+λw^2 \mathbf{w}_{*}=\argmin\limits_{\hat{\mathbf{w}}_{*}}\sum^{N}_{i}(t^i_{*}-\hat{\mathbf{w}}_{*}^{T}\phi(\mathbf{P}^i))^2+\lambda||\hat{\mathbf{w}}_{*}||^2

LossFunction

注意这里的 v=w^Tϕ(Pi)\mathbf{v}=\hat{\mathbf{w}}_{*}^{T}\phi(\mathbf{P}^i) ,即预测的变形函数的参数
L(p,u,tu,v)=Lcls(p,u)+λ[u1]Lloc(tu,v) L(\mathbf{p},u,\mathbf{t}^u,\mathbf{v})=L_{cls}(\mathbf{p},u)+\lambda[u\geqslant1]L_{loc}(\mathbf{t}^u,\mathbf{v})

Lloc(tu,v)=i{x,y,w,h}smoothL1(tiu,vi) L_{loc}(\mathbf{t}^u,\mathbf{v})=\sum_{i\in\{x,y,w,h\}}smooth_{L_{1}}(t^u_{i},v_{i})

smoothL1(x)={0.5(σx)2 if x<1σ2x0.5σ2 otherwise smooth_{L_{1}}(x)=\left\{ \begin{array}{ll} 0.5 (\sigma x)^2 & \textrm{ if } |x| < \frac{1}{\sigma ^2}\\ |x| - \frac{0.5 }{\sigma ^2} & \textrm{ otherwise}\\ \end{array} \right.

在caffe中的数据流

Deep Learning的案例FasterRCNN(二)
Deep Learning的案例FasterRCNN(二)
Deep Learning的案例FasterRCNN(二)

  • 一张原始图片经过共享卷积层得到bottom[0]=[...,Wc,Hc]bottom[0]=[...,W_{c},H_{c}]
  • ROIDataLayer从一张随机缩放过的图片中抽出所有的ROI区域,得到bottom[1]=gtbox[x1,y1,x2,y2,cls];bottom[2]=[W0,H,scale]bottom[1]=gtbox[x1,y1,x2,y2,cls];bottom[2]=[W_{0},H_{},scale]
  • AnchorTargetLayer在setup时原点处产生AA个anchor
  • 在Forward中产生WcHcW_{c}*H_{c}个shift值,通过shift偏移anchor共产生AWcHcA*W_{c}*H_{c}all_anchorsall\_anchors
  • 去掉all_anchorsall\_anchors中越界的anchor得到新的anchors
  • 计算anchors与gtbox的overlap值,给anchors标记label,其中>0.7,label=1;<0.3,label=0;other,label=1>0.7,label=1;<0.3,label=0;other,label=-1top[0]top[0]
  • 抽取256个anchors的样本数,正负样本保持1:1
  • 计算v\mathbf{v},给top[1]top[1];计算uu,给top[2]top[2];计算λ\lambda,给top[3]top[3]
  • Backward反向传播,更新权值

这些细节数据流程现在来看都有些模糊了,映像最深的还是那个变形函数的映射建立,说明带问题式搜索解答才是最有效率的。

后记

当年做到这里考虑的可以改造的思路

  • 替换数据集?
  • 替换共享卷积层?
  • 替换回归函数?
  • 多路输出+deepmusk+shapemusk=multipathnet?

这个时候就是看谁的动手能力强以及实验环境条件了。现在这个系列已经出到了MaskRCNN,甚至全部直接集成到Detectron2,也就意味着这一波用网络方法改造原有hardcoding视觉识别基础层的小高峰完成了。待其被各种花式应用探索潜力以后,应用层又会嗷嗷待哺,等待新一波的高峰到来。

- [1] Fast R-CNN
- [2] Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks.
- [3] https://www.jianshu.com/p/1f975b05ca86
- [4] https://www.jianshu.com/p/5056e6143ed5
- [5] https://www.jianshu.com/p/ab1ebddf58b1

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-08-22
  • 2021-08-19
  • 2021-04-27
猜你喜欢
  • 2021-11-19
  • 2021-05-25
  • 2021-11-29
  • 2022-12-23
  • 2021-12-03
  • 2021-07-03
  • 2021-07-01
相关资源
相似解决方案