决策树及随机森林在face alignment at 3000fps中的训练和测试

Contents

1. 准备训练样本

通过对参数的读取,若一个随机森林有10个树:
输入经过augmented的训练样本,被有overlapping的分割成10部分,每一部分训练一个决策树。然后,这些样本再训练另外一个random forest的10个决策树。

2. Split node分裂节点的确定和划分

        决策树的意义在于产生LBP特征,即得到Φ
  • 决策树的输入: pdf像素差特征,在每张图的一个关键点的固定半径内,随机生成M=500个,并记录其坐标;
    输入一个random forest的一棵树的训练集N=541;
    组成一个500×541的输入矩阵,即densities(j,i),每一列代表的是一个样本的500个像素差值,一共541列;每一行代表的是541个样本中,每个样本随机选择的一个像素差值。
 for(int j = 0;j < max_numfeats_;j++){
            double project_x1 = rotation(0,0) * candidate_pixel_locations(j,0) + rotation(0,1) * candidate_pixel_locations(j,1);
            double project_y1 = rotation(1,0) * candidate_pixel_locations(j,0) + rotation(1,1) * candidate_pixel_locations(j,1);

            project_x1 = scale * project_x1 * bounding_box[ind_samples[i]].width / 2.0;
            project_y1 = scale * project_y1 * bounding_box[ind_samples[i]].height / 2.0;
            int real_x1 = project_x1 + current_shapes[ind_samples[i]](landmarkID_,0);
            int real_y1 = project_y1 + current_shapes[ind_samples[i]](landmarkID_,1);
            real_x1 = max(0.0,min((double)real_x1,images[ind_samples[i]].cols-1.0));
            real_y1 = max(0.0,min((double)real_y1,images[ind_samples[i]].rows-1.0));

            double project_x2 = rotation(0,0) * candidate_pixel_locations(j,2) + rotation(0,1) * candidate_pixel_locations(j,3);
            double project_y2 = rotation(1,0) * candidate_pixel_locations(j,2) + rotation(1,1) * candidate_pixel_locations(j,3);
            project_x2 = scale * project_x2 * bounding_box[ind_samples[i]].width / 2.0;
            project_y2 = scale * project_y2 * bounding_box[ind_samples[i]].height / 2.0;
            int real_x2 = project_x2 + current_shapes[ind_samples[i]](landmarkID_,0);
            int real_y2 = project_y2 + current_shapes[ind_samples[i]](landmarkID_,1);

            real_x2 = max(0.0,min((double)real_x2,images[ind_samples[i]].cols-1.0));
            real_y2 = max(0.0,min((double)real_y2,images[ind_samples[i]].rows-1.0));

            densities(j,i) = ((int)(images[ind_samples[i]](real_y1,real_x1))-(int)(images[ind_samples[i]](real_y2,real_x2)));
        }
    }
  • 决策树的阈值确定:最大方差衰减 maximum variance reduction
    max(分裂前的样本方差总和 – 分裂后左样本集的方差 – 分裂后右样本集的方差)
    即argmax ( Var-Var_Left-Var_right)

    1. 500×541矩阵每一行,随机选任意一个样本的像素差值做分类阈值,用这个pdf值将第一行541个样本分成两类:< threshold的样本 和 >threshold的样本,分别放在左右子集。
    2. 计算541个样本的方差,左子集的方差,右子集的方差。保存
    3. 依次计算矩阵的每一行,随机产生阈值,分类,计算方差,保存
    4. 选择保存的所有( Var-Var_Left-Var_right)的值,选择最大的值,作为根节点的分裂阈值。
    5. 对根节点分类出来的左右子集的样本再分别计算方差,确定决策树的其他节点。确定一棵树的分裂节点和叶子节点。
    6. 另外的样本输入训练第二个决策树,循环,得到随机森林的结构。
    7. 同样的样本,训练第二个随机森林,循环所有人脸关键点,得到68个随机森林。
    

3. 由决策树得到LBF特征

这里写图片描述

1. 对输入的图片,每个关键点,选择pdf值,通过分裂节点,最后抵达叶子节点,点亮决策树的一个叶子节点输出。亮的为1,暗的为0。得到LBF稀疏特征。
2.  组合所有随机森林决策树的LBF特征得到ϕ

[Δx1Δy1Δx2Δy2Δx3...Δy3...]1000010000100001=[Δx1+Δx5+Δx10+Δx15Δy1+Δy5+Δy10+Δy15]


4. 训练参数

  1. data augmentation:每张训练图通过多次随机多个初始化shpe来增加训练样本数量
    测试时,我们只是用mean shape做初始化shape
  2. 两种参数:
    (1). 更精确LBF: stage T=5;tree depth D=7;每个stage中tree的个数 N=1200
    (2). 更快LBF fast: stage T=5;tree depth D=5;每个stage中tree的个数 N=300
  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值