* fix api async/await functions

* fix synaptics detector from throwing error when unused

* clean up
This commit is contained in:
Josh Hawkins
2025-09-28 07:08:52 -06:00
committed by GitHub
parent c207009d8a
commit b6552987b0
2 changed files with 35 additions and 19 deletions
+18 -6
View File
@@ -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,15 +34,21 @@ class SynapDetector(DetectionApi):
type_key = DETECTOR_KEY
def __init__(self, detector_config: SynapDetectorConfig):
if not SYNAP_SUPPORT:
logger.error(
"Error importing Synaptics SDK modules. You must use the -synaptics Docker image variant for Synaptics detector support."
)
return
try:
_, ext = os.path.splitext(detector_config.model.path)
if ext and ext != ".synap":
raise ValueError("Model path config for Synap1680 is wrong.")
raise ValueError("Model path config for Synap1680 is incorrect.")
synap_network = Network(detector_config.model.path)
logger.info(f"Synap NPU loaded model: {detector_config.model.path}")
except ValueError as ve:
logger.error(f"Config to Synap1680 was Failed: {ve}")
logger.error(f"Synap1680 setup has failed: {ve}")
raise
except Exception as e:
logger.error(f"Failed to init Synap NPU: {e}")