From 8e205597af418b008a43532434f5c0fb362a51d0 Mon Sep 17 00:00:00 2001 From: Indrek Mandre Date: Fri, 9 Feb 2024 17:06:06 +0200 Subject: [PATCH] applied ruff suggested fixes --- frigate/detectors/plugins/onnx.py | 9 ++------- frigate/detectors/plugins/rocm.py | 23 +++++++++++------------ frigate/detectors/util.py | 2 +- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/frigate/detectors/plugins/onnx.py b/frigate/detectors/plugins/onnx.py index 54b32d92f..41dc2a727 100644 --- a/frigate/detectors/plugins/onnx.py +++ b/frigate/detectors/plugins/onnx.py @@ -1,16 +1,11 @@ +import glob import logging -import sys -import os import numpy as np -import ctypes -from pydantic import Field from typing_extensions import Literal -import glob from frigate.detectors.detection_api import DetectionApi from frigate.detectors.detector_config import BaseDetectorConfig - from frigate.detectors.util import preprocess, yolov8_postprocess logger = logging.getLogger(__name__) @@ -29,7 +24,7 @@ class ONNXDetector(DetectionApi): try: import onnxruntime - logger.info(f"ONNX: loaded onnxruntime module") + logger.info("ONNX: loaded onnxruntime module") except ModuleNotFoundError: logger.error( "ONNX: module loading failed, need 'pip install onnxruntime'?!?" diff --git a/frigate/detectors/plugins/rocm.py b/frigate/detectors/plugins/rocm.py index ff5376d62..51c3a4620 100644 --- a/frigate/detectors/plugins/rocm.py +++ b/frigate/detectors/plugins/rocm.py @@ -1,17 +1,16 @@ -import logging - -import sys -import os -import numpy as np import ctypes +import glob +import logging +import os +import subprocess +import sys + +import numpy as np from pydantic import Field from typing_extensions import Literal -import glob -import subprocess from frigate.detectors.detection_api import DetectionApi from frigate.detectors.detector_config import BaseDetectorConfig - from frigate.detectors.util import preprocess, yolov8_postprocess logger = logging.getLogger(__name__) @@ -71,13 +70,13 @@ class ROCmDetector(DetectionApi): sys.path.append("/opt/rocm/lib") import migraphx - logger.info(f"AMD/ROCm: loaded migraphx module") + logger.info("AMD/ROCm: loaded migraphx module") except ModuleNotFoundError: logger.error("AMD/ROCm: module loading failed, missing ROCm environment?") raise if detector_config.conserve_cpu: - logger.info(f"AMD/ROCm: switching HIP to blocking mode to conserve CPU") + logger.info("AMD/ROCm: switching HIP to blocking mode to conserve CPU") ctypes.CDLL("/opt/rocm/lib/libamdhip64.so").hipSetDeviceFlags(4) assert ( detector_config.model.model_type == "yolov8" @@ -118,14 +117,14 @@ class ROCmDetector(DetectionApi): self.model = migraphx.parse_tf(path) else: raise Exception(f"AMD/ROCm: unkown model format {path}") - logger.info(f"AMD/ROCm: compiling the model") + logger.info("AMD/ROCm: compiling the model") self.model.compile( migraphx.get_target("gpu"), offload_copy=True, fast_math=True ) logger.info(f"AMD/ROCm: saving parsed model into {mxr_path}") os.makedirs("/config/model_cache/rocm", exist_ok=True) migraphx.save(self.model, mxr_path) - logger.info(f"AMD/ROCm: model loaded") + logger.info("AMD/ROCm: model loaded") def detect_raw(self, tensor_input): model_input_name = self.model.get_parameter_names()[0] diff --git a/frigate/detectors/util.py b/frigate/detectors/util.py index 4133fe9c6..db1b9f794 100644 --- a/frigate/detectors/util.py +++ b/frigate/detectors/util.py @@ -1,7 +1,7 @@ import logging -import numpy as np import cv2 +import numpy as np logger = logging.getLogger(__name__)