From b151bcca09c2e4fd90e5bd9272a598b69b37de6d Mon Sep 17 00:00:00 2001 From: Indrek Mandre Date: Sun, 4 Feb 2024 13:27:15 +0200 Subject: [PATCH] detectors/rocm: assume models are in /config/model_cache/yolov8/ --- docker/rocm/Dockerfile | 21 +++------------------ frigate/detectors/plugins/rocm.py | 4 ++-- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/docker/rocm/Dockerfile b/docker/rocm/Dockerfile index d0d4bd2fa..8943f1b87 100644 --- a/docker/rocm/Dockerfile +++ b/docker/rocm/Dockerfile @@ -61,24 +61,6 @@ RUN apt-get -y install libnuma1 WORKDIR /opt/frigate/ COPY --from=rootfs / / -# Could compose them directly from https://github.com/ultralytics/assets/releases/tag/v8.1.0 -# but would need to use a torch image of some sorts -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8n_320x320.onnx / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8n_labels.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8n_labels-frigate.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8s_320x320.onnx / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8s_labels.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8s_labels-frigate.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8m_320x320.onnx / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8m_labels.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8m_labels-frigate.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8n-oiv7_320x320.onnx / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8n-oiv7_labels.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8n-oiv7_labels-frigate.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8s-oiv7_320x320.onnx / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8s-oiv7_labels.txt / -ADD --chmod=0644 https://github.com/harakas/models/raw/main/ultralytics/yolov8.1/yolov8s-oiv7_labels-frigate.txt / - ####################################################################### FROM deps-prelim AS rocm-prelim-hsa-override0 @@ -107,3 +89,6 @@ ENV HSA_OVERRIDE_GFX_VERSION=$HSA_OVERRIDE_GFX_VERSION FROM rocm-prelim-hsa-override$HSA_OVERRIDE as rocm-deps +# Request yolov8 download at startup +ENV DOWNLOAD_YOLOV8=1 + diff --git a/frigate/detectors/plugins/rocm.py b/frigate/detectors/plugins/rocm.py index f38c3712e..b188a5854 100644 --- a/frigate/detectors/plugins/rocm.py +++ b/frigate/detectors/plugins/rocm.py @@ -45,10 +45,10 @@ class ROCmDetector(DetectionApi): if detector_config.model.input_pixel_format != 'rgb': logger.warn("AMD/ROCm: 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, "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, "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 - mxr_path = "/config/model_cache/rocm/" + os.path.basename(os.path.splitext(path)[0] + '.mxr') + mxr_path = os.path.splitext(path)[0] + '.mxr' if path.endswith('.mxr'): logger.info(f"AMD/ROCm: loading parsed model from {mxr_path}") self.model = migraphx.load(mxr_path)