From 5064a817c29860fc3fe9a0f1100284565e7d8737 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 20 Oct 2025 14:35:30 -0600 Subject: [PATCH] Add cutoff for object classification --- .../real_time/custom_classification.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frigate/data_processing/real_time/custom_classification.py b/frigate/data_processing/real_time/custom_classification.py index e5e4fc90e..8563742be 100644 --- a/frigate/data_processing/real_time/custom_classification.py +++ b/frigate/data_processing/real_time/custom_classification.py @@ -35,6 +35,10 @@ except ModuleNotFoundError: logger = logging.getLogger(__name__) +MAX_CLASSIFICATION_VERIFICATION_ATTEMPTS = 6 +MAX_CLASSIFICATION_ATTEMPTS = 12 + + class CustomStateClassificationProcessor(RealTimeProcessorApi): def __init__( self, @@ -264,6 +268,26 @@ class CustomObjectClassificationProcessor(RealTimeProcessorApi): if obj_data["label"] not in self.model_config.object_config.objects: return + if ( + obj_data["id"] in self.detected_objects + and len(self.detected_objects[obj_data["id"]]) + >= MAX_CLASSIFICATION_VERIFICATION_ATTEMPTS + ): + # if we are at max attempts after rec and we have a rec + if obj_data.get("sub_label"): + logger.debug( + "Not processing due to hitting max attempts after true recognition." + ) + return + + # if we don't have a rec and are at max attempts + if ( + len(self.detected_objects[obj_data["id"]]) + >= MAX_CLASSIFICATION_ATTEMPTS + ): + logger.debug("Not processing due to hitting max rec attempts.") + return + now = datetime.datetime.now().timestamp() x, y, x2, y2 = calculate_region( frame.shape,