From 9b816648e09f99f1305d2d1f9795075b4d4f560a Mon Sep 17 00:00:00 2001 From: Bosco Yung <15840328+bhky@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:01:51 +0800 Subject: [PATCH] Remove extra BGR2RGB call in RetinaFaceWrapper I suggest removing the extra BGR2RGB call. While the RetinaFace model does expect RGB images, the corresponding conversion will be done in the RetinaFace preprocessing: https://github.com/serengil/retinaface/blob/0c8d3ed8bd223c5753978a5e32549c25edff3316/retinaface/commons/preprocess.py#L45 The extra BGR2RGB call here will in fact make the final channel order wrong, because OpenCV does not know about the channel order, each call will simply swap the channels. Thanks! --- deepface/detectors/RetinaFaceWrapper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deepface/detectors/RetinaFaceWrapper.py b/deepface/detectors/RetinaFaceWrapper.py index e6aa45f..4dbca81 100644 --- a/deepface/detectors/RetinaFaceWrapper.py +++ b/deepface/detectors/RetinaFaceWrapper.py @@ -15,7 +15,8 @@ def detect_face(face_detector, img, align = True): resp = [] - img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) #retinaface expects RGB but OpenCV read BGR + # The BGR2RGB conversion will be done in the preprocessing step of retinaface. + # img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) #retinaface expects RGB but OpenCV read BGR """ face = None