mirror of
https://github.com/serengil/deepface.git
synced 2025-06-08 20:45:22 +00:00
issue 100 - if detected face has 0 in some dimension
This commit is contained in:
parent
f04cfbf689
commit
e6da083983
@ -450,14 +450,21 @@ def preprocess_face(img, target_size=(224, 224), grayscale = False, enforce_dete
|
||||
|
||||
#img might be path, base64 or numpy array. Convert it to numpy whatever it is.
|
||||
img = load_image(img)
|
||||
base_img = img.copy()
|
||||
|
||||
img = detect_face(img = img, detector_backend = detector_backend, grayscale = grayscale, enforce_detection = enforce_detection)
|
||||
|
||||
#--------------------------
|
||||
|
||||
#we will align base image instead of detected face not have black pixels
|
||||
|
||||
img = detect_face(img = img, detector_backend = detector_backend, grayscale = grayscale, enforce_detection = enforce_detection)
|
||||
img = align_face(img = img, detector_backend = detector_backend)
|
||||
|
||||
if img.shape[0] > 0 and img.shape[1] > 0:
|
||||
img = align_face(img = img, detector_backend = detector_backend)
|
||||
else:
|
||||
|
||||
if enforce_detection == True:
|
||||
raise ValueError("Detected face shape is ", img.shape,". Consider to set enforce_detection argument to False.")
|
||||
else: #restore base image
|
||||
img = base_img.copy()
|
||||
|
||||
#--------------------------
|
||||
|
||||
#post-processing
|
||||
|
Loading…
x
Reference in New Issue
Block a user