Spaces:
Runtime error
Runtime error
Shafeek Saleem
commited on
Commit
·
2b5e9d0
1
Parent(s):
775c70f
face recog fixed
Browse files- pages/4_Face Recognition.py +15 -14
pages/4_Face Recognition.py
CHANGED
@@ -57,22 +57,23 @@ def step4_page():
|
|
57 |
st.image(image)
|
58 |
st.info("Select the tolerance level you want for your model! (How much distance between faces to consider it a match. "
|
59 |
"Lower is more strict. 0.6 is typical best performance.)")
|
60 |
-
tolerance = st.slider('Select tolerance level', 0, 1, 0.6, 0.1)
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
|
77 |
st.info("Click on the button below to complete this level!")
|
78 |
if st.button("Complete Level"):
|
|
|
57 |
st.image(image)
|
58 |
st.info("Select the tolerance level you want for your model! (How much distance between faces to consider it a match. "
|
59 |
"Lower is more strict. 0.6 is typical best performance.)")
|
60 |
+
tolerance = st.slider('Select tolerance level', 0.0, 1.0, 0.6, 0.1)
|
61 |
+
if tolerance:
|
62 |
+
for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
|
63 |
+
# See if the face is a match for the known face(s)
|
64 |
+
matches = face_recognition.compare_faces(known_face_encodings, face_encoding, tolerance=tolerance)
|
65 |
|
66 |
+
name = "Unknown"
|
67 |
+
# If a match was found in known_face_encodings, just use the first one.
|
68 |
+
if True in matches:
|
69 |
+
first_match_index = matches.index(True)
|
70 |
+
name = known_face_names[first_match_index]
|
71 |
|
72 |
+
face_image = image[top:bottom, left:right]
|
73 |
+
pil_image = Image.fromarray(face_image)
|
74 |
+
cols[i].image(pil_image, use_column_width=True)
|
75 |
+
cols[i].write("Person name: " +name)
|
76 |
+
i+=1
|
77 |
|
78 |
st.info("Click on the button below to complete this level!")
|
79 |
if st.button("Complete Level"):
|