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

原论文:《J. Deng, J Guo, Y Zhou, et al. RetinaFace: Single-stage Dense Face Localisation in the Wild[J]. arXiv:1905.00641v2》
最后面有参考代码的 Github 链接

论文的两个特点

  1. 引入了人脸关键点信息;
  2. 引入了人脸的三维信息。

骨干网络:ResNet-152

1. 结构图如下:

在这里插入图片描述

  • 它使用了骨干网络中残差阶段 C 2 C_2 C2 C 3 C_3 C3 C 4 C_4 C4 以及 C 5 C_5 C5 的特征图;
  • C 5 C_5 C5 后使用步长为 2 的 3 × 3 3\times3 3×3 卷积构建了 C 6 C_6 C6在训练时,这个卷积层用 Xavier 方法进行随机初始化
  • C 2 C_2 C2 C 3 C_3 C3 C 4 C_4 C4 以及 C 5 C_5 C5 的特征图构建 特征金字塔 (Feature Pyramid)中的各层 P 2 P_2 P2 P 3 P_3 P3 P 4 P_4 P4 以及 P 5 P_5 P5
  • C 6 C_6 C6 作为 P 6 P_6 P6
  • P 2 P_2 P2 P 3 P_3 P3 P 4 P_4 P4 P 5 P_5 P5 以及 P 6 P_6 P6 上分别使用 上下文模块 (Context Module);
  • 每个上下文模块后面均跟一个多任务模块及相应的损失函数。

这里的 上下文模块 就是 SSH 模型中的检测器模块,或者 PyramidBox 模型中的 CPM 模块
上下文模块 中所有 3 × 3 3\times3 3×3 卷积层替换为 可形变卷积网络(Deformable Convolution)

2. Anchor 的设置

Anchor 的宽高比为 1,特征金字塔中每层 Anchor 的尺寸与步长如下表所示。Anchor 一共 102300 个,其中有 75% 在 P 2 P_2 P2 上。

特征金字塔 步长 Anchor尺寸
P 2 ( 160 × 160 × 256 ) P_2(160\times160\times256) P2(160×160×256) 4 16、20.16、25.40
P 3 ( 80 × 80 × 256 ) P_3(80\times80\times256) P3(80×80×256) 8 32、40.32、50.80
P 4 ( 40 × 40 × 256 ) P_4(40\times40\times256) P4(40×40×256) 16 64、80.63、101.59
P 5 ( 20 × 20 × 256 ) P_5(20\times20\times256) P5(20×20×256) 32 128、161.26、203.19
P 6 ( 10 × 10 × 256 ) P_6(10\times10\times256) P6(10×10×256) 64 256、322.54、406.37
  • I o U > 0.5 IoU>0.5 IoU>0.5 时,将 anchor 匹配到 Ground-Truth 上;
  • I o U < 0.3 IoU<0.3 IoU<0.3 时,将 anchor 匹配到 Background 上;
  • 使用分类的值对负样本 anchor 进行排序,仅使用第一个;
  • 使用 OHEM 缓解正负样本的不平衡;
  • 最终正负 anchor 样本比为 1 : 3 1:3 1:3

3. 损失函数

