zoukankan      html  css  js  c++  java
  • 百度人脸识别AI实践.doc

     

    0, 前言

    百度开放了很多AI能力,其中人脸识别就是其中之一。

    本文对百度人脸识别AI进行实践检验,看看其使用效果如何。

    鉴于是最为基础的实践,基本都是在其接口范例代码修改而来。

    百度人脸识别AI网站:

    https://console.bce.baidu.com/ai/#/ai/face/overview/index
    http://ai.baidu.com/docs#/FACE-API/6f44de4a

    首先要进行开发者认证,然后建立APP,再申请API Key  和 Secret Key,再获取access_token。

    这些步骤在此略过。

    1,人脸检测调用

    代码:face_detect.py

    运行结果:

    b'{"result_num":1,"result":[{"location":{"left":313,"top":109,"width":95,"height":92},"face_probability":0.96016013622284,"rotation_angle":31,"yaw":-12.178998947144,"pitch":6.8234496116638,"roll":30.81263923645,"landmark":[{"x":336,"y":144},{"x":370,"y":165},{"x":346,"y":184},{"x":331,"y":196}],"landmark72":[{"x":305,"y":122},{"x":298,"y":137},{"x":293,"y":153},{"x":290,"y":171},{"x":295,"y":191},{"x":304,"y":209},{"x":318,"y":219},{"x":334,"y":218},{"x":349,"y":210},{"x":362,"y":202},{"x":372,"y":193},{"x":380,"y":182},{"x":387,"y":170},{"x":327,"y":140},{"x":334,"y":140},{"x":339,"y":142},{"x":343,"y":146},{"x":344,"y":153},{"x":339,"y":151},{"x":334,"y":149},{"x":330,"y":144},{"x":336,"y":144},{"x":325,"y":125},{"x":336,"y":124},{"x":344,"y":127},{"x":351,"y":133},{"x":355,"y":141},{"x":348,"y":137},{"x":341,"y":132},{"x":334,"y":127},{"x":363,"y":165},{"x":369,"y":162},{"x":374,"y":163},{"x":378,"y":167},{"x":379,"y":172},{"x":375,"y":172},{"x":371,"y":171},{"x":367,"y":168},{"x":370,"y":165},{"x":372,"y":153},{"x":379,"y":152},{"x":385,"y":154},{"x":390,"y":157},{"x":390,"y":164},{"x":387,"y":160},{"x":383,"y":158},{"x":377,"y":155},{"x":350,"y":157},{"x":344,"y":165},{"x":338,"y":173},{"x":330,"y":178},{"x":336,"y":183},{"x":346,"y":189},{"x":350,"y":190},{"x":353,"y":181},{"x":356,"y":172},{"x":359,"y":163},{"x":346,"y":184},{"x":315,"y":184},{"x":326,"y":190},{"x":334,"y":195},{"x":340,"y":198},{"x":345,"y":201},{"x":337,"y":203},{"x":329,"y":202},{"x":321,"y":195},{"x":324,"y":192},{"x":332,"y":197},{"x":339,"y":200},{"x":338,"y":200},{"x":331,"y":198},{"x":324,"y":192}],"age":24.123235702515,"beauty":69.033996582031,"expression":1,"expression_probablity":0.9958593249321,"faceshape":[{"type":"square","probability":0.0057251220569015},{"type":"triangle","probability":0.0012500827433541},{"type":"oval","probability":0.21884967386723},{"type":"heart","probability":0.62574058771133},{"type":"round","probability":0.14843453466892}],"gender":"female","gender_probability":0.99999916553497,"glasses":0,"glasses_probability":0.99999940395355,"race":"yellow","race_probability":1,"qualities":{"occlusion":{"left_eye":0,"right_eye":0,"nose":0,"mouth":0,"left_cheek":0,"right_cheek":0,"chin":0},"blur":0,"illumination":0,"completeness":0,"type":{"human":0.99739569425583,"cartoon":0.0026042922399938}}}],"log_id":3917056385}'

    能够返回完整的轮廓描述信息。

    2,人脸比对

    运行代码:face_compare.py

    b'{"result":[{"index_i":"0","index_j":"1","score":79.925468444824}],"result_num":1,"log_id":4196468489123021}'

    文档说明score字段为比对得分,推荐80作为阈值,80分以上可以判断为同一人,此分值对应万分之一误识率。结果不够理想。

    换成马云后,辨识度很高:

     

     b'{"result":[{"index_i":"0","index_j":"1","score":91.242309570312}],"result_num":1,"log_id":4218484369123021}'

    换成马云和美女,完全不相似了,呵呵。

    b'{"result":[{"index_i":"0","index_j":"1","score":5.0950660705566}],"result_num":1,"log_id":4230167824123021}'

     

    3, 人脸注册

    代码:face_add.py

    将jackma.jpg和jackma2.jpg两张图片注册在id为jackma下。

    将timg.jpg和timg1.jpg两张图片注册在id为beauty1下。

    4,人脸识别

    代码:face_identify.py

    将下面2张图片,传入比对。

     

    结果如下:

    b'{"result":[{"uid":"jackma","scores":[94.850677490234],"group_id":"test_group_2","user_info":"\u9a6c\u4e91"},{"uid":"jackma","scores":[92.1611328125],"group_id":"test_group_2","user_info":"\u9a6c\u4e91"}],"result_num":2,"log_id":2863131081123023}'

     可见识别效果相当好!

    传入此美女的2张新的图片,也是识别不错。

    b'{"result":[{"uid":"beauty1","scores":[93.205795288086],"group_id":"test_group_2","user_info":"\u7f8e\u59731"},{"uid":"beauty1","scores":[91.085876464844],"group_id":"test_group_2","user_info":"\u7f8e\u59731"}],"result_num":2,"log_id":2922953983123023}'

    传入未注册过的2张图片试试,

    b'{"result":[{"uid":"beauty1","scores":[41.366012573242],"group_id":"test_group_2","user_info":"\u7f8e\u59731"},{"uid":"beauty1","scores":[30.834575653076],"group_id":"test_group_2","user_info":"\u7f8e\u59731"}],"result_num":2,"log_id":2954086825123100}'

    虽然归类为美女1,但置信度已大为降低,远低于80。因此可以认为匹配失败。这个识别结果是OK的。

  • 相关阅读:
    Circular dependency issuse on cocoapods version(0.36.0) 全然解决方式(非降版本号)
    Android Studio经常使用配置及使用技巧(二)
    poj 2195 Going Home(最小费最大流)
    OpenFace库(Tadas Baltrusaitis)中基于Haar Cascade Classifiers进行人脸检測的測试代码
    Divisibility by Eight
    hdu 5055(坑)
    微服务(Microservices)
    mysql 运行计划explain具体解释
    URAL 题目1297. Palindrome(后缀数组+RMQ求最长回文子串)
    Windows下将nginx安装为服务运行
  • 原文地址:https://www.cnblogs.com/jackkwok/p/8151722.html
Copyright © 2011-2022 走看看