前言
Dlib 68关键点检测基于CVPR2014《One Millisecond Face Alignment with an Ensemble of Regression Trees》实现,以gbdt为基础。基于Ensemble of Regression Tress算法(简称 ERT),速度极快(单人人脸关键点检测耗时约为1ms),效果也不错。同时又能处理训练集中部分关键点标定缺失的情况。
算法
输入标注人脸关键点的图像数据,先将脸提取处理,由于脸的尺寸不一,所以利用仿射变换将人脸关键点仿射到单位空间,统一尺寸和坐标系。将数据的人脸关键点做下平均,作为初始人脸形状,基于这个初始形状再进行残差计算拟合人脸关键点。
首先在初始关键点的范围内随机采样像素作为对应的特征像素点。特征像素点选择最接近的初始关键点作为anchor,并计算偏差。当前像素点通过旋转、转换、伸缩后的坐标系要与初始关键点(关键点的平均位置)接近,即最小化之间的距离平方,得到最优变换tform。tform作用于偏差,加上自身的位置信息,得到当前关键点的特征像素点。
得到特征像素点后开始构建残差树,计算出当前关键点与目标关键点的偏差。通过特征像素点,利用退火的方法选择多个分割点,进行左右树划分,选择最小化划分后的偏差为最优分割点。分割样本,基于样本的平均残差更新当前关键点位置。回到上一步骤,重新选择出特征关键点,拟合下一颗残差树,最终综合所有残差树的结果得到关键点位置。
论文概述
LBF(Face Alignment at 3000 FPS via Regressing Local Binary Features)这篇论文也是基于Tree的人脸关键点检测算法。LBF是基于Tree的方法,学习每个关键点的局部二值特征,然后将特征组合起来,使用线性回归检测关键点。与 LBF 不同的是, ERT 是在学习 Tree的过程中,直接将 shape 的更新值 ΔS存入叶子结点 leaf node. 初始位置 S 在通过所有学习到的 Tree后,mean shape 加上所有经过的叶子结点的ΔS,即可得到最终的人脸关键点位置。总体流程如下图所示:
用公式来表示:
其中 t 表示级联序号,rt(∙,∙) 表示当前级的回归器regressor。回归器的输入参数为图像 I 和上一级回归器更新后的 shape , 采用的特征可以是灰度值或者其它。
为了训练每一级的 rt, 文章采用了 gradient tree boosting算法减小 initial shape 和 ground truth 的平方误差总和。
每个回归器由很多棵树(tree)组成,每棵树参数是根据 current shape 和 ground truth 的坐标差和随机挑选的像素对训练得到的。具体算法可详见论文。
用级联回归其做人脸特征对齐,论文速读
1
站在巨人的肩膀上可以看得更远。这里我们借鉴了前人的两个思路:
1)The first revolves around the indexing of pixel intensities relative to the current estimate of the shape
这里我们使用了一个相对位置的像素差值作为特征,为什么如此选择了? 在图像中我们使用一个 向量的形式来表示人脸的 shape,因为 一些变化因素如: shape deformation and nuisance factors such as changes in illumination conditions,导致了 这个基于向量表示形式的特征变化的幅度很大,基于这个特征来做精确的 shape estimation 就比较难。这里面有一个鸡和蛋的问题: 可靠的特征和精度的 shape estimation 是相互依赖的。
The dilemma is that we need reliable features to accurately predict the shape, and on the other hand we need an accurate estimate of the shape to extract reliable features. 对于这种问题一般都是采用 iterative approach (the cascade) 来解决的。这里我们没有基于图像的 global coordinate system 来提取特征,而是基于当前估计的shape 的 normalized coordinate system 来提取特征。基于这个特征我们预测一个 update vector,一般迭代几个步骤就收敛了。
2) The second considers how to combat the difficulty of the inference/prediction problem。在测试阶段,基于向量的人脸特征点 shape 优化是一个 non-convex with many local optima。 an alignment algorithm has to estimate the shape, a high dimensional vector, that best agrees with the image data and our model of shape. 后来研究指出 基于 linear subspace 可以快速减少搜索空间并有助于 avoid local optima。
我们的高效回归函数学习的方法融合了上述的两个思想。
2 Method
2.1. The cascade of regressors
多个回归器的级联,每个回归器的预测基于图像和前一次的预测
initial shape can simply be chosen as the mean shape of the training data centered and scaled according to the bounding box output of a generic face detector
2.2. Learning each regressor in the cascade
首先介绍了 regression function r0 的 学习,初始化完成之后,就可以开始迭代:
2.3. Tree based regressor
这里主要介绍了训练每个 regression tree 的一些主要实现问题1)Shape invariant split tests2)Choosing the node splits3)Feature selection:exponential prior
2.4. Handling missing labels
这里介绍了怎么处理一部分特征点没有标记的问题
3 Experiments
关于回归树的基础知识
Microstrong:Regression Tree 回归树zhuanlan.zhihu.comDLIB代码分析
陈裕:dlib人脸关键点代码解析zhuanlan.zhihu.com参考
Microstrong:Regression Tree 回归树
陈裕:dlib人脸关键点代码解析
人脸对齐--One Millisecond Face Alignment with an Ensemble of Regression Trees