From 146aee709e9572bf7d5df217caf9b24fcbfd436e Mon Sep 17 00:00:00 2001 From: Indrek Mandre Date: Fri, 9 Feb 2024 15:58:30 +0200 Subject: [PATCH] renamed frigate.detectors.yolo_utils.py -> frigate.detectors.util.py --- frigate/detectors/plugins/onnx.py | 9 ++++----- frigate/detectors/plugins/rocm.py | 6 +++--- frigate/detectors/{yolo_utils.py => util.py} | 0 3 files changed, 7 insertions(+), 8 deletions(-) rename frigate/detectors/{yolo_utils.py => util.py} (100%) diff --git a/frigate/detectors/plugins/onnx.py b/frigate/detectors/plugins/onnx.py index 428b68078..b401d18d5 100644 --- a/frigate/detectors/plugins/onnx.py +++ b/frigate/detectors/plugins/onnx.py @@ -7,12 +7,11 @@ import ctypes from pydantic import Field from typing_extensions import Literal import glob -import cv2 from frigate.detectors.detection_api import DetectionApi from frigate.detectors.detector_config import BaseDetectorConfig -import frigate.detectors.yolo_utils as yolo_utils +from frigate.detectors.util import preprocess, yolov8_postprocess logger = logging.getLogger(__name__) @@ -40,7 +39,7 @@ class ONNXDetector(DetectionApi): if detector_config.model.input_pixel_format != 'rgb': logger.warn("ONNX: detector_config.model.input_pixel_format: should be 'rgb' for yolov8, but '{detector_config.model.input_pixel_format}' specified!") - assert detector_config.model.path is not None, "ONNX: no model.path configured, please configure model.path and model.labelmap_path; some suggestions: " + ', '.join(glob.glob("/*.onnx")) + " and " + ', '.join(glob.glob("/*_labels.txt")) + assert detector_config.model.path is not None, "ONNX: No model.path configured, please configure model.path and model.labelmap_path; some suggestions: " + ', '.join(glob.glob("/config/model_cache/yolov8/*.onnx")) + " and " + ', '.join(glob.glob("/config/model_cache/yolov8/*_labels.txt")) path = detector_config.model.path logger.info(f"ONNX: loading {detector_config.model.path}") @@ -51,9 +50,9 @@ class ONNXDetector(DetectionApi): model_input_name = self.model.get_inputs()[0].name model_input_shape = self.model.get_inputs()[0].shape - tensor_input = yolo_utils.preprocess(tensor_input, model_input_shape, np.float32) + tensor_input = preprocess(tensor_input, model_input_shape, np.float32) tensor_output = self.model.run(None, {model_input_name: tensor_input})[0] - return yolo_utils.yolov8_postprocess(model_input_shape, tensor_output) + return yolov8_postprocess(model_input_shape, tensor_output) diff --git a/frigate/detectors/plugins/rocm.py b/frigate/detectors/plugins/rocm.py index d5d0ba585..fa88e2e5c 100644 --- a/frigate/detectors/plugins/rocm.py +++ b/frigate/detectors/plugins/rocm.py @@ -12,7 +12,7 @@ import subprocess from frigate.detectors.detection_api import DetectionApi from frigate.detectors.detector_config import BaseDetectorConfig -import frigate.detectors.yolo_utils as yolo_utils +from frigate.detectors.util import preprocess, yolov8_postprocess logger = logging.getLogger(__name__) @@ -102,12 +102,12 @@ class ROCmDetector(DetectionApi): model_input_name = self.model.get_parameter_names()[0]; model_input_shape = tuple(self.model.get_parameter_shapes()[model_input_name].lens()); - tensor_input = yolo_utils.preprocess(tensor_input, model_input_shape, np.float32) + tensor_input = preprocess(tensor_input, model_input_shape, np.float32) detector_result = self.model.run({model_input_name: tensor_input})[0] addr = ctypes.cast(detector_result.data_ptr(), ctypes.POINTER(ctypes.c_float)) tensor_output = np.ctypeslib.as_array(addr, shape=detector_result.get_shape().lens()) - return yolo_utils.yolov8_postprocess(model_input_shape, tensor_output) + return yolov8_postprocess(model_input_shape, tensor_output) diff --git a/frigate/detectors/yolo_utils.py b/frigate/detectors/util.py similarity index 100% rename from frigate/detectors/yolo_utils.py rename to frigate/detectors/util.py