From bd8107f54c907ef9a2624d3f61a54cd6f61972a0 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 7 May 2025 09:37:27 -0500 Subject: [PATCH] catch lpr model inference exceptions --- .../common/license_plate/mixin.py | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.py index 8dea639d6..b4ccf9cb8 100644 --- a/frigate/data_processing/common/license_plate/mixin.py +++ b/frigate/data_processing/common/license_plate/mixin.py @@ -79,7 +79,12 @@ class LicensePlateProcessingMixin: resized_image, ) - outputs = self.model_runner.detection_model([normalized_image])[0] + try: + outputs = self.model_runner.detection_model([normalized_image])[0] + except Exception as e: + logger.warning(f"Error running LPR box detection model: {e}") + return [] + outputs = outputs[0, :, :] if False: @@ -115,7 +120,11 @@ class LicensePlateProcessingMixin: norm_img = norm_img[np.newaxis, :] norm_images.append(norm_img) - outputs = self.model_runner.classification_model(norm_images) + try: + outputs = self.model_runner.classification_model(norm_images) + except Exception as e: + logger.warning(f"Error running LPR classification model: {e}") + return return self._process_classification_output(images, outputs) @@ -152,7 +161,10 @@ class LicensePlateProcessingMixin: norm_image = norm_image[np.newaxis, :] norm_images.append(norm_image) - outputs = self.model_runner.recognition_model(norm_images) + try: + outputs = self.model_runner.recognition_model(norm_images) + except Exception as e: + logger.warning(f"Error running LPR recognition model: {e}") return self.ctc_decoder(outputs) def _process_license_plate( @@ -968,7 +980,11 @@ class LicensePlateProcessingMixin: Return the dimensions of the detected plate as [x1, y1, x2, y2]. """ - predictions = self.model_runner.yolov9_detection_model(input) + try: + predictions = self.model_runner.yolov9_detection_model(input) + except Exception as e: + logger.warning(f"Error running YOLOv9 license plate detection model: {e}") + return None confidence_threshold = self.lpr_config.detection_threshold