From 3ee2d7086d7eb2f2901916baf1de3df269e9b052 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 15 Apr 2025 06:39:31 -0600 Subject: [PATCH] Move object detection to folder --- benchmark.py | 2 +- frigate/app.py | 2 +- frigate/events/audio.py | 2 +- .../{object_detection.py => object_detection/base.py} | 0 frigate/object_detection/util.py | 0 frigate/stats/util.py | 2 +- frigate/test/test_object_detector.py | 10 +++++----- frigate/types.py | 2 +- frigate/video.py | 2 +- frigate/watchdog.py | 2 +- process_clip.py | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) rename frigate/{object_detection.py => object_detection/base.py} (100%) create mode 100644 frigate/object_detection/util.py diff --git a/benchmark.py b/benchmark.py index 7db09a5d75..1f39302a7a 100755 --- a/benchmark.py +++ b/benchmark.py @@ -6,7 +6,7 @@ import numpy as np import frigate.util as util from frigate.config import DetectorTypeEnum -from frigate.object_detection import ( +from frigate.object_detection.base import ( ObjectDetectProcess, RemoteObjectDetector, load_labels, diff --git a/frigate/app.py b/frigate/app.py index f433fd50f4..683ff7ab59 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -55,7 +55,7 @@ from frigate.models import ( Timeline, User, ) -from frigate.object_detection import ObjectDetectProcess +from frigate.object_detection.base import ObjectDetectProcess from frigate.output.output import output_frames from frigate.ptz.autotrack import PtzAutoTrackerThread from frigate.ptz.onvif import OnvifController diff --git a/frigate/events/audio.py b/frigate/events/audio.py index adf45431e4..0247393660 100644 --- a/frigate/events/audio.py +++ b/frigate/events/audio.py @@ -29,7 +29,7 @@ from frigate.const import ( ) from frigate.ffmpeg_presets import parse_preset_input from frigate.log import LogPipe -from frigate.object_detection import load_labels +from frigate.object_detection.base import load_labels from frigate.util.builtin import get_ffmpeg_arg_list from frigate.video import start_or_restart_ffmpeg, stop_ffmpeg diff --git a/frigate/object_detection.py b/frigate/object_detection/base.py similarity index 100% rename from frigate/object_detection.py rename to frigate/object_detection/base.py diff --git a/frigate/object_detection/util.py b/frigate/object_detection/util.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frigate/stats/util.py b/frigate/stats/util.py index 2b33a61730..7bdf92bf26 100644 --- a/frigate/stats/util.py +++ b/frigate/stats/util.py @@ -15,7 +15,7 @@ from frigate.camera import CameraMetrics from frigate.config import FrigateConfig from frigate.const import CACHE_DIR, CLIPS_DIR, RECORD_DIR from frigate.data_processing.types import DataProcessorMetrics -from frigate.object_detection import ObjectDetectProcess +from frigate.object_detection.base import ObjectDetectProcess from frigate.types import StatsTrackingTypes from frigate.util.services import ( get_amd_gpu_stats, diff --git a/frigate/test/test_object_detector.py b/frigate/test/test_object_detector.py index 40a9fac14c..a8c14df876 100644 --- a/frigate/test/test_object_detector.py +++ b/frigate/test/test_object_detector.py @@ -5,7 +5,7 @@ import numpy as np from pydantic import parse_obj_as import frigate.detectors as detectors -import frigate.object_detection +import frigate.object_detection.base from frigate.config import DetectorConfig, ModelConfig from frigate.detectors import DetectorTypeEnum from frigate.detectors.detector_config import InputTensorEnum @@ -23,7 +23,7 @@ class TestLocalObjectDetector(unittest.TestCase): DetectorConfig, ({"type": det_type, "model": {}}) ) test_cfg.model.path = "/test/modelpath" - test_obj = frigate.object_detection.LocalObjectDetector( + test_obj = frigate.object_detection.base.LocalObjectDetector( detector_config=test_cfg ) @@ -43,7 +43,7 @@ class TestLocalObjectDetector(unittest.TestCase): TEST_DATA = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TEST_DETECT_RESULT = np.ndarray([1, 2, 4, 8, 16, 32]) - test_obj_detect = frigate.object_detection.LocalObjectDetector( + test_obj_detect = frigate.object_detection.base.LocalObjectDetector( detector_config=parse_obj_as(DetectorConfig, {"type": "cpu", "model": {}}) ) @@ -70,7 +70,7 @@ class TestLocalObjectDetector(unittest.TestCase): test_cfg = parse_obj_as(DetectorConfig, {"type": "cpu", "model": {}}) test_cfg.model.input_tensor = InputTensorEnum.nchw - test_obj_detect = frigate.object_detection.LocalObjectDetector( + test_obj_detect = frigate.object_detection.base.LocalObjectDetector( detector_config=test_cfg ) @@ -118,7 +118,7 @@ class TestLocalObjectDetector(unittest.TestCase): test_cfg = parse_obj_as(DetectorConfig, {"type": "cpu", "model": {}}) test_cfg.model = ModelConfig() - test_obj_detect = frigate.object_detection.LocalObjectDetector( + test_obj_detect = frigate.object_detection.base.LocalObjectDetector( detector_config=test_cfg, labels=TEST_LABEL_FILE, ) diff --git a/frigate/types.py b/frigate/types.py index 4d3fe96b3c..2422c5551c 100644 --- a/frigate/types.py +++ b/frigate/types.py @@ -3,7 +3,7 @@ from typing import TypedDict from frigate.camera import CameraMetrics from frigate.data_processing.types import DataProcessorMetrics -from frigate.object_detection import ObjectDetectProcess +from frigate.object_detection.base import ObjectDetectProcess class StatsTrackingTypes(TypedDict): diff --git a/frigate/video.py b/frigate/video.py index b14f8567cf..d07a72b9a9 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -24,7 +24,7 @@ from frigate.const import ( from frigate.log import LogPipe from frigate.motion import MotionDetector from frigate.motion.improved_motion import ImprovedMotionDetector -from frigate.object_detection import RemoteObjectDetector +from frigate.object_detection.base import RemoteObjectDetector from frigate.ptz.autotrack import ptz_moving_at_frame_time from frigate.track import ObjectTracker from frigate.track.norfair_tracker import NorfairTracker diff --git a/frigate/watchdog.py b/frigate/watchdog.py index d7cdec796d..4c49de1a03 100644 --- a/frigate/watchdog.py +++ b/frigate/watchdog.py @@ -4,7 +4,7 @@ import threading import time from multiprocessing.synchronize import Event as MpEvent -from frigate.object_detection import ObjectDetectProcess +from frigate.object_detection.base import ObjectDetectProcess from frigate.util.services import restart_frigate logger = logging.getLogger(__name__) diff --git a/process_clip.py b/process_clip.py index 46bbc2c916..6f474de68f 100644 --- a/process_clip.py +++ b/process_clip.py @@ -14,7 +14,7 @@ sys.path.append("/workspace/frigate") from frigate.config import FrigateConfig # noqa: E402 from frigate.motion import MotionDetector # noqa: E402 -from frigate.object_detection import LocalObjectDetector # noqa: E402 +from frigate.object_detection.base import LocalObjectDetector # noqa: E402 from frigate.track.centroid_tracker import CentroidTracker # noqa: E402 from frigate.track.object_processing import CameraState # noqa: E402 from frigate.util import ( # noqa: E402