diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.py index 778c059214..2606661bef 100644 --- a/frigate/data_processing/common/license_plate/mixin.py +++ b/frigate/data_processing/common/license_plate/mixin.py @@ -789,9 +789,7 @@ class LicensePlateProcessingMixin: input_w = int(input_h * max_wh_ratio) # check for model-specific input width - model_input_w = self.model_runner.recognition_model.runner.ort.get_inputs()[ - 0 - ].shape[3] + model_input_w = self.model_runner.recognition_model.runner.get_input_width() if isinstance(model_input_w, int) and model_input_w > 0: input_w = model_input_w diff --git a/frigate/embeddings/maintainer.py b/frigate/embeddings/maintainer.py index be7843c9c0..1b5317ba86 100644 --- a/frigate/embeddings/maintainer.py +++ b/frigate/embeddings/maintainer.py @@ -108,7 +108,7 @@ class EmbeddingMaintainer(threading.Thread): # model runners to share between realtime and post processors if self.config.lpr.enabled: - lpr_model_runner = LicensePlateModelRunner(self.requestor) + lpr_model_runner = LicensePlateModelRunner(self.requestor, device="AUTO") # realtime processors self.realtime_processors: list[RealTimeProcessorApi] = [] diff --git a/frigate/embeddings/onnx/runner.py b/frigate/embeddings/onnx/runner.py index 7badae3258..645b99204c 100644 --- a/frigate/embeddings/onnx/runner.py +++ b/frigate/embeddings/onnx/runner.py @@ -65,6 +65,31 @@ class ONNXModelRunner: elif self.type == "ort": return [input.name for input in self.ort.get_inputs()] + def get_input_width(self): + """Get the input width of the model regardless of backend.""" + if self.type == "ort": + return self.ort.get_inputs()[0].shape[3] + elif self.type == "ov": + input_info = self.interpreter.inputs + first_input = input_info[0] + + try: + partial_shape = first_input.get_partial_shape() + # width dimension + if len(partial_shape) >= 4 and partial_shape[3].is_static: + return partial_shape[3].get_length() + + # If width is dynamic or we can't determine it + return -1 + except Exception: + try: + # gemini says some ov versions might still allow this + input_shape = first_input.shape + return input_shape[3] if len(input_shape) >= 4 else -1 + except Exception: + return -1 + return -1 + def run(self, input: dict[str, Any]) -> Any: if self.type == "ov": infer_request = self.interpreter.create_infer_request()