diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index 327f9a8..b4608fb 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -483,6 +483,7 @@ def extract_faces( align: bool = True, expand_percentage: int = 0, grayscale: bool = False, + normalize_face: bool = True, anti_spoofing: bool = False, ) -> List[Dict[str, Any]]: """ @@ -506,6 +507,9 @@ def extract_faces( grayscale (boolean): Flag to convert the output face image to grayscale (default is False). + normalize_face (boolean): Flag to enable normalization (divide by 255) of the output + face image output face image normalization (default is True). + anti_spoofing (boolean): Flag to enable anti spoofing (default is False). Returns: @@ -535,6 +539,7 @@ def extract_faces( align=align, expand_percentage=expand_percentage, grayscale=grayscale, + normalize_face=normalize_face, anti_spoofing=anti_spoofing, ) diff --git a/deepface/modules/detection.py b/deepface/modules/detection.py index 76daa08..d187944 100644 --- a/deepface/modules/detection.py +++ b/deepface/modules/detection.py @@ -25,6 +25,7 @@ def extract_faces( align: bool = True, expand_percentage: int = 0, grayscale: bool = False, + normalize_face: bool = True, anti_spoofing: bool = False, ) -> List[Dict[str, Any]]: """ @@ -43,11 +44,14 @@ def extract_faces( align (bool): Flag to enable face alignment (default is True). - expand_percentage (int): expand detected facial area with a percentage + expand_percentage (int): expand detected facial area with a percentage. grayscale (boolean): Flag to convert the output face image to grayscale (default is False). + normalize_face (boolean): Flag to enable normalization (divide by 255) of the output + face image output face image normalization (default is True). + anti_spoofing (boolean): Flag to enable anti spoofing (default is False). Returns: @@ -117,7 +121,8 @@ def extract_faces( if grayscale is True: current_img = cv2.cvtColor(current_img, cv2.COLOR_BGR2GRAY) - current_img = current_img / 255 # normalize input in [0, 1] + if normalize_face: + current_img = current_img / 255 # normalize input in [0, 1] x = int(current_region.x) y = int(current_region.y)