这个笔记只写了一部分,并不完全,我会抓紧时间写完它。
以下都是本人的个人见解与总结,不妥之处欢迎指正。
(一)anchor的作用
Q1:为什么不直接回归bbox的坐标,要用anchor来辅助?
A:因为自然图片中物体的大小是在几个常用的范围之内的,faster-rcnn中的9个anchor的大小,基本上就是自然图片中大多数物体的大小范围,所以找出与物体gt最接近的anchor,并且微调这个anchor,让其接近物体的gt(真实框的大小),更省时间,更准确。直接回归bbox坐标的话,会很慢。
Q2:RPN 网络的损失函数 loss function解析
对于一张image来说:(以下这个loss的计算单位是anchor,因为是对于一张image来说的,一张image保留了_C.TRAIN.RPN_BATCHSIZE = 256个anchors)
L = 1 N c l s ∑ i = 0 n L c l s ( p i , p i ∗ ) + λ 1 N r e g ∑ i = 0 n p i ∗ L r e g ( t i , t i ∗ ) L = \frac{1}{N_{cls}}\sum_{i=0}^n L_{cls}(p_i,p_i^*) + \lambda\frac{1}{N_{reg}}\sum_{i=0}^n p_i^*L_{reg}(t_i,t_i^*) L=Ncls1∑i=0nLcls(pi,pi∗)+λNreg1∑i=0npi∗Lreg(ti,ti∗)公式(1)
其中,i是一个mini-batch中的anchor的index,(这个mini-batch= N c l s N_{cls} Ncls=256,是256个anchors,不是指256张image)
第一个 p i ∗ p_i^* pi∗ : 在程序里面对应的参数是rpn_labels,与anchors一一对应, p i ∗ = 1 p_i^*=1 pi∗=1 ,表示该anchor是正样本; p i ∗ = 0 p_i^*=0 pi∗=0 ,表示该anchor是负样本;
第二个 p i ∗ p_i^* pi∗ :在实际的程序里面,对应的是这个参数rpn_bbox_inside_weight,意思与第一个 p i ∗ p_i^* pi∗一样。
t i ∗ t_i^* ti∗ :在程序里面对应的参数是rpn_bbox_targets
t i t_i ti :就是RPN网络的回归层的直接输出:anchors的4个偏移量: t x , t y , t w , t h t_x,t_y,t_w,t_h tx,ty,tw,th 。
The classification loss $L_{cls} $ is log loss over two classes(object vs. not object)
The regression loss