基于tensorflow的人脸识别技术(facenet)的测试

人脸识别的应用非常广泛,而且进展特别快。如LFW的评测结果上已经都有快接近99.9%的。

Uni-Ubi600.9900 ± 0.0032
FaceNet620.9963 ± 0.0009
Baidu640.9977 ± 0.0006
AuthenMetric650.9977 ± 0.0009
MMDFR670.9902 ± 0.0019
CW-DNA-1700.9950 ± 0.0022
Faceall710.9967 ± 0.0007
JustMeTalk720.9887 ± 0.0016
Facevisa740.9955 ± 0.0014
pose+shape+expression augmentation750.9807 ± 0.0060
ColorReco760.9940 ± 0.0022
Asaphus770.9815 ± 0.0039
Daream780.9968 ± 0.0009
Dahua-FaceImage800.9978 ± 0.0007
Easen Electron810.9978 ± 0.0006
Skytop Gaia820.9630 ± 0.0023
CNN-3DMM estimation830.9235 ± 0.0129
Samtech Facequest840.9971 ± 0.0018
XYZ Robot870.9895 ± 0.0020
THU CV-AI Lab880.9973 ± 0.0008
dlib900.9938 ± 0.0027
Aureus910.9920 ± 0.0030
YouTu Lab, Tencent630.9980 ± 0.0023
Orion Star920.9965 ± 0.0032
Yuntu WiseSight930.9943 ± 0.0045
PingAn AI Lab890.9980 ± 0.0016
Turing123940.9940 ± 0.0040
Hisign950.9968 ± 0.0030
VisionLabs V2.0380.9978 ± 0.0007
Deepmark960.9923 ± 0.0016
Force Infosystems970.9973 ± 0.0028
ReadSense980.9982 ± 0.0007

      在上述模型中,有许多是商业公司的排名,所以呢,基本上很少有开源的东西。此处只对谷歌的facenet进行测试。

      FaceNet的架构如下所示:

    

      从上面可以看出,没有使用softmax层,而直接利用L2层正则化输出,获取其图像表示,即特征抽象层。而深度学习的框架可以使用现有的成熟模型,如tensorflow slim中的每一种模型。

      而最后一个Triplet Loss则是采用了三元组的损失函数。其代码如下所示      

def triplet_loss(anchor, positive, negative, alpha):
    """Calculate the triplet loss according to the FaceNet paper
    
    Args:
      anchor: the embeddings for the anchor images.
      positive: the embeddings for the positive images.
      negative: the embeddings for the negative images.
  
    Returns:
      the triplet loss according to the FaceNet paper as a float tensor.
    """
    with tf.variable_scope('triplet_loss'):
        pos_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, positive)), 1)
        neg_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, negative)), 1)
        
        basic_loss = tf.add(tf.subtract(pos_dist,neg_dist), alpha)
        loss = tf.reduce_mean(tf.maximum(basic_loss, 0.0), 0)
      
    return loss

从上面代码可以看出,三元组其实就是三个样例,如(anchor, pos, neg),利用距离关系来判断。即在尽可能多的三元组中,使得anchor和pos正例的距离,小于anchor和neg负例的距离。

       其学习优化如下图所示:

    

      测试:(代码见:https://github.com/davidsandberg/facenet)

       

        由于facenet无需限制人脸对齐,但是代码中提供了MTCNN的对齐,而且在LFW评分中也发现经过对齐的分数能够提高一个档次。

        利用提供的代码,在LFW上进行EVAL,发现其精度高达99.2%

        

        

         当然,还有更高的。



另外,程序中还提供了进行两张图片距离的比较的代码,进行调试,结果如下:


  • 2
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值