From 805170dd87bfb8ef6701aa7c10e007793e06de5e Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sun, 28 Sep 2025 07:25:21 -0500 Subject: [PATCH] fix synaptics detector from throwing error when unused --- frigate/detectors/plugins/synaptics.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/frigate/detectors/plugins/synaptics.py b/frigate/detectors/plugins/synaptics.py index 0faed399a..e312ffdd9 100644 --- a/frigate/detectors/plugins/synaptics.py +++ b/frigate/detectors/plugins/synaptics.py @@ -2,10 +2,6 @@ import logging import os import numpy as np -from synap import Network -from synap.postprocessor import Detector -from synap.preprocessor import Preprocessor -from synap.types import Layout, Shape from typing_extensions import Literal from frigate.detectors.detection_api import DetectionApi @@ -15,6 +11,16 @@ from frigate.detectors.detector_config import ( ModelTypeEnum, ) +try: + from synap import Network + from synap.postprocessor import Detector + from synap.preprocessor import Preprocessor + from synap.types import Layout, Shape + + SYNAP_SUPPORT = True +except ImportError: + SYNAP_SUPPORT = False + logger = logging.getLogger(__name__) DETECTOR_KEY = "synaptics" @@ -28,6 +34,11 @@ class SynapDetector(DetectionApi): type_key = DETECTOR_KEY def __init__(self, detector_config: SynapDetectorConfig): + if not SYNAP_SUPPORT: + raise ImportError( + "Error importing Synaptics SDK modules. You must use the -synaptics Docker image variant for Synaptics detector support." + ) + try: _, ext = os.path.splitext(detector_config.model.path) if ext and ext != ".synap":