初识机器学习-人脸识别

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了初识机器学习-人脸识别相关的知识,希望对你有一定的参考价值。

 感谢知乎老狼https://zhuanlan.zhihu.com/p/27275307,点击链接

Anaconda的安装

face_recognition库安装

1.代码

from PIL import Image
import face_recognition

# Load the jpg file into a numpy array
image = face_recognition.load_image_file("wang.jpg")

# Find all the faces in the image
face_locations = face_recognition.face_locations(image)

print("I found {} face(s) in this photograph.".format(len(face_locations)))

for face_location in face_locations:

    # Print the location of each face in this image
    top, right, bottom, left = face_location
    print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))

    # You can access the actual face itself like this:
    face_image = image[top:bottom, left:right]
    pil_image = Image.fromarray(face_image)
    pil_image.show()
image = face_recognition.load_image_file("wang.jpg")读取jpg文件,jpg文件和程序放在同一个文件夹下
face_locations = face_recognition.face_locations(image)
face_recognition详细请参考 http://yongyuan.name/blog/deep-face-recognition-note.html

print("I found {} face(s) in this photograph.".format(len(face_locations)))
打印在改图片发现的人脸数
for face_location in face_locations:

    # Print the location of each face in this image
    top, right, bottom, left = face_location
    print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))
 for循环遍历face_locations,并且逐个打印图片上述属性

 

 

以上是关于初识机器学习-人脸识别的主要内容,如果未能解决你的问题,请参考以下文章

opencv 灰度图二分类 (人脸识别 非HOG)sklearn 机器学习

opencv 灰度图二分类 (人脸识别 非HOG)sklearn 机器学习

毕业设计 深度学习 机器视觉 人脸识别系统 - opencv python

AI识别照片是谁,人脸识别face_recognition开源项目安装使用 | 机器学习

机器学习:基于支持向量机(SVM)进行人脸识别预测

机器学习:基于支持向量机(SVM)进行人脸识别预测