Compare commits

...
7 Commits
11 changed files with 46 additions and 15 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ paths:
description: Authentication Accepted (no response body, different headers depending on auth method) description: Authentication Accepted (no response body, different headers depending on auth method)
headers: headers:
remote-user: remote-user:
description: Authenticated username or "anonymous" in proxy-only mode description: Authenticated username or "viewer" in proxy-only mode
schema: schema:
type: string type: string
remote-role: remote-role:
+6 -6
View File
@@ -167,7 +167,7 @@ def allow_any_authenticated():
Allows: Allows:
- Port 5000 internal requests (remote-user: "anonymous", remote-role: "admin") - Port 5000 internal requests (remote-user: "anonymous", remote-role: "admin")
- Authenticated users with JWT tokens (remote-user: username) - Authenticated users with JWT tokens (remote-user: username)
- Unauthenticated requests when auth is disabled (remote-user: "anonymous") - Unauthenticated requests when auth is disabled (remote-user: "viewer")
Rejects: Rejects:
- Requests with no remote-user header (did not pass through /auth endpoint) - Requests with no remote-user header (did not pass through /auth endpoint)
@@ -550,7 +550,7 @@ def resolve_role(
"description": "Authentication Accepted (no response body)", "description": "Authentication Accepted (no response body)",
"headers": { "headers": {
"remote-user": { "remote-user": {
"description": 'Authenticated username or "anonymous" in proxy-only mode', "description": 'Authenticated username or "viewer" in proxy-only mode',
"schema": {"type": "string"}, "schema": {"type": "string"},
}, },
"remote-role": { "remote-role": {
@@ -592,12 +592,12 @@ def auth(request: Request):
# if auth is disabled, just apply the proxy header map and return success # if auth is disabled, just apply the proxy header map and return success
if not auth_config.enabled: if not auth_config.enabled:
# pass the user header value from the upstream proxy if a mapping is specified # pass the user header value from the upstream proxy if a mapping is specified
# or use anonymous if none are specified # or use viewer if none are specified
user_header = proxy_config.header_map.user user_header = proxy_config.header_map.user
success_response.headers["remote-user"] = ( success_response.headers["remote-user"] = (
request.headers.get(user_header, default="anonymous") request.headers.get(user_header, default="viewer")
if user_header if user_header
else "anonymous" else "viewer"
) )
# parse header and resolve a valid role # parse header and resolve a valid role
@@ -712,7 +712,7 @@ def auth(request: Request):
description="Returns the current authenticated user's profile including username, role, and allowed cameras. This endpoint requires authentication and returns information about the user's permissions.", description="Returns the current authenticated user's profile including username, role, and allowed cameras. This endpoint requires authentication and returns information about the user's permissions.",
) )
def profile(request: Request): def profile(request: Request):
username = request.headers.get("remote-user", "anonymous") username = request.headers.get("remote-user", "viewer")
role = request.headers.get("remote-role", "viewer") role = request.headers.get("remote-role", "viewer")
all_camera_names = set(request.app.frigate_config.cameras.keys()) all_camera_names = set(request.app.frigate_config.cameras.keys())
+2 -1
View File
@@ -225,7 +225,8 @@ class MqttClient(Communicator):
"birdseye_mode", "birdseye_mode",
"review_alerts", "review_alerts",
"review_detections", "review_detections",
"genai", "object_descriptions",
"review_descriptions",
] ]
for name in self.config.cameras.keys(): for name in self.config.cameras.keys():
+3
View File
@@ -77,6 +77,9 @@ FFMPEG_HWACCEL_RKMPP = "preset-rkmpp"
FFMPEG_HWACCEL_AMF = "preset-amd-amf" FFMPEG_HWACCEL_AMF = "preset-amd-amf"
FFMPEG_HVC1_ARGS = ["-tag:v", "hvc1"] FFMPEG_HVC1_ARGS = ["-tag:v", "hvc1"]
# RKNN constants
SUPPORTED_RK_SOCS = ["rk3562", "rk3566", "rk3568", "rk3576", "rk3588"]
# Regex constants # Regex constants
REGEX_CAMERA_NAME = r"^[a-zA-Z0-9_-]+$" REGEX_CAMERA_NAME = r"^[a-zA-Z0-9_-]+$"
+3 -5
View File
@@ -8,7 +8,7 @@ import cv2
import numpy as np import numpy as np
from pydantic import Field 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_api import DetectionApi
from frigate.detectors.detection_runners import RKNNModelRunner from frigate.detectors.detection_runners import RKNNModelRunner
from frigate.detectors.detector_config import BaseDetectorConfig, ModelTypeEnum from frigate.detectors.detector_config import BaseDetectorConfig, ModelTypeEnum
@@ -19,8 +19,6 @@ logger = logging.getLogger(__name__)
DETECTOR_KEY = "rknn" DETECTOR_KEY = "rknn"
supported_socs = ["rk3562", "rk3566", "rk3568", "rk3576", "rk3588"]
supported_models = { supported_models = {
ModelTypeEnum.yologeneric: "^frigate-fp16-yolov9-[cemst]$", ModelTypeEnum.yologeneric: "^frigate-fp16-yolov9-[cemst]$",
ModelTypeEnum.yolonas: "^deci-fp16-yolonas_[sml]$", ModelTypeEnum.yolonas: "^deci-fp16-yolonas_[sml]$",
@@ -82,9 +80,9 @@ class Rknn(DetectionApi):
except FileNotFoundError: except FileNotFoundError:
raise Exception("Make sure to run docker in privileged mode.") 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( 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 return soc
+12
View File
@@ -8,6 +8,7 @@ import time
from pathlib import Path from pathlib import Path
from typing import Optional from typing import Optional
from frigate.const import SUPPORTED_RK_SOCS
from frigate.util.file import FileLock from frigate.util.file import FileLock
logger = logging.getLogger(__name__) 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 True if the model is RKNN-compatible, False otherwise
""" """
soc = get_soc_type() soc = get_soc_type()
if soc is None: if soc is None:
return False 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: if not model_type:
model_type = get_rknn_model_type(model_path) model_type = get_rknn_model_type(model_path)
@@ -139,6 +139,7 @@
"nameOnlyNumbers": "Model name cannot contain only numbers", "nameOnlyNumbers": "Model name cannot contain only numbers",
"classRequired": "At least 1 class is required", "classRequired": "At least 1 class is required",
"classesUnique": "Class names must be unique", "classesUnique": "Class names must be unique",
"noneNotAllowed": "The class 'none' is not allowed",
"stateRequiresTwoClasses": "State models require at least 2 classes", "stateRequiresTwoClasses": "State models require at least 2 classes",
"objectLabelRequired": "Please select an object label", "objectLabelRequired": "Please select an object label",
"objectTypeRequired": "Please select a classification type" "objectTypeRequired": "Please select a classification type"
@@ -40,6 +40,7 @@ type ClassificationCardProps = {
data: ClassificationItemData; data: ClassificationItemData;
threshold?: ClassificationThreshold; threshold?: ClassificationThreshold;
selected: boolean; selected: boolean;
clickable: boolean;
i18nLibrary: string; i18nLibrary: string;
showArea?: boolean; showArea?: boolean;
count?: number; count?: number;
@@ -56,6 +57,7 @@ export const ClassificationCard = forwardRef<
data, data,
threshold, threshold,
selected, selected,
clickable,
i18nLibrary, i18nLibrary,
showArea = true, showArea = true,
count, count,
@@ -101,11 +103,12 @@ export const ClassificationCard = forwardRef<
<div <div
ref={ref} ref={ref}
className={cn( className={cn(
"relative flex size-full cursor-pointer flex-col overflow-hidden rounded-lg outline outline-[3px]", "relative flex size-full flex-col overflow-hidden rounded-lg outline outline-[3px]",
className, className,
selected selected
? "shadow-selected outline-selected" ? "shadow-selected outline-selected"
: "outline-transparent duration-500", : "outline-transparent duration-500",
clickable && "cursor-pointer",
)} )}
onClick={(e) => { onClick={(e) => {
const isMeta = e.metaKey || e.ctrlKey; const isMeta = e.metaKey || e.ctrlKey;
@@ -289,6 +292,7 @@ export function GroupedClassificationCard({
data={bestItem} data={bestItem}
threshold={threshold} threshold={threshold}
selected={selectedItems.includes(bestItem.filename)} selected={selectedItems.includes(bestItem.filename)}
clickable={true}
i18nLibrary={i18nLibrary} i18nLibrary={i18nLibrary}
count={group.length} count={group.length}
onClick={(_, meta) => { onClick={(_, meta) => {
@@ -413,6 +417,7 @@ export function GroupedClassificationCard({
data={data} data={data}
threshold={threshold} threshold={threshold}
selected={false} selected={false}
clickable={false}
i18nLibrary={i18nLibrary} i18nLibrary={i18nLibrary}
onClick={() => {}} onClick={() => {}}
> >
@@ -94,7 +94,14 @@ export default function Step1NameAndDefine({
objectLabel: z.string().optional(), objectLabel: z.string().optional(),
objectType: z.enum(["sub_label", "attribute"]).optional(), objectType: z.enum(["sub_label", "attribute"]).optional(),
classes: z classes: z
.array(z.string()) .array(
z
.string()
.refine(
(val) => val.trim().toLowerCase() !== "none",
t("wizard.step1.errors.noneNotAllowed"),
),
)
.min(1, t("wizard.step1.errors.classRequired")) .min(1, t("wizard.step1.errors.classRequired"))
.refine( .refine(
(classes) => { (classes) => {
@@ -467,6 +474,7 @@ export default function Step1NameAndDefine({
)} )}
</div> </div>
</FormControl> </FormControl>
<FormMessage />
</FormItem> </FormItem>
)} )}
/> />
+1
View File
@@ -1026,6 +1026,7 @@ function FaceGrid({
filepath: `clips/faces/${pageToggle}/${image}`, filepath: `clips/faces/${pageToggle}/${image}`,
}} }}
selected={selectedFaces.includes(image)} selected={selectedFaces.includes(image)}
clickable={selectedFaces.length > 0}
i18nLibrary="views/faceLibrary" i18nLibrary="views/faceLibrary"
onClick={(data, meta) => onClickFaces([data.filename], meta)} onClick={(data, meta) => onClickFaces([data.filename], meta)}
> >
@@ -804,6 +804,7 @@ function DatasetGrid({
name: "", name: "",
}} }}
showArea={false} showArea={false}
clickable={selectedImages.length > 0}
selected={selectedImages.includes(image)} selected={selectedImages.includes(image)}
i18nLibrary="views/classificationModel" i18nLibrary="views/classificationModel"
onClick={(data, _) => onClickImages([data.filename], true)} onClick={(data, _) => onClickImages([data.filename], true)}
@@ -962,6 +963,7 @@ function StateTrainGrid({
data={data} data={data}
threshold={threshold} threshold={threshold}
selected={selectedImages.includes(data.filename)} selected={selectedImages.includes(data.filename)}
clickable={selectedImages.length > 0}
i18nLibrary="views/classificationModel" i18nLibrary="views/classificationModel"
showArea={false} showArea={false}
onClick={(data, meta) => onClickImages([data.filename], meta)} onClick={(data, meta) => onClickImages([data.filename], meta)}