人脸框检测模型PyramidBox论文学习笔记

人脸框检测模型PyramidBox论文学习笔记

原论文:《Xu Tang, Daniel K. Du, Zeqiang He, Jingtuo Liu. PyramidBox: A Context-assisted Single Shot Face Detector[C]. The European Conference on Computer Vision (ECCV), 2018, pp. 797-813.》
代码https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/face_detection

特点:

  • 提出了一种基于 anchor 的环境辅助方法,即 PyramidAnchors,从而引入有监督的信息来为较小的、模糊的和部分遮挡的人脸学习环境特征。
  • 设计了 LFPN 来更好地融合环境特征和面部特征。同时,该方法可以在单步中较好地处理不同尺度的人脸。
  • 提出了一种Context-Sensitive的预测模型,该模型由混合网络结构和 max-in-out 层组成,从融合的特征中学习准确的定位和分类。
  • 提出了一种关注尺度的 data-anchor sampling 策略,改变训练样本的分布,重点关注较小的人脸。

一、模型结构

骨干网络:基于VGG-16 S 3 F D S^3FD S3FD 模型

1. 结构图如下:

整体结构图

  • 它使用了骨干网络中 Conv3_3Conv4_3Conv5_3Conv_fc7Conv6_2 以及 Conv7_2 输出的特征图。

2. 主要结构说明:

2.1 低层级特征金字塔层(Low-level Feature Pyramid Layers)

作用:将高层特征图中蕴含的人脸上下文信息融合到低层特征图中。
结构:其主要由低层级特征金字塔网络(Low-level Feature Pyramid Network, LFPN)构成。

基本结构如下图所示。这个图是从 Conv_fc7 开始的,另两个从 Conv4_3Conv5_3 开始融合的结构图与此相似。
LFPN

2.2 金字塔检测层(Pyramid Detection Layers)

  • 选用的特征层为:lfpn_2lfpn_1lfpn_0conv_fc7conv6_2 以及 conv7_2
  • 这些特征层使用的 anchor 尺寸为:16、32、64、128、256以及512。
  • 其中,lfpn_2lfpn_1 以及 lfpn_0 是分别基于Conv3_3Conv4_3 以及 Conv5_3LFPN 层的输出。
  • 使用 L 2 L_2 L2LFPN 层进行正则处理。

2.3 预测层(Predict Layers)

  • 主要由 对上下文信息敏感的预测模块 (Context-sensitive Predict Module, CPM)构成。
  • CPM的结构:用 DSSD模型的无残差预测模块 (Residual-free Prediction Module)替换了 SSH模型的上下文模块 (Context Module)。
  • 每个检测模块后面都连接一个 CPM,所以一共有 6 个 CPM
  • l l lCPM 的输出的尺寸为: w l × h l × c l w_l \times h_l \times c_l wl×hl×cl。(其中 w l = h l = 640 / 2 2 + l w_l = h_l = 640/2^{2+l} wl=hl=640/22+l c l = 20 c_l=20 cl=20 l ∈ { 0 , 1 , 2 , 3 , 4 , 5 } l \in \{0,1,2,3,4,5\} l{ 0,1,2,3,4,5})。

基本结构如下图所示:
CPM

其中,每个通道的特征负责预测面部、头部与身体各自的分类与边界框回归。

  • 面部的分类需要 4( = c p l + c n l = cp_l + cn_l =cpl+cnl)通道,边界框回归需要 4个通道;
  • 头部的分类需要 2个通道,边界框回归需要 4个通道;
  • 身体的分类需要 2个通道,边界框回归需要 4个通道;
  • 所以一共有 20个通道 ( 4 + 4 ) + ( 2 + 4 ) + ( 2 + 4 ) = 20 (4+4)+(2+4)+(2+4)=20 (4+4)+(2+4)+(2+4)=20

c p l cp_l cpl c n l cn_l cnl 是前景与背景的max-in-out,并满足:
c p l = { 1 ,      i f    l = 0 , 3 ,      o t h e r w i s e . cp_l = \left\{ \begin{aligned} 1&,\ \ \ \ if\ \ l=0, \\ 3&,\ \ \ \ otherwise. \end{aligned} \right. cpl={ 13,    if  l=0,,    otherwise.

2.3.1 max-in-out算法

作用:减少小的负样本的FP值(False Positive Rate)。

应用的位置如下图所示:
max-in-out
每个预测模块预测出一共 c p + c n c_p + c_n cp+cn 个得分,然后:

扫描二维码关注公众号,回复: 13065094 查看本文章
  1. 选择 c p c_p cp 中最大的得分,作为正样本得分;
  2. 选择 c n c_n cn 中最大的得分,作为负样本得分。

在第一个预测模块中,设置: c p = 1 ,   c n = 3 c_p=1,\ c_n=3 cp=1, cn=3;(因为小anchor的背景更复杂,负样本就会更多)
其他几个预测模块中,设置: c p = 3 ,   c n = 1 c_p=3,\ c_n=1 cp=3, cn=1。(这是为了召回更多的面部)

2.4 PyramidBox损失层(PyramidBox loss layers)

  • 对于每个目标面部,都有一系列pyramid anchor来同时监督分类和回归的任务。
  • 这一层主要由 PyramidAnchors算法模块 构成。它会生成一些 anchor,这些 anchor 与某个面部所处的更大的区域相对应,而这些区域包含了面部丰富的上下文信息,如头部、肩膀以及躯体。

在原始图片上,对于一个位于 r e g i o n t a r g e t region_{target} regiontarget 的面部来说,考虑一个步幅为 s i s_i si,位于第 i i i 个特征层上的第 j j janchor a n c h o r i , j anchor_{i,j} anchori,j,定义第 k k kpyramid-anchor 的标签为:
l a b e l k ( a n c h o r i , j ) = { 1 ,      i f    I o U ( a n c h o r i , j ⋅ s i / 2 k , r e g i o n t a r g e t ) > 0.35 , 0 ,      o t h e r w i s e . label_{k}(anchor_{i,j}) = \left\{ \begin{aligned} 1&,\ \ \ \ if\ \ IoU(anchor_{i,j} \cdot s_i / 2^k, region_{target})>0.35, \\ 0&,\ \ \ \ otherwise. \end{aligned} \right. labelk(anchori,j)={ 10,    if  IoU(anchori,jsi/2k,regiontarget)>0.35,,    otherwise.

其中:
k ∈ { 0 , 1 , 2 } k \in \{0,1,2\} k{ 0,1,2},对应的 l a b e l 0 label_0 label0 l a b e l 1 label_1 label1 l a b e l 2 label_2 label2 分别为:面部、头部、身体
a n c h o r i , j ⋅ s i anchor_{i,j} \cdot s_i anchori,jsi a n c h o r i , j anchor_{i,j} anchori,j 在原始图片上的相应的区域;
a n c h o r i , j ⋅ s i / 2 k anchor_{i,j} \cdot s_i / 2^k anchori,jsi/2k 为相应的以 2 k 2^k 2k 为步幅的下采样区域。

2.4.1 基于anchor的数据采样方法(Data-anchor Sampling):

举例说明:(输入的图尺寸为: 640 × 640 640 \times 640 640×640

  • 对于一个尺寸为140的面部,在 { 2 4 + i ∣ i = 0 , 1 , . . . , 5 } \{2^{4+i}|i=0,1,...,5\} { 24+ii=0,1,...,5} 中距离其最近的anchor尺寸为128(此时 i a n c h o r = 3 i_{anchor}=3 ianchor=3),
  • 然后在 { 0 , 1 , . . . , m i n ( 5 , i a n c h o r + 1 ) } \{ {0,1,...,min(5,i_{anchor}+1)}\} { 0,1,...,min(5,ianchor+1)} (即在 { 0 , 1 , . . . , 4 ) } \{ {0,1,...,4)}\} { 0,1,...,4)})中随机地选择一个序号以得到目标尺寸,如32。
  • 32 / 140 = 0.2285 32/140=0.2285 32/140=0.2285 的比例重新调整原始图片的比例。
  • 从最后调整的图中,裁取一个 640 × 640 640\times640 640×640的图像,该图像包含了那个被选中的图片。
  • 最终得到了采样的训练数据
2.4.2 损失函数

L ( { p k , i } , { t k , i } ) = ∑ k λ k L k ( { p k , i } , { t k , i } ) L(\{p_{k,i}\},\{t_{k,i}\})=\sum_k \lambda_k L_k(\{p_{k,i}\},\{t_{k,i}\}) L({ pk,i},{ tk,i})=kλkLk({ pk,i},{ tk,i})
L k ( { p k , i } , { t k , i } ) = λ N k , c l s ∑ i k L k , c l s ( p k , i , p k , i ∗ ) + 1 N k , r e g ∑ i k p k , i ∗ L k , r e g ( t k , i , t k , i ∗ ) \begin{aligned} L_k(\{p_{k,i}\},\{t_{k,i}\}) &= \frac{\lambda}{N_{k,cls}} \sum_{i_k} L_{k,cls}(p_{k,i},p_{k,i}^*) \\ &+ \frac{1}{N_{k,reg}} \sum_{i_k} p_{k,i}^* L_{k,reg}(t_{k,i},t_{k,i}^*)\end{aligned} Lk({ pk,i},{ tk,i})=Nk,clsλikLk,cls(pk,i,pk,i)+Nk,reg1ikpk,iLk,reg(tk,i,tk,i)
其中, k k k 与面部、头部、身体相对应; i i ianchor相对应; L k , c l s L_{k,cls} Lk,cls 是在两个类别上的对数损失函数; L k , r e g L_{k,reg} Lk,reg s m o o t h   L 1 smooth\ L_1 smooth L1 损失函数; t k , i t_{k,i} tk,i t k , i ∗ t_{k,i}^* tk,i 是与边界框回归有关的坐标向量,前者是预测值,后者是Ground-Truth的边界框; p k , i p_{k,i} pk,i 是第 i i ianchor为第 k k k 个目标的概率值;Ground-Truth的标签 p k , i ∗ p_{k,i}^* pk,i 定义为:
p k , i ∗ = { 1 ,      如 果 以 步 幅   2 k   下 采 样 得 到 的 a n c h o r 是 正 样 例 , 0 ,      其 他 情 况 . p_{k,i}^* = \left\{ \begin{aligned} 1&,\ \ \ \ 如果以步幅\ 2^k\ 下采样得到的anchor是正样例, \\ 0&,\ \ \ \ 其他情况. \end{aligned} \right. pk,i={ 10,     2k anchor,,    .
t k , i ∗ t_{k,i}^* tk,i的定义如下:
t k , i ∗ = ( t x ∗ + 1 − 2 k 2 t w ∗ s w , k + Δ x , k , t y ∗ + 1 − 2 k 2 t h ∗ s h , k + Δ y , k , 2 k t w ∗ s w , k − 2 Δ x , k , 2 k t h ∗ s h , k − 2 Δ y , k ) \begin{aligned} t_{k,i}^*=(&t_x^* + \frac{1-2^k}{2}t_w^*s_{w,k}+\Delta_{x,k},\\ &t_y^* + \frac{1-2^k}{2}t_h^*s_{h,k}+\Delta_{y,k},\\ &2^kt_w^*s_{w,k}-2\Delta_{x,k},\\ &2^kt_h^*s_{h,k}-2\Delta_{y,k})\\ \end{aligned} tk,i=(tx+212ktwsw,k+Δx,k,ty+212kthsh,k+Δy,k,2ktwsw,k2Δx,k,2kthsh,k2Δy,k)

k < 2 k<2 k<2 时, Δ x , k = Δ y , k = 0 , s w , k = s h , k = 1 \Delta_{x,k}=\Delta_{y,k}=0,s_{w,k}=s_{h,k}=1 Δx,k=Δy,k=0,sw,k=sh,k=1
k = 2 k=2 k=2 时, Δ x , k = 0 , Δ y , k = t h ∗ , s w , k = 7 8 , s h , k = 1 \Delta_{x,k}=0,\Delta_{y,k}=t_h^*,s_{w,k}=\frac{7}{8},s_{h,k}=1 Δx,k=0,Δy,k=th,sw,k=87,sh,k=1

四、训练

使用带有冲量(momentatum) 0.9 与权重衰减(weight decay) 0.0005 的随机梯度下降法。

  • 数据集:WIDER FACE
  • batch size:16
  • 前期迭代八万次的学习率:0.001;
  • 中期迭代两万次的学习率:0.0001;
  • 后期迭代两万次的学习率:0.00001;

参考材料

猜你喜欢

转载自blog.csdn.net/qq_29695701/article/details/105377553
今日推荐