Merge pull request #1362 from tyasnk/configurable-mediapipe-params

Configurable mediapipe params
This commit is contained in:
Sefik Ilkin Serengil 2024-10-10 11:51:18 +01:00 committed by GitHub
commit 075d32ba38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
# built-in dependencies # built-in dependencies
import os
from typing import Any, List from typing import Any, List
# 3rd party dependencies # 3rd party dependencies
@ -32,7 +33,14 @@ class MediaPipeClient(Detector):
) from e ) from e
mp_face_detection = mp.solutions.face_detection mp_face_detection = mp.solutions.face_detection
face_detection = mp_face_detection.FaceDetection(min_detection_confidence=0.7)
min_detection_confidence = float(os.environ.get("MEDIAPIPE_MIN_DETECTION_CONFIDENCE", 0.7))
model_selection = int(os.environ.get("MEDIAPIPE_MODEL_SELECTION", 0))
face_detection = mp_face_detection.FaceDetection(
min_detection_confidence=min_detection_confidence,
model_selection=model_selection
)
return face_detection return face_detection
def detect_faces(self, img: np.ndarray) -> List[FacialAreaRegion]: def detect_faces(self, img: np.ndarray) -> List[FacialAreaRegion]: