From 8d05e7c5b90f38818da570e319578b2e3d7021b6 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 13 Mar 2025 11:22:14 -0600 Subject: [PATCH] Make detection threhsold configurable (#17136) --- frigate/config/classification.py | 8 +++++++- frigate/data_processing/real_time/face.py | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frigate/config/classification.py b/frigate/config/classification.py index 07d986d7d..30cd12b7c 100644 --- a/frigate/config/classification.py +++ b/frigate/config/classification.py @@ -55,7 +55,13 @@ class FaceRecognitionConfig(FrigateBaseModel): gt=0.0, le=1.0, ) - threshold: float = Field( + detection_threshold: float = Field( + default=0.7, + title="Minimum face detection score required to be considered a face.", + gt=0.0, + le=1.0, + ) + recognition_threshold: float = Field( default=0.9, title="Minimum face distance score required to be considered a match.", gt=0.0, diff --git a/frigate/data_processing/real_time/face.py b/frigate/data_processing/real_time/face.py index c88aae027..7d97f8586 100644 --- a/frigate/data_processing/real_time/face.py +++ b/frigate/data_processing/real_time/face.py @@ -88,7 +88,7 @@ class FaceRealTimeProcessor(RealTimeProcessorApi): os.path.join(MODEL_CACHE_DIR, "facedet/facedet.onnx"), config="", input_size=(320, 320), - score_threshold=0.8, + score_threshold=self.face_config.detection_threshold, nms_threshold=0.3, ) self.landmark_detector = cv2.face.createFacemarkLBF() @@ -367,9 +367,9 @@ class FaceRealTimeProcessor(RealTimeProcessorApi): os.makedirs(folder, exist_ok=True) cv2.imwrite(file, face_frame) - if score < self.config.face_recognition.threshold: + if score < self.config.face_recognition.recognition_threshold: logger.debug( - f"Recognized face distance {score} is less than threshold {self.config.face_recognition.threshold}" + f"Recognized face distance {score} is less than threshold {self.config.face_recognition.recognition_threshold}" ) self.__update_metrics(datetime.datetime.now().timestamp() - start) return