-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth_or_not.py
22 lines (17 loc) · 990 Bytes
/
auth_or_not.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import face_recognition
import os
from numpy import load
# Load the images into numpy arrays
authorized_encodings=load('embeddings.npy', allow_pickle=True)
unknown_images = [ face_recognition.load_image_file(f'unknown/{img}') for img in os.listdir('unknown/') ]
# Get the face encodings for each face in each image file
# Since there could be more than one face in each image, it returns a list of encodings.
try:
unknown_encodings = [ face_recognition.face_encodings(image) for image in unknown_images ]
except IndexError:
print("I wasn't able to locate any faces in at least one of the images. Check the image files. Aborting...")
quit()
# results is an array of True/False telling if the unknown face matched anyone in the known_faces array
results = [ face_recognition.compare_faces(authorized_encodings, unk) for unk in unknown_encodings]
new_res= [ result[i] for result in results for i in result ]
print("Is the person authorized? {}".format( True in new_res))