在这里插入图片描述
对训练的第 i i i 个 anchor,待最小化的损失函数为:
L = L c l s ( p i , p i ∗ ) + λ 1 p i ∗ L b o x ( t i , t i ∗ ) + λ 2 p i ∗ L p t s ( l i , l i ∗ ) + λ 3 L p i x e l \begin{aligned}\\ L&=L_{cls}(p_i,p_i^*)+\lambda_1 p_i^*L_{box}(t_i,t_i^*)\\ &+\lambda_2 p_i^*L_{pts}(l_i,l_i^*)+\lambda_3 L_{pixel}\\ \end{aligned} L=Lcls(pi,pi)+λ1piLbox(ti,ti)+λ2piLpts(li,li)+λ3Lpixel
其中,

  • λ 1 = 0.25 \lambda_1=0.25 λ1=0.25 λ 2 = 0.1 \lambda_2=0.1 λ2=0.1 λ 3 = 0.01 \lambda_3=0.01 λ3=0.01
  • p i ∗ p_i^* pi 是 anchor 的正负标记,1 为正样本,0 为负样本;
  • p i p_i pi 是 anchor 作为人脸的概率;
  • L c l s L_{cls} Lcls 是人脸的二分类 softmax 损失函数
  • t i ∗ = { t x ∗ , t y ∗ , t w ∗ , t h ∗ } i t_i^*=\{t_x^*,t_y^*,t_w^*,t_h^*\}_i ti={ tx,ty,tw,th}i 是与正样本 anchor 相关的 Ground-Truth 位置坐标;
  • t i = { t x , t y , t w , t h } i t_i=\{t_x,t_y,t_w,t_h\}_i ti={ tx,ty,tw,th}i 是模型预测的人脸框位置坐标;
  • L b o x L_{box} Lbox 是人脸框回归的 S m o o t h   L 1 Smooth\ L_1 Smooth L1 损失函数
  • l i ∗ = { l x 1 ∗ , l y 1 ∗ , . . . , l x 5 ∗ , l y 5 ∗ } i l_i^*=\{l_{x_1}^*,l_{y_1}^*,...,l_{x_5}^*,l_{y_5}^*\}_i li={ lx1,ly1,...,lx5,ly5}i 是与正样本 anchor 相关的五个人脸关键点坐标;
  • l i = { l x 1 , l y 1 , . . . , l x 5 , l y 5 } i l_i=\{l_{x_1},l_{y_1},...,l_{x_5},l_{y_5}\}_i li={ lx1,ly1,...,lx5,ly5}i 是模型预测的五个人脸关键点坐标;
  • L p t s L_{pts} Lpts 是人脸关键点回归的损失函数
  • L p i x e l L_{pixel} Lpixel 是稠密回归损失函数(Dense Regression Loss),用于控制模型对人脸 3 维信息的利用
    L p i x e l = 1 W ∗ H ∑ i W ∑ j H ∣ ∣ R ( D P S T , P c a m , P i l l ) i , j − I i , j ∗ ∣ ∣ 1 L_{pixel}=\frac{1}{W*H}\sum_{i}^{W}\sum_{j}^{H}||\mathcal{R}(\mathcal{D}_{P_{ST}},P_{cam},P_{ill})_{i,j}-I_{i,j}^*||_1 Lpixel=WH1iWjHR(DPST,Pcam,Pill)i,jIi,j1

其中,

  1. W W W H H H 分别是 Anchor Crop I i , j ∗ I_{i,j}^* Ii,j 的宽与高;
  2. P c a m = { x c , y c , z c , x c ′ , y c ′ , z c ′ , f c } P_{cam}=\{x_c,y_c,z_c,x_c',y_c',z_c',f_c\} Pcam={ xc,yc,zc,xc,yc,zc,fc} 是三维的摄像头参数,这里面的内容分别代表 摄像头位置 { x c , y c , z c } \{x_c,y_c,z_c\} { xc,yc,zc}、姿态 { x c ′ , y c ′ , z c ′ } \{x_c',y_c',z_c'\} { xc,yc,zc}、焦距 f c f_c fc
  3. P i l l = { x l , y l , z l , r l , g l , b l , r a , g a , b a } P_{ill}=\{x_l,y_l,z_l,r_l,g_l,b_l,r_a,g_a,b_a\} Pill={ xl,yl,zl,rl,gl,bl,ra,ga,ba} 是三维的照明参数,这里面的内容分别代表 点光源位置 { x l , y l , z l } \{x_l,y_l,z_l\} { xl,yl,zl}、点光源色值 { r l , g l , b l } \{r_l,g_l,b_l\} { rl,gl,bl}、侧光色值 { r a , g a , b a } \{r_a,g_a,b_a\} { ra,ga,ba}
  4. P S T ∈ R 128 P_{ST}\in \mathcal{R}^{128} PSTR128 是根据图片预测的人脸形状与纹理参数;
  5. D P S T \mathcal{D}_{P_{ST}} DPST 是着色的网状结构(Coloured-Mesh),它是由网状结构解码器(Mesh Decoder)对 P S T P_{ST} PST 解码得到的;
  6. R ( D P S T , P c a m , P i l l ) \mathcal{R}(\mathcal{D}_{P_{ST}},P_{cam},P_{ill}) R(DPST,Pcam,Pill)可微渲染器,负责将含有三维信息的 { D P S T , P c a m , P i l l } \{\mathcal{D}_{P_{ST}},P_{cam},P_{ill}\} { DPST,Pcam,Pill} 映射为一个二维的图片。
  7. 论文里使用的 Mesh Decoder 是在论文《Dense 3d
    face decoding over 2500fps: Joint texture and shape convolutional mesh decoders
    》中预训练得到的。

4、训练

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


参考材料

猜你喜欢

转载自blog.csdn.net/qq_29695701/article/details/105487042