From c77e201aa640bc3b28333295e7747d447c3da326 Mon Sep 17 00:00:00 2001 From: Tyas Date: Tue, 24 Sep 2024 20:37:26 +0700 Subject: [PATCH 1/5] Update MediaPipe.py --- deepface/models/face_detection/MediaPipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepface/models/face_detection/MediaPipe.py b/deepface/models/face_detection/MediaPipe.py index 61a84fd..6990dd8 100644 --- a/deepface/models/face_detection/MediaPipe.py +++ b/deepface/models/face_detection/MediaPipe.py @@ -32,7 +32,7 @@ class MediaPipeClient(Detector): ) from e mp_face_detection = mp.solutions.face_detection - face_detection = mp_face_detection.FaceDetection(min_detection_confidence=0.7) + face_detection = mp_face_detection.FaceDetection(min_detection_confidence=0.2, model_selection=1) return face_detection def detect_faces(self, img: np.ndarray) -> List[FacialAreaRegion]: From c4a49fff98e0a46f224a43f501d8879771c5245f Mon Sep 17 00:00:00 2001 From: Tyas Date: Thu, 3 Oct 2024 06:22:50 +0700 Subject: [PATCH 2/5] Update Mediapipe min_detection_confidence --- deepface/models/face_detection/MediaPipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepface/models/face_detection/MediaPipe.py b/deepface/models/face_detection/MediaPipe.py index 6990dd8..4358516 100644 --- a/deepface/models/face_detection/MediaPipe.py +++ b/deepface/models/face_detection/MediaPipe.py @@ -32,7 +32,7 @@ class MediaPipeClient(Detector): ) from e mp_face_detection = mp.solutions.face_detection - face_detection = mp_face_detection.FaceDetection(min_detection_confidence=0.2, model_selection=1) + face_detection = mp_face_detection.FaceDetection(min_detection_confidence=0.5, model_selection=1) return face_detection def detect_faces(self, img: np.ndarray) -> List[FacialAreaRegion]: From 8e5e42d4d3bee46546dd5d73c771e1dda1d7a600 Mon Sep 17 00:00:00 2001 From: tyasnk Date: Thu, 3 Oct 2024 10:39:27 +0700 Subject: [PATCH 3/5] Mediapipe paramater now configurable by env variable --- deepface/models/face_detection/MediaPipe.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deepface/models/face_detection/MediaPipe.py b/deepface/models/face_detection/MediaPipe.py index 4358516..9b0f9d6 100644 --- a/deepface/models/face_detection/MediaPipe.py +++ b/deepface/models/face_detection/MediaPipe.py @@ -7,6 +7,8 @@ import numpy as np # project dependencies from deepface.models.Detector import Detector, FacialAreaRegion +import os + class MediaPipeClient(Detector): """ @@ -32,7 +34,10 @@ class MediaPipeClient(Detector): ) from e mp_face_detection = mp.solutions.face_detection - face_detection = mp_face_detection.FaceDetection(min_detection_confidence=0.5, model_selection=1) + face_detection = mp_face_detection.FaceDetection( + min_detection_confidence=os.getenv("MEDIAPIPE_MIN_DETECTION_CONFIDENCE", 0.5), + model_selection=os.getenv("MEDIAPIPE_MODEL_SELECTION", 1) + ) return face_detection def detect_faces(self, img: np.ndarray) -> List[FacialAreaRegion]: From 5f1c51350ae884ad7ea879abe725a0308459150f Mon Sep 17 00:00:00 2001 From: tyasnk Date: Thu, 10 Oct 2024 16:58:58 +0700 Subject: [PATCH 4/5] Feat: Configurable Mediapipe parameters --- deepface/models/face_detection/MediaPipe.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/deepface/models/face_detection/MediaPipe.py b/deepface/models/face_detection/MediaPipe.py index 9b0f9d6..099d970 100644 --- a/deepface/models/face_detection/MediaPipe.py +++ b/deepface/models/face_detection/MediaPipe.py @@ -1,4 +1,5 @@ # built-in dependencies +import os from typing import Any, List # 3rd party dependencies @@ -7,8 +8,6 @@ import numpy as np # project dependencies from deepface.models.Detector import Detector, FacialAreaRegion -import os - class MediaPipeClient(Detector): """ @@ -34,9 +33,13 @@ class MediaPipeClient(Detector): ) from e mp_face_detection = mp.solutions.face_detection + + min_detection_confidence = float(os.environ.get("MEDIAPIPE_MIN_DETECTION_CONFIDENCE", 0.7)) + model_selection = float(os.environ.get("MEDIAPIPE_MODEL_SELECTION", 0)) + face_detection = mp_face_detection.FaceDetection( - min_detection_confidence=os.getenv("MEDIAPIPE_MIN_DETECTION_CONFIDENCE", 0.5), - model_selection=os.getenv("MEDIAPIPE_MODEL_SELECTION", 1) + min_detection_confidence=min_detection_confidence, + model_selection=model_selection ) return face_detection From 8766a412ec33f21c84e02b38d2ac8b723c8ecad6 Mon Sep 17 00:00:00 2001 From: tyasnk Date: Thu, 10 Oct 2024 17:03:38 +0700 Subject: [PATCH 5/5] Set model detection to int --- deepface/models/face_detection/MediaPipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepface/models/face_detection/MediaPipe.py b/deepface/models/face_detection/MediaPipe.py index 099d970..48bc2f8 100644 --- a/deepface/models/face_detection/MediaPipe.py +++ b/deepface/models/face_detection/MediaPipe.py @@ -35,7 +35,7 @@ class MediaPipeClient(Detector): mp_face_detection = mp.solutions.face_detection min_detection_confidence = float(os.environ.get("MEDIAPIPE_MIN_DETECTION_CONFIDENCE", 0.7)) - model_selection = float(os.environ.get("MEDIAPIPE_MODEL_SELECTION", 0)) + model_selection = int(os.environ.get("MEDIAPIPE_MODEL_SELECTION", 0)) face_detection = mp_face_detection.FaceDetection( min_detection_confidence=min_detection_confidence,