mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-23 19:11:14 +01:00
ab50d0b006
* Add isort and ruff linter Both linters are pretty common among modern python code bases. The isort tool provides stable sorting and grouping, as well as pruning of unused imports. Ruff is a modern linter, that is very fast due to being written in rust. It can detect many common issues in a python codebase. Removes the pylint dev requirement, since ruff replaces it. * treewide: fix issues detected by ruff * treewide: fix bare except clauses * .devcontainer: Set up isort * treewide: optimize imports * treewide: apply black * treewide: make regex patterns raw strings This is necessary for escape sequences to be properly recognized.
19 lines
605 B
Python
19 lines
605 B
Python
import logging
|
|
|
|
from .detector_config import InputTensorEnum, ModelConfig, PixelFormatEnum # noqa: F401
|
|
from .detector_types import DetectorConfig, DetectorTypeEnum, api_types # noqa: F401
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def create_detector(detector_config):
|
|
if detector_config.type == DetectorTypeEnum.cpu:
|
|
logger.warning(
|
|
"CPU detectors are not recommended and should only be used for testing or for trial purposes."
|
|
)
|
|
|
|
api = api_types.get(detector_config.type)
|
|
if not api:
|
|
raise ValueError(detector_config.type)
|
|
return api(detector_config)
|