diff --git a/frigate/const.py b/frigate/const.py index 11e89886f..41c24f087 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -77,6 +77,9 @@ FFMPEG_HWACCEL_RKMPP = "preset-rkmpp" FFMPEG_HWACCEL_AMF = "preset-amd-amf" FFMPEG_HVC1_ARGS = ["-tag:v", "hvc1"] +# RKNN constants +SUPPORTED_RK_SOCS = ["rk3562", "rk3566", "rk3568", "rk3576", "rk3588"] + # Regex constants REGEX_CAMERA_NAME = r"^[a-zA-Z0-9_-]+$" diff --git a/frigate/detectors/plugins/rknn.py b/frigate/detectors/plugins/rknn.py index 70186824b..c16df507e 100644 --- a/frigate/detectors/plugins/rknn.py +++ b/frigate/detectors/plugins/rknn.py @@ -8,7 +8,7 @@ import cv2 import numpy as np from pydantic import Field -from frigate.const import MODEL_CACHE_DIR +from frigate.const import MODEL_CACHE_DIR, SUPPORTED_RK_SOCS from frigate.detectors.detection_api import DetectionApi from frigate.detectors.detection_runners import RKNNModelRunner from frigate.detectors.detector_config import BaseDetectorConfig, ModelTypeEnum @@ -19,8 +19,6 @@ logger = logging.getLogger(__name__) DETECTOR_KEY = "rknn" -supported_socs = ["rk3562", "rk3566", "rk3568", "rk3576", "rk3588"] - supported_models = { ModelTypeEnum.yologeneric: "^frigate-fp16-yolov9-[cemst]$", ModelTypeEnum.yolonas: "^deci-fp16-yolonas_[sml]$", @@ -82,9 +80,9 @@ class Rknn(DetectionApi): except FileNotFoundError: raise Exception("Make sure to run docker in privileged mode.") - if soc not in supported_socs: + if soc not in SUPPORTED_RK_SOCS: raise Exception( - f"Your SoC is not supported. Your SoC is: {soc}. Currently these SoCs are supported: {supported_socs}." + f"Your SoC is not supported. Your SoC is: {soc}. Currently these SoCs are supported: {SUPPORTED_RK_SOCS}." ) return soc diff --git a/frigate/util/rknn_converter.py b/frigate/util/rknn_converter.py index 8b2fd0050..f7ebbf5e6 100644 --- a/frigate/util/rknn_converter.py +++ b/frigate/util/rknn_converter.py @@ -8,6 +8,7 @@ import time from pathlib import Path from typing import Optional +from frigate.const import SUPPORTED_RK_SOCS from frigate.util.file import FileLock logger = logging.getLogger(__name__) @@ -68,9 +69,20 @@ def is_rknn_compatible(model_path: str, model_type: str | None = None) -> bool: True if the model is RKNN-compatible, False otherwise """ soc = get_soc_type() + if soc is None: return False + # Check if the SoC is actually a supported RK device + # This prevents false positives on non-RK devices (e.g., macOS Docker) + # where /proc/device-tree/compatible might exist but contain non-RK content + if soc not in SUPPORTED_RK_SOCS: + logger.debug( + f"SoC '{soc}' is not a supported RK device for RKNN conversion. " + f"Supported SoCs: {SUPPORTED_RK_SOCS}" + ) + return False + if not model_type: model_type = get_rknn_model_type(model_path)