From 62c1efc430decbca94bf88671edc9061367f7275 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 18 Sep 2025 13:59:34 -0600 Subject: [PATCH] Use model type to decide if model can use full optimization --- frigate/detectors/detection_runners.py | 9 +++++++-- frigate/detectors/plugins/onnx.py | 2 +- frigate/detectors/plugins/openvino.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frigate/detectors/detection_runners.py b/frigate/detectors/detection_runners.py index d2ad07c02..332cf9488 100644 --- a/frigate/detectors/detection_runners.py +++ b/frigate/detectors/detection_runners.py @@ -6,8 +6,6 @@ from abc import ABC, abstractmethod from typing import Any import numpy as np -from frigate.detectors.detector_types import ModelTypeEnum -from frigate.embeddings.types import EnrichmentModelTypeEnum import onnxruntime as ort from frigate.util.model import get_ort_providers @@ -105,6 +103,10 @@ class CudaGraphRunner(BaseModelRunner): @staticmethod def is_complex_model(model_type: str) -> bool: + # Import here to avoid circular imports + from frigate.detectors.detector_config import ModelTypeEnum + from frigate.embeddings.types import EnrichmentModelTypeEnum + return model_type in [ ModelTypeEnum.yolonas.value, EnrichmentModelTypeEnum.paddleocr.value, @@ -169,6 +171,9 @@ class OpenVINOModelRunner(BaseModelRunner): @staticmethod def is_complex_model(model_type: str) -> bool: + # Import here to avoid circular imports + from frigate.embeddings.types import EnrichmentModelTypeEnum + return model_type in [EnrichmentModelTypeEnum.paddleocr.value] def __init__(self, model_path: str, device: str, model_type: str, **kwargs): diff --git a/frigate/detectors/plugins/onnx.py b/frigate/detectors/plugins/onnx.py index 90a5031e6..6c9e510ce 100644 --- a/frigate/detectors/plugins/onnx.py +++ b/frigate/detectors/plugins/onnx.py @@ -39,7 +39,7 @@ class ONNXDetector(DetectionApi): self.runner = get_optimized_runner( path, detector_config.device, - complex_model=False, + model_type=detector_config.model.model_type, ) self.onnx_model_type = detector_config.model.model_type diff --git a/frigate/detectors/plugins/openvino.py b/frigate/detectors/plugins/openvino.py index 789912b4a..bda5c8871 100644 --- a/frigate/detectors/plugins/openvino.py +++ b/frigate/detectors/plugins/openvino.py @@ -45,7 +45,7 @@ class OvDetector(DetectionApi): self.runner = OpenVINOModelRunner( model_path=detector_config.model.path, device=detector_config.device, - complex_model=False, + model_type=detector_config.model.model_type, ) # For dfine models, also pre-allocate target sizes tensor