Created
October 22, 2022 23:42
-
-
Save giljr/9eed6d71f8136842fe26e7cb4201a405 to your computer and use it in GitHub Desktop.
face recognition https://pypi.org/project/face-recognition/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import face_recognition | |
# Load the jpg file into a numpy array | |
image = face_recognition.load_image_file("office.jpg") | |
# Find all the faces in the image using the default HOG-based model. | |
# This method is fairly accurate, but not as accurate as the CNN model and not GPU accelerated. | |
# See also: find_faces_in_picture_cnn.py | |
face_locations = face_recognition.face_locations(image) | |
for face_location in face_locations: | |
# Print the location of each face in this image | |
top, right, bottom, left = face_location | |
# You can access the actual face itself like this: | |
face_image = image[top:bottom, left:right] | |
pil_image = Image.fromarray(face_image) | |
display(pil_image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment