作家
登录

手把手教你用1行命令实现人脸识别

作者: 来源: 2017-10-27 12:24:50 阅读 我要评论

image = face_recognition.load_image_file("/opt/face/unknown_pic/all_star.jpg"
  •  
  • # 应用默认的赐与HOG模型查找图像中所有人脸 
  • # 这个办法已经相当精确了,但照样不如CNN模型那么精确,因为没有应用GPU加快 
  • # 另请拜见: find_faces_in_picture_cnn.py 
  • face_locations = face_recognition.face_locations(image) 
  •  
  • # 应用CNN模型 
  • # face_locations = face_recognition.face_locations(image, number_of_times_to_upsample=0, model="cnn"
  •  
  • # 打印:我大年夜图片中找到了 若干 张人脸 
  • print("I found {} face(s) in this photograph.".format(len(face_locations))) 
  •  
  • # 轮回找到的所有人脸 
  • for face_location in face_locations: 
  •  
  •         # 打印每张脸的地位信息 
  •         topright, bottom, left = face_location 
  •         print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(topleft, bottom, right)) 
  •  
  •         # 指定人脸的地位信息,然后显示人脸图片 
  •         face_image = image[top:bottom, left:right
  •         pil_image = Image.fromarray(face_image) 
  •         pil_image.show()  
  • 用于识其余图片

    1. # 履行python文件 
    2. $ python find_faces_in_picture.py  

    大年夜图片中辨认出 7 张人脸,并显示出来

    示例三(主动辨认人脸特点):

    1. # filename : find_facial_features_in_picture.py 
    2. # -*- coding: utf-8 -*- 
    3. # 导入pil模块 ,可用敕令安装 apt-get install python-Imaging 
    4. from PIL import Image, ImageDraw 
    5. # 导入face_recogntion模块,可用敕令安装 pip install face_recognition 
    6. import face_recognition 
    7.  
    8. # 将jpg文件加载到numpy 数组中 
    9. image = face_recognition.load_image_file("biden.jpg"
    10.  
    11. #查找图像中所有面部的所有面部特点 
    12. face_landmarks_list = face_recognition.face_landmarks(image) 
    13.  
    14. print("I found {} face(s) in this photograph."

        推荐阅读

        大规模分布式存储-分布式剪枝系统

      沙龙晃荡 | 去哪儿、陌陌、ThoughtWorks在主动化运维中的实践!10.28不见不散! 在分布式键值体系中,半构造化>>>详细阅读


      本文标题:手把手教你用1行命令实现人脸识别

      地址:http://www.17bianji.com/lsqh/38279.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)