使用 yolov4 人脸检测 face_recognition
use yolov4 face detection with face_recognition
我可以使用yolov4进行物体检测并使用face_recognition库来识别检测到的人脸,还是我需要使用face_recognition库提供的人脸检测才能使用它的人脸识别?
face_recognition 库使用 dlib
特定于 face-detection 的内置算法。它声称准确度为 99%+。您不能将该算法更改为 YoloV4 或任何其他算法。
face_recognition的网络架构基于ResNet-34,但层数更少,滤波器数量减少一半。该网络在野外标记面孔 (LFW) 数据集上的 300 万张图像数据集上进行了训练。
看看 Davis King(dlib 的创建者)和 Adam Geitgey(face_recognition 的作者)关于learning-based 面部识别工作有多深的文章:
High Quality Face Recognition with Deep Metric Learning
Modern Face Recognition with Deep Learning
但是,如果这对您的情况来说还不够,您可以训练 YoloV4 来检测人脸,然后在检测之后裁剪该人脸并将其作为 face_recognition 库的输入。
import face_recognition
picture_of_me = face_recognition.load_image_file("me.jpg")
my_face_encoding = face_recognition.face_encodings(picture_of_me)[0]
# my_face_encoding now contains a universal 'encoding' of my facial features that can be compared to any other picture of a face!
unknown_picture = face_recognition.load_image_file("unknown.jpg")
unknown_face_encoding = face_recognition.face_encodings(unknown_picture)[0]
# Now we can see the two face encodings are of the same person with `compare_faces`!
results = face_recognition.compare_faces([my_face_encoding], unknown_face_encoding)
if results[0] == True:
print("It's a picture of me!")
else:
print("It's not a picture of me!")
我可以使用yolov4进行物体检测并使用face_recognition库来识别检测到的人脸,还是我需要使用face_recognition库提供的人脸检测才能使用它的人脸识别?
face_recognition 库使用 dlib
特定于 face-detection 的内置算法。它声称准确度为 99%+。您不能将该算法更改为 YoloV4 或任何其他算法。
face_recognition的网络架构基于ResNet-34,但层数更少,滤波器数量减少一半。该网络在野外标记面孔 (LFW) 数据集上的 300 万张图像数据集上进行了训练。
看看 Davis King(dlib 的创建者)和 Adam Geitgey(face_recognition 的作者)关于learning-based 面部识别工作有多深的文章:
High Quality Face Recognition with Deep Metric Learning
Modern Face Recognition with Deep Learning
但是,如果这对您的情况来说还不够,您可以训练 YoloV4 来检测人脸,然后在检测之后裁剪该人脸并将其作为 face_recognition 库的输入。
import face_recognition
picture_of_me = face_recognition.load_image_file("me.jpg")
my_face_encoding = face_recognition.face_encodings(picture_of_me)[0]
# my_face_encoding now contains a universal 'encoding' of my facial features that can be compared to any other picture of a face!
unknown_picture = face_recognition.load_image_file("unknown.jpg")
unknown_face_encoding = face_recognition.face_encodings(unknown_picture)[0]
# Now we can see the two face encodings are of the same person with `compare_faces`!
results = face_recognition.compare_faces([my_face_encoding], unknown_face_encoding)
if results[0] == True:
print("It's a picture of me!")
else:
print("It's not a picture of me!")