From add4c7394472a6495b27dc30bbf74d223954b758 Mon Sep 17 00:00:00 2001 From: galthran-wq Date: Fri, 21 Feb 2025 17:49:34 +0000 Subject: [PATCH] disable mtcnn batching by default due to unexpected behaviour --- deepface/models/face_detection/MtCnn.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/deepface/models/face_detection/MtCnn.py b/deepface/models/face_detection/MtCnn.py index be3a51f..8c42075 100644 --- a/deepface/models/face_detection/MtCnn.py +++ b/deepface/models/face_detection/MtCnn.py @@ -82,8 +82,21 @@ class MtCnnClient(Detector): 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