mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 03:55:21 +00:00
Add grayscale parameter again
This commit is contained in:
parent
878564ee1c
commit
9300ed0dfd
@ -482,6 +482,7 @@ def extract_faces(
|
|||||||
enforce_detection: bool = True,
|
enforce_detection: bool = True,
|
||||||
align: bool = True,
|
align: bool = True,
|
||||||
expand_percentage: int = 0,
|
expand_percentage: int = 0,
|
||||||
|
grayscale: bool = False,
|
||||||
color_face: str = 'rgb',
|
color_face: str = 'rgb',
|
||||||
normalize_face: bool = True,
|
normalize_face: bool = True,
|
||||||
anti_spoofing: bool = False,
|
anti_spoofing: bool = False,
|
||||||
@ -504,6 +505,9 @@ def extract_faces(
|
|||||||
|
|
||||||
expand_percentage (int): expand detected facial area with a percentage (default is 0).
|
expand_percentage (int): expand detected facial area with a percentage (default is 0).
|
||||||
|
|
||||||
|
grayscale (boolean): (Deprecated) Flag to convert the output face image to grayscale
|
||||||
|
(default is False).
|
||||||
|
|
||||||
color_face (string): Color to return face image output. Options: 'rgb', 'bgr' or 'gray'
|
color_face (string): Color to return face image output. Options: 'rgb', 'bgr' or 'gray'
|
||||||
(default is 'rgb').
|
(default is 'rgb').
|
||||||
|
|
||||||
@ -538,6 +542,7 @@ def extract_faces(
|
|||||||
enforce_detection=enforce_detection,
|
enforce_detection=enforce_detection,
|
||||||
align=align,
|
align=align,
|
||||||
expand_percentage=expand_percentage,
|
expand_percentage=expand_percentage,
|
||||||
|
grayscale=grayscale,
|
||||||
color_face=color_face,
|
color_face=color_face,
|
||||||
normalize_face=normalize_face,
|
normalize_face=normalize_face,
|
||||||
anti_spoofing=anti_spoofing,
|
anti_spoofing=anti_spoofing,
|
||||||
|
@ -24,6 +24,7 @@ def extract_faces(
|
|||||||
enforce_detection: bool = True,
|
enforce_detection: bool = True,
|
||||||
align: bool = True,
|
align: bool = True,
|
||||||
expand_percentage: int = 0,
|
expand_percentage: int = 0,
|
||||||
|
grayscale: bool = False,
|
||||||
color_face: str = 'rgb',
|
color_face: str = 'rgb',
|
||||||
normalize_face: bool = True,
|
normalize_face: bool = True,
|
||||||
anti_spoofing: bool = False,
|
anti_spoofing: bool = False,
|
||||||
@ -46,6 +47,9 @@ def extract_faces(
|
|||||||
|
|
||||||
expand_percentage (int): expand detected facial area with a percentage.
|
expand_percentage (int): expand detected facial area with a percentage.
|
||||||
|
|
||||||
|
grayscale (boolean): (Deprecated) Flag to convert the output face image to grayscale
|
||||||
|
(default is False).
|
||||||
|
|
||||||
color_face (string): Color to return face image output. Options: 'rgb', 'bgr' or 'gray'
|
color_face (string): Color to return face image output. Options: 'rgb', 'bgr' or 'gray'
|
||||||
(default is 'rgb').
|
(default is 'rgb').
|
||||||
|
|
||||||
@ -118,16 +122,20 @@ def extract_faces(
|
|||||||
if current_img.shape[0] == 0 or current_img.shape[1] == 0:
|
if current_img.shape[0] == 0 or current_img.shape[1] == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if color_face == 'rgb':
|
if grayscale is True:
|
||||||
current_img = current_img[:, :, ::-1]
|
logger.warn("Parameter grayscale is deprecated. Use color_face instead.")
|
||||||
elif color_face == 'bgr':
|
|
||||||
pass # image is in BGR
|
|
||||||
elif color_face == 'gray':
|
|
||||||
current_img = cv2.cvtColor(current_img, cv2.COLOR_BGR2GRAY)
|
current_img = cv2.cvtColor(current_img, cv2.COLOR_BGR2GRAY)
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
if color_face == 'rgb':
|
||||||
f"The color_face can be rgb, bgr or gray, but it is {color_face}."
|
current_img = current_img[:, :, ::-1]
|
||||||
)
|
elif color_face == 'bgr':
|
||||||
|
pass # image is in BGR
|
||||||
|
elif color_face == 'gray':
|
||||||
|
current_img = cv2.cvtColor(current_img, cv2.COLOR_BGR2GRAY)
|
||||||
|
else:
|
||||||
|
raise ValueError(
|
||||||
|
f"The color_face can be rgb, bgr or gray, but it is {color_face}."
|
||||||
|
)
|
||||||
|
|
||||||
if normalize_face:
|
if normalize_face:
|
||||||
current_img = current_img / 255 # normalize input in [0, 1]
|
current_img = current_img / 255 # normalize input in [0, 1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user