Make detection threhsold configurable (#17136)

This commit is contained in:
Nicolas Mowen 2025-03-13 11:22:14 -06:00 committed by GitHub
parent c93b82d6e1
commit 8d05e7c5b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

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

View File

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