Spaces:
Runtime error
Runtime error
Shafeek Saleem
commited on
Commit
•
f8438df
1
Parent(s):
2028549
face recog fixed
Browse files
pages/4_Face Recognition.py
CHANGED
@@ -64,13 +64,16 @@ def step4_page():
|
|
64 |
for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
|
65 |
# See if the face is a match for the known face(s)
|
66 |
st.write(known_face_encodings)
|
67 |
-
|
68 |
-
|
69 |
name = "Unknown"
|
70 |
-
|
71 |
-
if
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
74 |
|
75 |
face_image = image[top:bottom, left:right]
|
76 |
pil_image = Image.fromarray(face_image)
|
|
|
64 |
for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
|
65 |
# See if the face is a match for the known face(s)
|
66 |
st.write(known_face_encodings)
|
67 |
+
face_distances = face_recognition.face_distance(known_face_encodings, face_encoding)
|
|
|
68 |
name = "Unknown"
|
69 |
+
best_match_index = np.argmin(face_distances)
|
70 |
+
if matches[best_match_index]:
|
71 |
+
name = known_face_names[best_match_index]
|
72 |
+
#
|
73 |
+
# # If a match was found in known_face_encodings, just use the first one.
|
74 |
+
# if True in matches:
|
75 |
+
# first_match_index = matches.index(True)
|
76 |
+
# name = known_face_names[first_match_index]
|
77 |
|
78 |
face_image = image[top:bottom, left:right]
|
79 |
pil_image = Image.fromarray(face_image)
|