Shafeek Saleem commited on
Commit
df175b2
1 Parent(s): 679ac1e
Files changed (1) hide show
  1. pages/4_Face Recognition.py +4 -8
pages/4_Face Recognition.py CHANGED
@@ -39,8 +39,7 @@ def step4_page():
39
  face_name = face_encoding.split(".")[0]
40
  known_face_encodings.append(known_face_encoding)
41
  known_face_names.append(face_name)
42
- st.write(known_face_encodings)
43
- st.write(known_face_names)
44
  st.info("Select an image to analyze!")
45
  input_type = st.radio("Select the Input Type", ["Image", "Camera"])
46
 
@@ -63,19 +62,16 @@ def step4_page():
63
  if tolerance:
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
- matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
67
 
68
  name = "Unknown"
69
- st.write(matches)
70
  # If a match was found in known_face_encodings, just use the first one.
71
  face_distances = face_recognition.face_distance(known_face_encodings, face_encoding)
72
- st.write(face_distances)
73
- st.write(face_distances.shape)
74
  # Calculate the row sums
75
  row_sums = np.sum(face_distances, axis=1)
76
  best_match_index = np.argmin(row_sums)
77
- st.write(best_match_index)
78
- if matches[best_match_index]:
79
  name = known_face_names[best_match_index]
80
 
81
  face_image = image[top:bottom, left:right]
 
39
  face_name = face_encoding.split(".")[0]
40
  known_face_encodings.append(known_face_encoding)
41
  known_face_names.append(face_name)
42
+
 
43
  st.info("Select an image to analyze!")
44
  input_type = st.radio("Select the Input Type", ["Image", "Camera"])
45
 
 
62
  if tolerance:
63
  for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
64
  # See if the face is a match for the known face(s)
65
+ # matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
66
 
67
  name = "Unknown"
 
68
  # If a match was found in known_face_encodings, just use the first one.
69
  face_distances = face_recognition.face_distance(known_face_encodings, face_encoding)
70
+
 
71
  # Calculate the row sums
72
  row_sums = np.sum(face_distances, axis=1)
73
  best_match_index = np.argmin(row_sums)
74
+ if best_match_index is not None:
 
75
  name = known_face_names[best_match_index]
76
 
77
  face_image = image[top:bottom, left:right]