From a0c06a37924825467541554c8c6e385974b26bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eefik=20Serangil?= Date: Tue, 8 Sep 2020 09:07:08 +0300 Subject: [PATCH] stream bug fixed --- deepface/commons/functions.py | 4 ++-- deepface/commons/realtime.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deepface/commons/functions.py b/deepface/commons/functions.py index 1b33b45..b1fdc3b 100644 --- a/deepface/commons/functions.py +++ b/deepface/commons/functions.py @@ -456,8 +456,8 @@ def preprocess_face(img, target_size=(224, 224), grayscale = False, enforce_dete #we will align base image instead of detected face not have black pixels - img = align_face(img = img, detector_backend = detector_backend) - img = detect_face(img = img, detector_backend = detector_backend, grayscale = grayscale, enforce_detection = False) + img = detect_face(img = img, detector_backend = detector_backend, grayscale = grayscale, enforce_detection = enforce_detection) + img = align_face(img = img, detector_backend = detector_backend) #-------------------------- diff --git a/deepface/commons/realtime.py b/deepface/commons/realtime.py index 5d8c483..3f23135 100644 --- a/deepface/commons/realtime.py +++ b/deepface/commons/realtime.py @@ -112,7 +112,7 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True): employee = employees[index] pbar.set_description("Finding embedding for %s" % (employee.split("/")[-1])) embedding = [] - img = functions.preprocess_face(employee, (input_shape_y, input_shape_x)) + img = functions.preprocess_face(img = employee, target_size = (input_shape_y, input_shape_x), enforce_detection = False) img_representation = model.predict(img)[0,:] embedding.append(employee) @@ -222,7 +222,7 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True): if enable_face_analysis == True: - gray_img = functions.preprocess_face(custom_face, (48, 48), True) + gray_img = functions.preprocess_face(img = custom_face, target_size = (48, 48), grayscale = True, enforce_detection = False) emotion_labels = ['Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral'] emotion_predictions = emotion_model.predict(gray_img)[0,:] sum_of_predictions = emotion_predictions.sum() @@ -300,7 +300,7 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True): #------------------------------- - face_224 = functions.preprocess_face(custom_face, (224, 224), False) + face_224 = functions.preprocess_face(img = custom_face, target_size = (224, 224), grayscale = False, enforce_detection = False) age_predictions = age_model.predict(face_224)[0,:] apparent_age = Age.findApparentAge(age_predictions) @@ -355,7 +355,7 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True): #------------------------------- #face recognition - custom_face = functions.preprocess_face(custom_face, (input_shape_y, input_shape_x)) + custom_face = functions.preprocess_face(img = custom_face, target_size = (input_shape_y, input_shape_x), enforce_detection = False) #check preprocess_face function handled if custom_face.shape[1:3] == input_shape: