Browse Source

Better output

StrayWarrior 6 months ago
parent
commit
1cf1087b7a
5 changed files with 7 additions and 2 deletions
  1. BIN
      images_to_check/2.jpg
  2. BIN
      images_to_check/3.jpg
  3. BIN
      images_to_check/4.jpg
  4. BIN
      images_to_check/5.jpg
  5. 7 2
      test.py

BIN
images_to_check/2.jpg


BIN
images_to_check/3.jpg


BIN
images_to_check/4.jpg


BIN
images_to_check/5.jpg


+ 7 - 2
test.py

@@ -35,7 +35,7 @@ def find_faces_in_images(image_dir, known_face_encodings, known_face_names):
 
             found_faces = []
             for face_encoding in face_encodings:
-                matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
+                matches = face_recognition.compare_faces(known_face_encodings, face_encoding, tolerance=0.35)
                 name = "Unknown"
 
                 if True in matches:
@@ -46,6 +46,8 @@ def find_faces_in_images(image_dir, known_face_encodings, known_face_names):
 
             if found_faces:
                 results[filename] = found_faces
+            else:
+                results[filename] = None
 
     return results
 
@@ -57,7 +59,10 @@ def main():
     results = find_faces_in_images(image_dir, known_face_encodings, known_face_names)
 
     for image_name, found_faces in results.items():
-        print(f"In {image_name}, found faces: {', '.join(found_faces)}")
+        if not found_faces:
+            print(f"In {image_name}, no faces detected")
+        else:
+            print(f"In {image_name}, found faces: {', '.join(found_faces)}")
 
 if __name__ == "__main__":
     main()