mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-30 13:48:07 +02:00
* Refactor common functions for tflite detector implementations * Add detector using mesa teflon delegate Non-EdgeTPU TFLite can use the standard .tflite format * Add mesa-teflon-delegate from bookworm-backports to arm64 images
39 lines
1003 B
Python
39 lines
1003 B
Python
import logging
|
|
|
|
from typing_extensions import Literal
|
|
|
|
from frigate.detectors.detection_api import DetectionApi
|
|
from frigate.detectors.detector_config import BaseDetectorConfig
|
|
|
|
from ..detector_utils import (
|
|
tflite_detect_raw,
|
|
tflite_init,
|
|
tflite_load_delegate_interpreter,
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Use _tfl suffix to default tflite model
|
|
DETECTOR_KEY = "teflon_tfl"
|
|
|
|
|
|
class TeflonDetectorConfig(BaseDetectorConfig):
|
|
type: Literal[DETECTOR_KEY]
|
|
|
|
|
|
class TeflonTfl(DetectionApi):
|
|
type_key = DETECTOR_KEY
|
|
|
|
def __init__(self, detector_config: TeflonDetectorConfig):
|
|
# Location in Debian's mesa-teflon-delegate
|
|
delegate_library = "/usr/lib/teflon/libteflon.so"
|
|
device_config = {}
|
|
|
|
interpreter = tflite_load_delegate_interpreter(
|
|
delegate_library, detector_config, device_config
|
|
)
|
|
tflite_init(self, interpreter)
|
|
|
|
def detect_raw(self, tensor_input):
|
|
return tflite_detect_raw(self, tensor_input)
|