From 5cf98824f55a334f1d8ad0b0bfa29d13dfce61b6 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 11 Jul 2025 06:30:26 -0600 Subject: [PATCH] Misc fixes (#19089) * Correctly handle min_faces * Change to use recognized faces --- docs/docs/configuration/face_recognition.md | 2 +- docs/docs/configuration/reference.md | 2 +- frigate/config/classification.py | 2 +- frigate/data_processing/real_time/face.py | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/docs/configuration/face_recognition.md b/docs/docs/configuration/face_recognition.md index b7265bb87..3026615d4 100644 --- a/docs/docs/configuration/face_recognition.md +++ b/docs/docs/configuration/face_recognition.md @@ -67,7 +67,7 @@ Fine-tune face recognition with these optional parameters at the global level of - Default: `0.8`. - `recognition_threshold`: Recognition confidence score required to add the face to the object as a sub label. - Default: `0.9`. -- `min_faces`: Min face attempts for the sub label to be applied to the person object. +- `min_faces`: Min face recognitions for the sub label to be applied to the person object. - Default: `1` - `save_attempts`: Number of images of recognized faces to save for training. - Default: `100`. diff --git a/docs/docs/configuration/reference.md b/docs/docs/configuration/reference.md index 5f6644bdb..295a74892 100644 --- a/docs/docs/configuration/reference.md +++ b/docs/docs/configuration/reference.md @@ -561,7 +561,7 @@ face_recognition: recognition_threshold: 0.9 # Optional: Min area of detected face box to consider running face recognition (default: shown below) min_area: 500 - # Optional: Min face attempts for the sub label to be applied to the person object (default: shown below) + # Optional: Min face recognitions for the sub label to be applied to the person object (default: shown below) min_faces: 1 # Optional: Number of images of recognized faces to save for training (default: shown below) save_attempts: 100 diff --git a/frigate/config/classification.py b/frigate/config/classification.py index 4c34f8ab3..06e69a774 100644 --- a/frigate/config/classification.py +++ b/frigate/config/classification.py @@ -84,7 +84,7 @@ class FaceRecognitionConfig(FrigateBaseModel): default=1, gt=0, le=6, - title="Min face attempts for the sub label to be applied to the person object.", + title="Min face recognitions for the sub label to be applied to the person object.", ) save_attempts: int = Field( default=100, ge=0, title="Number of face attempts to save in the train tab." diff --git a/frigate/data_processing/real_time/face.py b/frigate/data_processing/real_time/face.py index 940373d3b..144ec42d4 100644 --- a/frigate/data_processing/real_time/face.py +++ b/frigate/data_processing/real_time/face.py @@ -303,9 +303,6 @@ class FaceRealTimeProcessor(RealTimeProcessorApi): self.person_face_history[id] ) - if len(self.person_face_history[id]) < self.face_config.min_faces: - weighted_sub_label = "unknown" - self.requestor.send_data( "tracked_object_update", json.dumps( @@ -489,6 +486,10 @@ class FaceRealTimeProcessor(RealTimeProcessorApi): best_name = max(weighted_scores, key=weighted_scores.get) + # If the number of faces for this person < min_faces, we are not confident it is a correct result + if counts[best_name] < self.face_config.min_faces: + return None, 0.0 + # If the best name has the same number of results as another name, we are not confident it is a correct result for name, count in counts.items(): if name != best_name and counts[best_name] == count: