加入收藏 | 设为首页 | 会员中心 | 我要投稿 西安站长网 (https://www.029zz.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 建站 > 正文

超简单而强大的人脸识别项目登上GitHub趋势榜

发布时间:2019-08-13 23:26:46 所属栏目:建站 来源:TommyZihao编译
导读:副标题#e# 近日,一个名为 face_recognition 的人脸识别项目登上了 GitHub Trending 趋势榜,赚足了眼球。自开源至截稿,此项目在 Github 上的 Star 数已达 26500,Fork 数也达到了 7117。本文主要介绍了该项目的使用说明和使用方法,便于国内的开发者们进

如果你使用Python3.4或更新的版本,可以传入 --cpus <number_of_cpu_cores_to_use> 参数:

  1. $ face_recognition --cpus 4 ./pictures_of_people_i_know/ ./unknown_pictures/ 

(你可以传入 --cpus -1参数来调用cpu的所有核心。)此外,子豪兄Tommy 表示树莓派3B有4个CPU核心,传入多核参数可以显著提升图片识别的速度。

更多案例

如果你并不在乎图片的文件名,只想知道文件夹中的图片里有谁,可以用这个管道命令:

  1. $ face_recognition ./pictures_of_people_i_know/ ./unknown_pictures/ | cut -d ',' -f2 
  2. Barack Obama 
  3. unknown_person 

2.使用Python

在 Python 中导入 face_recognition模块,调用丰富的API接口,用几行代码就可以轻松玩转各种人脸识别功能!API 接口文档:

https://face-recognition.readthedocs.io

如何定位人脸位置或者识别人脸身份?

在 Python 中可以分别通过以下代码来实现在图片中定位人脸的位置

  1. import face_recognition 
  2. image = face_recognition.load_image_file("my_picture.jpg") 
  3. face_locations = face_recognition.face_locations(image) 
  4. # face_locations is now an array listing the co-ordinates of each face 

参考案例:

https://github.com/ageitgey/face_recognition/blob/master/examples/find_faces_in_picture.py

在图片中识别人脸身份

  1. import face_recognition 
  2. picture_of_me = face_recognition.load_image_file("me.jpg") 
  3. my_face_encoding = face_recognition.face_encodings(picture_of_me)[0] 
  4. # my_face_encoding now contains a universal 'encoding' of my facial features that can be compared to any other picture of a face! 
  5. unknown_picture = face_recognition.load_image_file("unknown.jpg") 
  6. unknown_face_encoding = face_recognition.face_encodings(unknown_picture)[0] 
  7. # Now we can see the two face encodings are of the same person with `compare_faces`! 
  8. results = face_recognition.compare_faces([my_face_encoding], unknown_face_encoding) 
  9. if results[0] == True: 
  10.  print("It's a picture of me!") 
  11. else: 
  12.  print("It's not a picture of 

参考案例:

https://github.com/ageitgey/face_recognition/blob/master/examples/recognize_faces_in_pictures.py

对人脸识别有精准要求怎么办?

(编辑:西安站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读