no env variable to set batch mode for mtcnn and opencv

This commit is contained in:
galthran-wq 2025-03-08 15:18:44 +00:00
parent da8f644c79
commit 3111a2895a
2 changed files with 10 additions and 40 deletions

View File

@ -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

View File

@ -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,