mirror of
https://github.com/serengil/deepface.git
synced 2025-06-08 12:35:22 +00:00
clean code in preprocess
This commit is contained in:
parent
7f6d9075d1
commit
01614eaeff
@ -454,24 +454,14 @@ 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 might be path, base64 or numpy array. Convert it to numpy whatever it is.
|
||||||
img = load_image(img)
|
img = load_image(img)
|
||||||
img_base = img.copy()
|
|
||||||
|
|
||||||
#face detection
|
|
||||||
img = detect_face(img = img, detector_backend = detector_backend, grayscale = grayscale, enforce_detection = enforce_detection)
|
|
||||||
|
|
||||||
#--------------------------
|
#--------------------------
|
||||||
|
|
||||||
#face alignment
|
#we will align base image instead of detected face not have black pixels
|
||||||
#img = align_face(img = img, detector_backend = detector_backend)
|
|
||||||
img = align_face(img = img_base, detector_backend = detector_backend)
|
|
||||||
|
|
||||||
|
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 = False)
|
||||||
|
|
||||||
#note: if you apply align first and detect second, it might be problematic for pictures including more than one faces.
|
|
||||||
#we detected one face and align the base image based on the detected one.
|
|
||||||
#pros: aligned images have many black pixels if you align detected face
|
|
||||||
#cons: this requires to apply detection twice.
|
|
||||||
|
|
||||||
#--------------------------
|
#--------------------------
|
||||||
|
|
||||||
#post-processing
|
#post-processing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user