mirror of
https://github.com/serengil/deepface.git
synced 2025-06-06 11:35: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,
|
||||
align: bool = True,
|
||||
expand_percentage: int = 0,
|
||||
grayscale: bool = False,
|
||||
color_face: str = 'rgb',
|
||||
normalize_face: bool = True,
|
||||
anti_spoofing: bool = False,
|
||||
@ -504,6 +505,9 @@ def extract_faces(
|
||||
|
||||
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'
|
||||
(default is 'rgb').
|
||||
|
||||
@ -538,6 +542,7 @@ def extract_faces(
|
||||
enforce_detection=enforce_detection,
|
||||
align=align,
|
||||
expand_percentage=expand_percentage,
|
||||
grayscale=grayscale,
|
||||
color_face=color_face,
|
||||
normalize_face=normalize_face,
|
||||
anti_spoofing=anti_spoofing,
|
||||
|
@ -24,6 +24,7 @@ def extract_faces(
|
||||
enforce_detection: bool = True,
|
||||
align: bool = True,
|
||||
expand_percentage: int = 0,
|
||||
grayscale: bool = False,
|
||||
color_face: str = 'rgb',
|
||||
normalize_face: bool = True,
|
||||
anti_spoofing: bool = False,
|
||||
@ -46,6 +47,9 @@ def extract_faces(
|
||||
|
||||
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'
|
||||
(default is 'rgb').
|
||||
|
||||
@ -118,16 +122,20 @@ def extract_faces(
|
||||
if current_img.shape[0] == 0 or current_img.shape[1] == 0:
|
||||
continue
|
||||
|
||||
if color_face == 'rgb':
|
||||
current_img = current_img[:, :, ::-1]
|
||||
elif color_face == 'bgr':
|
||||
pass # image is in BGR
|
||||
elif color_face == 'gray':
|
||||
if grayscale is True:
|
||||
logger.warn("Parameter grayscale is deprecated. Use color_face instead.")
|
||||
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 color_face == 'rgb':
|
||||
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:
|
||||
current_img = current_img / 255 # normalize input in [0, 1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user