mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-01 08:32:18 +03:00
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / Jetson Jetpack 6 (push) Waiting to run
* Pin ruff * Add python upgrade fixes This enables python upgrade checks in ruff to look for deprecated types and patterns. This namely fixes: - usage of deprecated `Typing` which is now built in - some specific exceptions which are caught and have new aliases Some specific UP checks were also ignored as they are stylistic / unimportant and likely to cause bugs * Remove async blocking calls Use asyncio.to_thread on two remaining blocking calls to fix hanging event thread loop. Enable this specific rule to block it in the future. * Use proper logging mechanism * Correctly format logs * Raise with context When raising an exception include the from context to improve debugging * Cleanup
46 lines
1.2 KiB
Python
46 lines
1.2 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 (
|
|
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):
|
|
"""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
|
|
|
|
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)
|