From 3111a2895a0e2561403ea193dd2f75f069160d57 Mon Sep 17 00:00:00 2001 From: galthran-wq Date: Sat, 8 Mar 2025 15:18:44 +0000 Subject: [PATCH] no env variable to set batch mode for mtcnn and opencv --- deepface/models/face_detection/MtCnn.py | 34 ++++-------------------- deepface/models/face_detection/OpenCv.py | 16 ++++------- 2 files changed, 10 insertions(+), 40 deletions(-) diff --git a/deepface/models/face_detection/MtCnn.py b/deepface/models/face_detection/MtCnn.py index 2382670..3806e99 100644 --- a/deepface/models/face_detection/MtCnn.py +++ b/deepface/models/face_detection/MtCnn.py @@ -82,32 +82,8 @@ class MtCnnClient(Detector): return resp def _supports_batch_detection(self) -> bool: - import mtcnn - import os - supports_batch_detection = os.getenv( - "ENABLE_MTCNN_BATCH_DETECTION", "false" - ).lower() == "true" - if not supports_batch_detection: - logger.warning( - "Batch detection is disabled for mtcnn by default " - "since the results are not consistent with single image detection. " - "You can force enable it by setting the environment variable " - "ENABLE_MTCNN_BATCH_DETECTION to true." - ) - return False - try: - mtcnn_version = mtcnn.__version__ - supports_batch_detection = mtcnn_version >= "1.0.0" - except AttributeError: - try: - import mtcnn.metadata - mtcnn_version = mtcnn.metadata.__version__ - except AttributeError: - logger.warning("Failed to determine mtcnn version") - logger.warning("Fallback to single image detection") - return False - supports_batch_detection = mtcnn_version >= "1.0.0" - if not supports_batch_detection: - logger.warning("MtCnn version is less than 1.0.0, batch detection is not supported") - logger.warning("Fallback to single image detection") - return supports_batch_detection + logger.warning( + "Batch detection is disabled for mtcnn by default " + "since the results are not consistent with single image detection. " + ) + return False diff --git a/deepface/models/face_detection/OpenCv.py b/deepface/models/face_detection/OpenCv.py index c86f2da..667e8fb 100644 --- a/deepface/models/face_detection/OpenCv.py +++ b/deepface/models/face_detection/OpenCv.py @@ -33,17 +33,11 @@ class OpenCvClient(Detector): return detector def _supports_batch_detection(self) -> bool: - supports_batch_detection = os.getenv( - "ENABLE_OPENCV_BATCH_DETECTION", "false" - ).lower() == "true" - if not supports_batch_detection: - logger.warning( - "Batch detection is disabled for opencv by default " - "since the results are not consistent with single image detection. " - "You can force enable it by setting the environment variable " - "ENABLE_OPENCV_BATCH_DETECTION to true." - ) - return supports_batch_detection + logger.warning( + "Batch detection is disabled for opencv by default " + "since the results are not consistent with single image detection. " + ) + return False def detect_faces( self,