|
@@ -17,6 +17,9 @@ train_list = []
|
|
lock = None
|
|
lock = None
|
|
model_name = 'saved_model_2.pkl'
|
|
model_name = 'saved_model_2.pkl'
|
|
known_people_folder = os.path.join('application_data', 'verification_images')
|
|
known_people_folder = os.path.join('application_data', 'verification_images')
|
|
|
|
+face_model = "large"
|
|
|
|
+if face_model == "large":
|
|
|
|
+ model_name = 'saved_model_2_large.pkl'
|
|
|
|
|
|
dummy_data = [
|
|
dummy_data = [
|
|
{
|
|
{
|
|
@@ -51,6 +54,7 @@ dummy_data = [
|
|
},
|
|
},
|
|
]
|
|
]
|
|
|
|
|
|
|
|
+
|
|
def scan_known_people(known_people_folder):
|
|
def scan_known_people(known_people_folder):
|
|
known_names = []
|
|
known_names = []
|
|
known_face_encodings = []
|
|
known_face_encodings = []
|
|
@@ -77,7 +81,7 @@ def image_files_in_folder(folder):
|
|
return img_list
|
|
return img_list
|
|
|
|
|
|
|
|
|
|
-face_encodings = scan_known_people(known_people_folder)
|
|
|
|
|
|
+known_faces = scan_known_people(known_people_folder)
|
|
|
|
|
|
is_train = False
|
|
is_train = False
|
|
|
|
|
|
@@ -96,7 +100,7 @@ def train_image(image, person):
|
|
|
|
|
|
# If training image contains exactly one face
|
|
# If training image contains exactly one face
|
|
if len(face_bounding_boxes) == 1:
|
|
if len(face_bounding_boxes) == 1:
|
|
- face_enc = face_recognition.face_encodings(face)[0]
|
|
|
|
|
|
+ face_enc = face_recognition.face_encodings(face, model=face_model)[0]
|
|
# Add face encoding for current image with corresponding label (name) to the training data
|
|
# Add face encoding for current image with corresponding label (name) to the training data
|
|
tuples.append((face_enc, person))
|
|
tuples.append((face_enc, person))
|
|
else:
|
|
else:
|
|
@@ -141,10 +145,10 @@ print("Number of faces detected: ", no)
|
|
# Predict all the faces in the test image using the trained classifier
|
|
# Predict all the faces in the test image using the trained classifier
|
|
print("Found:")
|
|
print("Found:")
|
|
for i in range(no):
|
|
for i in range(no):
|
|
- test_image_enc = face_recognition.face_encodings(test_image)[i]
|
|
|
|
|
|
+ test_image_enc = face_recognition.face_encodings(test_image, model=face_model)[i]
|
|
start_time = time.perf_counter_ns()
|
|
start_time = time.perf_counter_ns()
|
|
proba_list = clf.predict_proba([test_image_enc])
|
|
proba_list = clf.predict_proba([test_image_enc])
|
|
- dist = face_recognition.face_distance(face_encodings, test_image_enc)
|
|
|
|
|
|
+ dist = face_recognition.face_distance(known_faces, test_image_enc)
|
|
total = np.subtract(proba_list, dist)
|
|
total = np.subtract(proba_list, dist)
|
|
end_time = time.perf_counter_ns()
|
|
end_time = time.perf_counter_ns()
|
|
process_time = end_time - start_time
|
|
process_time = end_time - start_time
|