mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 13:34:13 +03:00
[Update] Update synaptics detector coding format
This commit is contained in:
parent
f2df550a2a
commit
7a575a90bf
@ -1,19 +1,18 @@
|
|||||||
import os
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from typing_extensions import Literal
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from synap import Network
|
from synap import Network
|
||||||
from synap.types import Shape, Layout
|
|
||||||
from synap.preprocessor import Preprocessor
|
|
||||||
from synap.postprocessor import Detector
|
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
|
from frigate.detectors.detection_api import DetectionApi
|
||||||
from frigate.detectors.detector_config import (
|
from frigate.detectors.detector_config import (
|
||||||
BaseDetectorConfig,
|
BaseDetectorConfig,
|
||||||
ModelTypeEnum,
|
|
||||||
InputTensorEnum,
|
InputTensorEnum,
|
||||||
|
ModelTypeEnum,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -43,7 +42,6 @@ class SynapDetector(DetectionApi):
|
|||||||
logger.error(f"Failed to init Synap NPU: {e}")
|
logger.error(f"Failed to init Synap NPU: {e}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
self.width = detector_config.model.width
|
self.width = detector_config.model.width
|
||||||
self.height = detector_config.model.height
|
self.height = detector_config.model.height
|
||||||
self.model_type = detector_config.model.model_type
|
self.model_type = detector_config.model.model_type
|
||||||
@ -62,7 +60,7 @@ class SynapDetector(DetectionApi):
|
|||||||
|
|
||||||
if self.input_tensor_layout == InputTensorEnum.nhwc:
|
if self.input_tensor_layout == InputTensorEnum.nhwc:
|
||||||
layout = Layout.nhwc
|
layout = Layout.nhwc
|
||||||
|
|
||||||
postprocess_data = self.preprocessor.assign(
|
postprocess_data = self.preprocessor.assign(
|
||||||
self.network.inputs, tensor_input, Shape(tensor_input.shape), layout
|
self.network.inputs, tensor_input, Shape(tensor_input.shape), layout
|
||||||
)
|
)
|
||||||
@ -75,15 +73,11 @@ class SynapDetector(DetectionApi):
|
|||||||
break
|
break
|
||||||
|
|
||||||
bb = item.bounding_box
|
bb = item.bounding_box
|
||||||
|
|
||||||
|
|
||||||
# Convert corner coordinates to normalized [0,1] range
|
# Convert corner coordinates to normalized [0,1] range
|
||||||
x1 = bb.origin.x / self.width # Top-left X
|
x1 = bb.origin.x / self.width # Top-left X
|
||||||
y1 = bb.origin.y / self.height # Top-left Y
|
y1 = bb.origin.y / self.height # Top-left Y
|
||||||
x2 = (bb.origin.x + bb.size.x) / self.width # Bottom-right X
|
x2 = (bb.origin.x + bb.size.x) / self.width # Bottom-right X
|
||||||
y2 = (bb.origin.y + bb.size.y) / self.height # Bottom-right Y
|
y2 = (bb.origin.y + bb.size.y) / self.height # Bottom-right Y
|
||||||
|
|
||||||
|
|
||||||
detections[i] = [
|
detections[i] = [
|
||||||
item.class_index,
|
item.class_index,
|
||||||
float(item.confidence),
|
float(item.confidence),
|
||||||
@ -94,6 +88,4 @@ class SynapDetector(DetectionApi):
|
|||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
logger.error(f"Unsupported model type: {self.model_type}")
|
logger.error(f"Unsupported model type: {self.model_type}")
|
||||||
|
return detections
|
||||||
return np.zeros((20, 6), np.float32)
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user