mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-02 20:00:51 +03:00
CI / AMD64 Build (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
import logging
|
|
from typing import Literal
|
|
|
|
from pydantic import ConfigDict
|
|
|
|
from frigate.detectors.detection_api import DetectionApi
|
|
from frigate.detectors.detector_config import BaseDetectorConfig
|
|
|
|
from ..detector_utils import (
|
|
TFLiteDetectionModel,
|
|
tflite_load_delegate_interpreter,
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Use _tfl suffix to default tflite model
|
|
DETECTOR_KEY = "teflon_tfl"
|
|
|
|
|
|
class TeflonDetectorConfig(BaseDetectorConfig):
|
|
"""Teflon delegate detector for TFLite using Mesa Teflon delegate library to accelerate inference on supported GPUs."""
|
|
|
|
model_config = ConfigDict(
|
|
title="Teflon",
|
|
)
|
|
|
|
type: Literal[DETECTOR_KEY]
|
|
|
|
|
|
class TeflonTfl(DetectionApi):
|
|
type_key = DETECTOR_KEY
|
|
supported_models = TFLiteDetectionModel.supported_models
|
|
|
|
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
|
|
)
|
|
self.tflite_model = TFLiteDetectionModel(
|
|
interpreter, detector_config.model, DETECTOR_KEY
|
|
)
|
|
|
|
def detect_raw(self, tensor_input):
|
|
return self.tflite_model.detect_raw(tensor_input)
|