mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-15 11:12:49 +03:00
Compare commits
36
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2aa0ee29a | ||
|
|
9c7e32d0d6 | ||
|
|
ad79e666eb | ||
|
|
fc79aeab5e | ||
|
|
b1cdf1f76b | ||
|
|
fc319f4223 | ||
|
|
bf35e90bc8 | ||
|
|
07abbd2c0a | ||
|
|
694d162071 | ||
|
|
b1d9676638 | ||
|
|
891a0df879 | ||
|
|
2d5845c770 | ||
|
|
612a7cb871 | ||
|
|
101e5d0e98 | ||
|
|
bcff29c35b | ||
|
|
467404b410 | ||
|
|
767597967e | ||
|
|
57b8206e86 | ||
|
|
86b828f52e | ||
|
|
4b39edf983 | ||
|
|
06f5229567 | ||
|
|
90a33f504c | ||
|
|
d0766aa3ee | ||
|
|
76a5e00bd5 | ||
|
|
b914f32cea | ||
|
|
48acba8dab | ||
|
|
c605295483 | ||
|
|
ad35bf49f7 | ||
|
|
000bf4a03b | ||
|
|
d2982bd144 | ||
|
|
2cd53ccdfe | ||
|
|
2ba33e227c | ||
|
|
036bae4ea9 | ||
|
|
8384a8c5b3 | ||
|
|
77fc2ce174 | ||
|
|
8425a76558 |
@@ -1,7 +1,7 @@
|
|||||||
default_target: local
|
default_target: local
|
||||||
|
|
||||||
COMMIT_HASH := $(shell git log -1 --pretty=format:"%h"|tail -1)
|
COMMIT_HASH := $(shell git log -1 --pretty=format:"%h"|tail -1)
|
||||||
VERSION = 0.19.0
|
VERSION = 0.18.0
|
||||||
IMAGE_REPO ?= ghcr.io/blakeblackshear/frigate
|
IMAGE_REPO ?= ghcr.io/blakeblackshear/frigate
|
||||||
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
BOARDS= #Initialized empty
|
BOARDS= #Initialized empty
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ edgeTPU:
|
|||||||
download: A TensorFlow Lite model is provided in the container at `/edgetpu_model.tflite` and is used by this detector type by default. To provide your own model, bind mount the file into the container and provide the path with `model.path`.
|
download: A TensorFlow Lite model is provided in the container at `/edgetpu_model.tflite` and is used by this detector type by default. To provide your own model, bind mount the file into the container and provide the path with `model.path`.
|
||||||
ui: Navigate to **Settings > System > Detectors and model** and select **EdgeTPU** from the detector type dropdown and click **Add**, then set device to `usb`.
|
ui: Navigate to **Settings > System > Detectors and model** and select **EdgeTPU** from the detector type dropdown and click **Add**, then set device to `usb`.
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral:
|
||||||
- edgetpu:usb
|
type: edgetpu
|
||||||
|
device: usb
|
||||||
- key: yolov9
|
- key: yolov9
|
||||||
label: YOLOv9
|
label: YOLOv9
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -28,14 +29,17 @@ edgeTPU:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral:
|
||||||
- edgetpu:usb
|
type: edgetpu
|
||||||
model_type: yolo-generic
|
device: usb
|
||||||
width: 320 # <--- should match the imgsize of the model, typically 320
|
|
||||||
height: 320 # <--- should match the imgsize of the model, typically 320
|
model:
|
||||||
path: /config/model_cache/yolov9-s-relu6-best_320_int8_edgetpu.tflite
|
model_type: yolo-generic
|
||||||
labelmap_path: /config/labels-coco17.txt
|
width: 320 # <--- should match the imgsize of the model, typically 320
|
||||||
|
height: 320 # <--- should match the imgsize of the model, typically 320
|
||||||
|
path: /config/model_cache/yolov9-s-relu6-best_320_int8_edgetpu.tflite
|
||||||
|
labelmap_path: /config/labels-coco17.txt
|
||||||
hailo8l:
|
hailo8l:
|
||||||
title: Hailo-8/Hailo-8L
|
title: Hailo-8/Hailo-8L
|
||||||
models:
|
models:
|
||||||
@@ -58,29 +62,32 @@ hailo8l:
|
|||||||
|
|
||||||
The detector automatically selects the default model based on your hardware. Optionally, specify a local model path or URL to override.
|
The detector automatically selects the default model based on your hardware. Optionally, specify a local model path or URL to override.
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
hailo:
|
||||||
- hailo8l:PCIe
|
type: hailo8l
|
||||||
width: 320
|
device: PCIe
|
||||||
height: 320
|
|
||||||
input_tensor: nhwc
|
|
||||||
input_pixel_format: rgb
|
|
||||||
input_dtype: int
|
|
||||||
model_type: yolo-generic
|
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
|
||||||
|
|
||||||
# The detector automatically selects the default model based on your hardware:
|
model:
|
||||||
# - For Hailo-8 hardware: YOLOv6n (default: yolov6n.hef)
|
width: 320
|
||||||
# - For Hailo-8L hardware: YOLOv6n (default: yolov6n.hef)
|
height: 320
|
||||||
#
|
input_tensor: nhwc
|
||||||
# Optionally, you can specify a local model path to override the default.
|
input_pixel_format: rgb
|
||||||
# If a local path is provided and the file exists, it will be used instead of downloading.
|
input_dtype: int
|
||||||
# Example:
|
model_type: yolo-generic
|
||||||
# path: /config/model_cache/hailo/yolov6n.hef
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
#
|
|
||||||
# You can also override using a custom URL:
|
# The detector automatically selects the default model based on your hardware:
|
||||||
# path: https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.14.0/hailo8/yolov6n.hef
|
# - For Hailo-8 hardware: YOLOv6n (default: yolov6n.hef)
|
||||||
# just make sure to give it the write configuration based on the model
|
# - For Hailo-8L hardware: YOLOv6n (default: yolov6n.hef)
|
||||||
|
#
|
||||||
|
# Optionally, you can specify a local model path to override the default.
|
||||||
|
# If a local path is provided and the file exists, it will be used instead of downloading.
|
||||||
|
# Example:
|
||||||
|
# path: /config/model_cache/hailo/yolov6n.hef
|
||||||
|
#
|
||||||
|
# You can also override using a custom URL:
|
||||||
|
# path: https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.14.0/hailo8/yolov6n.hef
|
||||||
|
# just make sure to give it the write configuration based on the model
|
||||||
- key: ssd
|
- key: ssd
|
||||||
label: SSD MobileNet v1
|
label: SSD MobileNet v1
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -99,20 +106,23 @@ hailo8l:
|
|||||||
|
|
||||||
Specify the local model path or URL for SSD MobileNet v1.
|
Specify the local model path or URL for SSD MobileNet v1.
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
hailo:
|
||||||
- hailo8l:PCIe
|
type: hailo8l
|
||||||
width: 300
|
device: PCIe
|
||||||
height: 300
|
|
||||||
input_tensor: nhwc
|
model:
|
||||||
input_pixel_format: rgb
|
width: 300
|
||||||
model_type: ssd
|
height: 300
|
||||||
# Specify the local model path (if available) or URL for SSD MobileNet v1.
|
input_tensor: nhwc
|
||||||
# Example with a local path:
|
input_pixel_format: rgb
|
||||||
# path: /config/model_cache/h8l_cache/ssd_mobilenet_v1.hef
|
model_type: ssd
|
||||||
#
|
# Specify the local model path (if available) or URL for SSD MobileNet v1.
|
||||||
# Or override using a custom URL:
|
# Example with a local path:
|
||||||
# path: https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.14.0/hailo8l/ssd_mobilenet_v1.hef
|
# path: /config/model_cache/h8l_cache/ssd_mobilenet_v1.hef
|
||||||
|
#
|
||||||
|
# Or override using a custom URL:
|
||||||
|
# path: https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.14.0/hailo8l/ssd_mobilenet_v1.hef
|
||||||
openvino:
|
openvino:
|
||||||
title: OpenVINO
|
title: OpenVINO
|
||||||
models:
|
models:
|
||||||
@@ -156,16 +166,19 @@ openvino:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov:
|
||||||
- openvino:GPU
|
type: openvino
|
||||||
model_type: yolo-generic
|
device: GPU # or NPU
|
||||||
width: 320 # <--- should match the imgsize set during model export
|
|
||||||
height: 320 # <--- should match the imgsize set during model export
|
model:
|
||||||
input_tensor: nchw
|
model_type: yolo-generic
|
||||||
input_dtype: float
|
width: 320 # <--- should match the imgsize set during model export
|
||||||
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
height: 320 # <--- should match the imgsize set during model export
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_tensor: nchw
|
||||||
|
input_dtype: float
|
||||||
|
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: ssd
|
- key: ssd
|
||||||
label: SSDLite MobileNet v2
|
label: SSDLite MobileNet v2
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -184,15 +197,18 @@ openvino:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `ssd` (Frigate's default value) |
|
| **Object Detection Model Type** | `ssd` (Frigate's default value) |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov:
|
||||||
- openvino:GPU
|
type: openvino
|
||||||
width: 300
|
device: GPU # Or NPU
|
||||||
height: 300
|
|
||||||
input_tensor: nhwc
|
model:
|
||||||
input_pixel_format: bgr
|
width: 300
|
||||||
path: /openvino-model/ssdlite_mobilenet_v2.xml
|
height: 300
|
||||||
labelmap_path: /openvino-model/coco_91cl_bkgr.txt
|
input_tensor: nhwc
|
||||||
|
input_pixel_format: bgr
|
||||||
|
path: /openvino-model/ssdlite_mobilenet_v2.xml
|
||||||
|
labelmap_path: /openvino-model/coco_91cl_bkgr.txt
|
||||||
- key: yolo-legacy
|
- key: yolo-legacy
|
||||||
label: YOLO (v3, v4, v7)
|
label: YOLO (v3, v4, v7)
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -219,16 +235,19 @@ openvino:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov:
|
||||||
- openvino:GPU
|
type: openvino
|
||||||
model_type: yolo-generic
|
device: GPU # or NPU
|
||||||
width: 320 # <--- should match the imgsize set during model export
|
|
||||||
height: 320 # <--- should match the imgsize set during model export
|
model:
|
||||||
input_tensor: nchw
|
model_type: yolo-generic
|
||||||
input_dtype: float
|
width: 320 # <--- should match the imgsize set during model export
|
||||||
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
height: 320 # <--- should match the imgsize set during model export
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_tensor: nchw
|
||||||
|
input_dtype: float
|
||||||
|
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: yolonas
|
- key: yolonas
|
||||||
label: YOLO-NAS
|
label: YOLO-NAS
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -256,16 +275,19 @@ openvino:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `yolonas` |
|
| **Object Detection Model Type** | `yolonas` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov:
|
||||||
- openvino:GPU
|
type: openvino
|
||||||
model_type: yolonas
|
device: GPU
|
||||||
width: 320 # <--- should match whatever was set in notebook
|
|
||||||
height: 320 # <--- should match whatever was set in notebook
|
model:
|
||||||
input_tensor: nchw
|
model_type: yolonas
|
||||||
input_pixel_format: bgr
|
width: 320 # <--- should match whatever was set in notebook
|
||||||
path: /config/yolo_nas_s.onnx
|
height: 320 # <--- should match whatever was set in notebook
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_tensor: nchw
|
||||||
|
input_pixel_format: bgr
|
||||||
|
path: /config/yolo_nas_s.onnx
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: yolox
|
- key: yolox
|
||||||
label: YOLOX
|
label: YOLOX
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -281,12 +303,15 @@ openvino:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `yolox` |
|
| **Object Detection Model Type** | `yolox` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov:
|
||||||
- openvino:GPU
|
type: openvino
|
||||||
model_type: yolox
|
device: GPU
|
||||||
path: /config/model_cache/yolox.onnx # use the filename you generated above
|
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
model:
|
||||||
|
model_type: yolox
|
||||||
|
path: /config/model_cache/yolox.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: rfdetr
|
- key: rfdetr
|
||||||
label: RF-DETR
|
label: RF-DETR
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -320,15 +345,18 @@ openvino:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `rfdetr` |
|
| **Object Detection Model Type** | `rfdetr` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov:
|
||||||
- openvino:GPU
|
type: openvino
|
||||||
model_type: rfdetr
|
device: GPU
|
||||||
width: 320
|
|
||||||
height: 320
|
model:
|
||||||
input_tensor: nchw
|
model_type: rfdetr
|
||||||
input_dtype: float
|
width: 320
|
||||||
path: /config/model_cache/rfdetr.onnx # use the filename you generated above
|
height: 320
|
||||||
|
input_tensor: nchw
|
||||||
|
input_dtype: float
|
||||||
|
path: /config/model_cache/rfdetr.onnx # use the filename you generated above
|
||||||
- key: dfine
|
- key: dfine
|
||||||
label: D-FINE / DEIMv2
|
label: D-FINE / DEIMv2
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -415,16 +443,19 @@ openvino:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `dfine` |
|
| **Object Detection Model Type** | `dfine` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov:
|
||||||
- openvino:CPU
|
type: openvino
|
||||||
model_type: dfine
|
device: CPU
|
||||||
width: 640
|
|
||||||
height: 640
|
model:
|
||||||
input_tensor: nchw
|
model_type: dfine
|
||||||
input_dtype: float
|
width: 640
|
||||||
path: /config/model_cache/dfine-s.onnx # use the filename you generated above
|
height: 640
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_tensor: nchw
|
||||||
|
input_dtype: float
|
||||||
|
path: /config/model_cache/dfine-s.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
appleSilicon:
|
appleSilicon:
|
||||||
title: Apple Silicon
|
title: Apple Silicon
|
||||||
models:
|
models:
|
||||||
@@ -468,16 +499,19 @@ appleSilicon:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
apple-silicon:
|
||||||
- zmq:tcp://host.docker.internal:5555
|
type: zmq
|
||||||
model_type: yolo-generic
|
endpoint: tcp://host.docker.internal:5555
|
||||||
width: 320 # <--- should match the imgsize set during model export
|
|
||||||
height: 320 # <--- should match the imgsize set during model export
|
model:
|
||||||
input_tensor: nchw
|
model_type: yolo-generic
|
||||||
input_dtype: float
|
width: 320 # <--- should match the imgsize set during model export
|
||||||
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
height: 320 # <--- should match the imgsize set during model export
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_tensor: nchw
|
||||||
|
input_dtype: float
|
||||||
|
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: yolo-legacy
|
- key: yolo-legacy
|
||||||
label: YOLO (v3, v4, v7)
|
label: YOLO (v3, v4, v7)
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -504,16 +538,19 @@ appleSilicon:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
apple-silicon:
|
||||||
- zmq:tcp://host.docker.internal:5555
|
type: zmq
|
||||||
model_type: yolo-generic
|
endpoint: tcp://host.docker.internal:5555
|
||||||
width: 320 # <--- should match the imgsize set during model export
|
|
||||||
height: 320 # <--- should match the imgsize set during model export
|
model:
|
||||||
input_tensor: nchw
|
model_type: yolo-generic
|
||||||
input_dtype: float
|
width: 320 # <--- should match the imgsize set during model export
|
||||||
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
height: 320 # <--- should match the imgsize set during model export
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_tensor: nchw
|
||||||
|
input_dtype: float
|
||||||
|
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
onnx:
|
onnx:
|
||||||
title: ONNX
|
title: ONNX
|
||||||
models:
|
models:
|
||||||
@@ -557,16 +594,18 @@ onnx:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
onnx:
|
||||||
- onnx
|
type: onnx
|
||||||
model_type: yolo-generic
|
|
||||||
width: 320 # <--- should match the imgsize set during model export
|
model:
|
||||||
height: 320 # <--- should match the imgsize set during model export
|
model_type: yolo-generic
|
||||||
input_tensor: nchw
|
width: 320 # <--- should match the imgsize set during model export
|
||||||
input_dtype: float
|
height: 320 # <--- should match the imgsize set during model export
|
||||||
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
input_tensor: nchw
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_dtype: float
|
||||||
|
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: rfdetr
|
- key: rfdetr
|
||||||
label: RF-DETR
|
label: RF-DETR
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -600,15 +639,17 @@ onnx:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `rfdetr` |
|
| **Object Detection Model Type** | `rfdetr` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
onnx:
|
||||||
- onnx
|
type: onnx
|
||||||
model_type: rfdetr
|
|
||||||
width: 320
|
model:
|
||||||
height: 320
|
model_type: rfdetr
|
||||||
input_tensor: nchw
|
width: 320
|
||||||
input_dtype: float
|
height: 320
|
||||||
path: /config/model_cache/rfdetr.onnx # use the filename you generated above
|
input_tensor: nchw
|
||||||
|
input_dtype: float
|
||||||
|
path: /config/model_cache/rfdetr.onnx # use the filename you generated above
|
||||||
- key: yolonas
|
- key: yolonas
|
||||||
label: YOLO-NAS
|
label: YOLO-NAS
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -636,16 +677,18 @@ onnx:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `yolonas` |
|
| **Object Detection Model Type** | `yolonas` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
onnx:
|
||||||
- onnx
|
type: onnx
|
||||||
model_type: yolonas
|
|
||||||
width: 320 # <--- should match whatever was set in notebook
|
model:
|
||||||
height: 320 # <--- should match whatever was set in notebook
|
model_type: yolonas
|
||||||
input_pixel_format: bgr
|
width: 320 # <--- should match whatever was set in notebook
|
||||||
input_tensor: nchw
|
height: 320 # <--- should match whatever was set in notebook
|
||||||
path: /config/yolo_nas_s.onnx
|
input_pixel_format: bgr
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_tensor: nchw
|
||||||
|
path: /config/yolo_nas_s.onnx
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: yolox
|
- key: yolox
|
||||||
label: YOLOX
|
label: YOLOX
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -664,16 +707,18 @@ onnx:
|
|||||||
| **Model Input D Type** | `float_denorm` |
|
| **Model Input D Type** | `float_denorm` |
|
||||||
| **Object Detection Model Type** | `yolox` |
|
| **Object Detection Model Type** | `yolox` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
onnx:
|
||||||
- onnx
|
type: onnx
|
||||||
model_type: yolox
|
|
||||||
width: 416 # <--- should match the imgsize set during model export
|
model:
|
||||||
height: 416 # <--- should match the imgsize set during model export
|
model_type: yolox
|
||||||
input_tensor: nchw
|
width: 416 # <--- should match the imgsize set during model export
|
||||||
input_dtype: float_denorm
|
height: 416 # <--- should match the imgsize set during model export
|
||||||
path: /config/model_cache/yolox_tiny.onnx # use the filename you generated above
|
input_tensor: nchw
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_dtype: float_denorm
|
||||||
|
path: /config/model_cache/yolox_tiny.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: dfine
|
- key: dfine
|
||||||
label: D-FINE / DEIMv2
|
label: D-FINE / DEIMv2
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -760,16 +805,18 @@ onnx:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `dfine` |
|
| **Object Detection Model Type** | `dfine` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
onnx:
|
||||||
- onnx
|
type: onnx
|
||||||
model_type: dfine
|
|
||||||
width: 640
|
model:
|
||||||
height: 640
|
model_type: dfine
|
||||||
input_tensor: nchw
|
width: 640
|
||||||
input_dtype: float
|
height: 640
|
||||||
path: /config/model_cache/dfine_m_obj2coco.onnx # use the filename you generated above
|
input_tensor: nchw
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_dtype: float
|
||||||
|
path: /config/model_cache/dfine_m_obj2coco.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
- key: yolo-legacy
|
- key: yolo-legacy
|
||||||
label: YOLO (v3, v4, v7)
|
label: YOLO (v3, v4, v7)
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -796,16 +843,18 @@ onnx:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
onnx:
|
||||||
- onnx
|
type: onnx
|
||||||
model_type: yolo-generic
|
|
||||||
width: 320 # <--- should match the imgsize set during model export
|
model:
|
||||||
height: 320 # <--- should match the imgsize set during model export
|
model_type: yolo-generic
|
||||||
input_tensor: nchw
|
width: 320 # <--- should match the imgsize set during model export
|
||||||
input_dtype: float
|
height: 320 # <--- should match the imgsize set during model export
|
||||||
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
input_tensor: nchw
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
input_dtype: float
|
||||||
|
path: /config/model_cache/yolo.onnx # use the filename you generated above
|
||||||
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
cpu:
|
cpu:
|
||||||
title: CPU
|
title: CPU
|
||||||
models:
|
models:
|
||||||
@@ -821,9 +870,10 @@ cpu:
|
|||||||
| **Detector type** | `cpu` |
|
| **Detector type** | `cpu` |
|
||||||
| **Num threads** | `3` |
|
| **Num threads** | `3` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
cpu1:
|
||||||
- cpu:3
|
type: cpu
|
||||||
|
num_threads: 3
|
||||||
deepstack:
|
deepstack:
|
||||||
title: DeepStack / CodeProject.AI
|
title: DeepStack / CodeProject.AI
|
||||||
models:
|
models:
|
||||||
@@ -839,9 +889,11 @@ deepstack:
|
|||||||
| **API URL** | `http://<your_codeproject_ai_server_ip>:<port>/v1/vision/detection` |
|
| **API URL** | `http://<your_codeproject_ai_server_ip>:<port>/v1/vision/detection` |
|
||||||
| **API Timeout** | `0.1` (seconds) |
|
| **API Timeout** | `0.1` (seconds) |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
deepstack:
|
||||||
- deepstack:http://<your_codeproject_ai_server_ip>:<port>/v1/vision/detection
|
api_url: http://<your_codeproject_ai_server_ip>:<port>/v1/vision/detection
|
||||||
|
type: deepstack
|
||||||
|
api_timeout: 0.1 # seconds
|
||||||
memryx:
|
memryx:
|
||||||
title: MemryX
|
title: MemryX
|
||||||
models:
|
models:
|
||||||
@@ -871,20 +923,23 @@ memryx:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `yolonas` |
|
| **Object Detection Model Type** | `yolonas` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
memx0:
|
||||||
- memryx:PCIe:0
|
type: memryx
|
||||||
model_type: yolonas
|
device: PCIe:0
|
||||||
width: 320 # (Can be set to 640 for higher resolution)
|
|
||||||
height: 320 # (Can be set to 640 for higher resolution)
|
model:
|
||||||
input_tensor: nchw
|
model_type: yolonas
|
||||||
input_dtype: float
|
width: 320 # (Can be set to 640 for higher resolution)
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
height: 320 # (Can be set to 640 for higher resolution)
|
||||||
# Optional: The model is normally fetched through the runtime, so 'path' can be omitted unless you want to use a custom or local model.
|
input_tensor: nchw
|
||||||
# path: /config/yolonas.zip
|
input_dtype: float
|
||||||
# The .zip file must contain:
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
# ├── yolonas.dfp (a file ending with .dfp)
|
# Optional: The model is normally fetched through the runtime, so 'path' can be omitted unless you want to use a custom or local model.
|
||||||
# └── yolonas_post.onnx (optional; only if the model includes a cropped post-processing network)
|
# path: /config/yolonas.zip
|
||||||
|
# The .zip file must contain:
|
||||||
|
# ├── yolonas.dfp (a file ending with .dfp)
|
||||||
|
# └── yolonas_post.onnx (optional; only if the model includes a cropped post-processing network)
|
||||||
- key: yolov9
|
- key: yolov9
|
||||||
label: YOLOv9
|
label: YOLOv9
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -905,19 +960,22 @@ memryx:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
memx0:
|
||||||
- memryx:PCIe:0
|
type: memryx
|
||||||
model_type: yolo-generic
|
device: PCIe:0
|
||||||
width: 320 # (Can be set to 640 for higher resolution)
|
|
||||||
height: 320 # (Can be set to 640 for higher resolution)
|
model:
|
||||||
input_tensor: nchw
|
model_type: yolo-generic
|
||||||
input_dtype: float
|
width: 320 # (Can be set to 640 for higher resolution)
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
height: 320 # (Can be set to 640 for higher resolution)
|
||||||
# Optional: The model is normally fetched through the runtime, so 'path' can be omitted unless you want to use a custom or local model.
|
input_tensor: nchw
|
||||||
# path: /config/yolov9.zip
|
input_dtype: float
|
||||||
# The .zip file must contain:
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
# ├── yolov9.dfp (a file ending with .dfp)
|
# Optional: The model is normally fetched through the runtime, so 'path' can be omitted unless you want to use a custom or local model.
|
||||||
|
# path: /config/yolov9.zip
|
||||||
|
# The .zip file must contain:
|
||||||
|
# ├── yolov9.dfp (a file ending with .dfp)
|
||||||
- key: yolox
|
- key: yolox
|
||||||
label: YOLOX
|
label: YOLOX
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -938,19 +996,22 @@ memryx:
|
|||||||
| **Model Input D Type** | `float_denorm` |
|
| **Model Input D Type** | `float_denorm` |
|
||||||
| **Object Detection Model Type** | `yolox` |
|
| **Object Detection Model Type** | `yolox` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
memx0:
|
||||||
- memryx:PCIe:0
|
type: memryx
|
||||||
model_type: yolox
|
device: PCIe:0
|
||||||
width: 640
|
|
||||||
height: 640
|
model:
|
||||||
input_tensor: nchw
|
model_type: yolox
|
||||||
input_dtype: float_denorm
|
width: 640
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
height: 640
|
||||||
# Optional: The model is normally fetched through the runtime, so 'path' can be omitted unless you want to use a custom or local model.
|
input_tensor: nchw
|
||||||
# path: /config/yolox.zip
|
input_dtype: float_denorm
|
||||||
# The .zip file must contain:
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
# ├── yolox.dfp (a file ending with .dfp)
|
# Optional: The model is normally fetched through the runtime, so 'path' can be omitted unless you want to use a custom or local model.
|
||||||
|
# path: /config/yolox.zip
|
||||||
|
# The .zip file must contain:
|
||||||
|
# ├── yolox.dfp (a file ending with .dfp)
|
||||||
- key: ssd
|
- key: ssd
|
||||||
label: SSDLite MobileNet v2
|
label: SSDLite MobileNet v2
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -971,20 +1032,23 @@ memryx:
|
|||||||
| **Model Input D Type** | `float` |
|
| **Model Input D Type** | `float` |
|
||||||
| **Object Detection Model Type** | `ssd` |
|
| **Object Detection Model Type** | `ssd` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
memx0:
|
||||||
- memryx:PCIe:0
|
type: memryx
|
||||||
model_type: ssd
|
device: PCIe:0
|
||||||
width: 320
|
|
||||||
height: 320
|
model:
|
||||||
input_tensor: nchw
|
model_type: ssd
|
||||||
input_dtype: float
|
width: 320
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
height: 320
|
||||||
# Optional: The model is normally fetched through the runtime, so 'path' can be omitted unless you want to use a custom or local model.
|
input_tensor: nchw
|
||||||
# path: /config/ssdlite_mobilenet.zip
|
input_dtype: float
|
||||||
# The .zip file must contain:
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
# ├── ssdlite_mobilenet.dfp (a file ending with .dfp)
|
# Optional: The model is normally fetched through the runtime, so 'path' can be omitted unless you want to use a custom or local model.
|
||||||
# └── ssdlite_mobilenet_post.onnx (optional; only if the model includes a cropped post-processing network)
|
# path: /config/ssdlite_mobilenet.zip
|
||||||
|
# The .zip file must contain:
|
||||||
|
# ├── ssdlite_mobilenet.dfp (a file ending with .dfp)
|
||||||
|
# └── ssdlite_mobilenet_post.onnx (optional; only if the model includes a cropped post-processing network)
|
||||||
tensorrt:
|
tensorrt:
|
||||||
title: TensorRT
|
title: TensorRT
|
||||||
models:
|
models:
|
||||||
@@ -1018,15 +1082,18 @@ tensorrt:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `ssd` (Frigate's default value) |
|
| **Object Detection Model Type** | `ssd` (Frigate's default value) |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
tensorrt:
|
||||||
- tensorrt:0
|
type: tensorrt
|
||||||
path: /config/model_cache/tensorrt/yolov7-320.trt # use the filename you generated above
|
device: 0 #This is the default, select the first GPU
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
|
||||||
input_tensor: nchw
|
model:
|
||||||
input_pixel_format: rgb
|
path: /config/model_cache/tensorrt/yolov7-320.trt # use the filename you generated above
|
||||||
width: 320 # MUST match the chosen model i.e yolov7-320 -> 320, yolov4-416 -> 416
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
height: 320 # MUST match the chosen model i.e yolov7-320 -> 320 yolov4-416 -> 416
|
input_tensor: nchw
|
||||||
|
input_pixel_format: rgb
|
||||||
|
width: 320 # MUST match the chosen model i.e yolov7-320 -> 320, yolov4-416 -> 416
|
||||||
|
height: 320 # MUST match the chosen model i.e yolov7-320 -> 320 yolov4-416 -> 416
|
||||||
synaptics:
|
synaptics:
|
||||||
title: Synaptics
|
title: Synaptics
|
||||||
models:
|
models:
|
||||||
@@ -1048,15 +1115,16 @@ synaptics:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `ssd` (Frigate's default value) |
|
| **Object Detection Model Type** | `ssd` (Frigate's default value) |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
detectors: # required
|
||||||
- # required
|
synap_npu: # required
|
||||||
devices:
|
type: synaptics # required
|
||||||
- synaptics
|
|
||||||
path: /synaptics/mobilenet.synap # required
|
model: # required
|
||||||
width: 224 # required
|
path: /synaptics/mobilenet.synap # required
|
||||||
height: 224 # required
|
width: 224 # required
|
||||||
input_tensor: nhwc # default value (optional. If you change the model, it is required)
|
height: 224 # required
|
||||||
labelmap_path: /labelmap/coco-80.txt # required
|
input_tensor: nhwc # default value (optional. If you change the model, it is required)
|
||||||
|
labelmap_path: /labelmap/coco-80.txt # required
|
||||||
rknn:
|
rknn:
|
||||||
title: RKNN
|
title: RKNN
|
||||||
models:
|
models:
|
||||||
@@ -1081,23 +1149,21 @@ rknn:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
model: # required
|
||||||
- devices:
|
# name of model (will be automatically downloaded) or path to your own .rknn model file
|
||||||
- rknn
|
# possible values are:
|
||||||
# name of model (will be automatically downloaded) or path to your own .rknn model file
|
# - frigate-fp16-yolov9-t
|
||||||
# possible values are:
|
# - frigate-fp16-yolov9-s
|
||||||
# - frigate-fp16-yolov9-t
|
# - frigate-fp16-yolov9-m
|
||||||
# - frigate-fp16-yolov9-s
|
# - frigate-fp16-yolov9-c
|
||||||
# - frigate-fp16-yolov9-m
|
# - frigate-fp16-yolov9-e
|
||||||
# - frigate-fp16-yolov9-c
|
# your yolo_model.rknn
|
||||||
# - frigate-fp16-yolov9-e
|
path: frigate-fp16-yolov9-t
|
||||||
# your yolo_model.rknn
|
model_type: yolo-generic
|
||||||
path: frigate-fp16-yolov9-t
|
width: 320
|
||||||
model_type: yolo-generic
|
height: 320
|
||||||
width: 320
|
input_tensor: nhwc
|
||||||
height: 320
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
input_tensor: nhwc
|
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
|
||||||
- key: yolonas
|
- key: yolonas
|
||||||
label: YOLO-NAS
|
label: YOLO-NAS
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -1121,22 +1187,20 @@ rknn:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `yolonas` |
|
| **Object Detection Model Type** | `yolonas` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
model: # required
|
||||||
- devices:
|
# name of model (will be automatically downloaded) or path to your own .rknn model file
|
||||||
- rknn
|
# possible values are:
|
||||||
# name of model (will be automatically downloaded) or path to your own .rknn model file
|
# - deci-fp16-yolonas_s
|
||||||
# possible values are:
|
# - deci-fp16-yolonas_m
|
||||||
# - deci-fp16-yolonas_s
|
# - deci-fp16-yolonas_l
|
||||||
# - deci-fp16-yolonas_m
|
# your yolonas_model.rknn
|
||||||
# - deci-fp16-yolonas_l
|
path: deci-fp16-yolonas_s
|
||||||
# your yolonas_model.rknn
|
model_type: yolonas
|
||||||
path: deci-fp16-yolonas_s
|
width: 320
|
||||||
model_type: yolonas
|
height: 320
|
||||||
width: 320
|
input_pixel_format: bgr
|
||||||
height: 320
|
input_tensor: nhwc
|
||||||
input_pixel_format: bgr
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
input_tensor: nhwc
|
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
|
||||||
- key: yolox
|
- key: yolox
|
||||||
label: YOLOx
|
label: YOLOx
|
||||||
recommended: false
|
recommended: false
|
||||||
@@ -1158,22 +1222,20 @@ rknn:
|
|||||||
| **Model Input D Type** | `int` (Frigate's default value) |
|
| **Model Input D Type** | `int` (Frigate's default value) |
|
||||||
| **Object Detection Model Type** | `yolox` |
|
| **Object Detection Model Type** | `yolox` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
models:
|
model: # required
|
||||||
- devices:
|
# name of model (will be automatically downloaded) or path to your own .rknn model file
|
||||||
- rknn
|
# possible values are:
|
||||||
# name of model (will be automatically downloaded) or path to your own .rknn model file
|
# - rock-i8-yolox_nano
|
||||||
# possible values are:
|
# - rock-i8-yolox_tiny
|
||||||
# - rock-i8-yolox_nano
|
# - rock-fp16-yolox_nano
|
||||||
# - rock-i8-yolox_tiny
|
# - rock-fp16-yolox_tiny
|
||||||
# - rock-fp16-yolox_nano
|
# your yolox_model.rknn
|
||||||
# - rock-fp16-yolox_tiny
|
path: rock-i8-yolox_nano
|
||||||
# your yolox_model.rknn
|
model_type: yolox
|
||||||
path: rock-i8-yolox_nano
|
width: 416
|
||||||
model_type: yolox
|
height: 416
|
||||||
width: 416
|
input_tensor: nhwc
|
||||||
height: 416
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
input_tensor: nhwc
|
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
|
||||||
axengine:
|
axengine:
|
||||||
title: AXEngine
|
title: AXEngine
|
||||||
models:
|
models:
|
||||||
@@ -1195,7 +1257,6 @@ axengine:
|
|||||||
| **Model Input D Type** | `int` |
|
| **Model Input D Type** | `int` |
|
||||||
| **Object Detection Model Type** | `yolo-generic` |
|
| **Object Detection Model Type** | `yolo-generic` |
|
||||||
yaml: |-
|
yaml: |-
|
||||||
<<<<<<< HEAD
|
|
||||||
detectors:
|
detectors:
|
||||||
axengine:
|
axengine:
|
||||||
type: axengine
|
type: axengine
|
||||||
@@ -1208,96 +1269,3 @@ axengine:
|
|||||||
input_dtype: int
|
input_dtype: int
|
||||||
input_pixel_format: bgr
|
input_pixel_format: bgr
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
labelmap_path: /labelmap/coco-80.txt
|
||||||
=======
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- axengine
|
|
||||||
path: frigate-yolov9-tiny
|
|
||||||
model_type: yolo-generic
|
|
||||||
width: 320
|
|
||||||
height: 320
|
|
||||||
input_dtype: int
|
|
||||||
input_pixel_format: bgr
|
|
||||||
labelmap_path: /labelmap/coco-80.txt
|
|
||||||
degirumAiServer:
|
|
||||||
title: DeGirum AI Server
|
|
||||||
models:
|
|
||||||
- key: ai-server-inference
|
|
||||||
label: AI Server Inference
|
|
||||||
recommended: true
|
|
||||||
download: |-
|
|
||||||
Launch a DeGirum AI server as a Docker container, then point the detector at it. Add this to your `docker-compose.yml`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
degirum_detector:
|
|
||||||
container_name: degirum
|
|
||||||
image: degirum/aiserver:latest
|
|
||||||
privileged: true
|
|
||||||
ports:
|
|
||||||
- "8778:8778"
|
|
||||||
```
|
|
||||||
|
|
||||||
Set `location` to the server's service name, container name, or `host:port`.
|
|
||||||
ui: |
|
|
||||||
Navigate to **Settings > System > Detectors and model** and select **DeGirum** from the detector type dropdown and click **Add**.
|
|
||||||
|
|
||||||
| Field | Value |
|
|
||||||
| --- | --- |
|
|
||||||
| **Location** | `degirum` |
|
|
||||||
| **Zoo** | `degirum/public` |
|
|
||||||
| **Token** | your AI Hub token (optional for the public zoo) |
|
|
||||||
yaml: |
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- degirum:degirum
|
|
||||||
path: ./mobilenet_v2_ssd_coco--300x300_quant_n2x_orca1_1
|
|
||||||
width: 300
|
|
||||||
height: 300
|
|
||||||
input_pixel_format: rgb
|
|
||||||
degirumLocal:
|
|
||||||
title: DeGirum Local
|
|
||||||
models:
|
|
||||||
- key: local-inference
|
|
||||||
label: Local Inference
|
|
||||||
recommended: true
|
|
||||||
download: Run hardware directly inside the Frigate container with `@local`, removing the AI server hop. The matching device runtime (e.g. the Hailo runtime) must be installed in the container; confirm it with `degirum sys-info`.
|
|
||||||
ui: |
|
|
||||||
Navigate to **Settings > System > Detectors and model** and select **DeGirum** from the detector type dropdown and click **Add**.
|
|
||||||
|
|
||||||
| Field | Value |
|
|
||||||
| --- | --- |
|
|
||||||
| **Location** | `@local` |
|
|
||||||
| **Zoo** | `degirum/public` |
|
|
||||||
| **Token** | your AI Hub token (optional for the public zoo) |
|
|
||||||
yaml: |
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- degirum:@local
|
|
||||||
path: ./mobilenet_v2_ssd_coco--300x300_quant_n2x_orca1_1
|
|
||||||
width: 300
|
|
||||||
height: 300
|
|
||||||
input_pixel_format: rgb
|
|
||||||
degirumCloud:
|
|
||||||
title: DeGirum AI Hub Cloud
|
|
||||||
models:
|
|
||||||
- key: ai-hub-cloud-inference
|
|
||||||
label: AI Hub Cloud Inference
|
|
||||||
recommended: true
|
|
||||||
download: Run inferences on DeGirum's [AI Hub](https://hub.degirum.com) cloud with `@cloud`. Sign up, create an access token, and set it as `token`. Network latency may require lowering your detection fps.
|
|
||||||
ui: |
|
|
||||||
Navigate to **Settings > System > Detectors and model** and select **DeGirum** from the detector type dropdown and click **Add**.
|
|
||||||
|
|
||||||
| Field | Value |
|
|
||||||
| --- | --- |
|
|
||||||
| **Location** | `@cloud` |
|
|
||||||
| **Zoo** | `degirum/public` |
|
|
||||||
| **Token** | your AI Hub token (optional for the public zoo) |
|
|
||||||
yaml: |
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- degirum:@cloud
|
|
||||||
path: ./mobilenet_v2_ssd_coco--300x300_quant_n2x_orca1_1
|
|
||||||
width: 300
|
|
||||||
height: 300
|
|
||||||
input_pixel_format: rgb
|
|
||||||
>>>>>>> 34363affa (Refactor detector and model management)
|
|
||||||
|
|||||||
@@ -56,6 +56,17 @@ mqtt:
|
|||||||
# 2 = exactly once
|
# 2 = exactly once
|
||||||
qos: 0
|
qos: 0
|
||||||
|
|
||||||
|
# Optional: Detectors configuration. Defaults to a single CPU detector
|
||||||
|
detectors:
|
||||||
|
# Required: name of the detector
|
||||||
|
detector_name:
|
||||||
|
# Required: type of the detector
|
||||||
|
# Frigate provides many types, see https://docs.frigate.video/configuration/object_detectors for more details (default: shown below)
|
||||||
|
# Additional detector types can also be plugged in.
|
||||||
|
# Detectors may require additional configuration.
|
||||||
|
# Refer to the Detectors configuration page for more information.
|
||||||
|
type: cpu
|
||||||
|
|
||||||
# Optional: Database configuration
|
# Optional: Database configuration
|
||||||
database:
|
database:
|
||||||
# The path to store the SQLite DB (default: shown below)
|
# The path to store the SQLite DB (default: shown below)
|
||||||
@@ -146,56 +157,44 @@ auth:
|
|||||||
- front_door
|
- front_door
|
||||||
- back_yard
|
- back_yard
|
||||||
|
|
||||||
# Optional: object detection models. Defaults to a single model on a CPU detector.
|
# Optional: model modifications
|
||||||
# NOTE: The default values are for the EdgeTPU detector.
|
# NOTE: The default values are for the EdgeTPU detector.
|
||||||
# Other detectors will require the model config to be set.
|
# Other detectors will require the model config to be set.
|
||||||
models:
|
model:
|
||||||
# Optional: the camera environment this model is for (default: shown below)
|
# Required: path to the model. Frigate+ models use plus://<model_id> (default: automatic based on detector)
|
||||||
# Cameras select a model by setting detect -> scene to a matching value, and
|
path: /edgetpu_model.tflite
|
||||||
# a model with a scene of all is used by any camera that does not set one.
|
# Required: path to the labelmap (default: shown below)
|
||||||
# Valid values are all, indoor, outdoor, indoor_thermal, outdoor_thermal
|
labelmap_path: /labelmap.txt
|
||||||
- scene: all
|
# Required: Object detection model input width (default: shown below)
|
||||||
# Required: hardware this model runs on, as <detector> or <detector>:<device>
|
width: 320
|
||||||
# See https://docs.frigate.video/configuration/object_detectors for the
|
# Required: Object detection model input height (default: shown below)
|
||||||
# detectors available and the devices each one accepts. All of a model's
|
height: 320
|
||||||
# devices must use the same detector. Listing the same device more than once
|
# Required: Object detection model input colorspace
|
||||||
# runs additional inference processes on it.
|
# Valid values are rgb, bgr, or yuv. (default: shown below)
|
||||||
devices:
|
input_pixel_format: rgb
|
||||||
- edgetpu:pci:0
|
# Required: Object detection model input tensor format
|
||||||
# Required: path to the model. Frigate+ models use plus://<model_id> (default: automatic based on detector)
|
# Valid values are nhwc, nchw, hwnc, or hwcn (default: shown below)
|
||||||
path: /edgetpu_model.tflite
|
input_tensor: nhwc
|
||||||
# Required: path to the labelmap (default: shown below)
|
# Optional: Data type of the model input tensor
|
||||||
labelmap_path: /labelmap.txt
|
# Valid values are float, float_denorm, or int (default: shown below)
|
||||||
# Required: Object detection model input width (default: shown below)
|
input_dtype: int
|
||||||
width: 320
|
# Required: Object detection model architecture, used by detectors that support more
|
||||||
# Required: Object detection model input height (default: shown below)
|
# than one model type (openvino, onnx, rknn, memryx, axengine, synaptics, and others)
|
||||||
height: 320
|
# Valid values are ssd, yolox, yolonas, yolo-generic, rfdetr, dfine (default: shown below)
|
||||||
# Required: Object detection model input colorspace
|
model_type: ssd
|
||||||
# Valid values are rgb, bgr, or yuv. (default: shown below)
|
# Required: Label name modifications. These are merged into the standard labelmap.
|
||||||
input_pixel_format: rgb
|
labelmap:
|
||||||
# Required: Object detection model input tensor format
|
2: vehicle
|
||||||
# Valid values are nhwc, nchw, hwnc, or hwcn (default: shown below)
|
# Optional: Map of object labels to their attribute labels (default: depends on model)
|
||||||
input_tensor: nhwc
|
attributes_map:
|
||||||
# Optional: Data type of the model input tensor
|
person:
|
||||||
# Valid values are float, float_denorm, or int (default: shown below)
|
- amazon
|
||||||
input_dtype: int
|
- face
|
||||||
# Required: Object detection model architecture, used by detectors that support more
|
car:
|
||||||
# than one model type (openvino, onnx, rknn, memryx, axengine, synaptics, and others)
|
- amazon
|
||||||
# Valid values are ssd, yolox, yolonas, yolo-generic, rfdetr, dfine (default: shown below)
|
- fedex
|
||||||
model_type: ssd
|
- license_plate
|
||||||
# Required: Label name modifications. These are merged into the standard labelmap.
|
- ups
|
||||||
labelmap:
|
|
||||||
2: vehicle
|
|
||||||
# Optional: Map of object labels to their attribute labels (default: depends on model)
|
|
||||||
attributes_map:
|
|
||||||
person:
|
|
||||||
- amazon
|
|
||||||
- face
|
|
||||||
car:
|
|
||||||
- amazon
|
|
||||||
- fedex
|
|
||||||
- license_plate
|
|
||||||
- ups
|
|
||||||
|
|
||||||
# Optional: Audio Events Configuration
|
# Optional: Audio Events Configuration
|
||||||
# NOTE: Can be overridden at the camera level
|
# NOTE: Can be overridden at the camera level
|
||||||
@@ -252,17 +251,11 @@ birdseye:
|
|||||||
# Optional: Encoding quality of the mpeg1 feed (default: shown below)
|
# Optional: Encoding quality of the mpeg1 feed (default: shown below)
|
||||||
# 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
|
# 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
|
||||||
quality: 8
|
quality: 8
|
||||||
# Optional: Activity types that include cameras in Birdseye (default: shown below)
|
# Optional: Mode of the view. Available options are: objects, motion, and continuous
|
||||||
# Multiple activity types can be enabled at the same time.
|
# objects - cameras are included if they have had a tracked object within the last 30 seconds
|
||||||
mode:
|
# motion - cameras are included if motion was detected in the last 30 seconds
|
||||||
# Optional: All cameras are included always (default: shown below)
|
# continuous - all cameras are included always
|
||||||
continuous: False
|
mode: objects
|
||||||
# Optional: Cameras are included if motion was detected in the last 30 seconds (default: shown below)
|
|
||||||
motion: False
|
|
||||||
# Optional: Cameras are included if they have had an active tracked object within the last 30 seconds (default: shown below)
|
|
||||||
objects: True
|
|
||||||
# Optional: Cameras are included while they have a stationary tracked object (default: shown below)
|
|
||||||
stationary_objects: False
|
|
||||||
# Optional: Threshold for camera activity to stop showing camera (default: shown below)
|
# Optional: Threshold for camera activity to stop showing camera (default: shown below)
|
||||||
inactivity_threshold: 30
|
inactivity_threshold: 30
|
||||||
# Optional: Configure the birdseye layout
|
# Optional: Configure the birdseye layout
|
||||||
@@ -313,10 +306,6 @@ detect:
|
|||||||
width: 1280
|
width: 1280
|
||||||
# Optional: height of the frame for the input with the detect role (default: use native stream resolution)
|
# Optional: height of the frame for the input with the detect role (default: use native stream resolution)
|
||||||
height: 720
|
height: 720
|
||||||
# Optional: the environment this camera looks at, which picks the model it runs on
|
|
||||||
# (default: the model with a scene of all)
|
|
||||||
# Valid values are all, indoor, outdoor, indoor_thermal, outdoor_thermal
|
|
||||||
scene: outdoor
|
|
||||||
# Optional: desired fps for your camera for the input with the detect role (default: shown below)
|
# Optional: desired fps for your camera for the input with the detect role (default: shown below)
|
||||||
# NOTE: Recommended value of 5. Ideally, try and reduce your FPS on the camera.
|
# NOTE: Recommended value of 5. Ideally, try and reduce your FPS on the camera.
|
||||||
fps: 5
|
fps: 5
|
||||||
|
|||||||
@@ -192,14 +192,12 @@ Navigate to <NavPath path="Settings > System > Detectors and model" /> and open
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Optional: model config
|
# Optional: model config
|
||||||
models:
|
model:
|
||||||
- devices:
|
path: /path/to/model
|
||||||
- openvino:GPU
|
width: 320
|
||||||
path: /path/to/model
|
height: 320
|
||||||
width: 320
|
input_tensor: "nhwc"
|
||||||
height: 320
|
input_pixel_format: "bgr"
|
||||||
input_tensor: "nhwc"
|
|
||||||
input_pixel_format: "bgr"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -216,15 +214,15 @@ If the labelmap is customized then the labels used for alerts will need to be ad
|
|||||||
The labelmap can be customized to your needs. A common reason to do this is to combine multiple object types that are easily confused when you don't need to be as granular such as car/truck. By default, truck is renamed to car because they are often confused. You cannot add new object types, but you can change the names of existing objects in the model.
|
The labelmap can be customized to your needs. A common reason to do this is to combine multiple object types that are easily confused when you don't need to be as granular such as car/truck. By default, truck is renamed to car because they are often confused. You cannot add new object types, but you can change the names of existing objects in the model.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
model:
|
||||||
- labelmap:
|
labelmap:
|
||||||
2: vehicle
|
2: vehicle
|
||||||
3: vehicle
|
3: vehicle
|
||||||
5: vehicle
|
5: vehicle
|
||||||
7: vehicle
|
7: vehicle
|
||||||
15: animal
|
15: animal
|
||||||
16: animal
|
16: animal
|
||||||
17: animal
|
17: animal
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that if you rename objects in the labelmap, you will also need to update your `objects -> track` list as well.
|
Note that if you rename objects in the labelmap, you will also need to update your `objects -> track` list as well.
|
||||||
|
|||||||
@@ -18,14 +18,13 @@ Each camera tile in Birdseye is composed from the frames of the stream assigned
|
|||||||
|
|
||||||
## Birdseye Behavior
|
## Birdseye Behavior
|
||||||
|
|
||||||
### Birdseye Activity Types
|
### Birdseye Modes
|
||||||
|
|
||||||
Birdseye offers independent activity types that control when cameras are shown. Multiple activity types can be enabled together.
|
Birdseye offers different modes to customize which cameras show under which circumstances.
|
||||||
|
|
||||||
- **continuous:** The camera is always included
|
- **continuous:** All cameras are always included
|
||||||
- **motion:** The camera is included when motion was detected within the last 30 seconds
|
- **motion:** Cameras that have detected motion within the last 30 seconds are included
|
||||||
- **objects:** The camera is included when an active object was tracked within the last 30 seconds
|
- **objects:** Cameras that have tracked an active object within the last 30 seconds are included
|
||||||
- **stationary_objects:** The camera is included while a stationary object is tracked
|
|
||||||
|
|
||||||
### Custom Birdseye Icon
|
### Custom Birdseye Icon
|
||||||
|
|
||||||
@@ -40,30 +39,27 @@ To include a camera in Birdseye view only for specific circumstances, or exclude
|
|||||||
|
|
||||||
**Global settings:** Navigate to <NavPath path="Settings > System > Birdseye" /> to configure the default Birdseye behavior for all cameras.
|
**Global settings:** Navigate to <NavPath path="Settings > System > Birdseye" /> to configure the default Birdseye behavior for all cameras.
|
||||||
|
|
||||||
**Per-camera overrides:** Navigate to <NavPath path="Settings > Camera configuration > Birdseye" /> to override the activity types or disable Birdseye for a specific camera.
|
**Per-camera overrides:** Navigate to <NavPath path="Settings > Camera configuration > Birdseye" /> to override the mode or disable Birdseye for a specific camera.
|
||||||
|
|
||||||
| Field | Description |
|
| Field | Description |
|
||||||
| ---------------------- | ---------------------------------------------------------- |
|
| ------------------- | ------------------------------------------------------------- |
|
||||||
| **Enable Birdseye** | Whether this camera appears in Birdseye view |
|
| **Enable Birdseye** | Whether this camera appears in Birdseye view |
|
||||||
| **Activity types** | Conditions that determine when to show the camera |
|
| **Tracking mode** | When to show the camera: `continuous`, `motion`, or `objects` |
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="yaml">
|
<TabItem value="yaml">
|
||||||
|
|
||||||
```yaml {8-11,13-15}
|
```yaml {8-10,12-14}
|
||||||
# Include all cameras by default in Birdseye view
|
# Include all cameras by default in Birdseye view
|
||||||
birdseye:
|
birdseye:
|
||||||
enabled: True
|
enabled: True
|
||||||
mode:
|
mode: continuous
|
||||||
continuous: True
|
|
||||||
|
|
||||||
cameras:
|
cameras:
|
||||||
front:
|
front:
|
||||||
# Only include the "front" camera in Birdseye view when objects are detected
|
# Only include the "front" camera in Birdseye view when objects are detected
|
||||||
birdseye:
|
birdseye:
|
||||||
mode:
|
mode: objects
|
||||||
continuous: False
|
|
||||||
objects: True
|
|
||||||
back:
|
back:
|
||||||
# Exclude the "back" camera from Birdseye view
|
# Exclude the "back" camera from Birdseye view
|
||||||
birdseye:
|
birdseye:
|
||||||
|
|||||||
@@ -172,9 +172,10 @@ mqtt:
|
|||||||
ffmpeg:
|
ffmpeg:
|
||||||
hwaccel_args: preset-rpi-64-h264
|
hwaccel_args: preset-rpi-64-h264
|
||||||
|
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral:
|
||||||
- edgetpu:usb
|
type: edgetpu
|
||||||
|
device: usb
|
||||||
|
|
||||||
record:
|
record:
|
||||||
enabled: True
|
enabled: True
|
||||||
@@ -248,9 +249,10 @@ mqtt:
|
|||||||
ffmpeg:
|
ffmpeg:
|
||||||
hwaccel_args: preset-vaapi
|
hwaccel_args: preset-vaapi
|
||||||
|
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral:
|
||||||
- edgetpu:usb
|
type: edgetpu
|
||||||
|
device: usb
|
||||||
|
|
||||||
record:
|
record:
|
||||||
enabled: True
|
enabled: True
|
||||||
@@ -327,12 +329,15 @@ mqtt:
|
|||||||
ffmpeg:
|
ffmpeg:
|
||||||
hwaccel_args: preset-vaapi
|
hwaccel_args: preset-vaapi
|
||||||
|
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov:
|
||||||
- openvino:AUTO
|
type: openvino
|
||||||
width: 300
|
device: AUTO
|
||||||
height: 300
|
|
||||||
input_tensor: nhwc
|
model:
|
||||||
|
width: 300
|
||||||
|
height: 300
|
||||||
|
input_tensor: nhwc
|
||||||
input_pixel_format: bgr
|
input_pixel_format: bgr
|
||||||
path: /openvino-model/ssdlite_mobilenet_v2.xml
|
path: /openvino-model/ssdlite_mobilenet_v2.xml
|
||||||
labelmap_path: /openvino-model/coco_91cl_bkgr.txt
|
labelmap_path: /openvino-model/coco_91cl_bkgr.txt
|
||||||
|
|||||||
@@ -59,13 +59,17 @@ Running Generative AI models on CPU is not recommended, as high inference times
|
|||||||
|
|
||||||
### Recommended Local Models
|
### Recommended Local Models
|
||||||
|
|
||||||
|
#### Vision models
|
||||||
|
|
||||||
You must use a vision-capable model with Frigate. The following models are recommended for local deployment of the `descriptions` and `chat` roles:
|
You must use a vision-capable model with Frigate. The following models are recommended for local deployment of the `descriptions` and `chat` roles:
|
||||||
|
|
||||||
| Model | Notes |
|
| Model | Notes |
|
||||||
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `qwen3-vl` | Strong visual and situational understanding, enhanced ability to identify smaller objects and interactions with object. |
|
| `qwen3-vl` | Strong visual and situational understanding, enhanced ability to identify smaller objects and interactions with object. |
|
||||||
| `qwen3.6` | Strong situational understanding, but missing DeepStack from qwen3-vl leading to worse performance for identifying objects in people's hand and other small details. |
|
| `qwen3.6`/`qwen3.8` | Strong situational understanding, but missing DeepStack from qwen3-vl leading to worse performance for identifying objects in people's hand and other small details. |
|
||||||
| `gemma4` | Strong situational understanding, sometimes resorts to more vague terms like 'interacts' instead of assigning a specific action. |
|
| `gemma4` | Strong situational understanding, sometimes resorts to more vague terms like 'interacts' instead of assigning a specific action. |
|
||||||
|
|
||||||
|
#### Embedding models
|
||||||
|
|
||||||
The `embeddings` role needs a different kind of model. Text queries are matched against the stored image embeddings, so the model must be trained to place images and text into the same vector space. A chat or description model will still return vectors when asked, but those vectors are not trained for retrieval and text searches will return poor matches with no error to indicate why.
|
The `embeddings` role needs a different kind of model. Text queries are matched against the stored image embeddings, so the model must be trained to place images and text into the same vector space. A chat or description model will still return vectors when asked, but those vectors are not trained for retrieval and text searches will return poor matches with no error to indicate why.
|
||||||
|
|
||||||
|
|||||||
@@ -68,66 +68,12 @@ Frigate supports multiple different detectors that work on different types of ha
|
|||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|
||||||
A single model can not be spread across different detector types (ex: OpenVINO and Coral EdgeTPU can not run the same model at the same time). Configuring more than one model, each on its own detector type, is supported.
|
Multiple detectors can not be mixed for object detection (ex: OpenVINO and Coral EdgeTPU can not be used for object detection at the same time).
|
||||||
|
|
||||||
This does not affect using hardware for accelerating other tasks such as [semantic search](./semantic_search.md)
|
This does not affect using hardware for accelerating other tasks such as [semantic search](./semantic_search.md)
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Configuring models and hardware
|
|
||||||
|
|
||||||
Object detection is configured with a `models` list. Each entry describes one model and the hardware it runs on:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- openvino:GPU
|
|
||||||
path: /config/model_cache/yolov9-s.onnx
|
|
||||||
model_type: yolo-generic
|
|
||||||
width: 320
|
|
||||||
height: 320
|
|
||||||
```
|
|
||||||
|
|
||||||
Each entry in `devices` is a detector type, optionally followed by a colon and a device for that detector, such as `edgetpu:pci:0`, `openvino:NPU`, or `tensorrt:0`. The per-detector sections below document the device values each one accepts. Listing several devices runs the model on all of them, and listing the **same** device more than once runs additional inference processes against it, which can improve throughput on hardware that keeps up with more than one stream:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- openvino:GPU
|
|
||||||
- openvino:GPU
|
|
||||||
```
|
|
||||||
|
|
||||||
Coral EdgeTPU and MemryX accelerators can only be opened by one process, so those devices can not be repeated.
|
|
||||||
|
|
||||||
### Running more than one model
|
|
||||||
|
|
||||||
Cameras can be split across models by scene, which is useful when indoor and outdoor cameras benefit from differently trained models. Each model declares the `scene` it is for, and each camera picks one with `detect -> scene`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
models:
|
|
||||||
- scene: outdoor
|
|
||||||
path: plus://your-outdoor-model
|
|
||||||
devices:
|
|
||||||
- edgetpu:pci:0
|
|
||||||
- scene: indoor
|
|
||||||
path: /config/model_cache/indoor.onnx
|
|
||||||
model_type: yolo-generic
|
|
||||||
devices:
|
|
||||||
- openvino:GPU
|
|
||||||
|
|
||||||
cameras:
|
|
||||||
driveway:
|
|
||||||
detect:
|
|
||||||
scene: outdoor
|
|
||||||
...
|
|
||||||
hallway:
|
|
||||||
detect:
|
|
||||||
scene: indoor
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
Available scenes are `all`, `indoor`, `outdoor`, `indoor_thermal`, and `outdoor_thermal`. A model with a scene of `all` is used by every camera that does not set one, and `all` is the default when a model does not declare a scene. Changing a camera's scene requires a restart.
|
|
||||||
|
|
||||||
### Choosing a model size
|
### Choosing a model size
|
||||||
|
|
||||||
Along with picking a detector for your hardware, you will choose a model's **input resolution** (such as `320x320` or `640x640`) and, for model families like YOLOv9, a **variant size** (`tiny`, `small`, etc.). Both affect the balance between accuracy and the inference time your hardware can sustain.
|
Along with picking a detector for your hardware, you will choose a model's **input resolution** (such as `320x320` or `640x640`) and, for model families like YOLOv9, a **variant size** (`tiny`, `small`, etc.). Both affect the balance between accuracy and the inference time your hardware can sustain.
|
||||||
@@ -146,11 +92,11 @@ The best detection accuracy comes from a model trained on images that look like
|
|||||||
|
|
||||||
# Officially Supported Detectors
|
# Officially Supported Detectors
|
||||||
|
|
||||||
Frigate provides a number of builtin detector types. By default, Frigate will use a single CPU detector. Other detectors may require additional configuration as described below. Each of a model's devices runs in a dedicated process, and they pull from a common queue of detection requests from the cameras assigned to that model.
|
Frigate provides a number of builtin detector types. By default, Frigate will use a single CPU detector. Other detectors may require additional configuration as described below. When using multiple detectors they will run in dedicated processes, but pull from a common queue of detection requests from across all cameras.
|
||||||
|
|
||||||
## Edge TPU Detector
|
## Edge TPU Detector
|
||||||
|
|
||||||
The Edge TPU detector type runs TensorFlow Lite models utilizing the Google Coral delegate for hardware acceleration. To use it, prefix a model's device with `edgetpu`.
|
The Edge TPU detector type runs TensorFlow Lite models utilizing the Google Coral delegate for hardware acceleration. To configure an Edge TPU detector, set the `"type"` attribute to `"edgetpu"`.
|
||||||
|
|
||||||
The Edge TPU device can be specified using the `"device"` attribute according to the [Documentation for the TensorFlow Lite Python API](https://coral.ai/docs/edgetpu/multiple-edgetpu/#using-the-tensorflow-lite-python-api). If not set, the delegate will use the first device it finds.
|
The Edge TPU device can be specified using the `"device"` attribute according to the [Documentation for the TensorFlow Lite Python API](https://coral.ai/docs/edgetpu/multiple-edgetpu/#using-the-tensorflow-lite-python-api). If not set, the delegate will use the first device it finds.
|
||||||
|
|
||||||
@@ -171,9 +117,10 @@ Navigate to <NavPath path="Settings > System > Detectors and model" /> and selec
|
|||||||
<TabItem value="yaml">
|
<TabItem value="yaml">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral:
|
||||||
- edgetpu:usb
|
type: edgetpu
|
||||||
|
device: usb
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -190,10 +137,13 @@ Navigate to <NavPath path="Settings > System > Detectors and model" /> and selec
|
|||||||
<TabItem value="yaml">
|
<TabItem value="yaml">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral1:
|
||||||
- edgetpu:usb:0
|
type: edgetpu
|
||||||
- edgetpu:usb:1
|
device: usb:0
|
||||||
|
coral2:
|
||||||
|
type: edgetpu
|
||||||
|
device: usb:1
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -212,9 +162,10 @@ Navigate to <NavPath path="Settings > System > Detectors and model" /> and selec
|
|||||||
<TabItem value="yaml">
|
<TabItem value="yaml">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral:
|
||||||
- 'edgetpu:'
|
type: edgetpu
|
||||||
|
device: ""
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -231,9 +182,10 @@ Navigate to <NavPath path="Settings > System > Detectors and model" /> and selec
|
|||||||
<TabItem value="yaml">
|
<TabItem value="yaml">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral:
|
||||||
- edgetpu:pci
|
type: edgetpu
|
||||||
|
device: pci
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -250,10 +202,13 @@ Navigate to <NavPath path="Settings > System > Detectors and model" /> and selec
|
|||||||
<TabItem value="yaml">
|
<TabItem value="yaml">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral1:
|
||||||
- edgetpu:pci:0
|
type: edgetpu
|
||||||
- edgetpu:pci:1
|
device: pci:0
|
||||||
|
coral2:
|
||||||
|
type: edgetpu
|
||||||
|
device: pci:1
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -270,10 +225,13 @@ Navigate to <NavPath path="Settings > System > Detectors and model" /> and selec
|
|||||||
<TabItem value="yaml">
|
<TabItem value="yaml">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral_usb:
|
||||||
- edgetpu:usb
|
type: edgetpu
|
||||||
- edgetpu:pci
|
device: usb
|
||||||
|
coral_pci:
|
||||||
|
type: edgetpu
|
||||||
|
device: pci
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -315,7 +273,7 @@ Hailo8 supports all models in the Hailo Model Zoo that include HailoRT post-proc
|
|||||||
|
|
||||||
## OpenVINO Detector
|
## OpenVINO Detector
|
||||||
|
|
||||||
The OpenVINO detector type runs an OpenVINO IR model on AMD and Intel CPUs, Intel GPUs and Intel NPUs. To use it, prefix a model's device with `openvino`.
|
The OpenVINO detector type runs an OpenVINO IR model on AMD and Intel CPUs, Intel GPUs and Intel NPUs. To configure an OpenVINO detector, set the `"type"` attribute to `"openvino"`.
|
||||||
|
|
||||||
The OpenVINO device to be used is specified using the `"device"` attribute according to the naming conventions in the [Device Documentation](https://docs.openvino.ai/2025/openvino-workflow/running-inference/inference-devices-and-modes.html). The most common devices are `CPU`, `GPU`, or `NPU`.
|
The OpenVINO device to be used is specified using the `"device"` attribute according to the naming conventions in the [Device Documentation](https://docs.openvino.ai/2025/openvino-workflow/running-inference/inference-devices-and-modes.html). The most common devices are `CPU`, `GPU`, or `NPU`.
|
||||||
|
|
||||||
@@ -328,10 +286,13 @@ OpenVINO is supported on 6th Gen Intel platforms (Skylake) and newer. It will al
|
|||||||
When using many cameras one detector may not be enough to keep up. Multiple detectors can be defined assuming GPU resources are available. An example configuration would be:
|
When using many cameras one detector may not be enough to keep up. Multiple detectors can be defined assuming GPU resources are available. An example configuration would be:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
ov_0:
|
||||||
- openvino:GPU # or NPU
|
type: openvino
|
||||||
- openvino:GPU # or NPU
|
device: GPU # or NPU
|
||||||
|
ov_1:
|
||||||
|
type: openvino
|
||||||
|
device: GPU # or NPU
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
@@ -352,12 +313,6 @@ Intel NPUs cannot be used under Home Assistant OS, which does not include the NP
|
|||||||
|
|
||||||
## Apple Silicon detector
|
## Apple Silicon detector
|
||||||
|
|
||||||
:::warning
|
|
||||||
|
|
||||||
The network-based detectors (Deepstack, DeGirum, and the Apple Silicon client) are being reworked. Their extra options no longer have a place in the config, so only the endpoint carried in the device string is honored right now: Deepstack ignores `api_key` and `api_timeout`, DeGirum ignores `zoo` and `token`, and the Apple Silicon client ignores `request_timeout_ms` and `linger_ms`. Anything else is dropped when your config is migrated.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
The NPU in Apple Silicon can't be accessed from within a container, so the [Apple Silicon detector client](https://github.com/frigate-nvr/apple-silicon-detector) must first be setup. It is recommended to use the Frigate docker image with `-standard-arm64` suffix, for example `ghcr.io/blakeblackshear/frigate:stable-standard-arm64`.
|
The NPU in Apple Silicon can't be accessed from within a container, so the [Apple Silicon detector client](https://github.com/frigate-nvr/apple-silicon-detector) must first be setup. It is recommended to use the Frigate docker image with `-standard-arm64` suffix, for example `ghcr.io/blakeblackshear/frigate:stable-standard-arm64`.
|
||||||
|
|
||||||
### Setup {#setup-apple-silicon}
|
### Setup {#setup-apple-silicon}
|
||||||
@@ -498,10 +453,11 @@ If the correct build is used for your GPU then the GPU will be detected and used
|
|||||||
When using many cameras one detector may not be enough to keep up. Multiple detectors can be defined assuming GPU resources are available. An example configuration would be:
|
When using many cameras one detector may not be enough to keep up. Multiple detectors can be defined assuming GPU resources are available. An example configuration would be:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
onnx_0:
|
||||||
- onnx
|
type: onnx
|
||||||
- onnx
|
onnx_1:
|
||||||
|
type: onnx
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
@@ -514,7 +470,7 @@ models:
|
|||||||
|
|
||||||
## CPU Detector (not recommended)
|
## CPU Detector (not recommended)
|
||||||
|
|
||||||
The CPU detector type runs a TensorFlow Lite model utilizing the CPU without hardware acceleration. It is recommended to use a hardware accelerated detector type instead for better performance. To use it, set a model's device to `cpu`.
|
The CPU detector type runs a TensorFlow Lite model utilizing the CPU without hardware acceleration. It is recommended to use a hardware accelerated detector type instead for better performance. To configure a CPU based detector, set the `"type"` attribute to `"cpu"`.
|
||||||
|
|
||||||
:::danger
|
:::danger
|
||||||
|
|
||||||
@@ -524,7 +480,7 @@ The CPU detector is not recommended for general use. If you do not have GPU or E
|
|||||||
|
|
||||||
The number of threads used by the interpreter can be specified using the `"num_threads"` attribute, and defaults to `3.`
|
The number of threads used by the interpreter can be specified using the `"num_threads"` attribute, and defaults to `3.`
|
||||||
|
|
||||||
A TensorFlow Lite model is provided in the container at `/cpu_model.tflite` and is used by this detector type by default. To provide your own model, bind mount the file into the container and provide the path with the model's `path`.
|
A TensorFlow Lite model is provided in the container at `/cpu_model.tflite` and is used by this detector type by default. To provide your own model, bind mount the file into the container and provide the path with `model.path`.
|
||||||
|
|
||||||
### Configuration {#configuration-cpu}
|
### Configuration {#configuration-cpu}
|
||||||
|
|
||||||
@@ -534,12 +490,6 @@ When using CPU detectors, you can add one CPU detector per camera. Adding more d
|
|||||||
|
|
||||||
## Deepstack / CodeProject.AI Server Detector
|
## Deepstack / CodeProject.AI Server Detector
|
||||||
|
|
||||||
:::warning
|
|
||||||
|
|
||||||
The network-based detectors (Deepstack, DeGirum, and the Apple Silicon client) are being reworked. Their extra options no longer have a place in the config, so only the endpoint carried in the device string is honored right now: Deepstack ignores `api_key` and `api_timeout`, DeGirum ignores `zoo` and `token`, and the Apple Silicon client ignores `request_timeout_ms` and `linger_ms`. Anything else is dropped when your config is migrated.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
The Deepstack / CodeProject.AI Server detector for Frigate allows you to integrate Deepstack and CodeProject.AI object detection capabilities into Frigate. CodeProject.AI and DeepStack are open-source AI platforms that can be run on various devices such as the Raspberry Pi, Nvidia Jetson, and other compatible hardware. It is important to note that the integration is performed over the network, so the inference times may not be as fast as native Frigate detectors, but it still provides an efficient and reliable solution for object detection and tracking.
|
The Deepstack / CodeProject.AI Server detector for Frigate allows you to integrate Deepstack and CodeProject.AI object detection capabilities into Frigate. CodeProject.AI and DeepStack are open-source AI platforms that can be run on various devices such as the Raspberry Pi, Nvidia Jetson, and other compatible hardware. It is important to note that the integration is performed over the network, so the inference times may not be as fast as native Frigate detectors, but it still provides an efficient and reliable solution for object detection and tracking.
|
||||||
|
|
||||||
### Setup {#setup-deepstack}
|
### Setup {#setup-deepstack}
|
||||||
@@ -602,7 +552,7 @@ For detailed instructions on compiling models, refer to the [MemryX Compiler](ht
|
|||||||
|
|
||||||
3. Depending on the model, the compiler may also generate a cropped post-processing network. If present, it will be named with the suffix `_post.onnx`.
|
3. Depending on the model, the compiler may also generate a cropped post-processing network. If present, it will be named with the suffix `_post.onnx`.
|
||||||
|
|
||||||
4. Bind-mount the `.zip` file into the container and specify its path using the model's `path` in your config.
|
4. Bind-mount the `.zip` file into the container and specify its path using `model.path` in your config.
|
||||||
|
|
||||||
5. Update `labelmap_path` to match your custom model's labels.
|
5. Update `labelmap_path` to match your custom model's labels.
|
||||||
|
|
||||||
@@ -732,10 +682,13 @@ If no custom model is provided, the RKNN detector downloads a default model from
|
|||||||
When using many cameras one detector may not be enough to keep up. Multiple detectors can be defined assuming NPU resources are available. An example configuration would be:
|
When using many cameras one detector may not be enough to keep up. Multiple detectors can be defined assuming NPU resources are available. An example configuration would be:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
rknn_0:
|
||||||
- rknn:0
|
type: rknn
|
||||||
- rknn:0
|
num_cores: 0
|
||||||
|
rknn_1:
|
||||||
|
type: rknn
|
||||||
|
num_cores: 0
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
@@ -809,101 +762,6 @@ Explanation of the parameters:
|
|||||||
- **example**: Specifying `output_name = "frigate-{quant}-{input_basename}-{soc}-v{tk_version}"` could result in a model called `frigate-i8-my_model-rk3588-v2.3.0.rknn`.
|
- **example**: Specifying `output_name = "frigate-{quant}-{input_basename}-{soc}-v{tk_version}"` could result in a model called `frigate-i8-my_model-rk3588-v2.3.0.rknn`.
|
||||||
- `config`: Configuration passed to `rknn-toolkit2` for model conversion. For an explanation of all available parameters have a look at section "2.2. Model configuration" of [this manual](https://github.com/MarcA711/rknn-toolkit2/releases/download/v2.3.2/03_Rockchip_RKNPU_API_Reference_RKNN_Toolkit2_V2.3.2_EN.pdf).
|
- `config`: Configuration passed to `rknn-toolkit2` for model conversion. For an explanation of all available parameters have a look at section "2.2. Model configuration" of [this manual](https://github.com/MarcA711/rknn-toolkit2/releases/download/v2.3.2/03_Rockchip_RKNPU_API_Reference_RKNN_Toolkit2_V2.3.2_EN.pdf).
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
## DeGirum
|
|
||||||
|
|
||||||
:::warning
|
|
||||||
|
|
||||||
The network-based detectors (Deepstack, DeGirum, and the Apple Silicon client) are being reworked. Their extra options no longer have a place in the config, so only the endpoint carried in the device string is honored right now: Deepstack ignores `api_key` and `api_timeout`, DeGirum ignores `zoo` and `token`, and the Apple Silicon client ignores `request_timeout_ms` and `linger_ms`. Anything else is dropped when your config is migrated.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
DeGirum is a detector that can use any type of hardware listed on [their website](https://hub.degirum.com). DeGirum can be used with local hardware through a DeGirum AI Server, or through the use of `@local`. You can also connect directly to DeGirum's AI Hub to run inferences. **Please Note:** This detector _cannot_ be used for commercial purposes.
|
|
||||||
|
|
||||||
### Configuration {#configuration-degirum}
|
|
||||||
|
|
||||||
#### AI Server Inference
|
|
||||||
|
|
||||||
Before starting with the config file for this section, you must first launch an AI server. DeGirum has an AI server ready to use as a docker container. Add this to your `docker-compose.yml` to get started:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
degirum_detector:
|
|
||||||
container_name: degirum
|
|
||||||
image: degirum/aiserver:latest
|
|
||||||
privileged: true
|
|
||||||
ports:
|
|
||||||
- "8778:8778"
|
|
||||||
```
|
|
||||||
|
|
||||||
All supported hardware will automatically be found on your AI server host as long as relevant runtimes and drivers are properly installed on your machine. Refer to [DeGirum's docs site](https://docs.degirum.com/pysdk/runtimes-and-drivers) if you have any trouble.
|
|
||||||
|
|
||||||
Once completed, configure the detector as follows:
|
|
||||||
|
|
||||||
<ModelConfigDropdown detectorTitle="DeGirum" models={objectDetectorsModels.degirumAiServer.models} />
|
|
||||||
|
|
||||||
The model is set on the same `models` entry as the DeGirum device. You can set it to:
|
|
||||||
|
|
||||||
- A model listed on the [AI Hub](https://hub.degirum.com)
|
|
||||||
- If this is what you choose to do, the correct model will be downloaded onto your machine before running.
|
|
||||||
- A local directory acting as a zoo. See DeGirum's docs site [for more information](https://docs.degirum.com/pysdk/user-guide-pysdk/organizing-models#model-zoo-directory-structure).
|
|
||||||
- A path to some model.json.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- degirum:<location>
|
|
||||||
path: ./mobilenet_v2_ssd_coco--300x300_quant_n2x_orca1_1 # directory to model .json and file
|
|
||||||
width: 300 # width is in the model name as the first number in the "int"x"int" section
|
|
||||||
height: 300 # height is in the model name as the second number in the "int"x"int" section
|
|
||||||
input_pixel_format: rgb/bgr # look at the model.json to figure out which to put here
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Local Inference
|
|
||||||
|
|
||||||
It is also possible to eliminate the need for an AI server and run the hardware directly. The benefit of this approach is that you eliminate any bottlenecks that occur when transferring prediction results from the AI server docker container to the frigate one. However, the method of implementing local inference is different for every device and hardware combination, so it's usually more trouble than it's worth. A general guideline to achieve this would be:
|
|
||||||
|
|
||||||
1. Ensuring that the frigate docker container has the runtime you want to use. So for instance, running `@local` for Hailo means making sure the container you're using has the Hailo runtime installed.
|
|
||||||
2. To double check the runtime is detected by the DeGirum detector, make sure the `degirum sys-info` command properly shows whatever runtimes you mean to install.
|
|
||||||
3. Create a DeGirum detector in your configuration.
|
|
||||||
|
|
||||||
<ModelConfigDropdown detectorTitle="DeGirum" models={objectDetectorsModels.degirumLocal.models} />
|
|
||||||
|
|
||||||
Once the DeGirum device is set up, you can choose a model on the same `models` entry in the `config.yml` file.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- degirum:<location>
|
|
||||||
path: mobilenet_v2_ssd_coco--300x300_quant_n2x_orca1_1
|
|
||||||
width: 300 # width is in the model name as the first number in the "int"x"int" section
|
|
||||||
height: 300 # height is in the model name as the second number in the "int"x"int" section
|
|
||||||
input_pixel_format: rgb/bgr # look at the model.json to figure out which to put here
|
|
||||||
```
|
|
||||||
|
|
||||||
#### AI Hub Cloud Inference
|
|
||||||
|
|
||||||
If you do not possess whatever hardware you want to run, there's also the option to run cloud inferences. Do note that your detection fps might need to be lowered as network latency does significantly slow down this method of detection. For use with Frigate, we highly recommend using a local AI server as described above. To set up cloud inferences,
|
|
||||||
|
|
||||||
1. Sign up at [DeGirum's AI Hub](https://hub.degirum.com).
|
|
||||||
2. Get an access token.
|
|
||||||
3. Create a DeGirum detector in your configuration.
|
|
||||||
|
|
||||||
<ModelConfigDropdown detectorTitle="DeGirum" models={objectDetectorsModels.degirumCloud.models} />
|
|
||||||
|
|
||||||
Once the DeGirum device is set up, you can choose a model on the same `models` entry in the `config.yml` file.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
models:
|
|
||||||
- devices:
|
|
||||||
- degirum:<location>
|
|
||||||
path: mobilenet_v2_ssd_coco--300x300_quant_n2x_orca1_1
|
|
||||||
width: 300 # width is in the model name as the first number in the "int"x"int" section
|
|
||||||
height: 300 # height is in the model name as the second number in the "int"x"int" section
|
|
||||||
input_pixel_format: rgb/bgr # look at the model.json to figure out which to put here
|
|
||||||
```
|
|
||||||
|
|
||||||
>>>>>>> 34363affa (Refactor detector and model management)
|
|
||||||
## AXERA
|
## AXERA
|
||||||
|
|
||||||
Hardware accelerated object detection is supported on the following SoCs:
|
Hardware accelerated object detection is supported on the following SoCs:
|
||||||
|
|||||||
@@ -222,12 +222,15 @@ You need to refer to **Configure hardware acceleration** above to enable the con
|
|||||||
```yaml {3-6,9-15,20-21}
|
```yaml {3-6,9-15,20-21}
|
||||||
mqtt: ...
|
mqtt: ...
|
||||||
|
|
||||||
models: # <---- add models
|
detectors: # <---- add detectors
|
||||||
- devices:
|
ov:
|
||||||
- openvino:GPU # <---- use the openvino detector on the GPU
|
type: openvino # <---- use openvino detector
|
||||||
# We will use the default MobileNet_v2 model from OpenVINO.
|
device: GPU
|
||||||
width: 300
|
|
||||||
height: 300
|
# We will use the default MobileNet_v2 model from OpenVINO.
|
||||||
|
model:
|
||||||
|
width: 300
|
||||||
|
height: 300
|
||||||
input_tensor: nhwc
|
input_tensor: nhwc
|
||||||
input_pixel_format: bgr
|
input_pixel_format: bgr
|
||||||
path: /openvino-model/ssdlite_mobilenet_v2.xml
|
path: /openvino-model/ssdlite_mobilenet_v2.xml
|
||||||
@@ -278,9 +281,10 @@ Navigate to <NavPath path="Settings > System > Detectors and model" /> and add a
|
|||||||
```yaml {3-6,11-12}
|
```yaml {3-6,11-12}
|
||||||
mqtt: ...
|
mqtt: ...
|
||||||
|
|
||||||
models: # <---- add models
|
detectors: # <---- add detectors
|
||||||
- devices:
|
coral:
|
||||||
- edgetpu:usb
|
type: edgetpu
|
||||||
|
device: usb
|
||||||
|
|
||||||
cameras:
|
cameras:
|
||||||
name_of_your_camera:
|
name_of_your_camera:
|
||||||
@@ -317,9 +321,10 @@ If you are using YAML to configure Frigate instead of the UI, your configuration
|
|||||||
mqtt:
|
mqtt:
|
||||||
enabled: False
|
enabled: False
|
||||||
|
|
||||||
models:
|
detectors:
|
||||||
- devices:
|
coral:
|
||||||
- edgetpu:usb
|
type: edgetpu
|
||||||
|
device: usb
|
||||||
|
|
||||||
cameras:
|
cameras:
|
||||||
name_of_your_camera:
|
name_of_your_camera:
|
||||||
@@ -352,7 +357,7 @@ In order to review activity in the Frigate UI, recordings need to be enabled.
|
|||||||
```yaml {16-17}
|
```yaml {16-17}
|
||||||
mqtt: ...
|
mqtt: ...
|
||||||
|
|
||||||
models: ...
|
detectors: ...
|
||||||
|
|
||||||
cameras:
|
cameras:
|
||||||
name_of_your_camera:
|
name_of_your_camera:
|
||||||
|
|||||||
@@ -555,21 +555,20 @@ Topic with current state of Birdseye for a camera. Published values are `ON` and
|
|||||||
|
|
||||||
### `frigate/<camera_name>/birdseye_mode/set`
|
### `frigate/<camera_name>/birdseye_mode/set`
|
||||||
|
|
||||||
Topic to set the Birdseye activity types for a camera. Send one uppercase activity type or combine multiple types with commas, for example `MOTION,OBJECTS,STATIONARY_OBJECTS`.
|
Topic to set Birdseye mode for a camera. Birdseye offers different modes to customize under which circumstances the camera is shown.
|
||||||
|
|
||||||
_Note: Changing the value from `CONTINUOUS` to non-continuous activity types will take up to 30 seconds for
|
_Note: Changing the value from `CONTINUOUS` -> `MOTION | OBJECTS` will take up to 30 seconds for
|
||||||
the camera to be removed from the view._
|
the camera to be removed from the view._
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| -------------------- | ---------------------------------------------------------------- |
|
| ------------ | ----------------------------------------------------------------- |
|
||||||
| `CONTINUOUS` | Always included |
|
| `CONTINUOUS` | Always included |
|
||||||
| `MOTION` | Shown if motion was detected within the last 30 seconds |
|
| `MOTION` | Show when detected motion within the last 30 seconds are included |
|
||||||
| `OBJECTS` | Shown if an active object was tracked within the last 30 seconds |
|
| `OBJECTS` | Shown if an active object tracked within the last 30 seconds |
|
||||||
| `STATIONARY_OBJECTS` | Shown while a stationary object is tracked |
|
|
||||||
|
|
||||||
### `frigate/<camera_name>/birdseye_mode/state`
|
### `frigate/<camera_name>/birdseye_mode/state`
|
||||||
|
|
||||||
Topic with the current Birdseye activity types for a camera. Multiple enabled types are published as a comma-separated value in the order `OBJECTS`, `MOTION`, `STATIONARY_OBJECTS`, `CONTINUOUS`.
|
Topic with current state of the Birdseye mode for a camera. Published values are `CONTINUOUS`, `MOTION`, `OBJECTS`.
|
||||||
|
|
||||||
### `frigate/<camera_name>/notifications/set`
|
### `frigate/<camera_name>/notifications/set`
|
||||||
|
|
||||||
|
|||||||
@@ -62,9 +62,10 @@ Once you have [requested your first model](../plus/first_model.md) and gotten yo
|
|||||||
You can either choose the new model from the <NavPath path="Settings > System > Detectors and model" /> pane in the Frigate UI (the **Frigate+ Model** tab), or manually set the model at the root level in your config:
|
You can either choose the new model from the <NavPath path="Settings > System > Detectors and model" /> pane in the Frigate UI (the **Frigate+ Model** tab), or manually set the model at the root level in your config:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors: ...
|
||||||
- devices: ...
|
|
||||||
path: plus://<your_model_id>
|
model:
|
||||||
|
path: plus://<your_model_id>
|
||||||
```
|
```
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
@@ -78,11 +79,10 @@ Models are downloaded into the `/config/model_cache` folder and only downloaded
|
|||||||
If needed, you can override the labelmap for Frigate+ models. This is not recommended as renaming labels will break the Submit to Frigate+ feature if the labels are not available in Frigate+.
|
If needed, you can override the labelmap for Frigate+ models. This is not recommended as renaming labels will break the Submit to Frigate+ feature if the labels are not available in Frigate+.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
model:
|
||||||
- devices: ...
|
path: plus://<your_model_id>
|
||||||
path: plus://<your_model_id>
|
labelmap:
|
||||||
labelmap:
|
3: animal
|
||||||
3: animal
|
4: animal
|
||||||
4: animal
|
5: animal
|
||||||
5: animal
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -36,9 +36,10 @@ Navigate to <NavPath path="Settings > System > Detectors and model" />. In the *
|
|||||||
<TabItem value="yaml">
|
<TabItem value="yaml">
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
models:
|
detectors: ...
|
||||||
- devices: ...
|
|
||||||
path: plus://<your_model_id>
|
model:
|
||||||
|
path: plus://<your_model_id>
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|||||||
@@ -3,7 +3,31 @@ id: cpu
|
|||||||
title: High CPU Usage
|
title: High CPU Usage
|
||||||
---
|
---
|
||||||
|
|
||||||
High CPU usage can impact Frigate's performance and responsiveness. This guide outlines the most effective configuration changes to help reduce CPU consumption and optimize resource usage.
|
High CPU usage can impact Frigate's performance and responsiveness. This guide explains how to interpret the CPU values Frigate reports and outlines the most effective configuration changes to help reduce CPU consumption and optimize resource usage.
|
||||||
|
|
||||||
|
## Understanding Frigate's Reported CPU Usage
|
||||||
|
|
||||||
|
Frigate's CPU percentages often look much higher than what the host reports. Usually both numbers are correct and are simply measured against different denominators, so confirm you actually have a problem before tuning anything.
|
||||||
|
|
||||||
|
### Per-process values are relative to a single core
|
||||||
|
|
||||||
|
The values Frigate reports for FFmpeg, capture, detect, detector, and other processes follow the same convention as `top`: 100% means one CPU core is fully saturated, not that the whole system is saturated. A multithreaded process such as FFmpeg can legitimately report well over 100%.
|
||||||
|
|
||||||
|
Host and hypervisor tools instead report a percentage of the machine's total capacity across all cores. This includes `docker stats`, the `htop` summary, the Proxmox summary graph, the Unraid dashboard, Synology Resource Monitor, and Home Assistant's system monitor sensors. To reconcile the two:
|
||||||
|
|
||||||
|
```
|
||||||
|
host percentage ≈ (sum of Frigate's process percentages) / (number of cores)
|
||||||
|
```
|
||||||
|
|
||||||
|
On a 4 core system, an FFmpeg process reporting 100% is consuming one quarter of the machine, so the host will show roughly 25 to 30% once the remaining Frigate processes are included. That same 100% on a 16 core system is about 6%. Frigate's own warning thresholds use the per-core convention as well, so an FFmpeg process is flagged at 20% of a single core, not 20% of the system.
|
||||||
|
|
||||||
|
### Instantaneous samples and averages measure different things
|
||||||
|
|
||||||
|
Frigate collects stats every 15 seconds, and the `cpu` value covers only the interval since the previous collection. The `cpu_average` value in the stats API and MQTT payload is the average across the entire life of the process, and it is what the high CPU usage warnings are based on. Host dashboards generally plot data averaged over a longer window, so a single Frigate sample can show a peak that a host graph never displays. A process that has just started, such as FFmpeg after a camera reconnect, reports 0 until it has been sampled twice.
|
||||||
|
|
||||||
|
### The system-wide value depends on what the container can see
|
||||||
|
|
||||||
|
The system CPU value is read from `/proc/stat`. Under Docker that file belongs to the host, so the value covers the entire machine including workloads unrelated to Frigate, and it will not match `docker stats` for the Frigate container. Under an LXC container, lxcfs virtualizes `/proc/stat` and the value reflects only the cores assigned to the container. In a virtual machine, the guest sees only its assigned vCPUs while the hypervisor divides by every physical thread on the node, so guest and host percentages will not agree even when both are accurate.
|
||||||
|
|
||||||
## 1. Hardware Acceleration for Video Decoding
|
## 1. Hardware Acceleration for Video Decoding
|
||||||
|
|
||||||
@@ -72,3 +96,19 @@ The model you use significantly impacts detector performance. Frigate provides d
|
|||||||
- Larger models (640x640): Slower inference, can sometimes have higher accuracy on very large objects that take up a majority of the frame.
|
- Larger models (640x640): Slower inference, can sometimes have higher accuracy on very large objects that take up a majority of the frame.
|
||||||
|
|
||||||
For more detail on picking the right size, see [Choosing a model size](../configuration/object_detectors.md#choosing-a-model-size).
|
For more detail on picking the right size, see [Choosing a model size](../configuration/object_detectors.md#choosing-a-model-size).
|
||||||
|
|
||||||
|
## 3. Reducing Detector CPU Usage
|
||||||
|
|
||||||
|
**Priority: High**
|
||||||
|
|
||||||
|
The **Detector CPU Usage** metric measures the CPU spent converting frames into the tensor format the model expects and post-processing the model's output. It does not include inference, so this value can be high even when you've configured a GPU, NPU, or Coral for object detection.
|
||||||
|
|
||||||
|
This metric scales with how many detections per second Frigate runs and how expensive each one is to prepare. Tuning [motion detection](../configuration/motion_detection) is usually the first recommendation to reduce the number of detections. Additionally, you can:
|
||||||
|
|
||||||
|
- **Lower `detect -> fps`.** 5 is the recommended value for nearly all cameras. Running at 10 doubles the frames eligible for detection and is one of the largest contributors to this metric.
|
||||||
|
- **Use a 320x320 model.** A 640x640 model has 4 times as many pixels to transpose, convert, and copy on every inference.
|
||||||
|
- **Prefer a model that takes integer input.** Models configured with `input_dtype: float` require each frame to be converted to float32 and normalized on the CPU first. Models taking `int` input, such as the tflite models used by the Edge TPU, skip that step.
|
||||||
|
- **Do not match the detect resolution to the model resolution.** The detect stream should match your camera's aspect ratio, for example `1280x720`, not the model's input size. Frigate crops and scales regions of motion itself, so an oversized detect stream only adds work.
|
||||||
|
- **Tune stationary object behavior.** Objects that never settle into a stationary state are re-detected continuously. Raising `detect -> stationary -> interval` reduces how often detection runs on objects that are already parked. See [stationary objects](../configuration/stationary_objects).
|
||||||
|
|
||||||
|
Adding [more detector instances](#multiple-detector-instances) spreads this work across more CPU cores, but does not reduce the total CPU used.
|
||||||
|
|||||||
@@ -133,6 +133,12 @@ cameras:
|
|||||||
height: 720
|
height: 720
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### What is the `version` key in my config file?
|
||||||
|
|
||||||
|
`version` records the config format that your config was last migrated to. On startup Frigate compares it against the format the running version expects, and if it is older it copies your config to `/config/backup_config.yaml`, rewrites it to the new format, and updates `version` as the final step. A config with no `version` key is assumed to predate 0.14 and is migrated from there.
|
||||||
|
|
||||||
|
Frigate manages this key for you, so do not set or edit it. Raising it makes Frigate skip migrations your config still needs, and lowering it re-runs migrations against config that has already been converted. Either can leave you with a config that no longer validates.
|
||||||
|
|
||||||
### Why does Frigate keep creating new tracked objects for my parked car?
|
### Why does Frigate keep creating new tracked objects for my parked car?
|
||||||
|
|
||||||
Stationary tracking is designed to _prevent_ this: a parked car should remain a single tracked object rather than generating new ones. If you're repeatedly getting new tracked objects for the same car, it's likely that Frigate is losing the object and re-detecting it as a new one.
|
Stationary tracking is designed to _prevent_ this: a parked car should remain a single tracked object rather than generating new ones. If you're repeatedly getting new tracked objects for the same car, it's likely that Frigate is losing the object and re-detecting it as a new one.
|
||||||
|
|||||||
Vendored
+8
-44
@@ -2308,15 +2308,15 @@ paths:
|
|||||||
$ref: '#/components/schemas/HTTPValidationError'
|
$ref: '#/components/schemas/HTTPValidationError'
|
||||||
security:
|
security:
|
||||||
- frigateUserAuth: []
|
- frigateUserAuth: []
|
||||||
x-required-role: any
|
x-required-role: camera
|
||||||
description: '**Access:** Any authenticated user.'
|
description: '**Access:** Authenticated user with access to the referenced camera.'
|
||||||
/review/summarize/start/{start_ts}/end/{end_ts}:
|
/review/summarize/start/{start_ts}/end/{end_ts}:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- Review
|
- Review
|
||||||
summary: Generate Review Summary
|
summary: Generate Review Summary
|
||||||
description: |-
|
description: |-
|
||||||
**Access:** Admin role required.
|
**Access:** Authenticated user with access to all cameras.
|
||||||
|
|
||||||
Use GenAI to summarize review items over a period of time.
|
Use GenAI to summarize review items over a period of time.
|
||||||
operationId:
|
operationId:
|
||||||
@@ -2347,8 +2347,8 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/HTTPValidationError'
|
$ref: '#/components/schemas/HTTPValidationError'
|
||||||
security:
|
security:
|
||||||
- frigateAdminAuth: []
|
- frigateUserAuth: []
|
||||||
x-required-role: admin
|
x-required-role: all_cameras
|
||||||
/:
|
/:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -2946,44 +2946,6 @@ paths:
|
|||||||
- frigateUserAuth: []
|
- frigateUserAuth: []
|
||||||
x-required-role: any
|
x-required-role: any
|
||||||
description: '**Access:** Any authenticated user.'
|
description: '**Access:** Any authenticated user.'
|
||||||
/categorized_object_names:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- App
|
|
||||||
summary: Get known object names by object type
|
|
||||||
description: |-
|
|
||||||
**Access:** Any authenticated user.
|
|
||||||
|
|
||||||
Returns the sub labels and attributes this install can attach,
|
|
||||||
grouped by object type. Unlike /sub_labels, which reflects what has already been
|
|
||||||
detected, this reads the config and model files, so it covers recognized face
|
|
||||||
names, named license plates, custom object classification categories, and the
|
|
||||||
detector attributes of tracked objects.
|
|
||||||
operationId: categorized_object_names_categorized_object_names_get
|
|
||||||
parameters:
|
|
||||||
- name: object_type
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
anyOf:
|
|
||||||
- type: string
|
|
||||||
- type: 'null'
|
|
||||||
title: Object Type
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Successful Response
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema: {}
|
|
||||||
'422':
|
|
||||||
description: Validation Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/HTTPValidationError'
|
|
||||||
security:
|
|
||||||
- frigateUserAuth: []
|
|
||||||
x-required-role: any
|
|
||||||
/audio_labels:
|
/audio_labels:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -7147,7 +7109,9 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/DebugReplayStartResponse'
|
$ref: '#/components/schemas/DebugReplayStartResponse'
|
||||||
'400':
|
'400':
|
||||||
description: Invalid camera, time range, or no recordings
|
description: Invalid camera or time range
|
||||||
|
'404':
|
||||||
|
description: No recordings in the requested time range
|
||||||
'409':
|
'409':
|
||||||
description: A replay session is already active
|
description: A replay session is already active
|
||||||
'422':
|
'422':
|
||||||
|
|||||||
+28
-47
@@ -71,7 +71,6 @@ from frigate.util.config import (
|
|||||||
find_config_file,
|
find_config_file,
|
||||||
redact_credential,
|
redact_credential,
|
||||||
)
|
)
|
||||||
from frigate.util.object_names import get_categorized_object_names
|
|
||||||
from frigate.util.schema import get_config_schema
|
from frigate.util.schema import get_config_schema
|
||||||
from frigate.util.services import (
|
from frigate.util.services import (
|
||||||
get_nvidia_driver_info,
|
get_nvidia_driver_info,
|
||||||
@@ -292,6 +291,10 @@ def config(request: Request):
|
|||||||
config: dict[str, dict[str, Any]] = config_obj.model_dump(
|
config: dict[str, dict[str, Any]] = config_obj.model_dump(
|
||||||
mode="json", warnings="none", exclude_none=True
|
mode="json", warnings="none", exclude_none=True
|
||||||
)
|
)
|
||||||
|
config["detectors"] = {
|
||||||
|
name: detector.model_dump(mode="json", warnings="none", exclude_none=True)
|
||||||
|
for name, detector in config_obj.detectors.items()
|
||||||
|
}
|
||||||
|
|
||||||
# remove environment_vars for non-admin users
|
# remove environment_vars for non-admin users
|
||||||
if request.headers.get("remote-role") != "admin":
|
if request.headers.get("remote-role") != "admin":
|
||||||
@@ -372,28 +375,31 @@ def config(request: Request):
|
|||||||
config["go2rtc"]["streams"][stream_name] = cleaned
|
config["go2rtc"]["streams"][stream_name] = cleaned
|
||||||
|
|
||||||
config["plus"] = {"enabled": request.app.frigate_config.plus_api.is_active()}
|
config["plus"] = {"enabled": request.app.frigate_config.plus_api.is_active()}
|
||||||
|
config["model"]["colormap"] = config_obj.model.colormap
|
||||||
|
config["model"]["all_attributes"] = config_obj.model.all_attributes
|
||||||
|
config["model"]["non_logo_attributes"] = config_obj.model.non_logo_attributes
|
||||||
|
|
||||||
for index, model in enumerate(config_obj.models):
|
# Add model plus data if plus is enabled
|
||||||
model_dict = config["models"][index]
|
if config["plus"]["enabled"]:
|
||||||
model_dict["colormap"] = model.colormap
|
model_path = config.get("model", {}).get("path")
|
||||||
model_dict["all_attributes"] = model.all_attributes
|
if model_path:
|
||||||
model_dict["non_logo_attributes"] = model.non_logo_attributes
|
model_json_path = FilePath(model_path).with_suffix(".json")
|
||||||
model_dict["labelmap"] = model.merged_labelmap
|
|
||||||
|
|
||||||
if not config["plus"]["enabled"]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Add model plus data if plus is enabled
|
|
||||||
model_dict["plus"] = None
|
|
||||||
|
|
||||||
if model.path:
|
|
||||||
model_json_path = FilePath(model.path).with_suffix(".json")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(model_json_path) as f:
|
with open(model_json_path) as f:
|
||||||
model_dict["plus"] = json.load(f)
|
model_plus_data = json.load(f)
|
||||||
except (FileNotFoundError, json.JSONDecodeError):
|
config["model"]["plus"] = model_plus_data
|
||||||
pass
|
except FileNotFoundError:
|
||||||
|
config["model"]["plus"] = None
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
config["model"]["plus"] = None
|
||||||
|
else:
|
||||||
|
config["model"]["plus"] = None
|
||||||
|
|
||||||
|
# use merged labelamp
|
||||||
|
for detector_config in config["detectors"].values():
|
||||||
|
detector_config["model"]["labelmap"] = (
|
||||||
|
request.app.frigate_config.model.merged_labelmap
|
||||||
|
)
|
||||||
|
|
||||||
return JSONResponse(content=config)
|
return JSONResponse(content=config)
|
||||||
|
|
||||||
@@ -1307,28 +1313,6 @@ def get_sub_labels(
|
|||||||
return JSONResponse(content=sub_labels)
|
return JSONResponse(content=sub_labels)
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
|
||||||
"/categorized_object_names",
|
|
||||||
dependencies=[Depends(allow_any_authenticated())],
|
|
||||||
summary="Get known object names by object type",
|
|
||||||
description="""Returns the sub labels and attributes this install can attach,
|
|
||||||
grouped by object type. Unlike /sub_labels, which reflects what has already been
|
|
||||||
detected, this reads the config and model files, so it covers recognized face
|
|
||||||
names, named license plates, custom object classification categories, and the
|
|
||||||
detector attributes of tracked objects.""",
|
|
||||||
)
|
|
||||||
def categorized_object_names(
|
|
||||||
request: Request,
|
|
||||||
object_type: str | None = None,
|
|
||||||
allowed_cameras: list[str] = Depends(get_allowed_cameras_for_filter),
|
|
||||||
):
|
|
||||||
return JSONResponse(
|
|
||||||
content=get_categorized_object_names(
|
|
||||||
request.app.frigate_config, allowed_cameras, object_type
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/audio_labels", dependencies=[Depends(allow_any_authenticated())])
|
@router.get("/audio_labels", dependencies=[Depends(allow_any_authenticated())])
|
||||||
def get_audio_labels():
|
def get_audio_labels():
|
||||||
labels = load_labels("/audio-labelmap.txt", prefill=521)
|
labels = load_labels("/audio-labelmap.txt", prefill=521)
|
||||||
@@ -1353,14 +1337,11 @@ def plusModels(request: Request, filterByCurrentModelDetector: bool = False):
|
|||||||
|
|
||||||
modelList = models["list"]
|
modelList = models["list"]
|
||||||
|
|
||||||
config: FrigateConfig = request.app.frigate_config
|
|
||||||
primary_model = config.primary_model
|
|
||||||
|
|
||||||
# current model type
|
# current model type
|
||||||
modelType = primary_model.model_type
|
modelType = request.app.frigate_config.model.model_type
|
||||||
|
|
||||||
# current detectorType for comparing to supportedDetectors
|
# current detectorType for comparing to supportedDetectors
|
||||||
detectorType = config.devices_for_model(primary_model)[0].detector
|
detectorType = list(request.app.frigate_config.detectors.values())[0].type
|
||||||
|
|
||||||
validModels = []
|
validModels = []
|
||||||
|
|
||||||
|
|||||||
+25
-4
@@ -83,7 +83,6 @@ def require_admin_by_default():
|
|||||||
"/nvinfo",
|
"/nvinfo",
|
||||||
"/labels",
|
"/labels",
|
||||||
"/sub_labels",
|
"/sub_labels",
|
||||||
"/categorized_object_names",
|
|
||||||
"/plus/models",
|
"/plus/models",
|
||||||
"/recognized_license_plates",
|
"/recognized_license_plates",
|
||||||
"/timeline",
|
"/timeline",
|
||||||
@@ -972,6 +971,7 @@ def delete_user(request: Request, username: str):
|
|||||||
summary="Update user password",
|
summary="Update user password",
|
||||||
description="Updates a user's password. Users can only change their own password unless they have admin role. Requires the current password to verify identity for non-admin users. Password must be at least 12 characters long. If user changes their own password, a new JWT cookie is automatically issued.",
|
description="Updates a user's password. Users can only change their own password unless they have admin role. Requires the current password to verify identity for non-admin users. Password must be at least 12 characters long. If user changes their own password, a new JWT cookie is automatically issued.",
|
||||||
)
|
)
|
||||||
|
@limiter.limit(limit_value=rateLimiter.get_limit)
|
||||||
async def update_password(
|
async def update_password(
|
||||||
request: Request,
|
request: Request,
|
||||||
username: str,
|
username: str,
|
||||||
@@ -985,10 +985,11 @@ async def update_password(
|
|||||||
current_username = current_user.get("username")
|
current_username = current_user.get("username")
|
||||||
current_role = current_user.get("role")
|
current_role = current_user.get("role")
|
||||||
|
|
||||||
# viewers can only change their own password
|
# Only admins may target another account. This has to cover every non-admin
|
||||||
if current_role == "viewer" and current_username != username:
|
# role rather than just viewer, since custom roles are arbitrary names
|
||||||
|
if current_role != "admin" and current_username != username:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=403, detail="Viewers can only update their own password"
|
status_code=403, detail="Users can only update their own password"
|
||||||
)
|
)
|
||||||
|
|
||||||
HASH_ITERATIONS = request.app.frigate_config.auth.hash_iterations
|
HASH_ITERATIONS = request.app.frigate_config.auth.hash_iterations
|
||||||
@@ -1252,3 +1253,23 @@ async def get_allowed_cameras_for_filter(request: Request):
|
|||||||
all_camera_names = set(request.app.frigate_config.cameras.keys())
|
all_camera_names = set(request.app.frigate_config.cameras.keys())
|
||||||
roles_dict = request.app.frigate_config.auth.roles
|
roles_dict = request.app.frigate_config.auth.roles
|
||||||
return User.get_allowed_cameras(role, roles_dict, all_camera_names)
|
return User.get_allowed_cameras(role, roles_dict, all_camera_names)
|
||||||
|
|
||||||
|
|
||||||
|
async def require_full_camera_access(
|
||||||
|
request: Request,
|
||||||
|
allowed_cameras: list[str] = Depends(get_allowed_cameras_for_filter),
|
||||||
|
):
|
||||||
|
"""Dependency for endpoints returning data that spans every camera.
|
||||||
|
|
||||||
|
Some responses cannot be meaningfully scoped to a subset of cameras, so
|
||||||
|
rather than filter them the endpoint is limited to callers who can already
|
||||||
|
see every camera. Admin and viewer always qualify; a custom role qualifies
|
||||||
|
only when its camera list covers all configured cameras.
|
||||||
|
"""
|
||||||
|
all_camera_names = set(request.app.frigate_config.cameras.keys())
|
||||||
|
|
||||||
|
if not all_camera_names.issubset(allowed_cameras):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=403,
|
||||||
|
detail="Access to all cameras is required for this endpoint",
|
||||||
|
)
|
||||||
|
|||||||
+2
-25
@@ -50,7 +50,6 @@ from frigate.jobs.vlm_watch import (
|
|||||||
stop_vlm_watch_job,
|
stop_vlm_watch_job,
|
||||||
)
|
)
|
||||||
from frigate.models import Event
|
from frigate.models import Event
|
||||||
from frigate.util.object_names import get_categorized_object_names
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -540,11 +539,6 @@ async def execute_tool(
|
|||||||
if tool_name == "search_objects":
|
if tool_name == "search_objects":
|
||||||
return await _execute_search_objects(request, arguments, allowed_cameras)
|
return await _execute_search_objects(request, arguments, allowed_cameras)
|
||||||
|
|
||||||
if tool_name == "get_categorized_object_names":
|
|
||||||
return JSONResponse(
|
|
||||||
content=_execute_get_categorized_object_names(request, allowed_cameras)
|
|
||||||
)
|
|
||||||
|
|
||||||
if tool_name == "find_similar_objects":
|
if tool_name == "find_similar_objects":
|
||||||
result = await _execute_find_similar_objects(
|
result = await _execute_find_similar_objects(
|
||||||
request, arguments, allowed_cameras
|
request, arguments, allowed_cameras
|
||||||
@@ -723,21 +717,6 @@ async def _execute_set_camera_state(
|
|||||||
return {"success": True, "camera": camera, "feature": feature, "value": value}
|
return {"success": True, "camera": camera, "feature": feature, "value": value}
|
||||||
|
|
||||||
|
|
||||||
def _execute_get_categorized_object_names(
|
|
||||||
request: Request,
|
|
||||||
allowed_cameras: list[str],
|
|
||||||
) -> dict[str, Any]:
|
|
||||||
names = get_categorized_object_names(request.app.frigate_config, allowed_cameras)
|
|
||||||
|
|
||||||
if not names:
|
|
||||||
return {
|
|
||||||
"names": {},
|
|
||||||
"message": "No names configured; search by label or semantic_query.",
|
|
||||||
}
|
|
||||||
|
|
||||||
return {"names": names}
|
|
||||||
|
|
||||||
|
|
||||||
async def _execute_tool_internal(
|
async def _execute_tool_internal(
|
||||||
tool_name: str,
|
tool_name: str,
|
||||||
arguments: dict[str, Any],
|
arguments: dict[str, Any],
|
||||||
@@ -762,8 +741,6 @@ async def _execute_tool_internal(
|
|||||||
except (json.JSONDecodeError, AttributeError) as e:
|
except (json.JSONDecodeError, AttributeError) as e:
|
||||||
logger.warning(f"Failed to extract tool result: {e}")
|
logger.warning(f"Failed to extract tool result: {e}")
|
||||||
return {"error": "Failed to parse tool result"}
|
return {"error": "Failed to parse tool result"}
|
||||||
elif tool_name == "get_categorized_object_names":
|
|
||||||
return _execute_get_categorized_object_names(request, allowed_cameras)
|
|
||||||
elif tool_name == "find_similar_objects":
|
elif tool_name == "find_similar_objects":
|
||||||
return await _execute_find_similar_objects(request, arguments, allowed_cameras)
|
return await _execute_find_similar_objects(request, arguments, allowed_cameras)
|
||||||
elif tool_name == "set_camera_state":
|
elif tool_name == "set_camera_state":
|
||||||
@@ -796,8 +773,8 @@ async def _execute_tool_internal(
|
|||||||
else:
|
else:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Tool call failed: unknown tool %r. Expected one of: search_objects, find_similar_objects, "
|
"Tool call failed: unknown tool %r. Expected one of: search_objects, find_similar_objects, "
|
||||||
"get_categorized_object_names, get_live_context, start_camera_watch, stop_camera_watch, "
|
"get_live_context, start_camera_watch, stop_camera_watch, get_profile_status, get_recap. "
|
||||||
"get_profile_status, get_recap. Arguments received: %s",
|
"Arguments received: %s",
|
||||||
tool_name,
|
tool_name,
|
||||||
json.dumps(arguments),
|
json.dumps(arguments),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from frigate.api.auth import require_role
|
|||||||
from frigate.api.defs.tags import Tags
|
from frigate.api.defs.tags import Tags
|
||||||
from frigate.jobs.debug_replay import (
|
from frigate.jobs.debug_replay import (
|
||||||
ExportDebugReplaySource,
|
ExportDebugReplaySource,
|
||||||
|
NoRecordingsError,
|
||||||
RecordingDebugReplaySource,
|
RecordingDebugReplaySource,
|
||||||
start_debug_replay_job,
|
start_debug_replay_job,
|
||||||
)
|
)
|
||||||
@@ -74,7 +75,8 @@ class DebugReplayStopResponse(BaseModel):
|
|||||||
response_model=DebugReplayStartResponse,
|
response_model=DebugReplayStartResponse,
|
||||||
status_code=202,
|
status_code=202,
|
||||||
responses={
|
responses={
|
||||||
400: {"description": "Invalid camera, time range, or no recordings"},
|
400: {"description": "Invalid camera or time range"},
|
||||||
|
404: {"description": "No recordings in the requested time range"},
|
||||||
409: {"description": "A replay session is already active"},
|
409: {"description": "A replay session is already active"},
|
||||||
},
|
},
|
||||||
dependencies=[Depends(require_role(["admin"]))],
|
dependencies=[Depends(require_role(["admin"]))],
|
||||||
@@ -113,6 +115,14 @@ async def start_debug_replay(request: Request, body: DebugReplayStartBody):
|
|||||||
},
|
},
|
||||||
status_code=409,
|
status_code=409,
|
||||||
)
|
)
|
||||||
|
except NoRecordingsError:
|
||||||
|
return JSONResponse(
|
||||||
|
content={
|
||||||
|
"success": False,
|
||||||
|
"message": "No recordings found in the selected time range",
|
||||||
|
},
|
||||||
|
status_code=404,
|
||||||
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.exception("Rejected debug replay start request")
|
logger.exception("Rejected debug replay start request")
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
|||||||
@@ -575,11 +575,11 @@ async def vod_ts(
|
|||||||
Recordings.start_time,
|
Recordings.start_time,
|
||||||
)
|
)
|
||||||
.where(
|
.where(
|
||||||
Recordings.camera == camera_name,
|
Recordings.start_time.between(start_ts, end_ts)
|
||||||
Recordings.start_time >= start_ts - MAX_SEGMENT_DURATION,
|
| Recordings.end_time.between(start_ts, end_ts)
|
||||||
Recordings.start_time <= end_ts,
|
| ((start_ts > Recordings.start_time) & (end_ts < Recordings.end_time))
|
||||||
Recordings.end_time >= start_ts,
|
|
||||||
)
|
)
|
||||||
|
.where(Recordings.camera == camera_name)
|
||||||
.order_by(Recordings.start_time.asc())
|
.order_by(Recordings.start_time.asc())
|
||||||
.iterator()
|
.iterator()
|
||||||
)
|
)
|
||||||
@@ -814,7 +814,7 @@ async def event_snapshot(
|
|||||||
timestamp_style=request.app.frigate_config.cameras[
|
timestamp_style=request.app.frigate_config.cameras[
|
||||||
event.camera
|
event.camera
|
||||||
].timestamp_style,
|
].timestamp_style,
|
||||||
colormap=request.app.frigate_config.model_for_camera(event.camera).colormap,
|
colormap=request.app.frigate_config.model.colormap,
|
||||||
)
|
)
|
||||||
except DoesNotExist:
|
except DoesNotExist:
|
||||||
# see if the object is currently being tracked
|
# see if the object is currently being tracked
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
"""Notification apis."""
|
"""Notification apis."""
|
||||||
|
|
||||||
|
import ipaddress
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from fastapi import APIRouter, Depends, Request
|
from fastapi import APIRouter, Depends, Request
|
||||||
@@ -19,6 +21,95 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
router = APIRouter(tags=[Tags.notifications])
|
router = APIRouter(tags=[Tags.notifications])
|
||||||
|
|
||||||
|
# Push endpoints are opaque URLs but stay well under this in practice
|
||||||
|
MAX_ENDPOINT_LENGTH = 2048
|
||||||
|
|
||||||
|
# Suffixes that only ever resolve on the local network
|
||||||
|
INTERNAL_HOST_SUFFIXES = (".local", ".localdomain", ".internal", ".home.arpa")
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_push_endpoint(endpoint: Any) -> str | None:
|
||||||
|
"""Return a reason the endpoint is unusable, or None when it is valid.
|
||||||
|
|
||||||
|
Subscriptions are issued by the browser vendor's push service, so a valid
|
||||||
|
endpoint is always a public https URL. Anything else is either a broken
|
||||||
|
registration or an attempt to aim the notification sender somewhere it
|
||||||
|
should not reach.
|
||||||
|
"""
|
||||||
|
if not isinstance(endpoint, str) or not endpoint:
|
||||||
|
return "endpoint must be a url"
|
||||||
|
|
||||||
|
if len(endpoint) > MAX_ENDPOINT_LENGTH:
|
||||||
|
return "endpoint is too long"
|
||||||
|
|
||||||
|
try:
|
||||||
|
parsed = urlparse(endpoint)
|
||||||
|
port = parsed.port
|
||||||
|
except ValueError:
|
||||||
|
return "endpoint is not a valid url"
|
||||||
|
|
||||||
|
if parsed.scheme != "https":
|
||||||
|
return "endpoint must use https"
|
||||||
|
|
||||||
|
if parsed.username or parsed.password:
|
||||||
|
return "endpoint must not include credentials"
|
||||||
|
|
||||||
|
if port is not None and port != 443:
|
||||||
|
return "endpoint must use the default https port"
|
||||||
|
|
||||||
|
hostname = parsed.hostname
|
||||||
|
|
||||||
|
if not hostname:
|
||||||
|
return "endpoint must include a hostname"
|
||||||
|
|
||||||
|
try:
|
||||||
|
address = ipaddress.ip_address(hostname)
|
||||||
|
except ValueError:
|
||||||
|
address = None
|
||||||
|
|
||||||
|
if address is not None:
|
||||||
|
# A push service is never reachable at an address only this network can
|
||||||
|
# route, so anything non-global is a misconfiguration at best
|
||||||
|
if not address.is_global:
|
||||||
|
return "endpoint must not use a private address"
|
||||||
|
elif hostname == "localhost" or "." not in hostname:
|
||||||
|
return "endpoint must use a fully qualified hostname"
|
||||||
|
elif hostname.endswith(INTERNAL_HOST_SUFFIXES):
|
||||||
|
return "endpoint must not use an internal hostname"
|
||||||
|
|
||||||
|
# The subscription token lives in the path, and webpush.py assumes there is
|
||||||
|
# a separator after the host when it builds the VAPID audience
|
||||||
|
if len(parsed.path) <= 1:
|
||||||
|
return "endpoint must include a subscription path"
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_subscription(sub: Any) -> str | None:
|
||||||
|
"""Return a reason the subscription is unusable, or None when it is valid."""
|
||||||
|
if not isinstance(sub, dict):
|
||||||
|
return "subscription must be an object"
|
||||||
|
|
||||||
|
reason = _validate_push_endpoint(sub.get("endpoint"))
|
||||||
|
|
||||||
|
if reason:
|
||||||
|
return reason
|
||||||
|
|
||||||
|
keys = sub.get("keys")
|
||||||
|
|
||||||
|
if not isinstance(keys, dict):
|
||||||
|
return "subscription must include keys"
|
||||||
|
|
||||||
|
# WebPusher raises on a missing key, which would break every send for the
|
||||||
|
# user rather than just this registration
|
||||||
|
for name in ("p256dh", "auth"):
|
||||||
|
value = keys.get(name)
|
||||||
|
|
||||||
|
if not isinstance(value, str) or not value:
|
||||||
|
return f"subscription keys must include {name}"
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/notifications/pubkey",
|
"/notifications/pubkey",
|
||||||
@@ -71,6 +162,17 @@ def register_notifications(request: Request, body: dict = None):
|
|||||||
status_code=400,
|
status_code=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
reason = _validate_subscription(sub)
|
||||||
|
|
||||||
|
if reason:
|
||||||
|
logger.warning(
|
||||||
|
"Rejected notification registration for %s: %s", username, reason
|
||||||
|
)
|
||||||
|
return JSONResponse(
|
||||||
|
content={"success": False, "message": f"Invalid subscription: {reason}"},
|
||||||
|
status_code=400,
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
User.update(notification_tokens=User.notification_tokens.append(sub)).where(
|
User.update(notification_tokens=User.notification_tokens.append(sub)).where(
|
||||||
User.username == username
|
User.username == username
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from frigate.api.defs.query.recordings_query_parameters import (
|
|||||||
)
|
)
|
||||||
from frigate.api.defs.response.generic_response import GenericResponse
|
from frigate.api.defs.response.generic_response import GenericResponse
|
||||||
from frigate.api.defs.tags import Tags
|
from frigate.api.defs.tags import Tags
|
||||||
from frigate.const import MAX_SEGMENT_DURATION, RECORD_DIR
|
from frigate.const import RECORD_DIR
|
||||||
from frigate.models import Event, Recordings
|
from frigate.models import Event, Recordings
|
||||||
from frigate.util.time import get_dst_transitions
|
from frigate.util.time import get_dst_transitions
|
||||||
|
|
||||||
@@ -243,7 +243,6 @@ async def recordings(
|
|||||||
)
|
)
|
||||||
.where(
|
.where(
|
||||||
Recordings.camera == camera_name,
|
Recordings.camera == camera_name,
|
||||||
Recordings.start_time >= after - MAX_SEGMENT_DURATION,
|
|
||||||
Recordings.end_time >= after,
|
Recordings.end_time >= after,
|
||||||
Recordings.start_time <= before,
|
Recordings.start_time <= before,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from frigate.api.auth import (
|
|||||||
get_allowed_cameras_for_filter,
|
get_allowed_cameras_for_filter,
|
||||||
get_current_user,
|
get_current_user,
|
||||||
require_camera_access,
|
require_camera_access,
|
||||||
|
require_full_camera_access,
|
||||||
require_role,
|
require_role,
|
||||||
)
|
)
|
||||||
from frigate.api.defs.query.review_query_parameters import (
|
from frigate.api.defs.query.review_query_parameters import (
|
||||||
@@ -709,6 +710,7 @@ async def get_review(request: Request, review_id: str):
|
|||||||
dependencies=[Depends(allow_any_authenticated())],
|
dependencies=[Depends(allow_any_authenticated())],
|
||||||
)
|
)
|
||||||
async def set_not_reviewed(
|
async def set_not_reviewed(
|
||||||
|
request: Request,
|
||||||
review_id: str,
|
review_id: str,
|
||||||
current_user: dict = Depends(get_current_user),
|
current_user: dict = Depends(get_current_user),
|
||||||
):
|
):
|
||||||
@@ -727,6 +729,8 @@ async def set_not_reviewed(
|
|||||||
status_code=404,
|
status_code=404,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await require_camera_access(review.camera, request=request)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_review = UserReviewStatus.get(
|
user_review = UserReviewStatus.get(
|
||||||
UserReviewStatus.user_id == user_id,
|
UserReviewStatus.user_id == user_id,
|
||||||
@@ -743,9 +747,12 @@ async def set_not_reviewed(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Intentionally not camera scoped, as the summary correlates each flagged event
|
||||||
|
# with overlapping activity on other cameras. Restricted to callers who can
|
||||||
|
# already see every camera, so the unscoped query discloses nothing.
|
||||||
@router.post(
|
@router.post(
|
||||||
"/review/summarize/start/{start_ts}/end/{end_ts}",
|
"/review/summarize/start/{start_ts}/end/{end_ts}",
|
||||||
dependencies=[Depends(require_role(["admin"]))],
|
dependencies=[Depends(require_full_camera_access)],
|
||||||
description="Use GenAI to summarize review items over a period of time.",
|
description="Use GenAI to summarize review items over a period of time.",
|
||||||
)
|
)
|
||||||
def generate_review_summary(request: Request, start_ts: float, end_ts: float):
|
def generate_review_summary(request: Request, start_ts: float, end_ts: float):
|
||||||
|
|||||||
+22
-39
@@ -49,8 +49,6 @@ from frigate.debug_replay import (
|
|||||||
DebugReplayManager,
|
DebugReplayManager,
|
||||||
cleanup_replay_cameras,
|
cleanup_replay_cameras,
|
||||||
)
|
)
|
||||||
from frigate.detectors.detector_config import SceneEnum
|
|
||||||
from frigate.detectors.device import build_detector_config, runner_names
|
|
||||||
from frigate.embeddings import EmbeddingProcess, EmbeddingsContext
|
from frigate.embeddings import EmbeddingProcess, EmbeddingsContext
|
||||||
from frigate.events.audio import AudioProcessor
|
from frigate.events.audio import AudioProcessor
|
||||||
from frigate.events.cleanup import EventCleanup
|
from frigate.events.cleanup import EventCleanup
|
||||||
@@ -71,7 +69,6 @@ from frigate.models import (
|
|||||||
User,
|
User,
|
||||||
)
|
)
|
||||||
from frigate.object_detection.base import ObjectDetectProcess
|
from frigate.object_detection.base import ObjectDetectProcess
|
||||||
from frigate.object_detection.util import detection_frame_size
|
|
||||||
from frigate.output.output import OutputProcess
|
from frigate.output.output import OutputProcess
|
||||||
from frigate.ptz.autotrack import PtzAutoTrackerThread
|
from frigate.ptz.autotrack import PtzAutoTrackerThread
|
||||||
from frigate.ptz.onvif import OnvifController
|
from frigate.ptz.onvif import OnvifController
|
||||||
@@ -101,9 +98,7 @@ class FrigateApp:
|
|||||||
self.metrics_manager = manager
|
self.metrics_manager = manager
|
||||||
self.audio_process: mp.Process | None = None
|
self.audio_process: mp.Process | None = None
|
||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
self.detection_queues: dict[SceneEnum, Queue] = {
|
self.detection_queue: Queue = mp.Queue()
|
||||||
model.scene: mp.Queue() for model in config.models
|
|
||||||
}
|
|
||||||
self.detectors: dict[str, ObjectDetectProcess] = {}
|
self.detectors: dict[str, ObjectDetectProcess] = {}
|
||||||
self.detection_shms: list[mp.shared_memory.SharedMemory] = []
|
self.detection_shms: list[mp.shared_memory.SharedMemory] = []
|
||||||
self.log_queue: Queue = mp.Queue()
|
self.log_queue: Queue = mp.Queue()
|
||||||
@@ -348,19 +343,20 @@ class FrigateApp:
|
|||||||
self.dispatcher.profile_manager = self.profile_manager
|
self.dispatcher.profile_manager = self.profile_manager
|
||||||
|
|
||||||
def start_detectors(self) -> None:
|
def start_detectors(self) -> None:
|
||||||
model_cameras: dict[SceneEnum, list[str]] = {
|
|
||||||
model.scene: [] for model in self.config.models
|
|
||||||
}
|
|
||||||
|
|
||||||
for name in self.config.cameras.keys():
|
for name in self.config.cameras.keys():
|
||||||
model = self.config.model_for_camera(name)
|
|
||||||
model_cameras[model.scene].append(name)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
largest_frame = max(
|
||||||
|
[
|
||||||
|
det.model.height * det.model.width * 3
|
||||||
|
if det.model is not None
|
||||||
|
else 320
|
||||||
|
for det in self.config.detectors.values()
|
||||||
|
]
|
||||||
|
)
|
||||||
shm_in = UntrackedSharedMemory(
|
shm_in = UntrackedSharedMemory(
|
||||||
name=name,
|
name=name,
|
||||||
create=True,
|
create=True,
|
||||||
size=detection_frame_size(model),
|
size=largest_frame,
|
||||||
)
|
)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
shm_in = UntrackedSharedMemory(name=name)
|
shm_in = UntrackedSharedMemory(name=name)
|
||||||
@@ -375,26 +371,15 @@ class FrigateApp:
|
|||||||
self.detection_shms.append(shm_in)
|
self.detection_shms.append(shm_in)
|
||||||
self.detection_shms.append(shm_out)
|
self.detection_shms.append(shm_out)
|
||||||
|
|
||||||
# a device may be listed more than once to run additional inference
|
for name, detector_config in self.config.detectors.items():
|
||||||
# processes on it, so names are only unique once de-duplicated
|
self.detectors[name] = ObjectDetectProcess(
|
||||||
all_devices = [
|
name,
|
||||||
device
|
self.detection_queue,
|
||||||
for model in self.config.models
|
list(self.config.cameras.keys()),
|
||||||
for device in self.config.devices_for_model(model)
|
self.config,
|
||||||
]
|
detector_config,
|
||||||
names = iter(runner_names(all_devices))
|
self.stop_event,
|
||||||
|
)
|
||||||
for model in self.config.models:
|
|
||||||
for device in self.config.devices_for_model(model):
|
|
||||||
name = next(names)
|
|
||||||
self.detectors[name] = ObjectDetectProcess(
|
|
||||||
name,
|
|
||||||
self.detection_queues[model.scene],
|
|
||||||
model_cameras[model.scene],
|
|
||||||
self.config,
|
|
||||||
build_detector_config(device, model),
|
|
||||||
self.stop_event,
|
|
||||||
)
|
|
||||||
|
|
||||||
def start_ptz_autotracker(self) -> None:
|
def start_ptz_autotracker(self) -> None:
|
||||||
self.ptz_autotracker_thread = PtzAutoTrackerThread(
|
self.ptz_autotracker_thread = PtzAutoTrackerThread(
|
||||||
@@ -425,7 +410,7 @@ class FrigateApp:
|
|||||||
def start_camera_processor(self) -> None:
|
def start_camera_processor(self) -> None:
|
||||||
self.camera_maintainer = CameraMaintainer(
|
self.camera_maintainer = CameraMaintainer(
|
||||||
self.config,
|
self.config,
|
||||||
self.detection_queues,
|
self.detection_queue,
|
||||||
self.detected_frames_queue,
|
self.detected_frames_queue,
|
||||||
self.camera_metrics,
|
self.camera_metrics,
|
||||||
self.ptz_metrics,
|
self.ptz_metrics,
|
||||||
@@ -689,10 +674,8 @@ class FrigateApp:
|
|||||||
for detector in self.detectors.values():
|
for detector in self.detectors.values():
|
||||||
detector.stop()
|
detector.stop()
|
||||||
|
|
||||||
for detection_queue in self.detection_queues.values():
|
empty_and_close_queue(self.detection_queue)
|
||||||
empty_and_close_queue(detection_queue)
|
logger.info("Detection queue closed")
|
||||||
|
|
||||||
logger.info("Detection queues closed")
|
|
||||||
|
|
||||||
self.detected_frames_processor.join()
|
self.detected_frames_processor.join()
|
||||||
empty_and_close_queue(self.detected_frames_queue)
|
empty_and_close_queue(self.detected_frames_queue)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ from frigate.config.camera.updater import (
|
|||||||
CameraConfigUpdateEnum,
|
CameraConfigUpdateEnum,
|
||||||
CameraConfigUpdateSubscriber,
|
CameraConfigUpdateSubscriber,
|
||||||
)
|
)
|
||||||
from frigate.detectors.detector_config import NON_LOGO_ATTRIBUTES
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -179,7 +178,7 @@ class CameraActivityManager:
|
|||||||
return
|
return
|
||||||
|
|
||||||
for label in camera_config.objects.track:
|
for label in camera_config.objects.track:
|
||||||
if label in NON_LOGO_ATTRIBUTES:
|
if label in self.config.model.non_logo_attributes:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
new_count = all_objects[label]
|
new_count = all_objects[label]
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ from frigate.config.camera.updater import (
|
|||||||
CameraConfigUpdateSubscriber,
|
CameraConfigUpdateSubscriber,
|
||||||
)
|
)
|
||||||
from frigate.const import REPLAY_CAMERA_PREFIX
|
from frigate.const import REPLAY_CAMERA_PREFIX
|
||||||
from frigate.detectors.detector_config import SceneEnum
|
|
||||||
from frigate.models import Regions
|
from frigate.models import Regions
|
||||||
from frigate.object_detection.util import detection_frame_size
|
|
||||||
from frigate.util.builtin import empty_and_close_queue
|
from frigate.util.builtin import empty_and_close_queue
|
||||||
from frigate.util.image import SharedMemoryFrameManager, UntrackedSharedMemory
|
from frigate.util.image import SharedMemoryFrameManager, UntrackedSharedMemory
|
||||||
from frigate.util.object import get_camera_regions_grid
|
from frigate.util.object import get_camera_regions_grid
|
||||||
@@ -31,7 +29,7 @@ class CameraMaintainer(threading.Thread):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: FrigateConfig,
|
config: FrigateConfig,
|
||||||
detection_queues: dict[SceneEnum, Queue],
|
detection_queue: Queue,
|
||||||
detected_frames_queue: Queue,
|
detected_frames_queue: Queue,
|
||||||
camera_metrics: DictProxy,
|
camera_metrics: DictProxy,
|
||||||
ptz_metrics: dict[str, PTZMetrics],
|
ptz_metrics: dict[str, PTZMetrics],
|
||||||
@@ -40,7 +38,7 @@ class CameraMaintainer(threading.Thread):
|
|||||||
):
|
):
|
||||||
super().__init__(name="camera_processor")
|
super().__init__(name="camera_processor")
|
||||||
self.config = config
|
self.config = config
|
||||||
self.detection_queues = detection_queues
|
self.detection_queue = detection_queue
|
||||||
self.detected_frames_queue = detected_frames_queue
|
self.detected_frames_queue = detected_frames_queue
|
||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
self.camera_metrics = camera_metrics
|
self.camera_metrics = camera_metrics
|
||||||
@@ -81,11 +79,10 @@ class CameraMaintainer(threading.Thread):
|
|||||||
# create or update region grids for each camera
|
# create or update region grids for each camera
|
||||||
for camera in self.config.cameras.values():
|
for camera in self.config.cameras.values():
|
||||||
assert camera.name is not None
|
assert camera.name is not None
|
||||||
model = self.config.model_for_camera(camera.name)
|
|
||||||
self.region_grids[camera.name] = get_camera_regions_grid(
|
self.region_grids[camera.name] = get_camera_regions_grid(
|
||||||
camera.name,
|
camera.name,
|
||||||
camera.detect,
|
camera.detect,
|
||||||
max(model.width, model.height),
|
max(self.config.model.width, self.config.model.height),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __calculate_shm_frame_count(self) -> int:
|
def __calculate_shm_frame_count(self) -> int:
|
||||||
@@ -117,7 +114,6 @@ class CameraMaintainer(threading.Thread):
|
|||||||
return
|
return
|
||||||
|
|
||||||
camera_stop_event = self.__ensure_camera_stop_event(name)
|
camera_stop_event = self.__ensure_camera_stop_event(name)
|
||||||
model = self.config.model_for_camera(name)
|
|
||||||
|
|
||||||
if runtime:
|
if runtime:
|
||||||
self.camera_metrics[name] = CameraMetrics(self.metrics_manager)
|
self.camera_metrics[name] = CameraMetrics(self.metrics_manager)
|
||||||
@@ -127,24 +123,32 @@ class CameraMaintainer(threading.Thread):
|
|||||||
self.region_grids[name] = get_camera_regions_grid(
|
self.region_grids[name] = get_camera_regions_grid(
|
||||||
name,
|
name,
|
||||||
config.detect,
|
config.detect,
|
||||||
max(model.width, model.height),
|
max(self.config.model.width, self.config.model.height),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
largest_frame = max(
|
||||||
|
[
|
||||||
|
det.model.height * det.model.width * 3
|
||||||
|
if det.model is not None
|
||||||
|
else 320
|
||||||
|
for det in self.config.detectors.values()
|
||||||
|
]
|
||||||
|
)
|
||||||
UntrackedSharedMemory(name=f"out-{name}", create=True, size=20 * 6 * 4)
|
UntrackedSharedMemory(name=f"out-{name}", create=True, size=20 * 6 * 4)
|
||||||
UntrackedSharedMemory(
|
UntrackedSharedMemory(
|
||||||
name=name,
|
name=name,
|
||||||
create=True,
|
create=True,
|
||||||
size=detection_frame_size(model),
|
size=largest_frame,
|
||||||
)
|
)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
camera_process = CameraTracker(
|
camera_process = CameraTracker(
|
||||||
config,
|
config,
|
||||||
model,
|
self.config.model,
|
||||||
model.merged_labelmap,
|
self.config.model.merged_labelmap,
|
||||||
self.detection_queues[model.scene],
|
self.detection_queue,
|
||||||
self.detected_frames_queue,
|
self.detected_frames_queue,
|
||||||
self.camera_metrics[name],
|
self.camera_metrics[name],
|
||||||
self.ptz_metrics[name],
|
self.ptz_metrics[name],
|
||||||
|
|||||||
+11
-7
@@ -40,7 +40,6 @@ class CameraState:
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.config = config
|
self.config = config
|
||||||
self.camera_config = config.cameras[name]
|
self.camera_config = config.cameras[name]
|
||||||
self.model = config.model_for_camera(name)
|
|
||||||
self.frame_manager = frame_manager
|
self.frame_manager = frame_manager
|
||||||
self.best_objects: dict[str, TrackedObject] = {}
|
self.best_objects: dict[str, TrackedObject] = {}
|
||||||
self.tracked_objects: dict[str, TrackedObject] = {}
|
self.tracked_objects: dict[str, TrackedObject] = {}
|
||||||
@@ -102,7 +101,9 @@ class CameraState:
|
|||||||
thickness = 1
|
thickness = 1
|
||||||
else:
|
else:
|
||||||
thickness = 2
|
thickness = 2
|
||||||
color = self.model.colormap.get(obj["label"], (255, 255, 255))
|
color = self.config.model.colormap.get(
|
||||||
|
obj["label"], (255, 255, 255)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
thickness = 1
|
thickness = 1
|
||||||
color = (255, 0, 0)
|
color = (255, 0, 0)
|
||||||
@@ -124,7 +125,9 @@ class CameraState:
|
|||||||
and obj["frame_time"] == frame_time
|
and obj["frame_time"] == frame_time
|
||||||
):
|
):
|
||||||
thickness = 5
|
thickness = 5
|
||||||
color = self.model.colormap.get(obj["label"], (255, 255, 255))
|
color = self.config.model.colormap.get(
|
||||||
|
obj["label"], (255, 255, 255)
|
||||||
|
)
|
||||||
|
|
||||||
# debug autotracking zooming - show the zoom factor box
|
# debug autotracking zooming - show the zoom factor box
|
||||||
if (
|
if (
|
||||||
@@ -258,7 +261,9 @@ class CameraState:
|
|||||||
if draw_options.get("paths"):
|
if draw_options.get("paths"):
|
||||||
for obj in tracked_objects.values():
|
for obj in tracked_objects.values():
|
||||||
if obj["frame_time"] == frame_time and obj["path_data"]:
|
if obj["frame_time"] == frame_time and obj["path_data"]:
|
||||||
color = self.model.colormap.get(obj["label"], (255, 255, 255))
|
color = self.config.model.colormap.get(
|
||||||
|
obj["label"], (255, 255, 255)
|
||||||
|
)
|
||||||
|
|
||||||
path_points = [
|
path_points = [
|
||||||
(
|
(
|
||||||
@@ -361,7 +366,7 @@ class CameraState:
|
|||||||
for id in new_ids:
|
for id in new_ids:
|
||||||
logger.debug(f"{self.name}: New tracked object ID: {id}")
|
logger.debug(f"{self.name}: New tracked object ID: {id}")
|
||||||
new_obj = tracked_objects[id] = TrackedObject(
|
new_obj = tracked_objects[id] = TrackedObject(
|
||||||
self.model,
|
self.config.model,
|
||||||
self.camera_config,
|
self.camera_config,
|
||||||
self.config.ui,
|
self.config.ui,
|
||||||
self.frame_cache,
|
self.frame_cache,
|
||||||
@@ -391,7 +396,6 @@ class CameraState:
|
|||||||
"attributes": new_obj.obj_data["attributes"],
|
"attributes": new_obj.obj_data["attributes"],
|
||||||
"current_estimated_speed": 0,
|
"current_estimated_speed": 0,
|
||||||
"velocity_angle": 0,
|
"velocity_angle": 0,
|
||||||
"path_data": [],
|
|
||||||
"recognized_license_plate": None,
|
"recognized_license_plate": None,
|
||||||
"recognized_license_plate_score": None,
|
"recognized_license_plate_score": None,
|
||||||
}
|
}
|
||||||
@@ -505,7 +509,7 @@ class CameraState:
|
|||||||
sub_label = None
|
sub_label = None
|
||||||
|
|
||||||
if obj.obj_data.get("sub_label"):
|
if obj.obj_data.get("sub_label"):
|
||||||
if obj.obj_data["sub_label"][0] in self.model.all_attributes:
|
if obj.obj_data["sub_label"][0] in self.config.model.all_attributes:
|
||||||
label = obj.obj_data["sub_label"][0]
|
label = obj.obj_data["sub_label"][0]
|
||||||
else:
|
else:
|
||||||
label = f"{object_type}-verified"
|
label = f"{object_type}-verified"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from frigate.camera.activity_manager import AudioActivityManager, CameraActivity
|
|||||||
from frigate.comms.base_communicator import Communicator
|
from frigate.comms.base_communicator import Communicator
|
||||||
from frigate.comms.runtime_state import RuntimeStatePersistence
|
from frigate.comms.runtime_state import RuntimeStatePersistence
|
||||||
from frigate.comms.webpush import WebPushClient
|
from frigate.comms.webpush import WebPushClient
|
||||||
from frigate.config import BirdseyeModeConfig, FrigateConfig
|
from frigate.config import BirdseyeModeEnum, FrigateConfig
|
||||||
from frigate.config.camera.updater import (
|
from frigate.config.camera.updater import (
|
||||||
CameraConfigUpdateEnum,
|
CameraConfigUpdateEnum,
|
||||||
CameraConfigUpdatePublisher,
|
CameraConfigUpdatePublisher,
|
||||||
@@ -156,11 +156,10 @@ class Dispatcher:
|
|||||||
if camera not in self.config.cameras:
|
if camera not in self.config.cameras:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
model = self.config.model_for_camera(camera)
|
|
||||||
grid = get_camera_regions_grid(
|
grid = get_camera_regions_grid(
|
||||||
camera,
|
camera,
|
||||||
self.config.cameras[camera].detect,
|
self.config.cameras[camera].detect,
|
||||||
max(model.width, model.height),
|
max(self.config.model.width, self.config.model.height),
|
||||||
)
|
)
|
||||||
return grid
|
return grid
|
||||||
|
|
||||||
@@ -883,9 +882,8 @@ class Dispatcher:
|
|||||||
def _on_birdseye_mode_command(self, camera_name: str, payload: str) -> None:
|
def _on_birdseye_mode_command(self, camera_name: str, payload: str) -> None:
|
||||||
"""Callback for birdseye mode topic."""
|
"""Callback for birdseye mode topic."""
|
||||||
|
|
||||||
mode = BirdseyeModeConfig.from_mqtt_payload(payload)
|
if payload not in ["CONTINUOUS", "MOTION", "OBJECTS"]:
|
||||||
if mode is None:
|
logger.info(f"Invalid birdseye_mode command: {payload}")
|
||||||
logger.info("Invalid birdseye_mode command: %s", payload)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
birdseye_settings = self.config.cameras[camera_name].birdseye
|
birdseye_settings = self.config.cameras[camera_name].birdseye
|
||||||
@@ -894,7 +892,7 @@ class Dispatcher:
|
|||||||
logger.info(f"Birdseye mode not enabled for {camera_name}")
|
logger.info(f"Birdseye mode not enabled for {camera_name}")
|
||||||
return
|
return
|
||||||
|
|
||||||
birdseye_settings.mode = mode
|
birdseye_settings.mode = BirdseyeModeEnum(payload.lower())
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Setting birdseye mode for {camera_name} to {birdseye_settings.mode}"
|
f"Setting birdseye mode for {camera_name} to {birdseye_settings.mode}"
|
||||||
)
|
)
|
||||||
@@ -903,9 +901,7 @@ class Dispatcher:
|
|||||||
CameraConfigUpdateTopic(CameraConfigUpdateEnum.birdseye, camera_name),
|
CameraConfigUpdateTopic(CameraConfigUpdateEnum.birdseye, camera_name),
|
||||||
birdseye_settings,
|
birdseye_settings,
|
||||||
)
|
)
|
||||||
self.publish(
|
self.publish(f"{camera_name}/birdseye_mode/state", payload, retain=True)
|
||||||
f"{camera_name}/birdseye_mode/state", mode.to_mqtt_payload(), retain=True
|
|
||||||
)
|
|
||||||
|
|
||||||
def _on_camera_notification_command(self, camera_name: str, payload: str) -> None:
|
def _on_camera_notification_command(self, camera_name: str, payload: str) -> None:
|
||||||
"""Callback for camera level notifications topic."""
|
"""Callback for camera level notifications topic."""
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class MqttClient(Communicator):
|
|||||||
self.publish(
|
self.publish(
|
||||||
f"{camera_name}/birdseye_mode/state",
|
f"{camera_name}/birdseye_mode/state",
|
||||||
(
|
(
|
||||||
camera.birdseye.mode.to_mqtt_payload()
|
camera.birdseye.mode.value.upper()
|
||||||
if camera.birdseye.enabled
|
if camera.birdseye.enabled
|
||||||
else "OFF"
|
else "OFF"
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ class WebPushClient(Communicator):
|
|||||||
# notification and auth config updater
|
# notification and auth config updater
|
||||||
self.global_config_subscriber = ConfigSubscriber("config/")
|
self.global_config_subscriber = ConfigSubscriber("config/")
|
||||||
self.config_subscriber = CameraConfigUpdateSubscriber(
|
self.config_subscriber = CameraConfigUpdateSubscriber(
|
||||||
self.config, self.config.cameras, [CameraConfigUpdateEnum.notifications]
|
self.config,
|
||||||
|
self.config.cameras,
|
||||||
|
[CameraConfigUpdateEnum.add, CameraConfigUpdateEnum.notifications],
|
||||||
)
|
)
|
||||||
self._refresh_user_cameras()
|
self._refresh_user_cameras()
|
||||||
|
|
||||||
@@ -213,6 +215,8 @@ class WebPushClient(Communicator):
|
|||||||
self.suspended_cameras[camera] = 0
|
self.suspended_cameras[camera] = 0
|
||||||
self.last_camera_notification_time[camera] = 0
|
self.last_camera_notification_time[camera] = 0
|
||||||
|
|
||||||
|
self._refresh_user_cameras()
|
||||||
|
|
||||||
if topic == "reviews":
|
if topic == "reviews":
|
||||||
decoded = json.loads(payload)
|
decoded = json.loads(payload)
|
||||||
camera = decoded["before"]["camera"]
|
camera = decoded["before"]["camera"]
|
||||||
|
|||||||
+63
-4
@@ -3,6 +3,8 @@
|
|||||||
import errno
|
import errno
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import queue
|
||||||
|
import socket
|
||||||
import threading
|
import threading
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@@ -74,6 +76,9 @@ _WS_VIEWER_TOPICS = frozenset(
|
|||||||
# Camera-scoped command topics a camera-authorized (non-admin) user may send.
|
# Camera-scoped command topics a camera-authorized (non-admin) user may send.
|
||||||
_WS_CAMERA_COMMAND_TOPICS = frozenset({"ptz"})
|
_WS_CAMERA_COMMAND_TOPICS = frozenset({"ptz"})
|
||||||
|
|
||||||
|
# Max outbound messages waiting on a client's writer thread.
|
||||||
|
WS_MAX_PENDING_MESSAGES = 256
|
||||||
|
|
||||||
|
|
||||||
def _check_ws_authorization(
|
def _check_ws_authorization(
|
||||||
topic: str,
|
topic: str,
|
||||||
@@ -446,6 +451,63 @@ def _materialize_for_ws(
|
|||||||
|
|
||||||
|
|
||||||
class WebSocket(WebSocket_): # type: ignore[misc]
|
class WebSocket(WebSocket_): # type: ignore[misc]
|
||||||
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self._send_queue: queue.Queue[tuple[Any, bool] | None] = queue.Queue(
|
||||||
|
maxsize=WS_MAX_PENDING_MESSAGES
|
||||||
|
)
|
||||||
|
self._writer: threading.Thread | None = None
|
||||||
|
self._aborted = False
|
||||||
|
|
||||||
|
def opened(self) -> None:
|
||||||
|
# every client gets its own writer so a client that stops reading only
|
||||||
|
# blocks itself, never the thread that called publish()
|
||||||
|
self._writer = threading.Thread(
|
||||||
|
target=self._drain_send_queue, name="ws_writer", daemon=True
|
||||||
|
)
|
||||||
|
self._writer.start()
|
||||||
|
|
||||||
|
def send(self, payload: Any, binary: bool = False) -> None:
|
||||||
|
try:
|
||||||
|
self._send_queue.put_nowait((payload, binary))
|
||||||
|
except queue.Full:
|
||||||
|
self._abort("Websocket client is not keeping up, disconnecting it")
|
||||||
|
|
||||||
|
def _drain_send_queue(self) -> None:
|
||||||
|
while True:
|
||||||
|
item = self._send_queue.get()
|
||||||
|
if item is None or self.terminated or self.sock is None:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
super().send(*item)
|
||||||
|
except Exception:
|
||||||
|
self._abort()
|
||||||
|
return
|
||||||
|
|
||||||
|
def _abort(self, reason: str | None = None) -> None:
|
||||||
|
# publish() keeps hitting a full queue until the manager thread removes
|
||||||
|
# the connection, so only act (and log) the first time
|
||||||
|
if self._aborted:
|
||||||
|
return
|
||||||
|
self._aborted = True
|
||||||
|
if reason:
|
||||||
|
logger.warning(reason)
|
||||||
|
|
||||||
|
# shutdown rather than close so the ws4py manager thread sees EOF and
|
||||||
|
# runs its normal unregister/terminate; this also unblocks a stuck sendall
|
||||||
|
sock = self.sock
|
||||||
|
if sock is not None:
|
||||||
|
try:
|
||||||
|
sock.shutdown(socket.SHUT_RDWR)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def closed(self, code: int, reason: str | None = None) -> None:
|
||||||
|
try:
|
||||||
|
self._send_queue.put_nowait(None)
|
||||||
|
except queue.Full:
|
||||||
|
pass
|
||||||
|
|
||||||
def unhandled_error(self, error: Any) -> None:
|
def unhandled_error(self, error: Any) -> None:
|
||||||
"""
|
"""
|
||||||
Handles the unfriendly socket closures on the server side
|
Handles the unfriendly socket closures on the server side
|
||||||
@@ -580,10 +642,7 @@ class WebSocketClient(Communicator):
|
|||||||
)
|
)
|
||||||
if message is None:
|
if message is None:
|
||||||
continue
|
continue
|
||||||
try:
|
ws.send(message)
|
||||||
ws.send(message)
|
|
||||||
except (ConnectionResetError, BrokenPipeError, ValueError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def stop(self) -> None:
|
def stop(self) -> None:
|
||||||
if self.websocket_server is not None:
|
if self.websocket_server is not None:
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from ..base import FrigateBaseModel
|
from ..base import FrigateBaseModel
|
||||||
@@ -6,78 +8,22 @@ __all__ = [
|
|||||||
"BirdseyeCameraConfig",
|
"BirdseyeCameraConfig",
|
||||||
"BirdseyeConfig",
|
"BirdseyeConfig",
|
||||||
"BirdseyeLayoutConfig",
|
"BirdseyeLayoutConfig",
|
||||||
"BirdseyeModeConfig",
|
"BirdseyeModeEnum",
|
||||||
]
|
]
|
||||||
|
|
||||||
BIRDSEYE_ACTIVITY_TYPES = (
|
|
||||||
"objects",
|
|
||||||
"motion",
|
|
||||||
"stationary_objects",
|
|
||||||
"continuous",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
class BirdseyeModeEnum(str, Enum):
|
||||||
class BirdseyeModeConfig(FrigateBaseModel):
|
objects = "objects"
|
||||||
continuous: bool = Field(
|
motion = "motion"
|
||||||
default=False,
|
continuous = "continuous"
|
||||||
title="Continuous",
|
|
||||||
description="Always include the camera in Birdseye.",
|
|
||||||
)
|
|
||||||
motion: bool = Field(
|
|
||||||
default=False,
|
|
||||||
title="Motion",
|
|
||||||
description="Include the camera in Birdseye when motion is detected.",
|
|
||||||
)
|
|
||||||
objects: bool = Field(
|
|
||||||
default=False,
|
|
||||||
title="Active objects",
|
|
||||||
description="Include the camera in Birdseye while an active object is tracked.",
|
|
||||||
)
|
|
||||||
stationary_objects: bool = Field(
|
|
||||||
default=False,
|
|
||||||
title="Stationary objects",
|
|
||||||
description="Include the camera in Birdseye while a stationary object is tracked.",
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_mqtt_payload(cls, payload: str) -> "BirdseyeModeConfig | None":
|
def get_index(cls, type):
|
||||||
"""Create mode options from an uppercase MQTT payload."""
|
return list(cls).index(type)
|
||||||
raw_modes = payload.split(",")
|
|
||||||
if not raw_modes or any(not mode for mode in raw_modes):
|
|
||||||
return None
|
|
||||||
|
|
||||||
modes = [mode.lower() for mode in raw_modes]
|
@classmethod
|
||||||
if any(
|
def get(cls, index):
|
||||||
raw_mode != mode.upper() or mode not in BIRDSEYE_ACTIVITY_TYPES
|
return list(cls)[index]
|
||||||
for raw_mode, mode in zip(raw_modes, modes)
|
|
||||||
):
|
|
||||||
return None
|
|
||||||
|
|
||||||
if len(modes) != len(set(modes)):
|
|
||||||
return None
|
|
||||||
|
|
||||||
return cls(**{mode: True for mode in modes})
|
|
||||||
|
|
||||||
def has_enabled_activity(self) -> bool:
|
|
||||||
"""Return whether at least one activity type is enabled."""
|
|
||||||
return any(getattr(self, activity) for activity in BIRDSEYE_ACTIVITY_TYPES)
|
|
||||||
|
|
||||||
def to_mqtt_payload(self) -> str:
|
|
||||||
"""Serialize enabled mode options for MQTT state topics."""
|
|
||||||
payload = ",".join(
|
|
||||||
activity.upper()
|
|
||||||
for activity in BIRDSEYE_ACTIVITY_TYPES
|
|
||||||
if getattr(self, activity)
|
|
||||||
)
|
|
||||||
if not payload:
|
|
||||||
raise ValueError("At least one Birdseye activity type must be enabled")
|
|
||||||
|
|
||||||
return payload
|
|
||||||
|
|
||||||
|
|
||||||
def default_birdseye_mode() -> BirdseyeModeConfig:
|
|
||||||
"""Return the default Birdseye mode configuration."""
|
|
||||||
return BirdseyeModeConfig(objects=True)
|
|
||||||
|
|
||||||
|
|
||||||
class BirdseyeLayoutConfig(FrigateBaseModel):
|
class BirdseyeLayoutConfig(FrigateBaseModel):
|
||||||
@@ -101,10 +47,10 @@ class BirdseyeConfig(FrigateBaseModel):
|
|||||||
title="Enable Birdseye",
|
title="Enable Birdseye",
|
||||||
description="Enable or disable the Birdseye view feature.",
|
description="Enable or disable the Birdseye view feature.",
|
||||||
)
|
)
|
||||||
mode: BirdseyeModeConfig = Field(
|
mode: BirdseyeModeEnum = Field(
|
||||||
default_factory=default_birdseye_mode,
|
default=BirdseyeModeEnum.objects,
|
||||||
title="Activity types",
|
title="Tracking mode",
|
||||||
description="Activity types that include cameras in Birdseye.",
|
description="Mode for including cameras in Birdseye: 'objects', 'motion', or 'continuous'.",
|
||||||
)
|
)
|
||||||
|
|
||||||
restream: bool = Field(
|
restream: bool = Field(
|
||||||
@@ -156,10 +102,10 @@ class BirdseyeCameraConfig(BaseModel):
|
|||||||
title="Enable Birdseye",
|
title="Enable Birdseye",
|
||||||
description="Enable or disable the Birdseye view feature.",
|
description="Enable or disable the Birdseye view feature.",
|
||||||
)
|
)
|
||||||
mode: BirdseyeModeConfig = Field(
|
mode: BirdseyeModeEnum = Field(
|
||||||
default_factory=default_birdseye_mode,
|
default=BirdseyeModeEnum.objects,
|
||||||
title="Activity types",
|
title="Tracking mode",
|
||||||
description="Activity types that include cameras in Birdseye.",
|
description="Mode for including cameras in Birdseye: 'objects', 'motion', or 'continuous'.",
|
||||||
)
|
)
|
||||||
|
|
||||||
order: int = Field(
|
order: int = Field(
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
from pydantic import Field, model_validator
|
from pydantic import Field, model_validator
|
||||||
|
|
||||||
from frigate.detectors.detector_config import SceneEnum
|
|
||||||
|
|
||||||
from ..base import FrigateBaseModel
|
from ..base import FrigateBaseModel
|
||||||
|
|
||||||
__all__ = ["DetectConfig", "StationaryConfig", "StationaryMaxFramesConfig"]
|
__all__ = ["DetectConfig", "StationaryConfig", "StationaryMaxFramesConfig"]
|
||||||
@@ -62,11 +60,6 @@ class DetectConfig(FrigateBaseModel):
|
|||||||
title="Detect width",
|
title="Detect width",
|
||||||
description="Width (pixels) of frames used for the detect stream; leave empty to use the native stream resolution.",
|
description="Width (pixels) of frames used for the detect stream; leave empty to use the native stream resolution.",
|
||||||
)
|
)
|
||||||
scene: SceneEnum | None = Field(
|
|
||||||
default=None,
|
|
||||||
title="Detect scene",
|
|
||||||
description="The environment this camera looks at, used to pick which of the configured models runs on it. Defaults to the model with a scene of 'all'.",
|
|
||||||
)
|
|
||||||
fps: int = Field(
|
fps: int = Field(
|
||||||
default=5,
|
default=5,
|
||||||
title="Detect FPS",
|
title="Detect FPS",
|
||||||
|
|||||||
+61
-244
@@ -11,6 +11,7 @@ from pydantic import (
|
|||||||
BaseModel,
|
BaseModel,
|
||||||
ConfigDict,
|
ConfigDict,
|
||||||
Field,
|
Field,
|
||||||
|
TypeAdapter,
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
field_validator,
|
field_validator,
|
||||||
model_validator,
|
model_validator,
|
||||||
@@ -18,9 +19,8 @@ from pydantic import (
|
|||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
|
|
||||||
from frigate.const import REGEX_JSON
|
from frigate.const import REGEX_JSON
|
||||||
from frigate.detectors import ModelConfig
|
from frigate.detectors import DetectorConfig, ModelConfig
|
||||||
from frigate.detectors.detector_config import SceneEnum
|
from frigate.detectors.detector_config import BaseDetectorConfig
|
||||||
from frigate.detectors.device import DeviceParseError, DeviceSpec, parse_device
|
|
||||||
from frigate.plus import PlusApi
|
from frigate.plus import PlusApi
|
||||||
from frigate.util.builtin import (
|
from frigate.util.builtin import (
|
||||||
deep_merge,
|
deep_merge,
|
||||||
@@ -41,7 +41,7 @@ from .auth import AuthConfig
|
|||||||
from .base import FrigateBaseModel
|
from .base import FrigateBaseModel
|
||||||
from .camera import CameraConfig, CameraLiveConfig
|
from .camera import CameraConfig, CameraLiveConfig
|
||||||
from .camera.audio import AudioConfig, AudioFilterConfig
|
from .camera.audio import AudioConfig, AudioFilterConfig
|
||||||
from .camera.birdseye import BirdseyeConfig, BirdseyeModeConfig
|
from .camera.birdseye import BirdseyeConfig
|
||||||
from .camera.detect import DetectConfig
|
from .camera.detect import DetectConfig
|
||||||
from .camera.ffmpeg import FfmpegConfig
|
from .camera.ffmpeg import FfmpegConfig
|
||||||
from .camera.genai import GenAIConfig, GenAIRoleEnum
|
from .camera.genai import GenAIConfig, GenAIRoleEnum
|
||||||
@@ -79,14 +79,9 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
yaml = YAML()
|
yaml = YAML()
|
||||||
|
|
||||||
# Pydantic field default applied when an existing config omits `models:`.
|
# Pydantic field default applied when an existing config omits `detectors:`.
|
||||||
# Kept as cpu tflite for backwards compatibility with 0.17 configs.
|
# Kept as cpu tflite for backwards compatibility with 0.17 configs.
|
||||||
DEFAULT_MODELS = [{"devices": ["cpu"]}]
|
DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
|
||||||
|
|
||||||
|
|
||||||
def _default_models() -> list[ModelConfig]:
|
|
||||||
return [ModelConfig.model_validate(model) for model in DEFAULT_MODELS]
|
|
||||||
|
|
||||||
|
|
||||||
# Used by the openvino branch below and rendered into the new-config YAML
|
# Used by the openvino branch below and rendered into the new-config YAML
|
||||||
# template so first-time setups default to openvino on CPU.
|
# template so first-time setups default to openvino on CPU.
|
||||||
@@ -98,7 +93,7 @@ DEFAULT_MODEL = {
|
|||||||
"path": "/openvino-model/ssdlite_mobilenet_v2.xml",
|
"path": "/openvino-model/ssdlite_mobilenet_v2.xml",
|
||||||
"labelmap_path": "/openvino-model/coco_91cl_bkgr.txt",
|
"labelmap_path": "/openvino-model/coco_91cl_bkgr.txt",
|
||||||
}
|
}
|
||||||
NEW_CONFIG_MODELS = [{"devices": ["openvino:CPU"], **DEFAULT_MODEL}]
|
NEW_CONFIG_DETECTORS = {"ov": {"type": "openvino", "device": "CPU"}}
|
||||||
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
|
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
|
||||||
|
|
||||||
|
|
||||||
@@ -114,7 +109,7 @@ DEFAULT_CONFIG = f"""
|
|||||||
mqtt:
|
mqtt:
|
||||||
enabled: False
|
enabled: False
|
||||||
|
|
||||||
{_render_default_yaml({"models": NEW_CONFIG_MODELS})}
|
{_render_default_yaml({"detectors": NEW_CONFIG_DETECTORS, "model": DEFAULT_MODEL})}
|
||||||
cameras: {{}} # No cameras defined, UI wizard should be used
|
cameras: {{}} # No cameras defined, UI wizard should be used
|
||||||
version: {CURRENT_CONFIG_VERSION}
|
version: {CURRENT_CONFIG_VERSION}
|
||||||
"""
|
"""
|
||||||
@@ -331,20 +326,8 @@ def verify_required_zones_exist(camera_config: CameraConfig) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def verify_profile_overrides_match_base(camera_config: CameraConfig) -> None:
|
def verify_profile_overrides_match_base(camera_config: CameraConfig) -> None:
|
||||||
"""Verify profile overrides against the resolved base camera configuration."""
|
"""Verify that profile zone and mask IDs reference entries defined on the base camera."""
|
||||||
for profile_name, profile in camera_config.profiles.items():
|
for profile_name, profile in camera_config.profiles.items():
|
||||||
if profile.birdseye is not None:
|
|
||||||
overrides = profile.birdseye.mode.model_dump(exclude_unset=True)
|
|
||||||
base_mode = camera_config.birdseye.mode.model_dump()
|
|
||||||
resolved_mode = BirdseyeModeConfig.model_validate(
|
|
||||||
deep_merge(overrides, base_mode)
|
|
||||||
)
|
|
||||||
if not resolved_mode.has_enabled_activity():
|
|
||||||
raise ValueError(
|
|
||||||
f"Camera '{camera_config.name}' profile '{profile_name}' must "
|
|
||||||
"enable at least one Birdseye activity type"
|
|
||||||
)
|
|
||||||
|
|
||||||
if profile.zones:
|
if profile.zones:
|
||||||
for zone_name in profile.zones:
|
for zone_name in profile.zones:
|
||||||
if zone_name not in camera_config.zones:
|
if zone_name not in camera_config.zones:
|
||||||
@@ -514,11 +497,16 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
description="User interface preferences such as timezone, time/date formatting, and units.",
|
description="User interface preferences such as timezone, time/date formatting, and units.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Detection model config
|
# Detector config
|
||||||
models: list[ModelConfig] = Field(
|
detectors: dict[str, BaseDetectorConfig] = Field(
|
||||||
default_factory=_default_models,
|
default=DEFAULT_DETECTORS,
|
||||||
title="Detection models",
|
title="Detector hardware",
|
||||||
description="Object detection models and the hardware each one runs on. Cameras pick a model by matching their detect.scene against a model's scene.",
|
description="Configuration for object detectors (CPU, GPU, ONNX backends) and any detector-specific model settings.",
|
||||||
|
)
|
||||||
|
model: ModelConfig = Field(
|
||||||
|
default_factory=ModelConfig,
|
||||||
|
title="Detection model",
|
||||||
|
description="Settings to configure a custom object detection model and its input shape.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# GenAI config (named provider configs: name -> GenAIConfig)
|
# GenAI config (named provider configs: name -> GenAIConfig)
|
||||||
@@ -633,202 +621,11 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
_plus_api: PlusApi
|
_plus_api: PlusApi
|
||||||
_model_devices: dict[SceneEnum, list[DeviceSpec]]
|
|
||||||
_camera_models: dict[str, ModelConfig]
|
|
||||||
_all_attributes: list[str]
|
|
||||||
_all_attribute_logos: list[str]
|
|
||||||
_all_attributes_map: dict[str, list[str]]
|
|
||||||
_all_labels: set[str]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def plus_api(self) -> PlusApi:
|
def plus_api(self) -> PlusApi:
|
||||||
return self._plus_api
|
return self._plus_api
|
||||||
|
|
||||||
@property
|
|
||||||
def all_attributes(self) -> list[str]:
|
|
||||||
"""Every attribute label across all configured models."""
|
|
||||||
return self._all_attributes
|
|
||||||
|
|
||||||
@property
|
|
||||||
def all_attribute_logos(self) -> list[str]:
|
|
||||||
"""Every logo attribute label across all configured models."""
|
|
||||||
return self._all_attribute_logos
|
|
||||||
|
|
||||||
@property
|
|
||||||
def all_attributes_map(self) -> dict[str, list[str]]:
|
|
||||||
"""Object label to attribute labels, merged across all configured models."""
|
|
||||||
return self._all_attributes_map
|
|
||||||
|
|
||||||
@property
|
|
||||||
def all_labels(self) -> set[str]:
|
|
||||||
"""Every object label across all configured models."""
|
|
||||||
return self._all_labels
|
|
||||||
|
|
||||||
@property
|
|
||||||
def primary_model(self) -> ModelConfig:
|
|
||||||
"""The model used when no specific camera is in play."""
|
|
||||||
for model in self.models:
|
|
||||||
if model.scene == SceneEnum.all:
|
|
||||||
return model
|
|
||||||
|
|
||||||
return self.models[0]
|
|
||||||
|
|
||||||
def model_for_camera(self, camera_name: str) -> ModelConfig:
|
|
||||||
"""Get the detection model a camera runs on.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
camera_name: Name of the camera
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The model matching the camera's detect scene
|
|
||||||
"""
|
|
||||||
return self._camera_models[camera_name]
|
|
||||||
|
|
||||||
def devices_for_model(self, model: ModelConfig) -> list[DeviceSpec]:
|
|
||||||
"""Get the parsed hardware devices a model runs on.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
model: One of the configured models
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The parsed device specs, in config order
|
|
||||||
"""
|
|
||||||
return self._model_devices[model.scene]
|
|
||||||
|
|
||||||
def _load_model(self, model: ModelConfig, detector: str) -> ModelConfig:
|
|
||||||
"""Apply detector specific defaults to a model and load its weights and labels.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
model: The configured model
|
|
||||||
detector: The detector type the model runs on
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The loaded model
|
|
||||||
"""
|
|
||||||
model_config = model.model_dump(exclude_unset=True, warnings="none")
|
|
||||||
|
|
||||||
if "path" not in model_config:
|
|
||||||
if detector == "cpu" or detector.endswith("_tfl"):
|
|
||||||
model_config["path"] = "/cpu_model.tflite"
|
|
||||||
elif detector == "edgetpu":
|
|
||||||
model_config["path"] = "/edgetpu_model.tflite"
|
|
||||||
elif detector == "openvino":
|
|
||||||
for default_key, default_value in DEFAULT_MODEL.items():
|
|
||||||
model_config.setdefault(default_key, default_value)
|
|
||||||
|
|
||||||
loaded = ModelConfig.model_validate(model_config)
|
|
||||||
loaded.check_and_load_plus_model(self.plus_api, detector)
|
|
||||||
loaded.compute_model_hash()
|
|
||||||
return loaded
|
|
||||||
|
|
||||||
def _load_models(self) -> None:
|
|
||||||
"""Validate the configured models and load each one."""
|
|
||||||
if not self.models:
|
|
||||||
raise ValueError("At least one model must be configured under models")
|
|
||||||
|
|
||||||
model_devices: dict[SceneEnum, list[DeviceSpec]] = {}
|
|
||||||
# device string -> the scene of the model that already claimed it
|
|
||||||
claimed_devices: dict[str, SceneEnum] = {}
|
|
||||||
|
|
||||||
for index, model in enumerate(self.models):
|
|
||||||
scene = model.scene.value
|
|
||||||
|
|
||||||
if model.scene in model_devices:
|
|
||||||
raise ValueError(
|
|
||||||
f"Multiple models are configured with a scene of '{scene}'. Each model must use a different scene."
|
|
||||||
)
|
|
||||||
|
|
||||||
if not model.devices:
|
|
||||||
raise ValueError(
|
|
||||||
f"Model '{scene}' must list at least one entry under devices."
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
devices = [parse_device(device) for device in model.devices]
|
|
||||||
except DeviceParseError as err:
|
|
||||||
raise ValueError(
|
|
||||||
f"Model '{scene}' has an invalid device: {err}"
|
|
||||||
) from err
|
|
||||||
|
|
||||||
detectors = {device.detector for device in devices}
|
|
||||||
|
|
||||||
if len(detectors) > 1:
|
|
||||||
raise ValueError(
|
|
||||||
f"Model '{scene}' mixes the {', '.join(sorted(detectors))} detectors. All of a model's devices must use the same detector."
|
|
||||||
)
|
|
||||||
|
|
||||||
for device in devices:
|
|
||||||
if device.raw in claimed_devices and not device.shareable:
|
|
||||||
other = claimed_devices[device.raw]
|
|
||||||
where = (
|
|
||||||
f"twice by model '{scene}'"
|
|
||||||
if other == model.scene
|
|
||||||
else f"by both the '{other.value}' and '{scene}' models"
|
|
||||||
)
|
|
||||||
raise ValueError(
|
|
||||||
f"Device '{device.raw}' is used {where}, but it can only run one detection process."
|
|
||||||
)
|
|
||||||
|
|
||||||
claimed_devices[device.raw] = model.scene
|
|
||||||
|
|
||||||
self.models[index] = self._load_model(model, devices[0].detector)
|
|
||||||
model_devices[model.scene] = devices
|
|
||||||
|
|
||||||
attributes: set[str] = set()
|
|
||||||
attribute_logos: set[str] = set()
|
|
||||||
attributes_map: dict[str, set[str]] = {}
|
|
||||||
labels: set[str] = set()
|
|
||||||
|
|
||||||
for model in self.models:
|
|
||||||
attributes.update(model.all_attributes)
|
|
||||||
attribute_logos.update(model.all_attribute_logos)
|
|
||||||
labels.update(model.merged_labelmap.values())
|
|
||||||
|
|
||||||
for label, label_attributes in model.attributes_map.items():
|
|
||||||
attributes_map.setdefault(label, set()).update(label_attributes)
|
|
||||||
|
|
||||||
self._model_devices = model_devices
|
|
||||||
self._all_attributes = sorted(attributes)
|
|
||||||
self._all_attribute_logos = sorted(attribute_logos)
|
|
||||||
self._all_attributes_map = {
|
|
||||||
label: sorted(label_attributes)
|
|
||||||
for label, label_attributes in sorted(attributes_map.items())
|
|
||||||
}
|
|
||||||
self._all_labels = labels
|
|
||||||
|
|
||||||
def _resolve_camera_model(self, name: str, scene: SceneEnum | None) -> ModelConfig:
|
|
||||||
"""Resolve which model a camera runs on.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
name: Name of the camera
|
|
||||||
scene: The camera's configured detect scene, if any
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The model the camera runs on
|
|
||||||
"""
|
|
||||||
by_scene = {model.scene: model for model in self.models}
|
|
||||||
|
|
||||||
if scene is not None:
|
|
||||||
model = by_scene.get(scene)
|
|
||||||
|
|
||||||
if model is None:
|
|
||||||
raise ValueError(
|
|
||||||
f"Camera '{name}' has a detect scene of '{scene.value}', but no model is configured for that scene."
|
|
||||||
)
|
|
||||||
|
|
||||||
return model
|
|
||||||
|
|
||||||
default = by_scene.get(SceneEnum.all) or (
|
|
||||||
self.models[0] if len(self.models) == 1 else None
|
|
||||||
)
|
|
||||||
|
|
||||||
if default is None:
|
|
||||||
raise ValueError(
|
|
||||||
f"Camera '{name}' must set detect -> scene, because more than one model is configured and none of them uses a scene of 'all'."
|
|
||||||
)
|
|
||||||
|
|
||||||
return default
|
|
||||||
|
|
||||||
@model_validator(mode="after")
|
@model_validator(mode="after")
|
||||||
def post_validation(self, info: ValidationInfo) -> Self:
|
def post_validation(self, info: ValidationInfo) -> Self:
|
||||||
# Load plus api from context, if possible.
|
# Load plus api from context, if possible.
|
||||||
@@ -873,10 +670,8 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
"'embeddings' in its roles for semantic search."
|
"'embeddings' in its roles for semantic search."
|
||||||
)
|
)
|
||||||
|
|
||||||
self._load_models()
|
|
||||||
|
|
||||||
# set default min_score for object attributes
|
# set default min_score for object attributes
|
||||||
for attribute in self.all_attributes:
|
for attribute in self.model.all_attributes:
|
||||||
existing = self.objects.filters.get(attribute)
|
existing = self.objects.filters.get(attribute)
|
||||||
if existing is None:
|
if existing is None:
|
||||||
self.objects.filters[attribute] = FilterConfig(min_score=0.7)
|
self.objects.filters[attribute] = FilterConfig(min_score=0.7)
|
||||||
@@ -926,7 +721,44 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
exclude_unset=True,
|
exclude_unset=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._camera_models = {}
|
for key, detector in self.detectors.items():
|
||||||
|
adapter = TypeAdapter(DetectorConfig)
|
||||||
|
model_dict = (
|
||||||
|
detector
|
||||||
|
if isinstance(detector, dict)
|
||||||
|
else detector.model_dump(warnings="none")
|
||||||
|
)
|
||||||
|
detector_config: BaseDetectorConfig = adapter.validate_python(model_dict)
|
||||||
|
|
||||||
|
# users should not set model themselves
|
||||||
|
if detector_config.model:
|
||||||
|
logger.warning(
|
||||||
|
"The model key should be specified at the root level of the config, not under detectors. The nested model key will be ignored."
|
||||||
|
)
|
||||||
|
detector_config.model = None
|
||||||
|
|
||||||
|
model_config = self.model.model_dump(exclude_unset=True, warnings="none")
|
||||||
|
|
||||||
|
if detector_config.model_path:
|
||||||
|
model_config["path"] = detector_config.model_path
|
||||||
|
|
||||||
|
if "path" not in model_config:
|
||||||
|
if detector_config.type == "cpu" or detector_config.type.endswith(
|
||||||
|
"_tfl"
|
||||||
|
):
|
||||||
|
model_config["path"] = "/cpu_model.tflite"
|
||||||
|
elif detector_config.type == "edgetpu":
|
||||||
|
model_config["path"] = "/edgetpu_model.tflite"
|
||||||
|
elif detector_config.type == "openvino":
|
||||||
|
for default_key, default_value in DEFAULT_MODEL.items():
|
||||||
|
model_config.setdefault(default_key, default_value)
|
||||||
|
|
||||||
|
model = ModelConfig.model_validate(model_config)
|
||||||
|
model.check_and_load_plus_model(self.plus_api, detector_config.type)
|
||||||
|
model.compute_model_hash()
|
||||||
|
labelmap_objects = model.merged_labelmap.values()
|
||||||
|
detector_config.model = model
|
||||||
|
self.detectors[key] = detector_config
|
||||||
|
|
||||||
for name, camera in self.cameras.items():
|
for name, camera in self.cameras.items():
|
||||||
modified_global_config = global_config.copy()
|
modified_global_config = global_config.copy()
|
||||||
@@ -953,9 +785,6 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
{"name": name, **merged_config}
|
{"name": name, **merged_config}
|
||||||
)
|
)
|
||||||
|
|
||||||
camera_model = self._resolve_camera_model(name, camera_config.detect.scene)
|
|
||||||
self._camera_models[name] = camera_model
|
|
||||||
|
|
||||||
if camera_config.ffmpeg.hwaccel_args == "auto":
|
if camera_config.ffmpeg.hwaccel_args == "auto":
|
||||||
camera_config.ffmpeg.hwaccel_args = self.ffmpeg.hwaccel_args
|
camera_config.ffmpeg.hwaccel_args = self.ffmpeg.hwaccel_args
|
||||||
|
|
||||||
@@ -1169,10 +998,6 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
self.cameras[name] = camera_config
|
self.cameras[name] = camera_config
|
||||||
|
|
||||||
verify_config_roles(camera_config)
|
verify_config_roles(camera_config)
|
||||||
if not camera_config.birdseye.mode.has_enabled_activity():
|
|
||||||
raise ValueError(
|
|
||||||
f"Camera '{name}' must enable at least one Birdseye activity type"
|
|
||||||
)
|
|
||||||
verify_valid_live_stream_names(self, camera_config)
|
verify_valid_live_stream_names(self, camera_config)
|
||||||
verify_recording_segments_setup_with_reasonable_time(camera_config)
|
verify_recording_segments_setup_with_reasonable_time(camera_config)
|
||||||
verify_zone_objects_are_tracked(camera_config)
|
verify_zone_objects_are_tracked(camera_config)
|
||||||
@@ -1180,7 +1005,7 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
verify_profile_overrides_match_base(camera_config)
|
verify_profile_overrides_match_base(camera_config)
|
||||||
verify_autotrack_zones(camera_config)
|
verify_autotrack_zones(camera_config)
|
||||||
verify_motion_and_detect(camera_config)
|
verify_motion_and_detect(camera_config)
|
||||||
verify_objects_track(camera_config, camera_model.merged_labelmap.values())
|
verify_objects_track(camera_config, labelmap_objects)
|
||||||
verify_lpr_and_face(self, camera_config)
|
verify_lpr_and_face(self, camera_config)
|
||||||
|
|
||||||
# Validate camera profiles reference top-level profile definitions
|
# Validate camera profiles reference top-level profile definitions
|
||||||
@@ -1197,16 +1022,8 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
config.name = name
|
config.name = name
|
||||||
|
|
||||||
self.objects.parse_all_objects(self.cameras)
|
self.objects.parse_all_objects(self.cameras)
|
||||||
|
self.model.create_colormap(sorted(self.objects.all_objects))
|
||||||
# every model shares one colormap so a label is drawn the same color no
|
self.model.check_and_load_plus_model(self.plus_api)
|
||||||
# matter which model detected it, so filter attributes across all models
|
|
||||||
# rather than letting each model filter with only its own
|
|
||||||
colored_labels = sorted(
|
|
||||||
set(self.objects.all_objects) - set(self.all_attributes)
|
|
||||||
)
|
|
||||||
|
|
||||||
for model in self.models:
|
|
||||||
model.create_colormap(colored_labels)
|
|
||||||
|
|
||||||
# Check audio transcription and audio detection requirements
|
# Check audio transcription and audio detection requirements
|
||||||
if self.audio_transcription.enabled:
|
if self.audio_transcription.enabled:
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ SECTION_STATE_TOPICS: dict[str, list[tuple[str, Callable[[Any], Any]]]] = {
|
|||||||
("birdseye", lambda c: "ON" if c.birdseye.enabled else "OFF"),
|
("birdseye", lambda c: "ON" if c.birdseye.enabled else "OFF"),
|
||||||
(
|
(
|
||||||
"birdseye_mode",
|
"birdseye_mode",
|
||||||
lambda c: (
|
lambda c: c.birdseye.mode.value.upper() if c.birdseye.enabled else "OFF",
|
||||||
c.birdseye.mode.to_mqtt_payload() if c.birdseye.enabled else "OFF"
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
"detect": [("detect", lambda c: "ON" if c.detect.enabled else "OFF")],
|
"detect": [("detect", lambda c: "ON" if c.detect.enabled else "OFF")],
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class LicensePlateProcessingMixin:
|
|||||||
# Object config
|
# Object config
|
||||||
self.lp_objects: list[str] = []
|
self.lp_objects: list[str] = []
|
||||||
|
|
||||||
for obj, attributes in self.config.all_attributes_map.items():
|
for obj, attributes in self.config.model.attributes_map.items():
|
||||||
if "license_plate" in attributes:
|
if "license_plate" in attributes:
|
||||||
self.lp_objects.append(obj)
|
self.lp_objects.append(obj)
|
||||||
|
|
||||||
|
|||||||
@@ -231,8 +231,8 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
|||||||
final_data,
|
final_data,
|
||||||
thumbs,
|
thumbs,
|
||||||
camera_config.review.genai,
|
camera_config.review.genai,
|
||||||
sorted(self.config.all_labels),
|
list(self.config.model.merged_labelmap.values()),
|
||||||
self.config.all_attributes,
|
self.config.model.all_attributes,
|
||||||
),
|
),
|
||||||
).start()
|
).start()
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, ClassVar
|
from typing import Any
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
@@ -15,9 +15,6 @@ from frigate.util.builtin import generate_color_palette, load_labels
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# attributes that are recognized rather than shown as a logo
|
|
||||||
NON_LOGO_ATTRIBUTES = ["face", "license_plate"]
|
|
||||||
|
|
||||||
|
|
||||||
class PixelFormatEnum(str, Enum):
|
class PixelFormatEnum(str, Enum):
|
||||||
rgb = "rgb"
|
rgb = "rgb"
|
||||||
@@ -47,27 +44,7 @@ class ModelTypeEnum(str, Enum):
|
|||||||
yologeneric = "yolo-generic"
|
yologeneric = "yolo-generic"
|
||||||
|
|
||||||
|
|
||||||
class SceneEnum(str, Enum):
|
|
||||||
"""The camera environment a detection model is intended for."""
|
|
||||||
|
|
||||||
all = "all"
|
|
||||||
indoor = "indoor"
|
|
||||||
outdoor = "outdoor"
|
|
||||||
indoor_thermal = "indoor_thermal"
|
|
||||||
outdoor_thermal = "outdoor_thermal"
|
|
||||||
|
|
||||||
|
|
||||||
class ModelConfig(BaseModel):
|
class ModelConfig(BaseModel):
|
||||||
scene: SceneEnum = Field(
|
|
||||||
default=SceneEnum.all,
|
|
||||||
title="Model scene",
|
|
||||||
description="The camera environment this model is used for. Cameras select a model by setting detect.scene to a matching value, and 'all' is used by any camera that does not set one.",
|
|
||||||
)
|
|
||||||
devices: list[str] = Field(
|
|
||||||
default_factory=list,
|
|
||||||
title="Detection hardware",
|
|
||||||
description="Hardware this model runs on, as '<detector>' or '<detector>:<device>' (for example 'edgetpu:pci:0' or 'openvino:GPU'). Listing the same device more than once runs additional inference processes on it.",
|
|
||||||
)
|
|
||||||
path: str | None = Field(
|
path: str | None = Field(
|
||||||
None,
|
None,
|
||||||
title="Custom object detector model path",
|
title="Custom object detector model path",
|
||||||
@@ -134,7 +111,7 @@ class ModelConfig(BaseModel):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def non_logo_attributes(self) -> list[str]:
|
def non_logo_attributes(self) -> list[str]:
|
||||||
return NON_LOGO_ATTRIBUTES
|
return ["face", "license_plate"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def all_attributes(self) -> list[str]:
|
def all_attributes(self) -> list[str]:
|
||||||
@@ -224,7 +201,9 @@ class ModelConfig(BaseModel):
|
|||||||
unique_attributes.update(attributes)
|
unique_attributes.update(attributes)
|
||||||
|
|
||||||
self._all_attributes = list(unique_attributes)
|
self._all_attributes = list(unique_attributes)
|
||||||
self._all_attribute_logos = list(unique_attributes - set(NON_LOGO_ATTRIBUTES))
|
self._all_attribute_logos = list(
|
||||||
|
unique_attributes - set(["face", "license_plate"])
|
||||||
|
)
|
||||||
|
|
||||||
self._merged_labelmap = {
|
self._merged_labelmap = {
|
||||||
**{int(key): val for key, val in model_info["labelMap"].items()},
|
**{int(key): val for key, val in model_info["labelMap"].items()},
|
||||||
@@ -255,14 +234,6 @@ class ModelConfig(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class BaseDetectorConfig(BaseModel):
|
class BaseDetectorConfig(BaseModel):
|
||||||
# how the trailing part of a device string ("openvino:GPU" -> "GPU") maps onto
|
|
||||||
# this detector's fields, and whether the same device may be listed more than
|
|
||||||
# once to run additional inference processes against it. Most accelerators
|
|
||||||
# multiplex fine, so this is opt-out rather than opt-in.
|
|
||||||
device_spec_field: ClassVar[str] = "device"
|
|
||||||
device_spec_type: ClassVar[type] = str
|
|
||||||
shareable: ClassVar[bool] = True
|
|
||||||
|
|
||||||
# the type field must be defined in all subclasses
|
# the type field must be defined in all subclasses
|
||||||
type: str = Field(
|
type: str = Field(
|
||||||
default="cpu",
|
default="cpu",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import importlib
|
|||||||
import logging
|
import logging
|
||||||
import pkgutil
|
import pkgutil
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Annotated, Union, get_args
|
from typing import Annotated, Union
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
@@ -39,21 +39,3 @@ DetectorConfig = Annotated[
|
|||||||
Union[tuple(BaseDetectorConfig.__subclasses__())], # noqa: UP007
|
Union[tuple(BaseDetectorConfig.__subclasses__())], # noqa: UP007
|
||||||
Field(discriminator="type"),
|
Field(discriminator="type"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def _discriminator_value(config_class: type[BaseDetectorConfig]) -> str | None:
|
|
||||||
"""Read the Literal value of a detector config class' type field."""
|
|
||||||
field = config_class.model_fields.get("type")
|
|
||||||
|
|
||||||
if field is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
values = get_args(field.annotation)
|
|
||||||
return values[0] if values else None
|
|
||||||
|
|
||||||
|
|
||||||
config_types: dict[str, type[BaseDetectorConfig]] = {
|
|
||||||
key: config_class
|
|
||||||
for config_class in BaseDetectorConfig.__subclasses__()
|
|
||||||
if (key := _discriminator_value(config_class)) is not None
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
"""Parsing of detection hardware device strings."""
|
|
||||||
|
|
||||||
import logging
|
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
from pydantic import TypeAdapter, ValidationError
|
|
||||||
|
|
||||||
from frigate.detectors.detector_config import BaseDetectorConfig, ModelConfig
|
|
||||||
from frigate.detectors.detector_types import DetectorConfig, config_types
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
_detector_adapter: TypeAdapter[BaseDetectorConfig] = TypeAdapter(DetectorConfig)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class DeviceSpec:
|
|
||||||
"""A parsed `<detector>` or `<detector>:<device>` string."""
|
|
||||||
|
|
||||||
raw: str
|
|
||||||
detector: str
|
|
||||||
device: str | None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def shareable(self) -> bool:
|
|
||||||
"""Whether this device may be listed more than once."""
|
|
||||||
return config_types[self.detector].shareable
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceParseError(ValueError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def parse_device(raw: str) -> DeviceSpec:
|
|
||||||
"""Parse a device string into its detector type and detector specific device.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
raw: The configured device string, for example 'edgetpu:pci:0'
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The parsed spec
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
DeviceParseError: If the detector type is unknown or the device is not
|
|
||||||
valid for that detector
|
|
||||||
"""
|
|
||||||
detector, separator, device = raw.partition(":")
|
|
||||||
|
|
||||||
if detector not in config_types:
|
|
||||||
raise DeviceParseError(
|
|
||||||
f"'{raw}' does not name a known detector. Available detectors are {', '.join(sorted(config_types))}"
|
|
||||||
)
|
|
||||||
|
|
||||||
spec = DeviceSpec(raw=raw, detector=detector, device=device if separator else None)
|
|
||||||
|
|
||||||
# surface a bad device now rather than when the detection process starts
|
|
||||||
build_detector_config(spec, None)
|
|
||||||
return spec
|
|
||||||
|
|
||||||
|
|
||||||
def build_detector_config(
|
|
||||||
spec: DeviceSpec, model: ModelConfig | None
|
|
||||||
) -> BaseDetectorConfig:
|
|
||||||
"""Build the detector config a device string describes.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
spec: The parsed device spec
|
|
||||||
model: The model this detector runs, if it has been resolved yet
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The validated detector config
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
DeviceParseError: If the device is not valid for this detector type
|
|
||||||
"""
|
|
||||||
config: dict[str, object] = {"type": spec.detector, "model": model}
|
|
||||||
|
|
||||||
if spec.device is not None:
|
|
||||||
config_class = config_types[spec.detector]
|
|
||||||
|
|
||||||
try:
|
|
||||||
config[config_class.device_spec_field] = config_class.device_spec_type(
|
|
||||||
spec.device
|
|
||||||
)
|
|
||||||
except ValueError as err:
|
|
||||||
raise DeviceParseError(
|
|
||||||
f"'{spec.raw}' is not a valid {spec.detector} device: {err}"
|
|
||||||
) from err
|
|
||||||
|
|
||||||
try:
|
|
||||||
return _detector_adapter.validate_python(config)
|
|
||||||
except ValidationError as err:
|
|
||||||
raise DeviceParseError(f"'{spec.raw}' is not a valid device: {err}") from err
|
|
||||||
|
|
||||||
|
|
||||||
def runner_names(devices: list[DeviceSpec]) -> list[str]:
|
|
||||||
"""Build a unique name for each device, since a shareable device may repeat.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
devices: Every device spec across every configured model, in config order
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
A name per device, suffixed with '#2', '#3', etc. on repeats
|
|
||||||
"""
|
|
||||||
names: list[str] = []
|
|
||||||
seen: dict[str, int] = {}
|
|
||||||
|
|
||||||
for spec in devices:
|
|
||||||
count = seen.get(spec.raw, 0) + 1
|
|
||||||
seen[spec.raw] = count
|
|
||||||
names.append(spec.raw if count == 1 else f"{spec.raw}#{count}")
|
|
||||||
|
|
||||||
return names
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
from typing import ClassVar, Literal
|
from typing import Literal
|
||||||
|
|
||||||
from pydantic import ConfigDict, Field
|
from pydantic import ConfigDict, Field
|
||||||
|
|
||||||
@@ -27,9 +27,6 @@ class CpuDetectorConfig(BaseDetectorConfig):
|
|||||||
title="CPU",
|
title="CPU",
|
||||||
)
|
)
|
||||||
|
|
||||||
device_spec_field: ClassVar[str] = "num_threads"
|
|
||||||
device_spec_type: ClassVar[type] = int
|
|
||||||
|
|
||||||
type: Literal[DETECTOR_KEY]
|
type: Literal[DETECTOR_KEY]
|
||||||
num_threads: int = Field(
|
num_threads: int = Field(
|
||||||
default=3,
|
default=3,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
from typing import ClassVar, Literal
|
from typing import Literal
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -28,9 +28,6 @@ class EdgeTpuDetectorConfig(BaseDetectorConfig):
|
|||||||
title="EdgeTPU",
|
title="EdgeTPU",
|
||||||
)
|
)
|
||||||
|
|
||||||
# a TPU can only be opened by one process
|
|
||||||
shareable: ClassVar[bool] = False
|
|
||||||
|
|
||||||
type: Literal[DETECTOR_KEY]
|
type: Literal[DETECTOR_KEY]
|
||||||
device: str = Field(
|
device: str = Field(
|
||||||
default=None,
|
default=None,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import shutil
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
import zipfile
|
import zipfile
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from typing import ClassVar, Literal
|
from typing import Literal
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -37,9 +37,6 @@ class MemryXDetectorConfig(BaseDetectorConfig):
|
|||||||
title="MemryX",
|
title="MemryX",
|
||||||
)
|
)
|
||||||
|
|
||||||
# an accelerator can only be opened by one process
|
|
||||||
shareable: ClassVar[bool] = False
|
|
||||||
|
|
||||||
type: Literal[DETECTOR_KEY]
|
type: Literal[DETECTOR_KEY]
|
||||||
device: str = Field(
|
device: str = Field(
|
||||||
default="PCIe",
|
default="PCIe",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class OvDetectorConfig(BaseDetectorConfig):
|
|||||||
|
|
||||||
type: Literal[DETECTOR_KEY]
|
type: Literal[DETECTOR_KEY]
|
||||||
device: str = Field(
|
device: str = Field(
|
||||||
default="AUTO",
|
default=None,
|
||||||
title="Device Type",
|
title="Device Type",
|
||||||
description="The device to use for OpenVINO inference (e.g. 'CPU', 'GPU', 'NPU').",
|
description="The device to use for OpenVINO inference (e.g. 'CPU', 'GPU', 'NPU').",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import logging
|
|||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from typing import ClassVar, Literal
|
from typing import Literal
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -35,9 +35,6 @@ class RknnDetectorConfig(BaseDetectorConfig):
|
|||||||
title="RKNN",
|
title="RKNN",
|
||||||
)
|
)
|
||||||
|
|
||||||
device_spec_field: ClassVar[str] = "num_cores"
|
|
||||||
device_spec_type: ClassVar[type] = int
|
|
||||||
|
|
||||||
type: Literal[DETECTOR_KEY]
|
type: Literal[DETECTOR_KEY]
|
||||||
num_cores: int = Field(
|
num_cores: int = Field(
|
||||||
default=0,
|
default=0,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ try:
|
|||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
TRT_SUPPORT = False
|
TRT_SUPPORT = False
|
||||||
|
|
||||||
from typing import ClassVar, Literal
|
from typing import Literal
|
||||||
|
|
||||||
from pydantic import ConfigDict, Field
|
from pydantic import ConfigDict, Field
|
||||||
|
|
||||||
@@ -53,8 +53,6 @@ class TensorRTDetectorConfig(BaseDetectorConfig):
|
|||||||
title="TensorRT",
|
title="TensorRT",
|
||||||
)
|
)
|
||||||
|
|
||||||
device_spec_type: ClassVar[type] = int
|
|
||||||
|
|
||||||
type: Literal[DETECTOR_KEY]
|
type: Literal[DETECTOR_KEY]
|
||||||
device: int = Field(
|
device: int = Field(
|
||||||
default=0, title="GPU Device Index", description="The GPU device index to use."
|
default=0, title="GPU Device Index", description="The GPU device index to use."
|
||||||
|
|||||||
@@ -159,8 +159,7 @@ class EventProcessor(threading.Thread):
|
|||||||
if width is None or height is None:
|
if width is None or height is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
camera_model = self.config.model_for_camera(camera)
|
first_detector = list(self.config.detectors.values())[0]
|
||||||
camera_detector = self.config.devices_for_model(camera_model)[0].detector
|
|
||||||
|
|
||||||
start_time = event_data["start_time"]
|
start_time = event_data["start_time"]
|
||||||
end_time = (
|
end_time = (
|
||||||
@@ -230,9 +229,13 @@ class EventProcessor(threading.Thread):
|
|||||||
Event.thumbnail: event_data.get("thumbnail"),
|
Event.thumbnail: event_data.get("thumbnail"),
|
||||||
Event.has_clip: event_data["has_clip"],
|
Event.has_clip: event_data["has_clip"],
|
||||||
Event.has_snapshot: event_data["has_snapshot"],
|
Event.has_snapshot: event_data["has_snapshot"],
|
||||||
Event.model_hash: camera_model.model_hash,
|
Event.model_hash: first_detector.model.model_hash
|
||||||
Event.model_type: camera_model.model_type,
|
if first_detector.model
|
||||||
Event.detector_type: camera_detector,
|
else None,
|
||||||
|
Event.model_type: first_detector.model.model_type
|
||||||
|
if first_detector.model
|
||||||
|
else None,
|
||||||
|
Event.detector_type: first_detector.type,
|
||||||
Event.data: {
|
Event.data: {
|
||||||
"box": box,
|
"box": box,
|
||||||
"region": region,
|
"region": region,
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ class GeminiClient(GenAIClient):
|
|||||||
)
|
)
|
||||||
gemini_messages.append(
|
gemini_messages.append(
|
||||||
types.Content(
|
types.Content(
|
||||||
role="function",
|
role="user",
|
||||||
parts=[
|
parts=[
|
||||||
types.Part.from_function_response(
|
types.Part.from_function_response(
|
||||||
name=msg.get("name")
|
name=msg.get("name")
|
||||||
@@ -501,7 +501,7 @@ class GeminiClient(GenAIClient):
|
|||||||
)
|
)
|
||||||
gemini_messages.append(
|
gemini_messages.append(
|
||||||
types.Content(
|
types.Content(
|
||||||
role="function",
|
role="user",
|
||||||
parts=[
|
parts=[
|
||||||
types.Part.from_function_response(
|
types.Part.from_function_response(
|
||||||
name=msg.get("name")
|
name=msg.get("name")
|
||||||
|
|||||||
+121
-65
@@ -262,10 +262,6 @@ def get_tool_definitions(
|
|||||||
`attribute` parameter is exposed for filtering by their labels. When the
|
`attribute` parameter is exposed for filtering by their labels. When the
|
||||||
embeddings model only understands English (JinaV1), the `semantic_query`
|
embeddings model only understands English (JinaV1), the `semantic_query`
|
||||||
description instructs the model to write the query in English.
|
description instructs the model to write the query in English.
|
||||||
|
|
||||||
Descriptions here stay mechanical: which tool to reach for, and how the
|
|
||||||
filters relate to each other, is stated once in the system prompt so the
|
|
||||||
guidance is not paid for twice on every request.
|
|
||||||
"""
|
"""
|
||||||
search_objects_properties: dict[str, Any] = {
|
search_objects_properties: dict[str, Any] = {
|
||||||
"camera": {
|
"camera": {
|
||||||
@@ -274,13 +270,26 @@ def get_tool_definitions(
|
|||||||
},
|
},
|
||||||
"label": {
|
"label": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Tracked object class to filter by.",
|
"description": (
|
||||||
|
"Generic object class to filter by — one of the tracked detector "
|
||||||
|
"labels such as 'person', 'package', 'car', 'dog', 'bird'. Use "
|
||||||
|
"this for broad queries like 'show me all cars today'. Combine "
|
||||||
|
"with semantic_query when the user also describes appearance or "
|
||||||
|
"behavior (e.g. label='person', semantic_query='riding a lawn "
|
||||||
|
"mower')."
|
||||||
|
),
|
||||||
},
|
},
|
||||||
"sub_label": {
|
"sub_label": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": (
|
"description": (
|
||||||
"Name recognized in the detection: a person, delivery company, "
|
"Filter by a DISCRETE NAMED entity recognized in the detection. "
|
||||||
"animal species or breed, or license plate."
|
"Use this for: a known person's name ('John'), a delivery "
|
||||||
|
"company ('Amazon', 'UPS'), a recognized animal species or "
|
||||||
|
"breed ('blue jay', 'cardinal', 'golden retriever'), or a "
|
||||||
|
"license plate string. When filtering by a specific name, set "
|
||||||
|
"only sub_label and leave label unset. Do NOT use sub_label "
|
||||||
|
"for descriptions of appearance, clothing, or actions — those "
|
||||||
|
"belong in semantic_query."
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"after": {
|
"after": {
|
||||||
@@ -304,11 +313,20 @@ def get_tool_definitions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if attribute_classifications:
|
if attribute_classifications:
|
||||||
|
model_outline = "; ".join(
|
||||||
|
f"{m['name']} (applies to {', '.join(m['objects']) or 'any object'})"
|
||||||
|
for m in attribute_classifications
|
||||||
|
)
|
||||||
search_objects_properties["attribute"] = {
|
search_objects_properties["attribute"] = {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": (
|
"description": (
|
||||||
"Attribute label produced by a configured classification model "
|
"Filter by a classification attribute label produced by a "
|
||||||
"(case-sensitive)."
|
"configured attribute classification model. Use this INSTEAD "
|
||||||
|
"of semantic_query when the user's request matches one of "
|
||||||
|
"these classifications. Configured models: "
|
||||||
|
f"{model_outline}. "
|
||||||
|
"Set the value to the attribute label that matches the user's "
|
||||||
|
"phrasing (case-sensitive)."
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,12 +334,29 @@ def get_tool_definitions(
|
|||||||
search_objects_properties["semantic_query"] = {
|
search_objects_properties["semantic_query"] = {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": (
|
"description": (
|
||||||
"Description of an appearance or activity, used to semantically "
|
"Optional natural-language description of a PHYSICAL "
|
||||||
"narrow results."
|
"CHARACTERISTIC, APPEARANCE, or ACTIVITY the user mentioned, "
|
||||||
|
"used to semantically narrow results. Only set this when the "
|
||||||
|
"user describes something beyond what label and sub_label can "
|
||||||
|
"express on their own.\n"
|
||||||
|
"USE for descriptive phrases like: 'riding a lawn mower', "
|
||||||
|
"'wearing a red jacket', 'carrying a package', 'walking a "
|
||||||
|
"dog', 'on a bicycle', 'holding an umbrella'.\n"
|
||||||
|
"DO NOT USE for:\n"
|
||||||
|
"- specific named people, pets, or delivery companies → use sub_label\n"
|
||||||
|
"- animal species or breed names like 'blue jay', 'cardinal', "
|
||||||
|
"'golden retriever' → use sub_label\n"
|
||||||
|
"- license plate strings → use sub_label\n"
|
||||||
|
"- generic object queries like 'all cars today' or 'every "
|
||||||
|
"person' → use label alone with no semantic_query\n"
|
||||||
|
"When set, combine with label/time/camera/zone filters as "
|
||||||
|
"usual (e.g. label='person', semantic_query='riding a lawn "
|
||||||
|
"mower', after='2024-05-01T00:00:00Z')."
|
||||||
+ (
|
+ (
|
||||||
" The configured embeddings model only understands English, so "
|
" The configured embeddings model only understands "
|
||||||
"always write this in English, translating the user's "
|
"English, so always write semantic_query in English, "
|
||||||
"description if they phrased it in another language."
|
"translating the user's description if they phrased it "
|
||||||
|
"in another language."
|
||||||
if embeddings_language == "english"
|
if embeddings_language == "english"
|
||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
@@ -329,10 +364,26 @@ def get_tool_definitions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
search_objects_description = (
|
search_objects_description = (
|
||||||
"Search the historical record of tracked detections. Use this ONLY for "
|
"Search the historical record of detected objects in Frigate. "
|
||||||
"questions about the PAST, e.g. 'did anyone come by today?', 'when was the "
|
"Use this ONLY for questions about the PAST — e.g. 'did anyone come by today?', "
|
||||||
"last car?'. For alerting on future events use start_camera_watch instead."
|
"'when was the last car?', 'show me detections from yesterday'. "
|
||||||
|
"Do NOT use this for monitoring or alerting requests about future events — "
|
||||||
|
"use start_camera_watch instead for those. "
|
||||||
|
"An 'object' in Frigate represents a tracked detection (e.g., a person, package, car).\n\n"
|
||||||
|
"Choose filters based on what the user is asking for:\n"
|
||||||
|
"- Generic class query ('show me all cars today'): set `label` only.\n"
|
||||||
|
"- Specific NAMED entity (known person, delivery company, animal "
|
||||||
|
"species/breed like 'blue jay' or 'golden retriever', license "
|
||||||
|
"plate): set `sub_label` only and leave `label` unset.\n"
|
||||||
)
|
)
|
||||||
|
if semantic_search_enabled:
|
||||||
|
search_objects_description += (
|
||||||
|
"- Physical CHARACTERISTIC, APPEARANCE, or ACTIVITY that is not a "
|
||||||
|
"discrete name ('person riding a lawn mower', 'someone in a red "
|
||||||
|
"jacket', 'person carrying a package'): set `semantic_query` with "
|
||||||
|
"the descriptive phrase, optionally alongside `label` for the "
|
||||||
|
"object class. Do NOT put descriptive phrases in sub_label."
|
||||||
|
)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -347,30 +398,20 @@ def get_tool_definitions(
|
|||||||
"required": [],
|
"required": [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "function",
|
|
||||||
"function": {
|
|
||||||
"name": "get_categorized_object_names",
|
|
||||||
"description": (
|
|
||||||
"Every name that can be attached as a sub_label, grouped by object "
|
|
||||||
"type: recognized faces, named license plates, classification "
|
|
||||||
"categories, and delivery logos. Takes no arguments and always "
|
|
||||||
"returns the complete map."
|
|
||||||
),
|
|
||||||
"parameters": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {},
|
|
||||||
"required": [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
"name": "find_similar_objects",
|
"name": "find_similar_objects",
|
||||||
"description": (
|
"description": (
|
||||||
"Find tracked objects visually and semantically similar to a "
|
"Find tracked objects that are visually and semantically similar "
|
||||||
"specific past event. Requires semantic search to be enabled."
|
"to a specific past event. Use this when the user references a "
|
||||||
|
"particular object they have seen and wants to find other "
|
||||||
|
"sightings of the same or similar one ('that green car', 'the "
|
||||||
|
"person in the red jacket', 'the package that was delivered'). "
|
||||||
|
"Prefer this over search_objects whenever the user's intent is "
|
||||||
|
"'find more like this specific one.' Use search_objects first "
|
||||||
|
"only if you need to locate the anchor event. Requires semantic "
|
||||||
|
"search to be enabled."
|
||||||
),
|
),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -432,8 +473,9 @@ def get_tool_definitions(
|
|||||||
"function": {
|
"function": {
|
||||||
"name": "set_camera_state",
|
"name": "set_camera_state",
|
||||||
"description": (
|
"description": (
|
||||||
"Change a camera's feature state, e.g. turn detection on or off. "
|
"Change a camera's feature state (e.g., turn detection on/off, enable/disable recordings). "
|
||||||
"Only call this when the user explicitly asks to change a setting. "
|
"Use camera='*' to apply to all cameras at once. "
|
||||||
|
"Only call this tool when the user explicitly asks to change a camera setting. "
|
||||||
"Requires admin privileges."
|
"Requires admin privileges."
|
||||||
),
|
),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -468,14 +510,14 @@ def get_tool_definitions(
|
|||||||
],
|
],
|
||||||
"description": (
|
"description": (
|
||||||
"The feature to change. Most features accept ON or OFF. "
|
"The feature to change. Most features accept ON or OFF. "
|
||||||
"birdseye_mode accepts CONTINUOUS, MOTION, OBJECTS, STATIONARY_OBJECTS, or a comma-separated combination. "
|
"birdseye_mode accepts CONTINUOUS, MOTION, or OBJECTS. "
|
||||||
"motion_contour_area and motion_threshold accept a number. "
|
"motion_contour_area and motion_threshold accept a number. "
|
||||||
"profile accepts a profile name or 'none' to deactivate (requires camera='*')."
|
"profile accepts a profile name or 'none' to deactivate (requires camera='*')."
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The value to set, as accepted by the chosen feature.",
|
"description": "The value to set. ON or OFF for toggles, a number for thresholds, a profile name or 'none' for profile.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"required": ["camera", "feature", "value"],
|
"required": ["camera", "feature", "value"],
|
||||||
@@ -487,9 +529,11 @@ def get_tool_definitions(
|
|||||||
"function": {
|
"function": {
|
||||||
"name": "get_live_context",
|
"name": "get_live_context",
|
||||||
"description": (
|
"description": (
|
||||||
"Current live image and detections (tracked objects, zones, "
|
"Get the current live image and detection information for a single camera: objects being tracked, "
|
||||||
"timestamps) for one camera. Use this for questions about what is "
|
"zones, timestamps. Use this to understand what is visible in the live view. "
|
||||||
"happening right now. Call it again for each additional camera."
|
"Call this when answering questions about what is happening right now on a specific camera. "
|
||||||
|
"Operates on one camera at a time; call the tool again for each additional camera. "
|
||||||
|
"Wildcards and empty values are not accepted."
|
||||||
),
|
),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -497,8 +541,8 @@ def get_tool_definitions(
|
|||||||
"camera": {
|
"camera": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": (
|
"description": (
|
||||||
"Exact name of a single camera. Wildcards (e.g. '*', "
|
"Exact name of a single camera to get live context for. "
|
||||||
"'all') and empty strings are not accepted."
|
"Wildcards (e.g. '*', 'all') and empty strings are not accepted."
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -511,9 +555,10 @@ def get_tool_definitions(
|
|||||||
"function": {
|
"function": {
|
||||||
"name": "start_camera_watch",
|
"name": "start_camera_watch",
|
||||||
"description": (
|
"description": (
|
||||||
"Start a continuous watch job that monitors a camera and notifies "
|
"Start a continuous VLM watch job that monitors a camera and sends a notification "
|
||||||
"the user when a condition is met, e.g. 'tell me when guests "
|
"when a specified condition is met. Use this when the user wants to be alerted about "
|
||||||
"arrive'. Only one watch job can run at a time. Returns a job ID."
|
"a future event, e.g. 'tell me when guests arrive' or 'notify me when the package is picked up'. "
|
||||||
|
"Only one watch job can run at a time. Returns a job ID."
|
||||||
),
|
),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -553,7 +598,10 @@ def get_tool_definitions(
|
|||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
"name": "stop_camera_watch",
|
"name": "stop_camera_watch",
|
||||||
"description": "Cancel the currently running watch job.",
|
"description": (
|
||||||
|
"Cancel the currently running VLM watch job. Use this when the user wants to "
|
||||||
|
"stop a previously started watch, e.g. 'stop watching the front door'."
|
||||||
|
),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {},
|
"properties": {},
|
||||||
@@ -566,9 +614,11 @@ def get_tool_definitions(
|
|||||||
"function": {
|
"function": {
|
||||||
"name": "get_profile_status",
|
"name": "get_profile_status",
|
||||||
"description": (
|
"description": (
|
||||||
"Get the active profile and when each profile was last activated. "
|
"Get the current profile status including the active profile and "
|
||||||
"Call this before get_recap to derive the time window for requests "
|
"timestamps of when each profile was last activated. Use this to "
|
||||||
"like 'what happened while I was away?'."
|
"determine time periods for recap requests — e.g. when the user asks "
|
||||||
|
"'what happened while I was away?', call this first to find the relevant "
|
||||||
|
"time window based on profile activation history."
|
||||||
),
|
),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -582,9 +632,11 @@ def get_tool_definitions(
|
|||||||
"function": {
|
"function": {
|
||||||
"name": "get_recap",
|
"name": "get_recap",
|
||||||
"description": (
|
"description": (
|
||||||
"Get all activity (alerts and detections) for a time period, as a "
|
"Get a recap of all activity (alerts and detections) for a given time period. "
|
||||||
"chronological list with camera, objects, zones, and descriptions "
|
"Use this after calling get_profile_status to retrieve what happened during "
|
||||||
"when available. Summarize the results for the user."
|
"a specific window — e.g. 'what happened while I was away?'. Returns a "
|
||||||
|
"chronological list of activity with camera, objects, zones, and GenAI-generated "
|
||||||
|
"descriptions when available. Summarize the results for the user."
|
||||||
),
|
),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -671,13 +723,14 @@ def build_chat_system_prompt(
|
|||||||
)
|
)
|
||||||
speed_units_section = f"\n\nReport object speeds to the user in {speed_unit}."
|
speed_units_section = f"\n\nReport object speeds to the user in {speed_unit}."
|
||||||
|
|
||||||
filter_routing_section = (
|
semantic_search_section = ""
|
||||||
"\n\nWhen routing a search_objects call, pick filters by the shape of the user's request:\n"
|
|
||||||
"- Generic class ('show me all cars today'): set `label` only.\n"
|
|
||||||
"- Specific named entity — a known person ('John'), delivery company ('Amazon'), animal species/breed ('blue jay', 'golden retriever'), or license plate: set `sub_label` only and leave `label` unset. Call get_categorized_object_names first and use the exact spelling it returns; a guessed spelling matches nothing. If the name is absent, say it is not configured rather than searching for it."
|
|
||||||
)
|
|
||||||
if semantic_search_enabled:
|
if semantic_search_enabled:
|
||||||
filter_routing_section += "\n- Physical characteristic, appearance, or activity that is NOT a discrete name ('riding a lawn mower', 'someone in a red jacket'): set `semantic_query` with the descriptive phrase, optionally combined with `label`. Never put descriptive phrases in `sub_label`."
|
semantic_search_section = (
|
||||||
|
"\n\nWhen routing a search_objects call, pick filters by the shape of the user's request:\n"
|
||||||
|
"- Generic class ('show me all cars today'): set `label` only.\n"
|
||||||
|
"- Specific named entity — a known person ('John'), delivery company ('Amazon'), animal species/breed ('blue jay', 'cardinal', 'golden retriever'), or license plate: set `sub_label` only and leave `label` unset.\n"
|
||||||
|
"- Physical characteristic, appearance, or activity that is NOT a discrete name ('find me people riding a lawn mower', 'someone in a red jacket', 'a person carrying a package'): set `semantic_query` with the descriptive phrase, optionally combined with `label` for the object class. Never put descriptive phrases in `sub_label`."
|
||||||
|
)
|
||||||
|
|
||||||
attribute_classification_section = ""
|
attribute_classification_section = ""
|
||||||
if attribute_classifications:
|
if attribute_classifications:
|
||||||
@@ -686,9 +739,9 @@ def build_chat_system_prompt(
|
|||||||
for m in attribute_classifications
|
for m in attribute_classifications
|
||||||
)
|
)
|
||||||
attribute_classification_section = (
|
attribute_classification_section = (
|
||||||
"\n\nConfigured attribute classification models:\n"
|
"\n\nAttribute classification models are configured for the following object types:\n"
|
||||||
f"{model_lines}\n"
|
f"{model_lines}\n"
|
||||||
"When the user's request matches one of these classifications, set the search_objects `attribute` field to the matching label (case-sensitive) rather than using `semantic_query`. Reserve `semantic_query` for descriptive phrases outside the configured attribute labels."
|
"When the user's request matches one of these classifications, set the search_objects `attribute` field to the matching label rather than using `semantic_query`. Reserve `semantic_query` for descriptive phrases that fall outside the configured attribute labels."
|
||||||
)
|
)
|
||||||
|
|
||||||
return f"""You are a helpful assistant for Frigate, a security camera NVR system. You help users answer questions about their cameras, detected objects, and events.
|
return f"""You are a helpful assistant for Frigate, a security camera NVR system. You help users answer questions about their cameras, detected objects, and events.
|
||||||
@@ -697,6 +750,9 @@ Current server local date and time: {current_date_str} at {current_time_str}
|
|||||||
|
|
||||||
Do not start your response with phrases like "I will check...", "Let me see...", or "Let me look...". Answer directly.
|
Do not start your response with phrases like "I will check...", "Let me see...", or "Let me look...". Answer directly.
|
||||||
|
|
||||||
Always present times in the server's local timezone. When tool results include start_time_local and end_time_local, quote those strings exactly; never convert or invent timestamps, and fall back to UTC or ISO format only when a result has no local time fields. Resolve relative dates like "today" or "this week" against the current date above, and pass dates to tools in ISO 8601 (e.g. {current_date_str}T00:00:00Z for the start of today).
|
Always present times to the user in the server's local timezone. When tool results include start_time_local and end_time_local, use those exact strings when listing or describing detection times—do not convert or invent timestamps. Do not use UTC or ISO format with Z for the user-facing answer unless the tool result only provides Unix timestamps without local time fields.
|
||||||
|
When users ask about "today", "yesterday", "this week", etc., use the current date above as reference.
|
||||||
|
When searching for objects or events, use ISO 8601 format for dates (e.g., {current_date_str}T00:00:00Z for the start of today).
|
||||||
|
Always be accurate with time calculations based on the current date provided.
|
||||||
|
|
||||||
When the user refers to a specific object they have seen ("that green car", "the person in the red jacket", "a package left today"), prefer find_similar_objects over search_objects, using search_objects only to locate the anchor event and passing its id along. Keep search_objects for generic queries like "show me all cars today". If a user message begins with [attached_event:<id>], treat that id as the anchor for any similarity or "tell me more" request in the same message.{filter_routing_section}{attribute_classification_section}{cameras_section}{speed_units_section}"""
|
When a user refers to a specific object they have seen or describe with identifying details ("that green car", "the person in the red jacket", "a package left today"), prefer the find_similar_objects tool over search_objects. Use search_objects first only to locate the anchor event, then pass its id to find_similar_objects. For generic queries like "show me all cars today", keep using search_objects. If a user message begins with [attached_event:<id>], treat that event id as the anchor for any similarity or "tell me more" request in the same message and call find_similar_objects with that id.{semantic_search_section}{attribute_classification_section}{cameras_section}{speed_units_section}"""
|
||||||
|
|||||||
@@ -115,6 +115,10 @@ def query_recordings(source_camera: str, start_ts: float, end_ts: float) -> Mode
|
|||||||
return cast(ModelSelect, query)
|
return cast(ModelSelect, query)
|
||||||
|
|
||||||
|
|
||||||
|
class NoRecordingsError(ValueError):
|
||||||
|
"""Raised when no recordings exist in the requested time range."""
|
||||||
|
|
||||||
|
|
||||||
class DebugReplaySource(ABC):
|
class DebugReplaySource(ABC):
|
||||||
"""Abstract source for a debug replay session.
|
"""Abstract source for a debug replay session.
|
||||||
|
|
||||||
@@ -187,7 +191,7 @@ class RecordingDebugReplaySource(DebugReplaySource):
|
|||||||
raise ValueError("End time must be after start time")
|
raise ValueError("End time must be after start time")
|
||||||
|
|
||||||
if not query_recordings(self._camera, self._start_ts, self._end_ts).count():
|
if not query_recordings(self._camera, self._start_ts, self._end_ts).count():
|
||||||
raise ValueError(
|
raise NoRecordingsError(
|
||||||
f"No recordings found for camera '{self._camera}' in the specified time range"
|
f"No recordings found for camera '{self._camera}' in the specified time range"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,7 @@ import threading
|
|||||||
|
|
||||||
from numpy import ndarray
|
from numpy import ndarray
|
||||||
|
|
||||||
from frigate.detectors.detector_config import InputTensorEnum, ModelConfig
|
from frigate.detectors.detector_config import InputTensorEnum
|
||||||
|
|
||||||
|
|
||||||
def detection_frame_size(model: ModelConfig) -> int:
|
|
||||||
"""Get the shared memory size a camera needs to hand frames to a model.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
model: The model the camera runs on
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Size in bytes of one model input frame
|
|
||||||
"""
|
|
||||||
return model.height * model.width * 3
|
|
||||||
|
|
||||||
|
|
||||||
class RequestStore:
|
class RequestStore:
|
||||||
|
|||||||
+117
-126
@@ -9,7 +9,6 @@ import queue
|
|||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
from dataclasses import dataclass
|
|
||||||
from multiprocessing.synchronize import Event as MpEvent
|
from multiprocessing.synchronize import Event as MpEvent
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ import cv2
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from frigate.comms.inter_process import InterProcessRequestor
|
from frigate.comms.inter_process import InterProcessRequestor
|
||||||
from frigate.config import BirdseyeModeConfig, FfmpegConfig, FrigateConfig
|
from frigate.config import BirdseyeModeEnum, FfmpegConfig, FrigateConfig
|
||||||
from frigate.const import BASE_DIR, BIRDSEYE_PIPE, INSTALL_DIR, UPDATE_BIRDSEYE_LAYOUT
|
from frigate.const import BASE_DIR, BIRDSEYE_PIPE, INSTALL_DIR, UPDATE_BIRDSEYE_LAYOUT
|
||||||
from frigate.output.ws_auth import ws_has_camera_access
|
from frigate.output.ws_auth import ws_has_camera_access
|
||||||
from frigate.util.image import (
|
from frigate.util.image import (
|
||||||
@@ -29,15 +28,6 @@ from frigate.util.image import (
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, slots=True)
|
|
||||||
class BirdseyeActivity:
|
|
||||||
"""Activity signals used to decide whether a camera is shown in Birdseye."""
|
|
||||||
|
|
||||||
has_active_object: bool
|
|
||||||
has_stationary_object: bool
|
|
||||||
has_motion: bool
|
|
||||||
|
|
||||||
|
|
||||||
def get_standard_aspect_ratio(width: int, height: int) -> tuple[int, int]:
|
def get_standard_aspect_ratio(width: int, height: int) -> tuple[int, int]:
|
||||||
"""Ensure that only standard aspect ratios are used."""
|
"""Ensure that only standard aspect ratios are used."""
|
||||||
# it is important that all ratios have the same scale
|
# it is important that all ratios have the same scale
|
||||||
@@ -419,16 +409,18 @@ class BirdsEyeFrameManager:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def camera_active(
|
def camera_active(
|
||||||
self,
|
self, mode: Any, object_box_count: int, motion_box_count: int
|
||||||
mode: BirdseyeModeConfig,
|
|
||||||
activity: BirdseyeActivity,
|
|
||||||
) -> bool:
|
) -> bool:
|
||||||
return (
|
if mode == BirdseyeModeEnum.continuous:
|
||||||
mode.continuous
|
return True
|
||||||
or (mode.motion and activity.has_motion)
|
|
||||||
or (mode.objects and activity.has_active_object)
|
if mode == BirdseyeModeEnum.motion and motion_box_count > 0:
|
||||||
or (mode.stationary_objects and activity.has_stationary_object)
|
return True
|
||||||
)
|
|
||||||
|
if mode == BirdseyeModeEnum.objects and object_box_count > 0:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def get_camera_coordinates(self) -> dict[str, dict[str, int]]:
|
def get_camera_coordinates(self) -> dict[str, dict[str, int]]:
|
||||||
"""Return the coordinates of each camera in the current layout."""
|
"""Return the coordinates of each camera in the current layout."""
|
||||||
@@ -612,92 +604,112 @@ class BirdsEyeFrameManager:
|
|||||||
) -> list[list[Any]] | None:
|
) -> list[list[Any]] | None:
|
||||||
"""Calculate the optimal layout for 2+ cameras."""
|
"""Calculate the optimal layout for 2+ cameras."""
|
||||||
|
|
||||||
def find_available_x(
|
def map_layout(
|
||||||
current_x: int,
|
camera_layout: list[list[Any]], row_height: int
|
||||||
width: int,
|
) -> tuple[int, int, list[list[Any]] | None]:
|
||||||
reserved_ranges: list[tuple[int, int]],
|
"""Map the calculated layout."""
|
||||||
max_width: int,
|
candidate_layout = []
|
||||||
) -> int | None:
|
starting_x = 0
|
||||||
"""Find the first horizontal slot that does not collide with reservations."""
|
x = 0
|
||||||
x = current_x
|
|
||||||
|
|
||||||
for reserved_start, reserved_end in sorted(reserved_ranges):
|
|
||||||
if x >= reserved_end:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if x + width <= reserved_start:
|
|
||||||
return x
|
|
||||||
|
|
||||||
x = max(x, reserved_end)
|
|
||||||
|
|
||||||
if x + width <= max_width:
|
|
||||||
return x
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def map_layout(row_height: int) -> tuple[int, int, list[list[Any]] | None]:
|
|
||||||
"""Lay out cameras row by row while reserving portrait spans for the next row."""
|
|
||||||
candidate_layout: list[list[Any]] = []
|
|
||||||
reserved_ranges: dict[int, list[tuple[int, int]]] = {}
|
|
||||||
current_row: list[Any] = []
|
|
||||||
row_index = 0
|
|
||||||
row_y = 0
|
|
||||||
row_x = 0
|
|
||||||
max_width = 0
|
max_width = 0
|
||||||
max_height = 0
|
y = 0
|
||||||
|
|
||||||
for camera in cameras_to_add:
|
for row in camera_layout:
|
||||||
camera_dims = self.cameras[camera]["dimensions"].copy()
|
final_row = []
|
||||||
camera_aspect_x, camera_aspect_y = self.canvas.get_camera_aspect(
|
max_width = max(max_width, x)
|
||||||
camera, camera_dims[0], camera_dims[1]
|
x = starting_x
|
||||||
|
for cameras in row:
|
||||||
|
camera_dims = self.cameras[cameras[0]]["dimensions"].copy()
|
||||||
|
camera_aspect = cameras[1]
|
||||||
|
|
||||||
|
if camera_dims[1] > camera_dims[0]:
|
||||||
|
scaled_height = int(row_height * 2)
|
||||||
|
scaled_width = int(scaled_height * camera_aspect)
|
||||||
|
starting_x = scaled_width
|
||||||
|
else:
|
||||||
|
scaled_height = row_height
|
||||||
|
scaled_width = int(scaled_height * camera_aspect)
|
||||||
|
|
||||||
|
# layout is too large
|
||||||
|
if (
|
||||||
|
x + scaled_width > self.canvas.width
|
||||||
|
or y + scaled_height > self.canvas.height
|
||||||
|
):
|
||||||
|
return x + scaled_width, y + scaled_height, None
|
||||||
|
|
||||||
|
final_row.append((cameras[0], (x, y, scaled_width, scaled_height)))
|
||||||
|
x += scaled_width
|
||||||
|
|
||||||
|
y += row_height
|
||||||
|
candidate_layout.append(final_row)
|
||||||
|
|
||||||
|
if max_width == 0:
|
||||||
|
max_width = x
|
||||||
|
|
||||||
|
return max_width, y, candidate_layout
|
||||||
|
|
||||||
|
canvas_aspect_x, canvas_aspect_y = self.canvas.get_aspect(coefficient)
|
||||||
|
camera_layout: list[list[Any]] = []
|
||||||
|
camera_layout.append([])
|
||||||
|
starting_x = 0
|
||||||
|
x = starting_x
|
||||||
|
y = 0
|
||||||
|
y_i = 0
|
||||||
|
max_y = 0
|
||||||
|
for camera in cameras_to_add:
|
||||||
|
camera_dims = self.cameras[camera]["dimensions"].copy()
|
||||||
|
camera_aspect_x, camera_aspect_y = self.canvas.get_camera_aspect(
|
||||||
|
camera, camera_dims[0], camera_dims[1]
|
||||||
|
)
|
||||||
|
|
||||||
|
if camera_dims[1] > camera_dims[0]:
|
||||||
|
portrait = True
|
||||||
|
else:
|
||||||
|
portrait = False
|
||||||
|
|
||||||
|
if (x + camera_aspect_x) <= canvas_aspect_x:
|
||||||
|
# insert if camera can fit on current row
|
||||||
|
camera_layout[y_i].append(
|
||||||
|
(
|
||||||
|
camera,
|
||||||
|
camera_aspect_x / camera_aspect_y,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
portrait = camera_dims[1] > camera_dims[0]
|
|
||||||
scaled_height = row_height * 2 if portrait else row_height
|
|
||||||
scaled_width = int(scaled_height * (camera_aspect_x / camera_aspect_y))
|
|
||||||
|
|
||||||
while True:
|
if portrait:
|
||||||
x = find_available_x(
|
starting_x = camera_aspect_x
|
||||||
row_x,
|
else:
|
||||||
scaled_width,
|
max_y = max(
|
||||||
reserved_ranges.get(row_index, []),
|
max_y,
|
||||||
self.canvas.width,
|
camera_aspect_y,
|
||||||
)
|
)
|
||||||
|
|
||||||
if x is not None and row_y + scaled_height <= self.canvas.height:
|
x += camera_aspect_x
|
||||||
current_row.append(
|
else:
|
||||||
(camera, (x, row_y, scaled_width, scaled_height))
|
# move on to the next row and insert
|
||||||
)
|
y += max_y
|
||||||
row_x = x + scaled_width
|
y_i += 1
|
||||||
max_width = max(max_width, row_x)
|
camera_layout.append([])
|
||||||
max_height = max(max_height, row_y + scaled_height)
|
x = starting_x
|
||||||
|
|
||||||
if portrait:
|
if x + camera_aspect_x > canvas_aspect_x:
|
||||||
reserved_ranges.setdefault(row_index + 1, []).append(
|
return None
|
||||||
(x, row_x)
|
|
||||||
)
|
|
||||||
|
|
||||||
break
|
camera_layout[y_i].append(
|
||||||
|
(
|
||||||
|
camera,
|
||||||
|
camera_aspect_x / camera_aspect_y,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
x += camera_aspect_x
|
||||||
|
|
||||||
if current_row:
|
if y + max_y > canvas_aspect_y:
|
||||||
candidate_layout.append(current_row)
|
return None
|
||||||
current_row = []
|
|
||||||
|
|
||||||
row_index += 1
|
row_height = int(self.canvas.height / coefficient)
|
||||||
row_y = row_index * row_height
|
total_width, total_height, standard_candidate_layout = map_layout(
|
||||||
row_x = 0
|
camera_layout, row_height
|
||||||
|
)
|
||||||
if row_y + scaled_height > self.canvas.height:
|
|
||||||
overflow_width = max(max_width, scaled_width)
|
|
||||||
overflow_height = row_y + scaled_height
|
|
||||||
return overflow_width, overflow_height, None
|
|
||||||
|
|
||||||
if current_row:
|
|
||||||
candidate_layout.append(current_row)
|
|
||||||
|
|
||||||
return max_width, max_height, candidate_layout
|
|
||||||
|
|
||||||
row_height = max(1, int(self.canvas.height / coefficient))
|
|
||||||
total_width, total_height, standard_candidate_layout = map_layout(row_height)
|
|
||||||
|
|
||||||
if not standard_candidate_layout:
|
if not standard_candidate_layout:
|
||||||
# if standard layout didn't work
|
# if standard layout didn't work
|
||||||
@@ -706,9 +718,9 @@ class BirdsEyeFrameManager:
|
|||||||
total_width / self.canvas.width,
|
total_width / self.canvas.width,
|
||||||
total_height / self.canvas.height,
|
total_height / self.canvas.height,
|
||||||
)
|
)
|
||||||
row_height = max(1, int(row_height / scale_down_percent))
|
row_height = int(row_height / scale_down_percent)
|
||||||
total_width, total_height, standard_candidate_layout = map_layout(
|
total_width, total_height, standard_candidate_layout = map_layout(
|
||||||
row_height
|
camera_layout, row_height
|
||||||
)
|
)
|
||||||
|
|
||||||
if not standard_candidate_layout:
|
if not standard_candidate_layout:
|
||||||
@@ -722,8 +734,8 @@ class BirdsEyeFrameManager:
|
|||||||
1 / (total_width / self.canvas.width),
|
1 / (total_width / self.canvas.width),
|
||||||
1 / (total_height / self.canvas.height),
|
1 / (total_height / self.canvas.height),
|
||||||
)
|
)
|
||||||
row_height = max(1, int(row_height * scale_up_percent))
|
row_height = int(row_height * scale_up_percent)
|
||||||
_, _, scaled_layout = map_layout(row_height)
|
_, _, scaled_layout = map_layout(camera_layout, row_height)
|
||||||
|
|
||||||
if scaled_layout:
|
if scaled_layout:
|
||||||
return scaled_layout
|
return scaled_layout
|
||||||
@@ -733,7 +745,8 @@ class BirdsEyeFrameManager:
|
|||||||
def update(
|
def update(
|
||||||
self,
|
self,
|
||||||
camera: str,
|
camera: str,
|
||||||
activity: BirdseyeActivity,
|
object_count: int,
|
||||||
|
motion_count: int,
|
||||||
frame_time: float,
|
frame_time: float,
|
||||||
frame: np.ndarray,
|
frame: np.ndarray,
|
||||||
) -> tuple[bool, bool]:
|
) -> tuple[bool, bool]:
|
||||||
@@ -761,10 +774,7 @@ class BirdsEyeFrameManager:
|
|||||||
# update the last active frame for the camera
|
# update the last active frame for the camera
|
||||||
self.cameras[camera]["current_frame"] = frame.copy()
|
self.cameras[camera]["current_frame"] = frame.copy()
|
||||||
self.cameras[camera]["current_frame_time"] = frame_time
|
self.cameras[camera]["current_frame_time"] = frame_time
|
||||||
if self.camera_active(
|
if self.camera_active(camera_config.birdseye.mode, object_count, motion_count):
|
||||||
camera_config.birdseye.mode,
|
|
||||||
activity,
|
|
||||||
):
|
|
||||||
self.cameras[camera]["last_active_frame"] = frame_time
|
self.cameras[camera]["last_active_frame"] = frame_time
|
||||||
|
|
||||||
now = datetime.datetime.now().timestamp()
|
now = datetime.datetime.now().timestamp()
|
||||||
@@ -872,29 +882,10 @@ class Birdseye:
|
|||||||
frame_time: float,
|
frame_time: float,
|
||||||
frame: np.ndarray,
|
frame: np.ndarray,
|
||||||
) -> None:
|
) -> None:
|
||||||
has_active_object = False
|
|
||||||
has_stationary_object = False
|
|
||||||
for tracked_object in current_tracked_objects:
|
|
||||||
if tracked_object["stationary"]:
|
|
||||||
if not tracked_object["false_positive"]:
|
|
||||||
has_stationary_object = True
|
|
||||||
else:
|
|
||||||
# Preserve the existing objects activity behavior, which includes
|
|
||||||
# non-stationary trackers before they are confirmed.
|
|
||||||
has_active_object = True
|
|
||||||
|
|
||||||
if has_active_object and has_stationary_object:
|
|
||||||
break
|
|
||||||
|
|
||||||
activity = BirdseyeActivity(
|
|
||||||
has_active_object=has_active_object,
|
|
||||||
has_stationary_object=has_stationary_object,
|
|
||||||
has_motion=bool(motion_boxes),
|
|
||||||
)
|
|
||||||
|
|
||||||
frame_changed, frame_layout_changed = self.birdseye_manager.update(
|
frame_changed, frame_layout_changed = self.birdseye_manager.update(
|
||||||
camera,
|
camera,
|
||||||
activity,
|
len([o for o in current_tracked_objects if not o["stationary"]]),
|
||||||
|
len(motion_boxes),
|
||||||
frame_time,
|
frame_time,
|
||||||
frame,
|
frame,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ class ReviewSegmentMaintainer(threading.Thread):
|
|||||||
|
|
||||||
if not object["sub_label"]:
|
if not object["sub_label"]:
|
||||||
segment.detections[object["id"]] = object["label"]
|
segment.detections[object["id"]] = object["label"]
|
||||||
elif object["sub_label"][0] in self.config.all_attributes:
|
elif object["sub_label"][0] in self.config.model.all_attributes:
|
||||||
segment.detections[object["id"]] = object["sub_label"][0]
|
segment.detections[object["id"]] = object["sub_label"][0]
|
||||||
else:
|
else:
|
||||||
segment.detections[object["id"]] = f"{object['label']}-verified"
|
segment.detections[object["id"]] = f"{object['label']}-verified"
|
||||||
@@ -614,7 +614,7 @@ class ReviewSegmentMaintainer(threading.Thread):
|
|||||||
for object in activity.get_all_objects():
|
for object in activity.get_all_objects():
|
||||||
if not object["sub_label"]:
|
if not object["sub_label"]:
|
||||||
detections[object["id"]] = object["label"]
|
detections[object["id"]] = object["label"]
|
||||||
elif object["sub_label"][0] in self.config.all_attributes:
|
elif object["sub_label"][0] in self.config.model.all_attributes:
|
||||||
detections[object["id"]] = object["sub_label"][0]
|
detections[object["id"]] = object["sub_label"][0]
|
||||||
else:
|
else:
|
||||||
detections[object["id"]] = f"{object['label']}-verified"
|
detections[object["id"]] = f"{object['label']}-verified"
|
||||||
|
|||||||
+13
-14
@@ -322,20 +322,19 @@ async def set_gpu_stats(
|
|||||||
async def set_npu_usages(config: FrigateConfig, all_stats: dict[str, Any]) -> None:
|
async def set_npu_usages(config: FrigateConfig, all_stats: dict[str, Any]) -> None:
|
||||||
stats: dict[str, dict] = {}
|
stats: dict[str, dict] = {}
|
||||||
|
|
||||||
for model in config.models:
|
for detector in config.detectors.values():
|
||||||
for device in config.devices_for_model(model):
|
if detector.type == "rknn":
|
||||||
if device.detector == "rknn":
|
# Rockchip NPU usage
|
||||||
# Rockchip NPU usage
|
rk_usage = get_rockchip_npu_stats()
|
||||||
rk_usage = get_rockchip_npu_stats()
|
stats["rockchip"] = rk_usage
|
||||||
stats["rockchip"] = rk_usage
|
elif detector.type == "openvino" and detector.device == "NPU":
|
||||||
elif device.detector == "openvino" and device.device == "NPU":
|
# OpenVINO NPU usage
|
||||||
# OpenVINO NPU usage
|
ov_usage = get_openvino_npu_stats()
|
||||||
ov_usage = get_openvino_npu_stats()
|
stats["openvino"] = ov_usage
|
||||||
stats["openvino"] = ov_usage
|
elif detector.type == "axengine":
|
||||||
elif device.detector == "axengine":
|
# AXERA NPU usage
|
||||||
# AXERA NPU usage
|
axcl_usage = get_axcl_npu_stats()
|
||||||
axcl_usage = get_axcl_npu_stats()
|
stats["axengine"] = axcl_usage
|
||||||
stats["axengine"] = axcl_usage
|
|
||||||
|
|
||||||
if stats:
|
if stats:
|
||||||
all_stats["npu_usages"] = stats
|
all_stats["npu_usages"] = stats
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from frigate.jobs.debug_replay import NoRecordingsError
|
||||||
from frigate.models import Event, Recordings, ReviewSegment
|
from frigate.models import Event, Recordings, ReviewSegment
|
||||||
from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp
|
from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp
|
||||||
|
|
||||||
@@ -66,6 +67,32 @@ class TestDebugReplayAPI(BaseTestHttp):
|
|||||||
# (CodeQL: information exposure through an exception).
|
# (CodeQL: information exposure through an exception).
|
||||||
self.assertEqual(body["message"], "Invalid debug replay parameters")
|
self.assertEqual(body["message"], "Invalid debug replay parameters")
|
||||||
|
|
||||||
|
def test_start_returns_404_when_no_recordings(self):
|
||||||
|
with patch(
|
||||||
|
"frigate.api.debug_replay.start_debug_replay_job",
|
||||||
|
side_effect=NoRecordingsError(
|
||||||
|
"No recordings found for camera 'front' in the specified time range"
|
||||||
|
),
|
||||||
|
):
|
||||||
|
with AuthTestClient(self.app) as client:
|
||||||
|
resp = client.post(
|
||||||
|
"/debug_replay/start",
|
||||||
|
json={
|
||||||
|
"camera": "front",
|
||||||
|
"start_time": 100,
|
||||||
|
"end_time": 200,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(resp.status_code, 404)
|
||||||
|
body = resp.json()
|
||||||
|
self.assertFalse(body["success"])
|
||||||
|
# Message is hard-coded so we don't echo exception text back to clients
|
||||||
|
# (CodeQL: information exposure through an exception).
|
||||||
|
self.assertEqual(
|
||||||
|
body["message"], "No recordings found in the selected time range"
|
||||||
|
)
|
||||||
|
|
||||||
def test_start_returns_409_when_session_already_active(self):
|
def test_start_returns_409_when_session_already_active(self):
|
||||||
with patch(
|
with patch(
|
||||||
"frigate.api.debug_replay.start_debug_replay_job",
|
"frigate.api.debug_replay.start_debug_replay_job",
|
||||||
|
|||||||
@@ -440,3 +440,68 @@ class TestGo2rtcStreamAccess(BaseTestHttp):
|
|||||||
f"limited_user should be denied on alias back_door_main; "
|
f"limited_user should be denied on alias back_door_main; "
|
||||||
f"got {resp.status_code}"
|
f"got {resp.status_code}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestReviewSummaryAccess(BaseTestHttp):
|
||||||
|
"""Tests for POST /review/summarize/start/{start_ts}/end/{end_ts}.
|
||||||
|
|
||||||
|
The summary correlates each flagged event with overlapping activity on
|
||||||
|
other cameras, so it is gated on full camera access rather than scoped to
|
||||||
|
the caller's cameras. These tests pin that decision so the dependency is
|
||||||
|
not loosened without first scoping the query.
|
||||||
|
|
||||||
|
GenAI is not configured in unit tests, so an authorized request returns 400
|
||||||
|
while an unauthorized one is rejected with 403 before the handler runs.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp([Event, ReviewSegment, Recordings])
|
||||||
|
self.minimal_config = _MULTI_CAMERA_CONFIG
|
||||||
|
self.app = super().create_app()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.app.dependency_overrides.clear()
|
||||||
|
super().tearDown()
|
||||||
|
|
||||||
|
def _summarize(self, allowed_cameras: list[str]):
|
||||||
|
async def mock_cameras(request: Request):
|
||||||
|
return allowed_cameras
|
||||||
|
|
||||||
|
self.app.dependency_overrides[get_allowed_cameras_for_filter] = mock_cameras
|
||||||
|
with AuthTestClient(self.app) as client:
|
||||||
|
return client.post("/review/summarize/start/0/end/9999999999")
|
||||||
|
|
||||||
|
def _assert_allowed(self, resp):
|
||||||
|
assert resp.status_code not in (401, 403), (
|
||||||
|
f"Caller should not be blocked; got {resp.status_code}"
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_partial_camera_access_blocked(self):
|
||||||
|
assert self._summarize(["front_door"]).status_code == 403
|
||||||
|
|
||||||
|
def test_no_camera_access_blocked(self):
|
||||||
|
assert self._summarize([]).status_code == 403
|
||||||
|
|
||||||
|
def test_full_camera_access_allowed(self):
|
||||||
|
# Covers admin and viewer, which always resolve to every camera, and a
|
||||||
|
# custom role whose list happens to name them all.
|
||||||
|
self._assert_allowed(self._summarize(["front_door", "back_door"]))
|
||||||
|
|
||||||
|
def _summarize_as_role(self, role: str):
|
||||||
|
"""Summarize using the real role to allowed-cameras resolution."""
|
||||||
|
self.app.dependency_overrides.pop(get_allowed_cameras_for_filter, None)
|
||||||
|
with AuthTestClient(self.app) as client:
|
||||||
|
return client.post(
|
||||||
|
"/review/summarize/start/0/end/9999999999",
|
||||||
|
headers={"remote-user": "test", "remote-role": role},
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_viewer_role_allowed(self):
|
||||||
|
# viewer is never camera restricted, so it resolves to every camera.
|
||||||
|
self._assert_allowed(self._summarize_as_role("viewer"))
|
||||||
|
|
||||||
|
def test_admin_role_allowed(self):
|
||||||
|
self._assert_allowed(self._summarize_as_role("admin"))
|
||||||
|
|
||||||
|
def test_restricted_role_blocked(self):
|
||||||
|
assert self._summarize_as_role("limited_user").status_code == 403
|
||||||
|
|||||||
@@ -386,19 +386,9 @@ class TestConfigSetWildcardPropagation(BaseTestHttp):
|
|||||||
guess (mode still equals the previous global) wrongly claims a camera
|
guess (mode still equals the previous global) wrongly claims a camera
|
||||||
whose explicit yaml mode happens to match.
|
whose explicit yaml mode happens to match.
|
||||||
"""
|
"""
|
||||||
self.minimal_config["birdseye"] = {
|
self.minimal_config["birdseye"] = {"enabled": True, "mode": "motion"}
|
||||||
"enabled": True,
|
|
||||||
"mode": {"motion": True},
|
|
||||||
}
|
|
||||||
# explicit override that matches the global value being replaced
|
# explicit override that matches the global value being replaced
|
||||||
self.minimal_config["cameras"]["front_door"]["birdseye"] = {
|
self.minimal_config["cameras"]["front_door"]["birdseye"] = {"mode": "motion"}
|
||||||
"mode": {
|
|
||||||
"continuous": False,
|
|
||||||
"motion": True,
|
|
||||||
"objects": False,
|
|
||||||
"stationary_objects": False,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config_path = self._write_config_file()
|
config_path = self._write_config_file()
|
||||||
mock_find_config.return_value = config_path
|
mock_find_config.return_value = config_path
|
||||||
@@ -409,16 +399,7 @@ class TestConfigSetWildcardPropagation(BaseTestHttp):
|
|||||||
resp = client.put(
|
resp = client.put(
|
||||||
"/config/set",
|
"/config/set",
|
||||||
json={
|
json={
|
||||||
"config_data": {
|
"config_data": {"birdseye": {"mode": "continuous"}},
|
||||||
"birdseye": {
|
|
||||||
"mode": {
|
|
||||||
"continuous": True,
|
|
||||||
"motion": False,
|
|
||||||
"objects": False,
|
|
||||||
"stationary_objects": False,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"update_topic": "config/birdseye",
|
"update_topic": "config/birdseye",
|
||||||
"requires_restart": 0,
|
"requires_restart": 0,
|
||||||
},
|
},
|
||||||
@@ -430,7 +411,7 @@ class TestConfigSetWildcardPropagation(BaseTestHttp):
|
|||||||
mock_publisher.publisher.publish.assert_called_once()
|
mock_publisher.publisher.publish.assert_called_once()
|
||||||
topic, settings = mock_publisher.publisher.publish.call_args[0]
|
topic, settings = mock_publisher.publisher.publish.call_args[0]
|
||||||
self.assertEqual(topic, "config/birdseye")
|
self.assertEqual(topic, "config/birdseye")
|
||||||
self.assertEqual(settings.mode.to_mqtt_payload(), "CONTINUOUS")
|
self.assertEqual(settings.mode.value, "continuous")
|
||||||
|
|
||||||
published = {
|
published = {
|
||||||
call[0][0].camera: call[0][1]
|
call[0][0].camera: call[0][1]
|
||||||
@@ -444,12 +425,8 @@ class TestConfigSetWildcardPropagation(BaseTestHttp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# the override survives, the inheriting camera follows global
|
# the override survives, the inheriting camera follows global
|
||||||
self.assertEqual(
|
self.assertEqual(published["front_door"].mode.value, "motion")
|
||||||
published["front_door"].mode.to_mqtt_payload(), "MOTION"
|
self.assertEqual(published["back_yard"].mode.value, "continuous")
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
published["back_yard"].mode.to_mqtt_payload(), "CONTINUOUS"
|
|
||||||
)
|
|
||||||
finally:
|
finally:
|
||||||
os.unlink(config_path)
|
os.unlink(config_path)
|
||||||
|
|
||||||
|
|||||||
@@ -1,73 +1,15 @@
|
|||||||
"""Unit tests for recordings/media API endpoints."""
|
"""Unit tests for recordings/media API endpoints."""
|
||||||
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
|
|
||||||
from frigate.api.auth import get_allowed_cameras_for_filter, get_current_user
|
from frigate.api.auth import get_allowed_cameras_for_filter, get_current_user
|
||||||
from frigate.const import MAX_SEGMENT_DURATION
|
|
||||||
from frigate.models import Recordings
|
from frigate.models import Recordings
|
||||||
from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp
|
from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class RangeCase:
|
|
||||||
"""Expected behavior for one segment relative to the requested range.
|
|
||||||
|
|
||||||
Offsets are seconds from REQUEST_START; the request ends at +100 seconds.
|
|
||||||
"""
|
|
||||||
|
|
||||||
name: str
|
|
||||||
start_offset: float
|
|
||||||
end_offset: float
|
|
||||||
included_in_recordings: bool
|
|
||||||
vod_clip_from_ms: int | None = None
|
|
||||||
vod_duration_ms: int | None = None
|
|
||||||
|
|
||||||
|
|
||||||
REQUEST_START = 1000
|
|
||||||
REQUEST_END = 1100
|
|
||||||
RANGE_CASES = (
|
|
||||||
RangeCase("before", -MAX_SEGMENT_DURATION + 1, -1, False),
|
|
||||||
RangeCase("meets_start", -10, 0, True),
|
|
||||||
RangeCase(
|
|
||||||
"overlaps_start",
|
|
||||||
-MAX_SEGMENT_DURATION + 0.5,
|
|
||||||
0.25,
|
|
||||||
True,
|
|
||||||
vod_clip_from_ms=599500,
|
|
||||||
vod_duration_ms=250,
|
|
||||||
),
|
|
||||||
RangeCase("starts_at_start", 0, 10, True, vod_duration_ms=10000),
|
|
||||||
RangeCase("inside", 20, 80, True, vod_duration_ms=60000),
|
|
||||||
RangeCase("ends_at_end", 90, 100, True, vod_duration_ms=10000),
|
|
||||||
RangeCase("matches_range", 0, 100, True, vod_duration_ms=100000),
|
|
||||||
RangeCase("starts_with_range", 0, 110, True, vod_duration_ms=100000),
|
|
||||||
RangeCase(
|
|
||||||
"covers_range",
|
|
||||||
-20,
|
|
||||||
120,
|
|
||||||
True,
|
|
||||||
vod_clip_from_ms=20000,
|
|
||||||
vod_duration_ms=100000,
|
|
||||||
),
|
|
||||||
RangeCase(
|
|
||||||
"ends_with_range",
|
|
||||||
-10,
|
|
||||||
100,
|
|
||||||
True,
|
|
||||||
vod_clip_from_ms=10000,
|
|
||||||
vod_duration_ms=100000,
|
|
||||||
),
|
|
||||||
RangeCase("overlaps_end", 95, 105, True, vod_duration_ms=5000),
|
|
||||||
RangeCase("starts_at_end", 100, 110, True),
|
|
||||||
RangeCase("after", 101, 110, False),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestHttpMedia(BaseTestHttp):
|
class TestHttpMedia(BaseTestHttp):
|
||||||
"""Test media API endpoints, particularly recordings with DST handling."""
|
"""Test media API endpoints, particularly recordings with DST handling."""
|
||||||
|
|
||||||
@@ -102,26 +44,6 @@ class TestHttpMedia(BaseTestHttp):
|
|||||||
self.app.dependency_overrides.clear()
|
self.app.dependency_overrides.clear()
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
|
||||||
def _assert_vod_response(
|
|
||||||
self,
|
|
||||||
response,
|
|
||||||
expected_clips: list[tuple[str, int | None, int]],
|
|
||||||
) -> None:
|
|
||||||
"""Assert VOD clip metadata and its derived duration fields."""
|
|
||||||
assert response.status_code == 200
|
|
||||||
vod = response.json()
|
|
||||||
assert [
|
|
||||||
(
|
|
||||||
clip["path"],
|
|
||||||
clip.get("clipFrom"),
|
|
||||||
clip["keyFrameDurations"][0],
|
|
||||||
)
|
|
||||||
for clip in vod["sequences"][0]["clips"]
|
|
||||||
] == expected_clips
|
|
||||||
expected_durations = [clip[2] for clip in expected_clips]
|
|
||||||
assert vod["durations"] == expected_durations
|
|
||||||
assert vod["segment_duration"] == max(expected_durations)
|
|
||||||
|
|
||||||
def test_recordings_summary_across_dst_spring_forward(self):
|
def test_recordings_summary_across_dst_spring_forward(self):
|
||||||
"""
|
"""
|
||||||
Test recordings summary across spring DST transition (spring forward).
|
Test recordings summary across spring DST transition (spring forward).
|
||||||
@@ -482,102 +404,6 @@ class TestHttpMedia(BaseTestHttp):
|
|||||||
assert "2024-03-10" in summary
|
assert "2024-03-10" in summary
|
||||||
assert summary["2024-03-10"] is True
|
assert summary["2024-03-10"] is True
|
||||||
|
|
||||||
def test_recordings_handles_all_range_relations(self):
|
|
||||||
"""Recordings return every interval relation that touches the range."""
|
|
||||||
with AuthTestClient(self.app) as client:
|
|
||||||
for case in RANGE_CASES:
|
|
||||||
with self.subTest(case=case.name):
|
|
||||||
Recordings.delete().execute()
|
|
||||||
super().insert_mock_recording(
|
|
||||||
case.name,
|
|
||||||
REQUEST_START + case.start_offset,
|
|
||||||
REQUEST_START + case.end_offset,
|
|
||||||
)
|
|
||||||
|
|
||||||
response = client.get(
|
|
||||||
"/front_door/recordings",
|
|
||||||
params={"after": REQUEST_START, "before": REQUEST_END},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert response.status_code == 200
|
|
||||||
expected_ids = [case.name] if case.included_in_recordings else []
|
|
||||||
assert [
|
|
||||||
recording["id"] for recording in response.json()
|
|
||||||
] == expected_ids
|
|
||||||
|
|
||||||
def test_vod_handles_all_range_relations(self):
|
|
||||||
"""VOD clips every interval relation with positive playback duration."""
|
|
||||||
with (
|
|
||||||
AuthTestClient(self.app) as client,
|
|
||||||
patch(
|
|
||||||
"frigate.api.media.get_keyframe_before",
|
|
||||||
side_effect=lambda _path, offset: offset,
|
|
||||||
),
|
|
||||||
):
|
|
||||||
for case in RANGE_CASES:
|
|
||||||
with self.subTest(case=case.name):
|
|
||||||
Recordings.delete().execute()
|
|
||||||
super().insert_mock_recording(
|
|
||||||
case.name,
|
|
||||||
REQUEST_START + case.start_offset,
|
|
||||||
REQUEST_START + case.end_offset,
|
|
||||||
)
|
|
||||||
|
|
||||||
response = client.get(
|
|
||||||
f"/vod/front_door/start/{REQUEST_START}/end/{REQUEST_END}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if case.vod_duration_ms is None:
|
|
||||||
assert response.status_code == 404
|
|
||||||
continue
|
|
||||||
|
|
||||||
self._assert_vod_response(
|
|
||||||
response,
|
|
||||||
[
|
|
||||||
(
|
|
||||||
case.name,
|
|
||||||
case.vod_clip_from_ms,
|
|
||||||
case.vod_duration_ms,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_vod_handles_segment_ending_at_start_with_keyframe_fallbacks(self):
|
|
||||||
"""VOD keeps a boundary segment when keyframe lookup extends it."""
|
|
||||||
|
|
||||||
def keyframe_before(path: str, offset: int) -> int | None:
|
|
||||||
return offset - 1000 if path == "previous_keyframe" else None
|
|
||||||
|
|
||||||
with (
|
|
||||||
AuthTestClient(self.app) as client,
|
|
||||||
patch(
|
|
||||||
"frigate.api.media.get_keyframe_before",
|
|
||||||
side_effect=keyframe_before,
|
|
||||||
),
|
|
||||||
):
|
|
||||||
super().insert_mock_recording(
|
|
||||||
"previous_keyframe",
|
|
||||||
REQUEST_START - 10,
|
|
||||||
REQUEST_START,
|
|
||||||
)
|
|
||||||
super().insert_mock_recording(
|
|
||||||
"missing_keyframe",
|
|
||||||
REQUEST_START - 5,
|
|
||||||
REQUEST_START,
|
|
||||||
)
|
|
||||||
|
|
||||||
response = client.get(
|
|
||||||
f"/vod/front_door/start/{REQUEST_START}/end/{REQUEST_END}"
|
|
||||||
)
|
|
||||||
|
|
||||||
self._assert_vod_response(
|
|
||||||
response,
|
|
||||||
[
|
|
||||||
("previous_keyframe", 9000, 1000),
|
|
||||||
("missing_keyframe", None, 5000),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_recordings_unavailable_reports_gap_between_recordings(self):
|
def test_recordings_unavailable_reports_gap_between_recordings(self):
|
||||||
"""A gap between two recordings is reported as an unavailable segment."""
|
"""A gap between two recordings is reported as an unavailable segment."""
|
||||||
with AuthTestClient(self.app) as client:
|
with AuthTestClient(self.app) as client:
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
"""Tests for password change authorization."""
|
||||||
|
|
||||||
|
from fastapi import Request
|
||||||
|
|
||||||
|
from frigate.api.auth import get_current_user, hash_password, verify_password
|
||||||
|
from frigate.models import Event, Recordings, ReviewSegment, User
|
||||||
|
from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp
|
||||||
|
|
||||||
|
# Config carrying a custom role, which is the class of user the literal
|
||||||
|
# "viewer" check used to let through.
|
||||||
|
_CUSTOM_ROLE_CONFIG = {
|
||||||
|
"mqtt": {"host": "mqtt"},
|
||||||
|
"auth": {"roles": {"neighbor": ["front_door"]}, "hash_iterations": 10},
|
||||||
|
"cameras": {
|
||||||
|
"front_door": {
|
||||||
|
"ffmpeg": {
|
||||||
|
"inputs": [{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}]
|
||||||
|
},
|
||||||
|
"detect": {"height": 1080, "width": 1920, "fps": 5},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
ADMIN_PASSWORD = "admin-real-password"
|
||||||
|
NEW_PASSWORD = "AttackerChosenPassword123!"
|
||||||
|
|
||||||
|
|
||||||
|
class TestUpdatePasswordAccess(BaseTestHttp):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp([Event, ReviewSegment, Recordings, User])
|
||||||
|
self.minimal_config = _CUSTOM_ROLE_CONFIG
|
||||||
|
self.app = super().create_app()
|
||||||
|
User.insert(
|
||||||
|
username="admin",
|
||||||
|
password_hash=hash_password(ADMIN_PASSWORD, iterations=10),
|
||||||
|
role="admin",
|
||||||
|
notification_tokens=[],
|
||||||
|
).execute()
|
||||||
|
|
||||||
|
async def mock_get_current_user(request: Request):
|
||||||
|
return {
|
||||||
|
"username": request.headers.get("remote-user"),
|
||||||
|
"role": request.headers.get("remote-role"),
|
||||||
|
}
|
||||||
|
|
||||||
|
self.app.dependency_overrides[get_current_user] = mock_get_current_user
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.app.dependency_overrides.clear()
|
||||||
|
super().tearDown()
|
||||||
|
|
||||||
|
def _change_password(self, actor: str, role: str, target: str, old_password: str):
|
||||||
|
with AuthTestClient(self.app) as client:
|
||||||
|
return client.put(
|
||||||
|
f"/users/{target}/password",
|
||||||
|
json={"password": NEW_PASSWORD, "old_password": old_password},
|
||||||
|
headers={"remote-user": actor, "remote-role": role},
|
||||||
|
)
|
||||||
|
|
||||||
|
def _admin_password_unchanged(self) -> bool:
|
||||||
|
return verify_password(ADMIN_PASSWORD, User.get_by_id("admin").password_hash)
|
||||||
|
|
||||||
|
def test_custom_role_cannot_target_another_account(self):
|
||||||
|
resp = self._change_password("neighbor", "neighbor", "admin", "wrong-guess")
|
||||||
|
assert resp.status_code == 403
|
||||||
|
assert self._admin_password_unchanged()
|
||||||
|
|
||||||
|
def test_custom_role_cannot_target_another_account_with_correct_password(self):
|
||||||
|
# The 403 must land before old_password is checked, so knowing the
|
||||||
|
# target's password is not a way through
|
||||||
|
resp = self._change_password("neighbor", "neighbor", "admin", ADMIN_PASSWORD)
|
||||||
|
assert resp.status_code == 403
|
||||||
|
assert self._admin_password_unchanged()
|
||||||
|
|
||||||
|
def test_viewer_cannot_target_another_account(self):
|
||||||
|
resp = self._change_password("viewer_user", "viewer", "admin", ADMIN_PASSWORD)
|
||||||
|
assert resp.status_code == 403
|
||||||
|
assert self._admin_password_unchanged()
|
||||||
|
|
||||||
|
def test_admin_can_target_another_account(self):
|
||||||
|
User.insert(
|
||||||
|
username="neighbor",
|
||||||
|
password_hash=hash_password("neighbor-password", iterations=10),
|
||||||
|
role="neighbor",
|
||||||
|
notification_tokens=[],
|
||||||
|
).execute()
|
||||||
|
|
||||||
|
resp = self._change_password("admin", "admin", "neighbor", "")
|
||||||
|
assert resp.status_code == 200
|
||||||
|
|
||||||
|
def test_non_admin_can_change_own_password(self):
|
||||||
|
User.insert(
|
||||||
|
username="neighbor",
|
||||||
|
password_hash=hash_password("neighbor-password", iterations=10),
|
||||||
|
role="neighbor",
|
||||||
|
notification_tokens=[],
|
||||||
|
).execute()
|
||||||
|
|
||||||
|
resp = self._change_password(
|
||||||
|
"neighbor", "neighbor", "neighbor", "neighbor-password"
|
||||||
|
)
|
||||||
|
assert resp.status_code == 200
|
||||||
|
|
||||||
|
def test_non_admin_own_password_still_requires_old_password(self):
|
||||||
|
User.insert(
|
||||||
|
username="neighbor",
|
||||||
|
password_hash=hash_password("neighbor-password", iterations=10),
|
||||||
|
role="neighbor",
|
||||||
|
notification_tokens=[],
|
||||||
|
).execute()
|
||||||
|
|
||||||
|
resp = self._change_password("neighbor", "neighbor", "neighbor", "wrong-guess")
|
||||||
|
assert resp.status_code == 401
|
||||||
@@ -1,70 +1,13 @@
|
|||||||
"""Tests for Birdseye canvas sizing and layout behavior."""
|
"""Test camera user and password cleanup."""
|
||||||
|
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import Mock
|
|
||||||
|
|
||||||
from frigate.config import BirdseyeModeConfig, FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
from frigate.output.birdseye import (
|
from frigate.output.birdseye import BirdsEyeFrameManager, get_canvas_shape
|
||||||
Birdseye,
|
|
||||||
BirdseyeActivity,
|
|
||||||
BirdsEyeFrameManager,
|
|
||||||
get_canvas_shape,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestBirdseye(unittest.TestCase):
|
class TestBirdseye(unittest.TestCase):
|
||||||
def _build_manager(
|
|
||||||
self, camera_dimensions: dict[str, tuple[int, int]]
|
|
||||||
) -> BirdsEyeFrameManager:
|
|
||||||
config = {
|
|
||||||
"mqtt": {"host": "mqtt"},
|
|
||||||
"birdseye": {"width": 1280, "height": 720},
|
|
||||||
"cameras": {},
|
|
||||||
}
|
|
||||||
|
|
||||||
for order, (camera, dimensions) in enumerate(
|
|
||||||
camera_dimensions.items(), start=1
|
|
||||||
):
|
|
||||||
config["cameras"][camera] = {
|
|
||||||
"ffmpeg": {
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"path": f"rtsp://10.0.0.1:554/{camera}",
|
|
||||||
"roles": ["detect"],
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"detect": {
|
|
||||||
"width": dimensions[0],
|
|
||||||
"height": dimensions[1],
|
|
||||||
"fps": 5,
|
|
||||||
},
|
|
||||||
"birdseye": {"order": order},
|
|
||||||
}
|
|
||||||
|
|
||||||
return BirdsEyeFrameManager(FrigateConfig(**config), mp.Event())
|
|
||||||
|
|
||||||
def _assert_no_overlaps(
|
|
||||||
self, layout: list[list[tuple[str, tuple[int, int, int, int]]]]
|
|
||||||
):
|
|
||||||
rectangles = [position for row in layout for _, position in row]
|
|
||||||
|
|
||||||
for index, rect in enumerate(rectangles):
|
|
||||||
x1, y1, width1, height1 = rect
|
|
||||||
for other in rectangles[index + 1 :]:
|
|
||||||
x2, y2, width2, height2 = other
|
|
||||||
overlap = (
|
|
||||||
x1 < x2 + width2
|
|
||||||
and x2 < x1 + width1
|
|
||||||
and y1 < y2 + height2
|
|
||||||
and y2 < y1 + height1
|
|
||||||
)
|
|
||||||
self.assertFalse(
|
|
||||||
overlap,
|
|
||||||
msg=f"Overlapping rectangles found: {rect} and {other}",
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_16x9(self):
|
def test_16x9(self):
|
||||||
"""Test 16x9 aspect ratio works as expected for birdseye."""
|
"""Test 16x9 aspect ratio works as expected for birdseye."""
|
||||||
width = 1280
|
width = 1280
|
||||||
@@ -105,212 +48,6 @@ class TestBirdseye(unittest.TestCase):
|
|||||||
assert canvas_width == width # width will be the same
|
assert canvas_width == width # width will be the same
|
||||||
assert canvas_height != height
|
assert canvas_height != height
|
||||||
|
|
||||||
def test_portrait_camera_does_not_overlap_next_row(self):
|
|
||||||
"""Portrait cameras should reserve their real horizontal position on the next row."""
|
|
||||||
manager = self._build_manager(
|
|
||||||
{
|
|
||||||
"cam_a": (1280, 720),
|
|
||||||
"cam_p": (360, 640),
|
|
||||||
"cam_b": (1280, 720),
|
|
||||||
"cam_c": (640, 480),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
layout = manager.calculate_layout(["cam_a", "cam_p", "cam_b", "cam_c"], 3)
|
|
||||||
|
|
||||||
self.assertIsNotNone(layout)
|
|
||||||
assert layout is not None
|
|
||||||
self._assert_no_overlaps(layout)
|
|
||||||
|
|
||||||
cam_c = [
|
|
||||||
position for row in layout for camera, position in row if camera == "cam_c"
|
|
||||||
][0]
|
|
||||||
self.assertEqual(cam_c[0], 0)
|
|
||||||
|
|
||||||
def test_portrait_reservation_only_applies_to_next_row(self):
|
|
||||||
"""Portrait reservations should not push later rows after the span ends."""
|
|
||||||
manager = self._build_manager(
|
|
||||||
{
|
|
||||||
"cam_a": (1280, 720),
|
|
||||||
"cam_p": (360, 640),
|
|
||||||
"cam_b": (1280, 720),
|
|
||||||
"cam_c": (1280, 720),
|
|
||||||
"cam_d": (1280, 720),
|
|
||||||
"cam_e": (1280, 720),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
layout = manager.calculate_layout(
|
|
||||||
["cam_a", "cam_p", "cam_b", "cam_c", "cam_d", "cam_e"],
|
|
||||||
3,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertIsNotNone(layout)
|
|
||||||
assert layout is not None
|
|
||||||
self._assert_no_overlaps(layout)
|
|
||||||
|
|
||||||
cam_e = [
|
|
||||||
position for row in layout for camera, position in row if camera == "cam_e"
|
|
||||||
][0]
|
|
||||||
self.assertEqual(cam_e[0], 0)
|
|
||||||
|
|
||||||
def test_multiple_portraits_reserve_distinct_ranges(self):
|
|
||||||
"""Multiple portrait cameras in one row should reserve separate spans below them."""
|
|
||||||
manager = self._build_manager(
|
|
||||||
{
|
|
||||||
"cam_a": (640, 480),
|
|
||||||
"cam_p1": (360, 640),
|
|
||||||
"cam_p2": (360, 640),
|
|
||||||
"cam_b": (640, 480),
|
|
||||||
"cam_c": (1280, 720),
|
|
||||||
"cam_d": (640, 480),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
layout = manager.calculate_layout(
|
|
||||||
["cam_a", "cam_p1", "cam_p2", "cam_b", "cam_c", "cam_d"],
|
|
||||||
4,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertIsNotNone(layout)
|
|
||||||
assert layout is not None
|
|
||||||
self._assert_no_overlaps(layout)
|
|
||||||
|
|
||||||
def test_two_landscapes_then_portrait_then_two_landscapes(self):
|
|
||||||
"""A portrait after two landscapes should reserve only its own tail span."""
|
|
||||||
manager = self._build_manager(
|
|
||||||
{
|
|
||||||
"cam_a": (1280, 720),
|
|
||||||
"cam_b": (1280, 720),
|
|
||||||
"cam_p": (360, 640),
|
|
||||||
"cam_c": (1280, 720),
|
|
||||||
"cam_d": (1280, 720),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
layout = manager.calculate_layout(
|
|
||||||
["cam_a", "cam_b", "cam_p", "cam_c", "cam_d"],
|
|
||||||
3,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertIsNotNone(layout)
|
|
||||||
assert layout is not None
|
|
||||||
self._assert_no_overlaps(layout)
|
|
||||||
|
|
||||||
cam_c = [
|
|
||||||
position for row in layout for camera, position in row if camera == "cam_c"
|
|
||||||
][0]
|
|
||||||
cam_d = [
|
|
||||||
position for row in layout for camera, position in row if camera == "cam_d"
|
|
||||||
][0]
|
|
||||||
self.assertEqual(cam_c[0], 0)
|
|
||||||
self.assertEqual(cam_d[0], cam_c[0] + cam_c[2])
|
|
||||||
|
|
||||||
|
|
||||||
class TestBirdseyeActivity(unittest.TestCase):
|
|
||||||
"""Test which camera activity is included in each Birdseye mode."""
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
config = {
|
|
||||||
"mqtt": {"enabled": False},
|
|
||||||
"birdseye": {
|
|
||||||
"enabled": True,
|
|
||||||
"mode": {
|
|
||||||
"motion": True,
|
|
||||||
"objects": True,
|
|
||||||
"stationary_objects": True,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"cameras": {
|
|
||||||
"front": {
|
|
||||||
"ffmpeg": {
|
|
||||||
"inputs": [
|
|
||||||
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"detect": {"height": 1080, "width": 1920, "fps": 5},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
self.manager = BirdsEyeFrameManager(FrigateConfig(**config), mp.Event())
|
|
||||||
|
|
||||||
def test_existing_modes_keep_their_activity_rules(self):
|
|
||||||
continuous = BirdseyeModeConfig(continuous=True)
|
|
||||||
motion = BirdseyeModeConfig(motion=True)
|
|
||||||
objects = BirdseyeModeConfig(objects=True)
|
|
||||||
|
|
||||||
no_activity = BirdseyeActivity(False, False, False)
|
|
||||||
motion_activity = BirdseyeActivity(False, False, True)
|
|
||||||
stationary_activity = BirdseyeActivity(False, True, False)
|
|
||||||
active_object_activity = BirdseyeActivity(True, False, False)
|
|
||||||
|
|
||||||
assert self.manager.camera_active(continuous, no_activity)
|
|
||||||
assert self.manager.camera_active(motion, motion_activity)
|
|
||||||
assert not self.manager.camera_active(motion, stationary_activity)
|
|
||||||
assert self.manager.camera_active(objects, active_object_activity)
|
|
||||||
assert not self.manager.camera_active(objects, stationary_activity)
|
|
||||||
|
|
||||||
def test_modes_can_be_combined(self):
|
|
||||||
mode = BirdseyeModeConfig(motion=True, stationary_objects=True)
|
|
||||||
|
|
||||||
assert self.manager.camera_active(mode, BirdseyeActivity(False, False, True))
|
|
||||||
assert self.manager.camera_active(mode, BirdseyeActivity(False, True, False))
|
|
||||||
assert not self.manager.camera_active(
|
|
||||||
mode, BirdseyeActivity(False, False, False)
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_stationary_objects_are_independent_from_active_objects(self):
|
|
||||||
stationary_objects = BirdseyeModeConfig(stationary_objects=True)
|
|
||||||
|
|
||||||
assert self.manager.camera_active(
|
|
||||||
stationary_objects, BirdseyeActivity(False, True, False)
|
|
||||||
)
|
|
||||||
assert not self.manager.camera_active(
|
|
||||||
stationary_objects, BirdseyeActivity(True, False, False)
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_write_data_preserves_active_and_confirms_stationary_activity(self):
|
|
||||||
birdseye = Birdseye.__new__(Birdseye)
|
|
||||||
birdseye.birdseye_manager = Mock()
|
|
||||||
birdseye.birdseye_manager.update.return_value = (False, False)
|
|
||||||
birdseye._idle_interval = None
|
|
||||||
frame = Mock()
|
|
||||||
|
|
||||||
birdseye.write_data(
|
|
||||||
"front",
|
|
||||||
[
|
|
||||||
{"stationary": True, "false_positive": True},
|
|
||||||
{"stationary": False, "false_positive": True},
|
|
||||||
{"stationary": True, "false_positive": False},
|
|
||||||
],
|
|
||||||
[[0, 0, 10, 10]],
|
|
||||||
1.0,
|
|
||||||
frame,
|
|
||||||
)
|
|
||||||
|
|
||||||
birdseye.birdseye_manager.update.assert_called_once_with(
|
|
||||||
"front", BirdseyeActivity(True, True, True), 1.0, frame
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_stationary_false_positive_does_not_activate_birdseye(self):
|
|
||||||
birdseye = Birdseye.__new__(Birdseye)
|
|
||||||
birdseye.birdseye_manager = Mock()
|
|
||||||
birdseye.birdseye_manager.update.return_value = (False, False)
|
|
||||||
birdseye._idle_interval = None
|
|
||||||
frame = Mock()
|
|
||||||
|
|
||||||
birdseye.write_data(
|
|
||||||
"front",
|
|
||||||
[{"stationary": True, "false_positive": True}],
|
|
||||||
[],
|
|
||||||
1.0,
|
|
||||||
frame,
|
|
||||||
)
|
|
||||||
|
|
||||||
birdseye.birdseye_manager.update.assert_called_once_with(
|
|
||||||
"front", BirdseyeActivity(False, False, False), 1.0, frame
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestBirdseyeCameraOrder(unittest.TestCase):
|
class TestBirdseyeCameraOrder(unittest.TestCase):
|
||||||
"""Test that birdseye reacts to camera order changes without a restart."""
|
"""Test that birdseye reacts to camera order changes without a restart."""
|
||||||
@@ -318,7 +55,7 @@ class TestBirdseyeCameraOrder(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"enabled": False},
|
"mqtt": {"enabled": False},
|
||||||
"birdseye": {"enabled": True, "mode": {"continuous": True}},
|
"birdseye": {"enabled": True, "mode": "continuous"},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
camera: {
|
camera: {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
|
|||||||
+46
-260
@@ -7,11 +7,9 @@ import numpy as np
|
|||||||
from pydantic import ValidationError
|
from pydantic import ValidationError
|
||||||
from ruamel.yaml.constructor import DuplicateKeyError
|
from ruamel.yaml.constructor import DuplicateKeyError
|
||||||
|
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import BirdseyeModeEnum, FrigateConfig
|
||||||
from frigate.const import MODEL_CACHE_DIR
|
from frigate.const import MODEL_CACHE_DIR
|
||||||
from frigate.detectors import DetectorTypeEnum
|
from frigate.detectors import DetectorTypeEnum
|
||||||
from frigate.detectors.detector_config import SceneEnum
|
|
||||||
from frigate.detectors.device import build_detector_config, runner_names
|
|
||||||
from frigate.util.builtin import deep_merge
|
from frigate.util.builtin import deep_merge
|
||||||
|
|
||||||
|
|
||||||
@@ -66,171 +64,49 @@ class TestConfig(unittest.TestCase):
|
|||||||
|
|
||||||
def test_config_class(self):
|
def test_config_class(self):
|
||||||
frigate_config = FrigateConfig(**self.minimal)
|
frigate_config = FrigateConfig(**self.minimal)
|
||||||
model = frigate_config.primary_model
|
assert "cpu" in frigate_config.detectors.keys()
|
||||||
assert model.scene == SceneEnum.all
|
assert frigate_config.detectors["cpu"].type == DetectorTypeEnum.cpu
|
||||||
assert model.width == 320
|
assert frigate_config.detectors["cpu"].model.width == 320
|
||||||
assert frigate_config.devices_for_model(model)[0].detector == (
|
|
||||||
DetectorTypeEnum.cpu
|
|
||||||
)
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
@patch("frigate.detectors.detector_config.load_labels")
|
||||||
def test_model_custom_path(self, mock_labels):
|
def test_detector_custom_model_path(self, mock_labels):
|
||||||
mock_labels.return_value = {}
|
mock_labels.return_value = {}
|
||||||
config = {
|
config = {
|
||||||
"models": [
|
"detectors": {
|
||||||
# needs to be a file that will exist, doesn't matter what
|
"cpu": {
|
||||||
{"path": "/etc/hosts", "width": 512, "devices": ["openvino:GPU"]},
|
"type": "cpu",
|
||||||
],
|
"model_path": "/cpu_model.tflite",
|
||||||
}
|
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
model = frigate_config.primary_model
|
|
||||||
|
|
||||||
assert model.path == "/etc/hosts"
|
|
||||||
assert model.width == 512
|
|
||||||
|
|
||||||
detector_config = build_detector_config(
|
|
||||||
frigate_config.devices_for_model(model)[0], model
|
|
||||||
)
|
|
||||||
assert detector_config.type == DetectorTypeEnum.openvino
|
|
||||||
assert detector_config.device == "GPU"
|
|
||||||
assert detector_config.model.path == "/etc/hosts"
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
|
||||||
def test_model_default_paths_per_detector(self, mock_labels):
|
|
||||||
mock_labels.return_value = {}
|
|
||||||
|
|
||||||
for devices, expected in (
|
|
||||||
(["cpu"], "/cpu_model.tflite"),
|
|
||||||
(["edgetpu:pci:0"], "/edgetpu_model.tflite"),
|
|
||||||
(["openvino:CPU"], "/openvino-model/ssdlite_mobilenet_v2.xml"),
|
|
||||||
):
|
|
||||||
config = {"models": [{"devices": devices}]}
|
|
||||||
frigate_config = FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
assert frigate_config.primary_model.path == expected
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
|
||||||
def test_camera_picks_model_by_scene(self, mock_labels):
|
|
||||||
mock_labels.return_value = {}
|
|
||||||
config = {
|
|
||||||
"models": [
|
|
||||||
{"scene": "outdoor", "devices": ["cpu"], "width": 320},
|
|
||||||
{"scene": "indoor", "devices": ["openvino:CPU"], "width": 300},
|
|
||||||
],
|
|
||||||
"cameras": {
|
|
||||||
"back": {
|
|
||||||
"detect": {"scene": "outdoor"},
|
|
||||||
"ffmpeg": {
|
|
||||||
"inputs": [
|
|
||||||
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"front": {
|
"edgetpu": {
|
||||||
"detect": {"scene": "indoor"},
|
"type": "edgetpu",
|
||||||
"ffmpeg": {
|
"model_path": "/edgetpu_model.tflite",
|
||||||
"inputs": [
|
},
|
||||||
{"path": "rtsp://10.0.0.2:554/video", "roles": ["detect"]},
|
"openvino": {
|
||||||
]
|
"type": "openvino",
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
# needs to be a file that will exist, doesn't matter what
|
||||||
|
"model": {"path": "/etc/hosts", "width": 512},
|
||||||
}
|
}
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**(deep_merge(config, self.minimal)))
|
frigate_config = FrigateConfig(**(deep_merge(config, self.minimal)))
|
||||||
|
|
||||||
assert frigate_config.model_for_camera("back").scene == SceneEnum.outdoor
|
assert "cpu" in frigate_config.detectors.keys()
|
||||||
assert frigate_config.model_for_camera("front").scene == SceneEnum.indoor
|
assert "edgetpu" in frigate_config.detectors.keys()
|
||||||
assert frigate_config.model_for_camera("back").width == 320
|
assert "openvino" in frigate_config.detectors.keys()
|
||||||
assert frigate_config.model_for_camera("front").width == 300
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
assert frigate_config.detectors["cpu"].type == DetectorTypeEnum.cpu
|
||||||
def test_camera_requires_a_scene_without_a_default(self, mock_labels):
|
assert frigate_config.detectors["edgetpu"].type == DetectorTypeEnum.edgetpu
|
||||||
mock_labels.return_value = {}
|
assert frigate_config.detectors["openvino"].type == DetectorTypeEnum.openvino
|
||||||
config = {
|
|
||||||
"models": [
|
|
||||||
{"scene": "outdoor", "devices": ["cpu"]},
|
|
||||||
{"scene": "indoor", "devices": ["openvino:CPU"]},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
assert frigate_config.detectors["cpu"].num_threads == 3
|
||||||
FrigateConfig(**(deep_merge(config, self.minimal)))
|
assert frigate_config.detectors["edgetpu"].device is None
|
||||||
|
assert frigate_config.detectors["openvino"].device is None
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
assert frigate_config.model.path == "/etc/hosts"
|
||||||
def test_camera_scene_must_match_a_model(self, mock_labels):
|
assert frigate_config.detectors["cpu"].model.path == "/cpu_model.tflite"
|
||||||
mock_labels.return_value = {}
|
assert frigate_config.detectors["edgetpu"].model.path == "/edgetpu_model.tflite"
|
||||||
config = {
|
assert frigate_config.detectors["openvino"].model.path == "/etc/hosts"
|
||||||
"models": [{"devices": ["cpu"]}],
|
|
||||||
"cameras": {
|
|
||||||
"back": {
|
|
||||||
"detect": {"scene": "outdoor"},
|
|
||||||
"ffmpeg": {
|
|
||||||
"inputs": [
|
|
||||||
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
|
||||||
FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
|
||||||
def test_models_must_use_unique_scenes(self, mock_labels):
|
|
||||||
mock_labels.return_value = {}
|
|
||||||
config = {
|
|
||||||
"models": [
|
|
||||||
{"scene": "outdoor", "devices": ["cpu"]},
|
|
||||||
{"scene": "outdoor", "devices": ["openvino:CPU"]},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
|
||||||
FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
|
||||||
def test_model_devices_must_share_a_detector(self, mock_labels):
|
|
||||||
mock_labels.return_value = {}
|
|
||||||
config = {"models": [{"devices": ["cpu", "openvino:CPU"]}]}
|
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
|
||||||
FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
|
||||||
def test_model_requires_a_known_detector(self, mock_labels):
|
|
||||||
mock_labels.return_value = {}
|
|
||||||
config = {"models": [{"devices": ["not_a_detector:0"]}]}
|
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
|
||||||
FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
|
||||||
def test_model_requires_a_device(self, mock_labels):
|
|
||||||
mock_labels.return_value = {}
|
|
||||||
config = {"models": [{"devices": []}]}
|
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
|
||||||
FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
|
||||||
def test_shareable_devices_may_repeat(self, mock_labels):
|
|
||||||
mock_labels.return_value = {}
|
|
||||||
config = {"models": [{"devices": ["openvino:GPU", "openvino:GPU"]}]}
|
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
devices = frigate_config.devices_for_model(frigate_config.primary_model)
|
|
||||||
|
|
||||||
assert runner_names(devices) == ["openvino:GPU", "openvino:GPU#2"]
|
|
||||||
|
|
||||||
@patch("frigate.detectors.detector_config.load_labels")
|
|
||||||
def test_exclusive_devices_may_not_repeat(self, mock_labels):
|
|
||||||
mock_labels.return_value = {}
|
|
||||||
config = {"models": [{"devices": ["edgetpu:pci:0", "edgetpu:pci:0"]}]}
|
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
|
||||||
FrigateConfig(**(deep_merge(config, self.minimal)))
|
|
||||||
|
|
||||||
def test_invalid_mqtt_config(self):
|
def test_invalid_mqtt_config(self):
|
||||||
config = {
|
config = {
|
||||||
@@ -294,7 +170,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
def test_override_birdseye(self):
|
def test_override_birdseye(self):
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"birdseye": {"enabled": True, "mode": {"continuous": True}},
|
"birdseye": {"enabled": True, "mode": "continuous"},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
@@ -307,30 +183,19 @@ class TestConfig(unittest.TestCase):
|
|||||||
"width": 1920,
|
"width": 1920,
|
||||||
"fps": 5,
|
"fps": 5,
|
||||||
},
|
},
|
||||||
"birdseye": {
|
"birdseye": {"enabled": False, "mode": "motion"},
|
||||||
"enabled": False,
|
|
||||||
"mode": {"continuous": False, "motion": True},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
frigate_config = FrigateConfig(**config)
|
||||||
assert not frigate_config.cameras["back"].birdseye.enabled
|
assert not frigate_config.cameras["back"].birdseye.enabled
|
||||||
mode = frigate_config.cameras["back"].birdseye.mode
|
assert frigate_config.cameras["back"].birdseye.mode is BirdseyeModeEnum.motion
|
||||||
assert mode.motion
|
|
||||||
assert not mode.continuous
|
|
||||||
assert not mode.objects
|
|
||||||
assert not mode.stationary_objects
|
|
||||||
|
|
||||||
def test_override_birdseye_non_inheritable(self):
|
def test_override_birdseye_non_inheritable(self):
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"birdseye": {
|
"birdseye": {"enabled": True, "mode": "continuous", "height": 1920},
|
||||||
"enabled": True,
|
|
||||||
"mode": {"continuous": True},
|
|
||||||
"height": 1920,
|
|
||||||
},
|
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
@@ -353,7 +218,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
def test_inherit_birdseye(self):
|
def test_inherit_birdseye(self):
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"birdseye": {"enabled": True, "mode": {"continuous": True}},
|
"birdseye": {"enabled": True, "mode": "continuous"},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
@@ -372,89 +237,9 @@ class TestConfig(unittest.TestCase):
|
|||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
frigate_config = FrigateConfig(**config)
|
||||||
assert frigate_config.cameras["back"].birdseye.enabled
|
assert frigate_config.cameras["back"].birdseye.enabled
|
||||||
mode = frigate_config.cameras["back"].birdseye.mode
|
assert (
|
||||||
assert mode.continuous
|
frigate_config.cameras["back"].birdseye.mode is BirdseyeModeEnum.continuous
|
||||||
assert not mode.motion
|
)
|
||||||
assert not mode.objects
|
|
||||||
assert not mode.stationary_objects
|
|
||||||
|
|
||||||
def test_combine_birdseye_activity_types(self):
|
|
||||||
config = {
|
|
||||||
**self.minimal,
|
|
||||||
"birdseye": {
|
|
||||||
"mode": {
|
|
||||||
"motion": True,
|
|
||||||
"stationary_objects": True,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
|
||||||
mode = frigate_config.cameras["back"].birdseye.mode
|
|
||||||
assert mode.motion
|
|
||||||
assert mode.stationary_objects
|
|
||||||
assert not mode.continuous
|
|
||||||
assert not mode.objects
|
|
||||||
|
|
||||||
def test_birdseye_requires_an_activity_type(self):
|
|
||||||
config = {
|
|
||||||
**self.minimal,
|
|
||||||
"birdseye": {
|
|
||||||
"mode": {
|
|
||||||
"continuous": False,
|
|
||||||
"motion": False,
|
|
||||||
"objects": False,
|
|
||||||
"stationary_objects": False,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
with self.assertRaisesRegex(
|
|
||||||
ValidationError, "must enable at least one Birdseye activity type"
|
|
||||||
):
|
|
||||||
FrigateConfig(**config)
|
|
||||||
|
|
||||||
def test_camera_can_disable_an_inherited_activity_type(self):
|
|
||||||
config = {
|
|
||||||
**self.minimal,
|
|
||||||
"birdseye": {"mode": {"motion": True, "objects": True}},
|
|
||||||
}
|
|
||||||
config["cameras"]["back"]["birdseye"] = {"mode": {"motion": False}}
|
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
|
||||||
mode = frigate_config.cameras["back"].birdseye.mode
|
|
||||||
assert not mode.motion
|
|
||||||
assert mode.objects
|
|
||||||
|
|
||||||
def test_profile_must_leave_an_activity_type_enabled(self):
|
|
||||||
config = {
|
|
||||||
**self.minimal,
|
|
||||||
"profiles": {"away": {"friendly_name": "Away"}},
|
|
||||||
"birdseye": {"mode": {"objects": True}},
|
|
||||||
}
|
|
||||||
config["cameras"]["back"]["profiles"] = {
|
|
||||||
"away": {"birdseye": {"mode": {"objects": False}}}
|
|
||||||
}
|
|
||||||
|
|
||||||
with self.assertRaisesRegex(
|
|
||||||
ValidationError, "must enable at least one Birdseye activity type"
|
|
||||||
):
|
|
||||||
FrigateConfig(**config)
|
|
||||||
|
|
||||||
def test_camera_birdseye_activity_types_override_global_values(self):
|
|
||||||
config = {
|
|
||||||
**self.minimal,
|
|
||||||
"birdseye": {"mode": {"motion": True, "objects": True}},
|
|
||||||
}
|
|
||||||
config["cameras"]["back"]["birdseye"] = {
|
|
||||||
"mode": {"motion": False, "stationary_objects": True}
|
|
||||||
}
|
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
|
||||||
mode = frigate_config.cameras["back"].birdseye.mode
|
|
||||||
assert not mode.motion
|
|
||||||
assert mode.objects
|
|
||||||
assert mode.stationary_objects
|
|
||||||
|
|
||||||
def test_override_tracked_objects(self):
|
def test_override_tracked_objects(self):
|
||||||
config = {
|
config = {
|
||||||
@@ -1171,7 +956,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
def test_merge_labelmap(self):
|
def test_merge_labelmap(self):
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"models": [{"labelmap": {7: "truck"}, "devices": ["cpu"]}],
|
"model": {"labelmap": {7: "truck"}},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
@@ -1192,7 +977,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
frigate_config = FrigateConfig(**config)
|
||||||
assert frigate_config.primary_model.merged_labelmap[7] == "truck"
|
assert frigate_config.model.merged_labelmap[7] == "truck"
|
||||||
|
|
||||||
def test_default_labelmap_empty(self):
|
def test_default_labelmap_empty(self):
|
||||||
config = {
|
config = {
|
||||||
@@ -1217,12 +1002,12 @@ class TestConfig(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
frigate_config = FrigateConfig(**config)
|
||||||
assert frigate_config.primary_model.merged_labelmap[0] == "person"
|
assert frigate_config.model.merged_labelmap[0] == "person"
|
||||||
|
|
||||||
def test_default_labelmap(self):
|
def test_default_labelmap(self):
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"models": [{"width": 320, "height": 320, "devices": ["cpu"]}],
|
"model": {"width": 320, "height": 320},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
@@ -1243,7 +1028,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
frigate_config = FrigateConfig(**config)
|
||||||
assert frigate_config.primary_model.merged_labelmap[0] == "person"
|
assert frigate_config.model.merged_labelmap[0] == "person"
|
||||||
|
|
||||||
def test_plus_labelmap(self):
|
def test_plus_labelmap(self):
|
||||||
with open(os.path.join(MODEL_CACHE_DIR, "test"), "w") as f:
|
with open(os.path.join(MODEL_CACHE_DIR, "test"), "w") as f:
|
||||||
@@ -1253,7 +1038,8 @@ class TestConfig(unittest.TestCase):
|
|||||||
|
|
||||||
config = {
|
config = {
|
||||||
"mqtt": {"host": "mqtt"},
|
"mqtt": {"host": "mqtt"},
|
||||||
"models": [{"path": "plus://test", "devices": ["cpu"]}],
|
"detectors": {"cpu": {"type": "cpu"}},
|
||||||
|
"model": {"path": "plus://test"},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"back": {
|
"back": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
@@ -1274,7 +1060,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
frigate_config = FrigateConfig(**config)
|
frigate_config = FrigateConfig(**config)
|
||||||
assert frigate_config.primary_model.merged_labelmap[0] == "amazon"
|
assert frigate_config.model.merged_labelmap[0] == "amazon"
|
||||||
|
|
||||||
def test_fails_on_invalid_role(self):
|
def test_fails_on_invalid_role(self):
|
||||||
config = {
|
config = {
|
||||||
|
|||||||
@@ -1,225 +0,0 @@
|
|||||||
"""Tests for migrating detectors and model into the models list."""
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import tempfile
|
|
||||||
import unittest
|
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
from ruamel.yaml import YAML
|
|
||||||
|
|
||||||
from frigate.util.config import (
|
|
||||||
CURRENT_CONFIG_VERSION,
|
|
||||||
migrate_frigate_config,
|
|
||||||
migrate_models,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestMigrateModels(unittest.TestCase):
|
|
||||||
def test_single_cpu_detector(self):
|
|
||||||
migrated = migrate_models({"detectors": {"cpu": {"type": "cpu"}}})
|
|
||||||
|
|
||||||
self.assertEqual(migrated["models"], [{"scene": "all", "devices": ["cpu"]}])
|
|
||||||
self.assertNotIn("detectors", migrated)
|
|
||||||
|
|
||||||
def test_model_settings_are_carried_over(self):
|
|
||||||
migrated = migrate_models(
|
|
||||||
{
|
|
||||||
"detectors": {"coral": {"type": "edgetpu", "device": "pci:0"}},
|
|
||||||
"model": {"path": "plus://abc", "width": 320},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
migrated["models"],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"scene": "all",
|
|
||||||
"path": "plus://abc",
|
|
||||||
"width": 320,
|
|
||||||
"devices": ["edgetpu:pci:0"],
|
|
||||||
}
|
|
||||||
],
|
|
||||||
)
|
|
||||||
self.assertNotIn("model", migrated)
|
|
||||||
|
|
||||||
def test_multiple_corals_become_multiple_devices(self):
|
|
||||||
migrated = migrate_models(
|
|
||||||
{
|
|
||||||
"detectors": {
|
|
||||||
"coral1": {"type": "edgetpu", "device": "pci:0"},
|
|
||||||
"coral2": {"type": "edgetpu", "device": "pci:1"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
migrated["models"][0]["devices"], ["edgetpu:pci:0", "edgetpu:pci:1"]
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_several_detectors_on_one_device_stay_separate(self):
|
|
||||||
# a repeated device is now what running two inference processes on one
|
|
||||||
# piece of hardware looks like
|
|
||||||
migrated = migrate_models(
|
|
||||||
{
|
|
||||||
"detectors": {
|
|
||||||
"ov_0": {"type": "openvino", "device": "GPU"},
|
|
||||||
"ov_1": {"type": "openvino", "device": "GPU"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
migrated["models"][0]["devices"], ["openvino:GPU", "openvino:GPU"]
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_repeated_exclusive_devices_are_collapsed(self):
|
|
||||||
# two detectors both grabbing the first TPU was never really two TPUs
|
|
||||||
migrated = migrate_models(
|
|
||||||
{
|
|
||||||
"detectors": {
|
|
||||||
"coral_0": {"type": "edgetpu", "device": "usb"},
|
|
||||||
"coral_1": {"type": "edgetpu", "device": "usb"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(migrated["models"][0]["devices"], ["edgetpu:usb"])
|
|
||||||
|
|
||||||
def test_detectors_that_named_the_device_field_differently(self):
|
|
||||||
migrated = migrate_models(
|
|
||||||
{
|
|
||||||
"detectors": {
|
|
||||||
"rk": {"type": "rknn", "num_cores": 2},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(migrated["models"][0]["devices"], ["rknn:2"])
|
|
||||||
|
|
||||||
def test_empty_edgetpu_device_is_kept(self):
|
|
||||||
# an empty device selects a native Coral, which is not the same as
|
|
||||||
# letting the delegate pick
|
|
||||||
migrated = migrate_models(
|
|
||||||
{"detectors": {"coral": {"type": "edgetpu", "device": ""}}}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(migrated["models"][0]["devices"], ["edgetpu:"])
|
|
||||||
|
|
||||||
def test_model_path_overrides_the_model(self):
|
|
||||||
migrated = migrate_models(
|
|
||||||
{
|
|
||||||
"detectors": {
|
|
||||||
"coral": {"type": "edgetpu", "model_path": "/custom.tflite"}
|
|
||||||
},
|
|
||||||
"model": {"path": "/ignored.tflite", "width": 320},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(migrated["models"][0]["path"], "/custom.tflite")
|
|
||||||
|
|
||||||
def test_no_detectors_falls_back_to_cpu(self):
|
|
||||||
migrated = migrate_models({"model": {"width": 320}})
|
|
||||||
|
|
||||||
self.assertEqual(migrated["models"][0]["devices"], ["cpu"])
|
|
||||||
|
|
||||||
def test_dropped_remote_detector_options_are_logged(self):
|
|
||||||
with self.assertLogs("frigate.util.config", level=logging.ERROR) as logs:
|
|
||||||
migrated = migrate_models(
|
|
||||||
{
|
|
||||||
"detectors": {
|
|
||||||
"ds": {
|
|
||||||
"type": "deepstack",
|
|
||||||
"api_url": "http://host:5000/v1/vision/detection",
|
|
||||||
"api_key": "secret",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
migrated["models"][0]["devices"],
|
|
||||||
["deepstack:http://host:5000/v1/vision/detection"],
|
|
||||||
)
|
|
||||||
self.assertTrue(any("api_key" in message for message in logs.output))
|
|
||||||
|
|
||||||
def test_mixed_detector_types_are_logged(self):
|
|
||||||
with self.assertLogs("frigate.util.config", level=logging.ERROR) as logs:
|
|
||||||
migrate_models(
|
|
||||||
{
|
|
||||||
"detectors": {
|
|
||||||
"ov": {"type": "openvino", "device": "GPU"},
|
|
||||||
"coral": {"type": "edgetpu", "device": "pci:0"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertTrue(any("more than one type" in message for message in logs.output))
|
|
||||||
|
|
||||||
def test_other_keys_are_untouched(self):
|
|
||||||
migrated = migrate_models(
|
|
||||||
{"mqtt": {"host": "mqtt"}, "detectors": {"cpu": {"type": "cpu"}}}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(migrated["mqtt"], {"host": "mqtt"})
|
|
||||||
|
|
||||||
|
|
||||||
class TestMigrateConfigFile(unittest.TestCase):
|
|
||||||
"""The full file migration, which is gated on shape as well as version."""
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.temp_dir = tempfile.TemporaryDirectory()
|
|
||||||
self.addCleanup(self.temp_dir.cleanup)
|
|
||||||
self.config_file = os.path.join(self.temp_dir.name, "config.yml")
|
|
||||||
patcher = patch("frigate.util.config.CONFIG_DIR", self.temp_dir.name)
|
|
||||||
patcher.start()
|
|
||||||
self.addCleanup(patcher.stop)
|
|
||||||
|
|
||||||
def _migrate(self, config: str) -> dict:
|
|
||||||
with open(self.config_file, "w") as f:
|
|
||||||
f.write(config)
|
|
||||||
|
|
||||||
migrate_frigate_config(self.config_file)
|
|
||||||
|
|
||||||
with open(self.config_file) as f:
|
|
||||||
return YAML().load(f)
|
|
||||||
|
|
||||||
def test_migrates_a_config_already_stamped_with_the_current_version(self):
|
|
||||||
# 0.19 is unreleased, so a dev config can be current and still use
|
|
||||||
# the pre-models keys
|
|
||||||
migrated = self._migrate(
|
|
||||||
"mqtt:\n"
|
|
||||||
" enabled: false\n"
|
|
||||||
"detectors:\n"
|
|
||||||
" ov:\n"
|
|
||||||
" type: openvino\n"
|
|
||||||
" device: GPU\n"
|
|
||||||
"cameras: {}\n"
|
|
||||||
f"version: {CURRENT_CONFIG_VERSION}\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(migrated["models"][0]["devices"], ["openvino:GPU"])
|
|
||||||
self.assertNotIn("detectors", migrated)
|
|
||||||
|
|
||||||
def test_a_migrated_config_is_left_alone(self):
|
|
||||||
migrated = self._migrate(
|
|
||||||
"mqtt:\n"
|
|
||||||
" enabled: false\n"
|
|
||||||
"models:\n"
|
|
||||||
" - scene: all\n"
|
|
||||||
" devices:\n"
|
|
||||||
" - openvino:GPU\n"
|
|
||||||
"cameras: {}\n"
|
|
||||||
f"version: {CURRENT_CONFIG_VERSION}\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
migrated["models"], [{"scene": "all", "devices": ["openvino:GPU"]}]
|
|
||||||
)
|
|
||||||
self.assertFalse(
|
|
||||||
os.path.exists(os.path.join(self.temp_dir.name, "backup_config.yaml"))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main(verbosity=2)
|
|
||||||
@@ -9,6 +9,7 @@ from unittest.mock import MagicMock, patch
|
|||||||
from frigate.debug_replay import DebugReplayManager
|
from frigate.debug_replay import DebugReplayManager
|
||||||
from frigate.jobs.debug_replay import (
|
from frigate.jobs.debug_replay import (
|
||||||
DebugReplayJob,
|
DebugReplayJob,
|
||||||
|
NoRecordingsError,
|
||||||
RecordingDebugReplaySource,
|
RecordingDebugReplaySource,
|
||||||
cancel_debug_replay_job,
|
cancel_debug_replay_job,
|
||||||
get_active_runner,
|
get_active_runner,
|
||||||
@@ -129,7 +130,7 @@ class TestStartDebugReplayJob(unittest.TestCase):
|
|||||||
empty_qs = MagicMock()
|
empty_qs = MagicMock()
|
||||||
empty_qs.count.return_value = 0
|
empty_qs.count.return_value = 0
|
||||||
with patch("frigate.jobs.debug_replay.query_recordings", return_value=empty_qs):
|
with patch("frigate.jobs.debug_replay.query_recordings", return_value=empty_qs):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(NoRecordingsError):
|
||||||
start_debug_replay_job(
|
start_debug_replay_job(
|
||||||
source=RecordingDebugReplaySource(
|
source=RecordingDebugReplaySource(
|
||||||
source_camera="front",
|
source_camera="front",
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
"""Tests for parsing detection hardware device strings."""
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from frigate.detectors.detector_config import ModelConfig
|
|
||||||
from frigate.detectors.device import (
|
|
||||||
DeviceParseError,
|
|
||||||
build_detector_config,
|
|
||||||
parse_device,
|
|
||||||
runner_names,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestParseDevice(unittest.TestCase):
|
|
||||||
def test_bare_detector_has_no_device(self):
|
|
||||||
spec = parse_device("cpu")
|
|
||||||
|
|
||||||
self.assertEqual(spec.detector, "cpu")
|
|
||||||
self.assertIsNone(spec.device)
|
|
||||||
|
|
||||||
def test_device_is_everything_after_the_first_colon(self):
|
|
||||||
spec = parse_device("edgetpu:pci:0")
|
|
||||||
|
|
||||||
self.assertEqual(spec.detector, "edgetpu")
|
|
||||||
self.assertEqual(spec.device, "pci:0")
|
|
||||||
|
|
||||||
def test_trailing_colon_keeps_an_empty_device(self):
|
|
||||||
# an empty edgetpu device selects a native Coral
|
|
||||||
spec = parse_device("edgetpu:")
|
|
||||||
|
|
||||||
self.assertEqual(spec.detector, "edgetpu")
|
|
||||||
self.assertEqual(spec.device, "")
|
|
||||||
|
|
||||||
def test_unknown_detector_is_rejected(self):
|
|
||||||
with self.assertRaises(DeviceParseError):
|
|
||||||
parse_device("not_a_detector:0")
|
|
||||||
|
|
||||||
def test_device_that_the_detector_cannot_use_is_rejected(self):
|
|
||||||
# tensorrt takes a gpu index
|
|
||||||
with self.assertRaises(DeviceParseError):
|
|
||||||
parse_device("tensorrt:the-fast-one")
|
|
||||||
|
|
||||||
|
|
||||||
class TestBuildDetectorConfig(unittest.TestCase):
|
|
||||||
def _build(self, raw: str):
|
|
||||||
return build_detector_config(parse_device(raw), ModelConfig())
|
|
||||||
|
|
||||||
def test_device_lands_on_the_detector_field(self):
|
|
||||||
for raw, expected in (
|
|
||||||
("edgetpu:usb", "usb"),
|
|
||||||
("edgetpu:pci:1", "pci:1"),
|
|
||||||
("openvino:GPU.1", "GPU.1"),
|
|
||||||
("onnx:CPU", "CPU"),
|
|
||||||
("memryx:PCIe:0", "PCIe:0"),
|
|
||||||
):
|
|
||||||
with self.subTest(raw=raw):
|
|
||||||
self.assertEqual(self._build(raw).device, expected)
|
|
||||||
|
|
||||||
def test_detectors_that_name_the_field_something_else(self):
|
|
||||||
self.assertEqual(self._build("cpu:4").num_threads, 4)
|
|
||||||
self.assertEqual(self._build("rknn:2").num_cores, 2)
|
|
||||||
|
|
||||||
def test_device_is_coerced_to_the_detector_field_type(self):
|
|
||||||
self.assertEqual(self._build("tensorrt:1").device, 1)
|
|
||||||
|
|
||||||
def test_omitted_device_falls_back_to_the_detector_default(self):
|
|
||||||
self.assertEqual(self._build("cpu").num_threads, 3)
|
|
||||||
self.assertEqual(self._build("rknn").num_cores, 0)
|
|
||||||
self.assertEqual(self._build("openvino").device, "AUTO")
|
|
||||||
self.assertIsNone(self._build("edgetpu").device)
|
|
||||||
|
|
||||||
def test_the_model_is_attached(self):
|
|
||||||
model = ModelConfig(path="/cpu_model.tflite")
|
|
||||||
|
|
||||||
self.assertIs(build_detector_config(parse_device("cpu"), model).model, model)
|
|
||||||
|
|
||||||
|
|
||||||
class TestRunnerNames(unittest.TestCase):
|
|
||||||
def test_unique_devices_keep_their_name(self):
|
|
||||||
devices = [parse_device("edgetpu:pci:0"), parse_device("edgetpu:pci:1")]
|
|
||||||
|
|
||||||
self.assertEqual(runner_names(devices), ["edgetpu:pci:0", "edgetpu:pci:1"])
|
|
||||||
|
|
||||||
def test_repeated_devices_are_numbered(self):
|
|
||||||
devices = [parse_device("openvino:GPU")] * 3
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
runner_names(devices),
|
|
||||||
["openvino:GPU", "openvino:GPU#2", "openvino:GPU#3"],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main(verbosity=2)
|
|
||||||
@@ -8,7 +8,6 @@ from unittest.mock import MagicMock, patch
|
|||||||
from frigate.app import FrigateApp
|
from frigate.app import FrigateApp
|
||||||
from frigate.comms.dispatcher import Dispatcher
|
from frigate.comms.dispatcher import Dispatcher
|
||||||
from frigate.comms.runtime_state import RuntimeStatePersistence
|
from frigate.comms.runtime_state import RuntimeStatePersistence
|
||||||
from frigate.config import BirdseyeModeConfig
|
|
||||||
|
|
||||||
|
|
||||||
def _make_camera_mock(
|
def _make_camera_mock(
|
||||||
@@ -52,58 +51,6 @@ def _build_dispatcher(cameras: dict[str, MagicMock]) -> Dispatcher:
|
|||||||
return Dispatcher(config, config_updater, onvif, ptz_metrics, communicators)
|
return Dispatcher(config, config_updater, onvif, ptz_metrics, communicators)
|
||||||
|
|
||||||
|
|
||||||
class TestBirdseyeModeCommands(unittest.TestCase):
|
|
||||||
"""Verify Birdseye mode commands use the boolean mode contract."""
|
|
||||||
|
|
||||||
def setUp(self) -> None:
|
|
||||||
self.camera = _make_camera_mock()
|
|
||||||
self.camera.birdseye.enabled = True
|
|
||||||
self.dispatcher = _build_dispatcher({"front_door": self.camera})
|
|
||||||
self.dispatcher.publish = MagicMock()
|
|
||||||
|
|
||||||
def test_combined_modes_are_accepted(self) -> None:
|
|
||||||
self.dispatcher._on_birdseye_mode_command(
|
|
||||||
"front_door", "STATIONARY_OBJECTS,MOTION"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
self.camera.birdseye.mode,
|
|
||||||
BirdseyeModeConfig(motion=True, stationary_objects=True),
|
|
||||||
)
|
|
||||||
self.dispatcher.config_updater.publish_update.assert_called_once()
|
|
||||||
self.dispatcher.publish.assert_called_once_with(
|
|
||||||
"front_door/birdseye_mode/state",
|
|
||||||
"MOTION,STATIONARY_OBJECTS",
|
|
||||||
retain=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_single_activity_type_is_accepted(self) -> None:
|
|
||||||
self.dispatcher._on_birdseye_mode_command("front_door", "OBJECTS")
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
self.camera.birdseye.mode,
|
|
||||||
BirdseyeModeConfig(objects=True),
|
|
||||||
)
|
|
||||||
self.dispatcher.publish.assert_called_once_with(
|
|
||||||
"front_door/birdseye_mode/state", "OBJECTS", retain=True
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_unknown_mode_is_rejected(self) -> None:
|
|
||||||
for payload in (
|
|
||||||
"UNKNOWN",
|
|
||||||
"motion",
|
|
||||||
"MOTION_OBJECTS",
|
|
||||||
"NONE",
|
|
||||||
"NONE,MOTION",
|
|
||||||
"MOTION,MOTION",
|
|
||||||
"MOTION,",
|
|
||||||
):
|
|
||||||
with self.subTest(payload=payload):
|
|
||||||
self.dispatcher._on_birdseye_mode_command("front_door", payload)
|
|
||||||
|
|
||||||
self.dispatcher.config_updater.publish_update.assert_not_called()
|
|
||||||
|
|
||||||
|
|
||||||
class TestRestoreRuntimeState(unittest.TestCase):
|
class TestRestoreRuntimeState(unittest.TestCase):
|
||||||
"""Verify replay routes through handlers and tolerates missing entries."""
|
"""Verify replay routes through handlers and tolerates missing entries."""
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from io import StringIO
|
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from frigate.util.services import (
|
from frigate.util.services import get_amd_gpu_stats, get_intel_gpu_stats
|
||||||
get_amd_gpu_stats,
|
|
||||||
get_intel_gpu_stats,
|
|
||||||
get_openvino_npu_stats,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestGpuStats(unittest.TestCase):
|
class TestGpuStats(unittest.TestCase):
|
||||||
@@ -22,88 +17,6 @@ class TestGpuStats(unittest.TestCase):
|
|||||||
amd_stats = get_amd_gpu_stats()
|
amd_stats = get_amd_gpu_stats()
|
||||||
assert amd_stats == {"gpu": "4.17%", "mem": "60.37%"}
|
assert amd_stats == {"gpu": "4.17%", "mem": "60.37%"}
|
||||||
|
|
||||||
@patch("frigate.util.services.time.sleep")
|
|
||||||
@patch("frigate.util.services.time.time", side_effect=[0.0, 1.0])
|
|
||||||
@patch(
|
|
||||||
"frigate.util.services.os.readlink",
|
|
||||||
return_value="/sys/bus/pci/drivers/intel_vpu",
|
|
||||||
)
|
|
||||||
@patch(
|
|
||||||
"frigate.util.services.glob.glob",
|
|
||||||
return_value=["/sys/class/accel/accel0"],
|
|
||||||
)
|
|
||||||
@patch(
|
|
||||||
"builtins.open",
|
|
||||||
side_effect=[StringIO("1000"), StringIO("1250")],
|
|
||||||
)
|
|
||||||
def test_openvino_npu_stats_discovers_accel0(
|
|
||||||
self, open_file, glob, readlink, time, sleep
|
|
||||||
):
|
|
||||||
assert get_openvino_npu_stats() == {"npu": "25.0", "mem": "-%"}
|
|
||||||
|
|
||||||
open_file.assert_any_call(
|
|
||||||
"/sys/class/accel/accel0/device/power/runtime_active_time"
|
|
||||||
)
|
|
||||||
|
|
||||||
@patch("frigate.util.services.time.sleep")
|
|
||||||
@patch("frigate.util.services.time.time", side_effect=[0.0, 1.0])
|
|
||||||
@patch(
|
|
||||||
"frigate.util.services.os.readlink",
|
|
||||||
side_effect=[
|
|
||||||
"/sys/bus/pci/drivers/other",
|
|
||||||
"/sys/bus/pci/drivers/intel_vpu",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
@patch(
|
|
||||||
"frigate.util.services.glob.glob",
|
|
||||||
return_value=[
|
|
||||||
"/sys/class/accel/accel0",
|
|
||||||
"/sys/class/accel/accel1",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
@patch(
|
|
||||||
"builtins.open",
|
|
||||||
side_effect=[StringIO("1000"), StringIO("1250")],
|
|
||||||
)
|
|
||||||
def test_openvino_npu_stats_skips_non_intel_accelerator(
|
|
||||||
self, open_file, glob, readlink, time, sleep
|
|
||||||
):
|
|
||||||
assert get_openvino_npu_stats() == {"npu": "25.0", "mem": "-%"}
|
|
||||||
|
|
||||||
open_file.assert_any_call(
|
|
||||||
"/sys/class/accel/accel1/device/power/runtime_active_time"
|
|
||||||
)
|
|
||||||
|
|
||||||
@patch(
|
|
||||||
"frigate.util.services.os.readlink",
|
|
||||||
return_value="/sys/bus/pci/drivers/other",
|
|
||||||
)
|
|
||||||
@patch(
|
|
||||||
"frigate.util.services.glob.glob",
|
|
||||||
return_value=["/sys/class/accel/accel0"],
|
|
||||||
)
|
|
||||||
@patch("builtins.open")
|
|
||||||
def test_openvino_npu_stats_no_intel_accelerator(self, open_file, glob, readlink):
|
|
||||||
assert get_openvino_npu_stats() is None
|
|
||||||
open_file.assert_not_called()
|
|
||||||
|
|
||||||
@patch(
|
|
||||||
"frigate.util.services.os.readlink",
|
|
||||||
return_value="/sys/bus/pci/drivers/intel_vpu",
|
|
||||||
)
|
|
||||||
@patch(
|
|
||||||
"frigate.util.services.glob.glob",
|
|
||||||
return_value=["/sys/class/accel/accel0"],
|
|
||||||
)
|
|
||||||
@patch("builtins.open", side_effect=FileNotFoundError)
|
|
||||||
def test_openvino_npu_stats_runtime_counter_unavailable(
|
|
||||||
self, open_file, glob, readlink
|
|
||||||
):
|
|
||||||
assert get_openvino_npu_stats() is None
|
|
||||||
open_file.assert_called_once_with(
|
|
||||||
"/sys/class/accel/accel0/device/power/runtime_active_time"
|
|
||||||
)
|
|
||||||
|
|
||||||
@patch("frigate.stats.intel_gpu_info.intel_gpu_name_resolver.get_names")
|
@patch("frigate.stats.intel_gpu_info.intel_gpu_name_resolver.get_names")
|
||||||
@patch("frigate.util.services.time.sleep")
|
@patch("frigate.util.services.time.sleep")
|
||||||
@patch("frigate.util.services.time.monotonic")
|
@patch("frigate.util.services.time.monotonic")
|
||||||
|
|||||||
@@ -560,25 +560,6 @@ class TestProfileManager(unittest.TestCase):
|
|||||||
assert err is None
|
assert err is None
|
||||||
assert self.config.cameras["front"].enabled is False
|
assert self.config.cameras["front"].enabled is False
|
||||||
|
|
||||||
@patch.object(ProfileManager, "_persist_active_profile")
|
|
||||||
def test_profile_can_disable_inherited_birdseye_activity(self, mock_persist):
|
|
||||||
"""A false-only mode override inherits the other base activity types."""
|
|
||||||
self.config.profiles["away"] = ProfileDefinitionConfig(friendly_name="Away")
|
|
||||||
base_mode = self.config.cameras["front"].birdseye.mode
|
|
||||||
base_mode.motion = True
|
|
||||||
base_mode.objects = True
|
|
||||||
self.config.cameras["front"].profiles["away"] = CameraProfileConfig(
|
|
||||||
birdseye={"mode": {"motion": False}}
|
|
||||||
)
|
|
||||||
self.manager = ProfileManager(self.config, self.mock_updater)
|
|
||||||
|
|
||||||
err = self.manager.activate_profile("away")
|
|
||||||
|
|
||||||
assert err is None
|
|
||||||
mode = self.config.cameras["front"].birdseye.mode
|
|
||||||
assert not mode.motion
|
|
||||||
assert mode.objects
|
|
||||||
|
|
||||||
@patch.object(ProfileManager, "_persist_active_profile")
|
@patch.object(ProfileManager, "_persist_active_profile")
|
||||||
def test_deactivate_restores_enabled(self, mock_persist):
|
def test_deactivate_restores_enabled(self, mock_persist):
|
||||||
"""Deactivating a profile restores the camera's base enabled state."""
|
"""Deactivating a profile restores the camera's base enabled state."""
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
"""Tests for push notification subscription validation."""
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from frigate.api.notification import _validate_push_endpoint, _validate_subscription
|
||||||
|
|
||||||
|
VALID_ENDPOINTS = [
|
||||||
|
"https://fcm.googleapis.com/fcm/send/dGhpcy1pcy1hLXRva2Vu",
|
||||||
|
"https://updates.push.services.mozilla.com/wpush/v2/dGhpcy1pcy1hLXRva2Vu",
|
||||||
|
"https://web.push.apple.com/dGhpcy1pcy1hLXRva2Vu",
|
||||||
|
"https://wns2-by3p.notify.windows.com/w/?token=dGhpcy1pcy1hLXRva2Vu",
|
||||||
|
"https://fcm.googleapis.com:443/fcm/send/dGhpcy1pcy1hLXRva2Vu",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _subscription(endpoint: str) -> dict:
|
||||||
|
return {
|
||||||
|
"endpoint": endpoint,
|
||||||
|
"keys": {"p256dh": "cHVibGljLWtleQ", "auth": "YXV0aC1zZWNyZXQ"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TestValidatePushEndpoint(unittest.TestCase):
|
||||||
|
def test_accepts_real_push_service_endpoints(self):
|
||||||
|
for endpoint in VALID_ENDPOINTS:
|
||||||
|
with self.subTest(endpoint=endpoint):
|
||||||
|
self.assertIsNone(_validate_push_endpoint(endpoint))
|
||||||
|
|
||||||
|
def test_rejects_http(self):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
_validate_push_endpoint("http://fcm.googleapis.com/fcm/send/token")
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_rejects_non_http_schemes(self):
|
||||||
|
for endpoint in (
|
||||||
|
"file:///etc/passwd",
|
||||||
|
"ftp://example.com/token",
|
||||||
|
"//example.com/token",
|
||||||
|
):
|
||||||
|
with self.subTest(endpoint=endpoint):
|
||||||
|
self.assertIsNotNone(_validate_push_endpoint(endpoint))
|
||||||
|
|
||||||
|
def test_rejects_localhost(self):
|
||||||
|
for endpoint in (
|
||||||
|
"https://localhost/token",
|
||||||
|
"https://localhost:443/token",
|
||||||
|
"https://127.0.0.1/token",
|
||||||
|
"https://[::1]/token",
|
||||||
|
):
|
||||||
|
with self.subTest(endpoint=endpoint):
|
||||||
|
self.assertIsNotNone(_validate_push_endpoint(endpoint))
|
||||||
|
|
||||||
|
def test_rejects_private_addresses(self):
|
||||||
|
for endpoint in (
|
||||||
|
"https://192.168.1.10/token",
|
||||||
|
"https://10.0.0.5/token",
|
||||||
|
"https://172.16.0.1/token",
|
||||||
|
"https://169.254.169.254/token",
|
||||||
|
"https://0.0.0.0/token",
|
||||||
|
):
|
||||||
|
with self.subTest(endpoint=endpoint):
|
||||||
|
self.assertIsNotNone(_validate_push_endpoint(endpoint))
|
||||||
|
|
||||||
|
def test_rejects_internal_hostnames(self):
|
||||||
|
for endpoint in (
|
||||||
|
"https://frigate/token",
|
||||||
|
"https://nas.local/token",
|
||||||
|
"https://push.internal/token",
|
||||||
|
"https://host.home.arpa/token",
|
||||||
|
):
|
||||||
|
with self.subTest(endpoint=endpoint):
|
||||||
|
self.assertIsNotNone(_validate_push_endpoint(endpoint))
|
||||||
|
|
||||||
|
def test_rejects_non_default_port(self):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
_validate_push_endpoint("https://fcm.googleapis.com:8080/fcm/send/token")
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_rejects_embedded_credentials(self):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
_validate_push_endpoint(
|
||||||
|
"https://user:pass@fcm.googleapis.com/fcm/send/token"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_rejects_endpoint_without_path(self):
|
||||||
|
for endpoint in ("https://fcm.googleapis.com", "https://fcm.googleapis.com/"):
|
||||||
|
with self.subTest(endpoint=endpoint):
|
||||||
|
self.assertIsNotNone(_validate_push_endpoint(endpoint))
|
||||||
|
|
||||||
|
def test_rejects_endpoint_that_breaks_audience_parsing(self):
|
||||||
|
# webpush.py locates the host by searching for a separator after index
|
||||||
|
# 10, which raises ValueError when the url has no path at all
|
||||||
|
endpoint = "https://fcm.googleapis.com"
|
||||||
|
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
endpoint.index("/", 10)
|
||||||
|
|
||||||
|
self.assertIsNotNone(_validate_push_endpoint(endpoint))
|
||||||
|
|
||||||
|
def test_rejects_missing_or_non_string_endpoint(self):
|
||||||
|
for endpoint in (None, "", 5, {"url": "https://example.com/token"}):
|
||||||
|
with self.subTest(endpoint=endpoint):
|
||||||
|
self.assertIsNotNone(_validate_push_endpoint(endpoint))
|
||||||
|
|
||||||
|
def test_rejects_overlong_endpoint(self):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
_validate_push_endpoint(f"https://fcm.googleapis.com/{'a' * 4096}")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestValidateSubscription(unittest.TestCase):
|
||||||
|
def test_accepts_valid_subscription(self):
|
||||||
|
self.assertIsNone(_validate_subscription(_subscription(VALID_ENDPOINTS[0])))
|
||||||
|
|
||||||
|
def test_accepts_extra_fields_sent_by_the_browser(self):
|
||||||
|
sub = _subscription(VALID_ENDPOINTS[0])
|
||||||
|
sub["expirationTime"] = None
|
||||||
|
self.assertIsNone(_validate_subscription(sub))
|
||||||
|
|
||||||
|
def test_rejects_non_object(self):
|
||||||
|
for sub in ("https://fcm.googleapis.com/fcm/send/token", ["endpoint"], 5):
|
||||||
|
with self.subTest(sub=sub):
|
||||||
|
self.assertIsNotNone(_validate_subscription(sub))
|
||||||
|
|
||||||
|
def test_rejects_bad_endpoint(self):
|
||||||
|
self.assertIsNotNone(
|
||||||
|
_validate_subscription(_subscription("https://localhost/t"))
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_rejects_missing_keys(self):
|
||||||
|
sub = _subscription(VALID_ENDPOINTS[0])
|
||||||
|
del sub["keys"]
|
||||||
|
self.assertIsNotNone(_validate_subscription(sub))
|
||||||
|
|
||||||
|
def test_rejects_incomplete_keys(self):
|
||||||
|
for keys in (
|
||||||
|
{"p256dh": "cHVibGljLWtleQ"},
|
||||||
|
{"auth": "YXV0aC1zZWNyZXQ"},
|
||||||
|
{"p256dh": "cHVibGljLWtleQ", "auth": ""},
|
||||||
|
{"p256dh": None, "auth": "YXV0aC1zZWNyZXQ"},
|
||||||
|
):
|
||||||
|
with self.subTest(keys=keys):
|
||||||
|
sub = _subscription(VALID_ENDPOINTS[0])
|
||||||
|
sub["keys"] = keys
|
||||||
|
self.assertIsNotNone(_validate_subscription(sub))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
"""Outbound websocket sends must never block the thread calling publish()."""
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import threading
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from frigate.comms.ws import WS_MAX_PENDING_MESSAGES, WebSocket
|
||||||
|
|
||||||
|
|
||||||
|
class _FakeSock:
|
||||||
|
"""Socket stand-in; ``block`` makes sendall hang like a client that stopped reading."""
|
||||||
|
|
||||||
|
def __init__(self, block: bool = False) -> None:
|
||||||
|
self.block = block
|
||||||
|
self.released = threading.Event()
|
||||||
|
self.shutdown_called = threading.Event()
|
||||||
|
self.frames: list[bytes] = []
|
||||||
|
|
||||||
|
def sendall(self, data: bytes) -> None:
|
||||||
|
if self.block and not self.released.is_set():
|
||||||
|
self.released.wait(timeout=10)
|
||||||
|
raise BrokenPipeError()
|
||||||
|
self.frames.append(data)
|
||||||
|
|
||||||
|
def shutdown(self, how: int) -> None:
|
||||||
|
assert how == socket.SHUT_RDWR
|
||||||
|
self.shutdown_called.set()
|
||||||
|
self.released.set()
|
||||||
|
|
||||||
|
def close(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def fileno(self) -> int:
|
||||||
|
return 99
|
||||||
|
|
||||||
|
|
||||||
|
def _wait_for(predicate, timeout: float = 2.0) -> bool:
|
||||||
|
deadline = threading.Event()
|
||||||
|
for _ in range(int(timeout / 0.01)):
|
||||||
|
if predicate():
|
||||||
|
return True
|
||||||
|
deadline.wait(0.01)
|
||||||
|
return predicate()
|
||||||
|
|
||||||
|
|
||||||
|
class TestWebSocketSendQueue(unittest.TestCase):
|
||||||
|
def _open(self, sock: _FakeSock) -> WebSocket:
|
||||||
|
ws = WebSocket(sock)
|
||||||
|
ws.opened()
|
||||||
|
return ws
|
||||||
|
|
||||||
|
def test_stalled_client_does_not_block_publisher(self):
|
||||||
|
sock = _FakeSock(block=True)
|
||||||
|
ws = self._open(sock)
|
||||||
|
|
||||||
|
def publish_many():
|
||||||
|
for i in range(WS_MAX_PENDING_MESSAGES + 5):
|
||||||
|
ws.send(f"message {i}")
|
||||||
|
|
||||||
|
publisher = threading.Thread(target=publish_many, daemon=True)
|
||||||
|
publisher.start()
|
||||||
|
publisher.join(timeout=2.0)
|
||||||
|
|
||||||
|
self.assertFalse(publisher.is_alive(), "publish() blocked on a stalled client")
|
||||||
|
self.assertTrue(
|
||||||
|
sock.shutdown_called.wait(timeout=2.0),
|
||||||
|
"a client that cannot keep up should be disconnected",
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_overflow_warns_and_shuts_down_once(self):
|
||||||
|
sock = _FakeSock(block=True)
|
||||||
|
ws = self._open(sock)
|
||||||
|
shutdown_calls = []
|
||||||
|
original_shutdown = sock.shutdown
|
||||||
|
sock.shutdown = lambda how: (shutdown_calls.append(how), original_shutdown(how))
|
||||||
|
|
||||||
|
with self.assertLogs("frigate.comms.ws", level="WARNING") as logs:
|
||||||
|
# keep publishing after overflow, as the dispatcher does until the
|
||||||
|
# manager thread removes the connection
|
||||||
|
for i in range(WS_MAX_PENDING_MESSAGES * 3):
|
||||||
|
ws.send(f"message {i}")
|
||||||
|
|
||||||
|
self.assertEqual(len(logs.output), 1)
|
||||||
|
self.assertEqual(len(shutdown_calls), 1)
|
||||||
|
|
||||||
|
def test_messages_delivered_in_order(self):
|
||||||
|
sock = _FakeSock()
|
||||||
|
ws = self._open(sock)
|
||||||
|
for i in range(3):
|
||||||
|
ws.send(f"message {i}")
|
||||||
|
|
||||||
|
self.assertTrue(_wait_for(lambda: len(sock.frames) == 3))
|
||||||
|
for i, frame in enumerate(sock.frames):
|
||||||
|
self.assertIn(f"message {i}".encode(), frame)
|
||||||
|
self.assertFalse(sock.shutdown_called.is_set())
|
||||||
|
|
||||||
|
def test_closed_stops_writer_thread(self):
|
||||||
|
sock = _FakeSock()
|
||||||
|
ws = self._open(sock)
|
||||||
|
writer = ws._writer
|
||||||
|
ws.closed(1000, "bye")
|
||||||
|
writer.join(timeout=2.0)
|
||||||
|
self.assertFalse(writer.is_alive())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
@@ -209,7 +209,7 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
if obj.obj_data.get("sub_label"):
|
if obj.obj_data.get("sub_label"):
|
||||||
sub_label = obj.obj_data["sub_label"][0]
|
sub_label = obj.obj_data["sub_label"][0]
|
||||||
|
|
||||||
if sub_label in self.config.all_attribute_logos:
|
if sub_label in self.config.model.all_attribute_logos:
|
||||||
self.dispatcher.publish(
|
self.dispatcher.publish(
|
||||||
f"{camera}/{sub_label}/snapshot",
|
f"{camera}/{sub_label}/snapshot",
|
||||||
jpg_bytes,
|
jpg_bytes,
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ class TrackedObject:
|
|||||||
"attributes": obj_data["attributes"],
|
"attributes": obj_data["attributes"],
|
||||||
"current_estimated_speed": self.current_estimated_speed,
|
"current_estimated_speed": self.current_estimated_speed,
|
||||||
"velocity_angle": self.velocity_angle,
|
"velocity_angle": self.velocity_angle,
|
||||||
"path_data": self.path_data.copy(),
|
|
||||||
"recognized_license_plate": obj_data.get(
|
"recognized_license_plate": obj_data.get(
|
||||||
"recognized_license_plate"
|
"recognized_license_plate"
|
||||||
),
|
),
|
||||||
|
|||||||
+2
-157
@@ -20,28 +20,9 @@ from frigate.util.services import get_video_properties
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
CURRENT_CONFIG_VERSION = "0.19-0"
|
CURRENT_CONFIG_VERSION = "0.18-0"
|
||||||
DEFAULT_CONFIG_FILE = os.path.join(CONFIG_DIR, "config.yml")
|
DEFAULT_CONFIG_FILE = os.path.join(CONFIG_DIR, "config.yml")
|
||||||
|
|
||||||
# the detector field that used to hold the device, for detectors that named it
|
|
||||||
# something other than "device"
|
|
||||||
DETECTOR_DEVICE_FIELDS = {
|
|
||||||
"cpu": "num_threads",
|
|
||||||
"rknn": "num_cores",
|
|
||||||
"deepstack": "api_url",
|
|
||||||
"degirum": "location",
|
|
||||||
"zmq": "endpoint",
|
|
||||||
}
|
|
||||||
|
|
||||||
# detector options that have no equivalent in a device string. The remote
|
|
||||||
# detectors that use them are being reworked, so they are dropped rather than
|
|
||||||
# carried over.
|
|
||||||
DROPPED_DETECTOR_OPTIONS = {
|
|
||||||
"deepstack": ["api_timeout", "api_key"],
|
|
||||||
"degirum": ["zoo", "token"],
|
|
||||||
"zmq": ["request_timeout_ms", "linger_ms"],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def resolve_ffmpeg_path(path: str, binary: str = "ffmpeg") -> str:
|
def resolve_ffmpeg_path(path: str, binary: str = "ffmpeg") -> str:
|
||||||
"""Resolve an ffmpeg version alias or custom path to a binary path.
|
"""Resolve an ffmpeg version alias or custom path to a binary path.
|
||||||
@@ -106,17 +87,12 @@ def migrate_frigate_config(config_file: str):
|
|||||||
|
|
||||||
previous_version = str(config.get("version", "0.13"))
|
previous_version = str(config.get("version", "0.13"))
|
||||||
|
|
||||||
# 0.19 is unreleased, so a config may already be stamped with the current
|
if previous_version == CURRENT_CONFIG_VERSION:
|
||||||
# version and still use the pre-models detectors and model keys
|
|
||||||
needs_models = "detectors" in config or "model" in config
|
|
||||||
|
|
||||||
if previous_version == CURRENT_CONFIG_VERSION and not needs_models:
|
|
||||||
logger.info("frigate config does not need migration...")
|
logger.info("frigate config does not need migration...")
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info("copying config as backup...")
|
logger.info("copying config as backup...")
|
||||||
shutil.copy(config_file, os.path.join(CONFIG_DIR, "backup_config.yaml"))
|
shutil.copy(config_file, os.path.join(CONFIG_DIR, "backup_config.yaml"))
|
||||||
new_config = config
|
|
||||||
|
|
||||||
if previous_version < "0.14":
|
if previous_version < "0.14":
|
||||||
logger.info(f"Migrating frigate config from {previous_version} to 0.14...")
|
logger.info(f"Migrating frigate config from {previous_version} to 0.14...")
|
||||||
@@ -171,19 +147,6 @@ def migrate_frigate_config(config_file: str):
|
|||||||
yaml.dump(new_config, f)
|
yaml.dump(new_config, f)
|
||||||
previous_version = "0.18-0"
|
previous_version = "0.18-0"
|
||||||
|
|
||||||
if previous_version < "0.19-0":
|
|
||||||
logger.info(f"Migrating frigate config from {previous_version} to 0.19-0...")
|
|
||||||
new_config = migrate_019_0(new_config)
|
|
||||||
with open(config_file, "w") as f:
|
|
||||||
yaml.dump(new_config, f)
|
|
||||||
previous_version = "0.19-0"
|
|
||||||
|
|
||||||
if needs_models:
|
|
||||||
logger.info("Migrating frigate detectors and model to models...")
|
|
||||||
new_config = migrate_models(new_config)
|
|
||||||
with open(config_file, "w") as f:
|
|
||||||
yaml.dump(new_config, f)
|
|
||||||
|
|
||||||
logger.info("Finished frigate config migration...")
|
logger.info("Finished frigate config migration...")
|
||||||
|
|
||||||
|
|
||||||
@@ -562,21 +525,6 @@ def _convert_legacy_mask_to_dict(
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _migrate_birdseye_mode(birdseye: dict[str, Any] | None) -> None:
|
|
||||||
"""Convert a scalar Birdseye mode to composable activity types."""
|
|
||||||
if not birdseye or not isinstance(birdseye.get("mode"), str):
|
|
||||||
return
|
|
||||||
|
|
||||||
legacy_mode = birdseye["mode"]
|
|
||||||
activity_types = ("continuous", "motion", "objects", "stationary_objects")
|
|
||||||
if legacy_mode not in activity_types:
|
|
||||||
return
|
|
||||||
|
|
||||||
birdseye["mode"] = {
|
|
||||||
activity_type: activity_type == legacy_mode for activity_type in activity_types
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def migrate_018_0(config: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]:
|
def migrate_018_0(config: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]:
|
||||||
"""Handle migrating frigate config to 0.18-0"""
|
"""Handle migrating frigate config to 0.18-0"""
|
||||||
new_config = config.copy()
|
new_config = config.copy()
|
||||||
@@ -710,109 +658,6 @@ def migrate_018_0(config: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]
|
|||||||
return new_config
|
return new_config
|
||||||
|
|
||||||
|
|
||||||
def migrate_019_0(config: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]:
|
|
||||||
"""Handle migrating Frigate config to 0.19-0."""
|
|
||||||
new_config = config.copy()
|
|
||||||
|
|
||||||
_migrate_birdseye_mode(new_config.get("birdseye"))
|
|
||||||
|
|
||||||
for name, camera in new_config.get("cameras", {}).items():
|
|
||||||
camera_config: dict[str, dict[str, Any]] = camera.copy()
|
|
||||||
_migrate_birdseye_mode(camera_config.get("birdseye"))
|
|
||||||
|
|
||||||
for profile in camera_config.get("profiles", {}).values():
|
|
||||||
if isinstance(profile, dict):
|
|
||||||
_migrate_birdseye_mode(profile.get("birdseye"))
|
|
||||||
|
|
||||||
new_config["cameras"][name] = camera_config
|
|
||||||
|
|
||||||
new_config["version"] = "0.19-0"
|
|
||||||
return new_config
|
|
||||||
|
|
||||||
|
|
||||||
def migrate_models(config: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]:
|
|
||||||
"""Merge the detectors and model keys into a single models list.
|
|
||||||
|
|
||||||
Every config before this change ran one model across all of its detectors,
|
|
||||||
so this always produces exactly one model.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
config: The loaded config
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The config with a models list in place of detectors and model
|
|
||||||
"""
|
|
||||||
# imported lazily so loading the detector plugins is not a cost of importing
|
|
||||||
# this module
|
|
||||||
from frigate.detectors.detector_types import config_types
|
|
||||||
|
|
||||||
new_config = config.copy()
|
|
||||||
detectors: dict[str, Any] = new_config.pop("detectors", None) or {}
|
|
||||||
model: dict[str, Any] = new_config.pop("model", None) or {}
|
|
||||||
|
|
||||||
devices: list[str] = []
|
|
||||||
model_path: str | None = None
|
|
||||||
|
|
||||||
for name, detector in detectors.items():
|
|
||||||
detector = detector or {}
|
|
||||||
detector_type = detector.get("type", "cpu")
|
|
||||||
device = detector.get(DETECTOR_DEVICE_FIELDS.get(detector_type, "device"))
|
|
||||||
device_string = detector_type if device is None else f"{detector_type}:{device}"
|
|
||||||
|
|
||||||
# repeating a device now means running an extra inference process on it,
|
|
||||||
# which is what several detectors on one device used to mean. Only
|
|
||||||
# collapse repeats of hardware that can serve a single process.
|
|
||||||
config_class = config_types.get(detector_type)
|
|
||||||
shareable = config_class.shareable if config_class else True
|
|
||||||
|
|
||||||
if shareable or device_string not in devices:
|
|
||||||
devices.append(device_string)
|
|
||||||
|
|
||||||
dropped = [
|
|
||||||
option
|
|
||||||
for option in DROPPED_DETECTOR_OPTIONS.get(detector_type, [])
|
|
||||||
if option in detector
|
|
||||||
]
|
|
||||||
|
|
||||||
if dropped:
|
|
||||||
logger.error(
|
|
||||||
"Detector '%s' had the %s options set, which are no longer supported and have been removed",
|
|
||||||
name,
|
|
||||||
", ".join(dropped),
|
|
||||||
)
|
|
||||||
|
|
||||||
detector_model_path = detector.get("model_path")
|
|
||||||
|
|
||||||
if detector_model_path:
|
|
||||||
if model_path is None:
|
|
||||||
model_path = detector_model_path
|
|
||||||
elif model_path != detector_model_path:
|
|
||||||
logger.warning(
|
|
||||||
"Detector '%s' set a different model_path than an earlier detector, using '%s' for the migrated model",
|
|
||||||
name,
|
|
||||||
model_path,
|
|
||||||
)
|
|
||||||
|
|
||||||
detector_types = {device.partition(":")[0] for device in devices}
|
|
||||||
|
|
||||||
if len(detector_types) > 1:
|
|
||||||
logger.error(
|
|
||||||
"Detectors of more than one type (%s) were configured. A model now runs on one detector type, so the migrated config will need to be corrected by hand",
|
|
||||||
", ".join(sorted(detector_types)),
|
|
||||||
)
|
|
||||||
|
|
||||||
entry: dict[str, Any] = {"scene": "all", **model}
|
|
||||||
|
|
||||||
if model_path:
|
|
||||||
entry["path"] = model_path
|
|
||||||
|
|
||||||
# a config with no detectors ran a single cpu detector
|
|
||||||
entry["devices"] = devices or ["cpu"]
|
|
||||||
|
|
||||||
new_config["models"] = [entry]
|
|
||||||
return new_config
|
|
||||||
|
|
||||||
|
|
||||||
def get_relative_coordinates(
|
def get_relative_coordinates(
|
||||||
mask: str | list | None,
|
mask: str | list | None,
|
||||||
frame_shape: tuple[int, int],
|
frame_shape: tuple[int, int],
|
||||||
|
|||||||
@@ -1,209 +0,0 @@
|
|||||||
"""Aggregation of the known sub label names an object can be tagged with."""
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
|
|
||||||
from pathvalidate import sanitize_filename
|
|
||||||
|
|
||||||
from frigate.config import FrigateConfig
|
|
||||||
from frigate.config.classification import ObjectClassificationType
|
|
||||||
from frigate.const import CLIPS_DIR, FACE_DIR, MODEL_CACHE_DIR
|
|
||||||
from frigate.util.builtin import load_labels
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
# subdirectory of FACE_DIR holding unassigned training images, not a face name
|
|
||||||
FACE_TRAIN_DIR = "train"
|
|
||||||
|
|
||||||
# category used by classification models for "no match", never attached to an object
|
|
||||||
CLASSIFICATION_NONE_CATEGORY = "none"
|
|
||||||
|
|
||||||
|
|
||||||
def get_categorized_object_names(
|
|
||||||
config: FrigateConfig,
|
|
||||||
allowed_cameras: list[str],
|
|
||||||
object_type: str | None = None,
|
|
||||||
) -> dict[str, list[str]]:
|
|
||||||
"""Collect every sub label name this install can attach, by object type.
|
|
||||||
|
|
||||||
Unlike the database-backed /sub_labels endpoint, this reads the config and
|
|
||||||
model files, so it also covers names that are configured but have not been
|
|
||||||
detected yet. Names come from the detector's logo attributes (limited to
|
|
||||||
objects the allowed cameras actually track), LPR known plate names,
|
|
||||||
registered face names, and custom object classification categories.
|
|
||||||
|
|
||||||
Structural attributes such as `face` and `license_plate` are excluded: they
|
|
||||||
describe a part of an object rather than naming it, and are never attached
|
|
||||||
as a sub label.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
config: The running Frigate config
|
|
||||||
allowed_cameras: Cameras the requesting user may see
|
|
||||||
object_type: Optional object label to restrict the result to
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Mapping of object label to its known sub label names, sorted and
|
|
||||||
deduplicated. Object types with no known names are omitted.
|
|
||||||
"""
|
|
||||||
tracked_objects = _get_tracked_objects(config, allowed_cameras)
|
|
||||||
names: dict[str, set[str]] = {}
|
|
||||||
logos = set(config.all_attribute_logos)
|
|
||||||
|
|
||||||
# 1. detector logo attributes, only for objects that are actually tracked
|
|
||||||
for label, label_attributes in config.all_attributes_map.items():
|
|
||||||
if label not in tracked_objects:
|
|
||||||
continue
|
|
||||||
|
|
||||||
label_logos = logos.intersection(label_attributes)
|
|
||||||
|
|
||||||
if label_logos:
|
|
||||||
names.setdefault(label, set()).update(label_logos)
|
|
||||||
|
|
||||||
# 2. LPR known plate names, for objects that can carry a plate
|
|
||||||
if config.lpr.known_plates and _lpr_enabled(config, allowed_cameras):
|
|
||||||
known_plates = set(config.lpr.known_plates)
|
|
||||||
|
|
||||||
for label in _objects_with_attribute(config, tracked_objects, "license_plate"):
|
|
||||||
names.setdefault(label, set()).update(known_plates)
|
|
||||||
|
|
||||||
# 3. registered face names, for objects that can carry a face
|
|
||||||
if _face_recognition_enabled(config, allowed_cameras):
|
|
||||||
face_names = _get_face_names()
|
|
||||||
|
|
||||||
if face_names:
|
|
||||||
for label in _objects_with_attribute(config, tracked_objects, "face"):
|
|
||||||
names.setdefault(label, set()).update(face_names)
|
|
||||||
|
|
||||||
# 4. custom object classification categories
|
|
||||||
for model_key, model_config in config.classification.custom.items():
|
|
||||||
if not model_config.enabled or model_config.object_config is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if (
|
|
||||||
model_config.object_config.classification_type
|
|
||||||
!= ObjectClassificationType.sub_label
|
|
||||||
):
|
|
||||||
continue
|
|
||||||
|
|
||||||
categories = _get_classification_categories(model_key)
|
|
||||||
|
|
||||||
if not categories:
|
|
||||||
continue
|
|
||||||
|
|
||||||
for label in model_config.object_config.objects:
|
|
||||||
names.setdefault(label, set()).update(categories)
|
|
||||||
|
|
||||||
return {
|
|
||||||
label: sorted(label_names)
|
|
||||||
for label, label_names in sorted(names.items())
|
|
||||||
if label_names and (object_type is None or label == object_type)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def _get_tracked_objects(config: FrigateConfig, allowed_cameras: list[str]) -> set[str]:
|
|
||||||
"""Get the union of objects tracked by the cameras the user can see."""
|
|
||||||
tracked: set[str] = set()
|
|
||||||
|
|
||||||
for camera_name in allowed_cameras:
|
|
||||||
camera_config = config.cameras.get(camera_name)
|
|
||||||
|
|
||||||
if camera_config is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
tracked.update(camera_config.objects.track)
|
|
||||||
|
|
||||||
return tracked
|
|
||||||
|
|
||||||
|
|
||||||
def _objects_with_attribute(
|
|
||||||
config: FrigateConfig, tracked_objects: set[str], attribute: str
|
|
||||||
) -> set[str]:
|
|
||||||
"""Get the tracked objects that a given attribute can be recognized on.
|
|
||||||
|
|
||||||
The attribute may also be tracked as an object in its own right, as
|
|
||||||
`license_plate` is on a dedicated LPR camera, in which case the name is
|
|
||||||
attached to that object directly.
|
|
||||||
"""
|
|
||||||
objects = {
|
|
||||||
label
|
|
||||||
for label, label_attributes in config.all_attributes_map.items()
|
|
||||||
if attribute in label_attributes and label in tracked_objects
|
|
||||||
}
|
|
||||||
|
|
||||||
if attribute in tracked_objects:
|
|
||||||
objects.add(attribute)
|
|
||||||
|
|
||||||
return objects
|
|
||||||
|
|
||||||
|
|
||||||
def _lpr_enabled(config: FrigateConfig, allowed_cameras: list[str]) -> bool:
|
|
||||||
return any(
|
|
||||||
config.cameras[camera_name].lpr.enabled
|
|
||||||
for camera_name in allowed_cameras
|
|
||||||
if camera_name in config.cameras
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _face_recognition_enabled(
|
|
||||||
config: FrigateConfig, allowed_cameras: list[str]
|
|
||||||
) -> bool:
|
|
||||||
return any(
|
|
||||||
config.cameras[camera_name].face_recognition.enabled
|
|
||||||
for camera_name in allowed_cameras
|
|
||||||
if camera_name in config.cameras
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_face_names() -> set[str]:
|
|
||||||
"""Get the names of every registered face collection."""
|
|
||||||
if not os.path.exists(FACE_DIR):
|
|
||||||
return set()
|
|
||||||
|
|
||||||
try:
|
|
||||||
entries = os.listdir(FACE_DIR)
|
|
||||||
except OSError:
|
|
||||||
logger.debug("Failed to read face directory %s", FACE_DIR)
|
|
||||||
return set()
|
|
||||||
|
|
||||||
return {
|
|
||||||
name
|
|
||||||
for name in entries
|
|
||||||
if name != FACE_TRAIN_DIR and os.path.isdir(os.path.join(FACE_DIR, name))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def _get_classification_categories(model_key: str) -> set[str]:
|
|
||||||
"""Get the categories a custom classification model can output.
|
|
||||||
|
|
||||||
The trained labelmap is authoritative, but it only exists once the model
|
|
||||||
has been trained, so fall back to the dataset directories that will become
|
|
||||||
the labelmap on the next training run.
|
|
||||||
"""
|
|
||||||
safe_key = sanitize_filename(model_key)
|
|
||||||
categories: set[str] = set()
|
|
||||||
labelmap_path = os.path.join(MODEL_CACHE_DIR, safe_key, "labelmap.txt")
|
|
||||||
|
|
||||||
if os.path.exists(labelmap_path):
|
|
||||||
try:
|
|
||||||
labelmap = load_labels(labelmap_path, prefill=0, indexed=False)
|
|
||||||
except OSError:
|
|
||||||
logger.debug("Failed to read labelmap %s", labelmap_path)
|
|
||||||
labelmap = {}
|
|
||||||
|
|
||||||
categories.update(label for label in labelmap.values() if label)
|
|
||||||
|
|
||||||
dataset_dir = os.path.join(CLIPS_DIR, safe_key, "dataset")
|
|
||||||
|
|
||||||
if os.path.exists(dataset_dir):
|
|
||||||
try:
|
|
||||||
entries = os.listdir(dataset_dir)
|
|
||||||
except OSError:
|
|
||||||
logger.debug("Failed to read dataset directory %s", dataset_dir)
|
|
||||||
entries = []
|
|
||||||
|
|
||||||
categories.update(
|
|
||||||
name for name in entries if os.path.isdir(os.path.join(dataset_dir, name))
|
|
||||||
)
|
|
||||||
|
|
||||||
categories.discard(CLASSIFICATION_NONE_CATEGORY)
|
|
||||||
return categories
|
|
||||||
+38
-9
@@ -2,16 +2,45 @@
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, TypeAdapter
|
||||||
|
|
||||||
|
|
||||||
def get_config_schema(config_class: type[BaseModel]) -> dict[str, Any]:
|
def get_config_schema(config_class: type[BaseModel]) -> dict[str, Any]:
|
||||||
"""Get the JSON schema for FrigateConfig.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
config_class: The config model to describe
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The JSON schema
|
|
||||||
"""
|
"""
|
||||||
return config_class.model_json_schema()
|
Returns the JSON schema for FrigateConfig with polymorphic detectors.
|
||||||
|
|
||||||
|
This utility patches the FrigateConfig schema to include the full polymorphic
|
||||||
|
definitions for detectors. By default, Pydantic's schema for Dict[str, BaseDetectorConfig]
|
||||||
|
only includes the base class fields. This function replaces it with a reference
|
||||||
|
to the DetectorConfig union, which includes all available detector subclasses.
|
||||||
|
"""
|
||||||
|
# Import here to ensure all detector plugins are loaded through the detectors module
|
||||||
|
from frigate.detectors import DetectorConfig
|
||||||
|
|
||||||
|
# Get the base schema for FrigateConfig
|
||||||
|
schema = config_class.model_json_schema()
|
||||||
|
|
||||||
|
# Get the schema for the polymorphic DetectorConfig union
|
||||||
|
detector_adapter: TypeAdapter = TypeAdapter(DetectorConfig)
|
||||||
|
detector_schema = detector_adapter.json_schema()
|
||||||
|
|
||||||
|
# Ensure $defs exists in FrigateConfig schema
|
||||||
|
if "$defs" not in schema:
|
||||||
|
schema["$defs"] = {}
|
||||||
|
|
||||||
|
# Merge $defs from DetectorConfig into FrigateConfig schema
|
||||||
|
# This includes the specific schemas for each detector plugin (OvDetectorConfig, etc.)
|
||||||
|
if "$defs" in detector_schema:
|
||||||
|
schema["$defs"].update(detector_schema["$defs"])
|
||||||
|
|
||||||
|
# Extract the union schema (oneOf/discriminator) and add it as a definition
|
||||||
|
detector_union_schema = {k: v for k, v in detector_schema.items() if k != "$defs"}
|
||||||
|
schema["$defs"]["DetectorConfig"] = detector_union_schema
|
||||||
|
|
||||||
|
# Update the 'detectors' property to use the polymorphic DetectorConfig definition
|
||||||
|
if "detectors" in schema.get("properties", {}):
|
||||||
|
schema["properties"]["detectors"]["additionalProperties"] = {
|
||||||
|
"$ref": "#/$defs/DetectorConfig"
|
||||||
|
}
|
||||||
|
|
||||||
|
return schema
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"""Utilities for services."""
|
"""Utilities for services."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import glob
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@@ -671,33 +670,19 @@ def get_intel_gpu_stats(
|
|||||||
|
|
||||||
def get_openvino_npu_stats() -> dict[str, str] | None:
|
def get_openvino_npu_stats() -> dict[str, str] | None:
|
||||||
"""Get NPU stats using openvino."""
|
"""Get NPU stats using openvino."""
|
||||||
for accel_path in sorted(glob.glob("/sys/class/accel/accel*")):
|
NPU_RUNTIME_PATH = "/sys/devices/pci0000:00/0000:00:0b.0/power/runtime_active_time"
|
||||||
try:
|
|
||||||
driver = os.path.basename(os.readlink(f"{accel_path}/device/driver"))
|
|
||||||
except OSError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if driver != "intel_vpu":
|
|
||||||
continue
|
|
||||||
|
|
||||||
try:
|
|
||||||
runtime_path = f"{accel_path}/device/power/runtime_active_time"
|
|
||||||
with open(runtime_path) as f:
|
|
||||||
initial_runtime = float(f.read().strip())
|
|
||||||
break
|
|
||||||
except (FileNotFoundError, PermissionError, ValueError):
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
with open(NPU_RUNTIME_PATH) as f:
|
||||||
|
initial_runtime = float(f.read().strip())
|
||||||
|
|
||||||
initial_time = time.time()
|
initial_time = time.time()
|
||||||
|
|
||||||
# Sleep for 1 second to get an accurate reading
|
# Sleep for 1 second to get an accurate reading
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
|
|
||||||
# Read runtime value again
|
# Read runtime value again
|
||||||
with open(runtime_path) as f:
|
with open(NPU_RUNTIME_PATH) as f:
|
||||||
current_runtime = float(f.read().strip())
|
current_runtime = float(f.read().strip())
|
||||||
|
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ SPEC_SERVERS = [
|
|||||||
PUBLIC = "public"
|
PUBLIC = "public"
|
||||||
AUTHENTICATED = "any"
|
AUTHENTICATED = "any"
|
||||||
CAMERA = "camera"
|
CAMERA = "camera"
|
||||||
|
ALL_CAMERAS = "all_cameras"
|
||||||
ADMIN = "admin"
|
ADMIN = "admin"
|
||||||
|
|
||||||
ADMIN_SCHEME = "frigateAdminAuth"
|
ADMIN_SCHEME = "frigateAdminAuth"
|
||||||
@@ -128,6 +129,7 @@ ACCESS_NOTES = {
|
|||||||
PUBLIC: "**Access:** Public — no authentication required.",
|
PUBLIC: "**Access:** Public — no authentication required.",
|
||||||
AUTHENTICATED: "**Access:** Any authenticated user.",
|
AUTHENTICATED: "**Access:** Any authenticated user.",
|
||||||
CAMERA: "**Access:** Authenticated user with access to the referenced camera.",
|
CAMERA: "**Access:** Authenticated user with access to the referenced camera.",
|
||||||
|
ALL_CAMERAS: "**Access:** Authenticated user with access to all cameras.",
|
||||||
ADMIN: "**Access:** Admin role required.",
|
ADMIN: "**Access:** Admin role required.",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,6 +199,8 @@ def _route_markers(route: APIRoute) -> tuple[set[str], list[str] | None]:
|
|||||||
pass
|
pass
|
||||||
elif name in ("require_camera_access", "require_go2rtc_stream_access"):
|
elif name in ("require_camera_access", "require_go2rtc_stream_access"):
|
||||||
markers.add(CAMERA)
|
markers.add(CAMERA)
|
||||||
|
elif name == "require_full_camera_access":
|
||||||
|
markers.add(ALL_CAMERAS)
|
||||||
elif "auth_checker" in qualname:
|
elif "auth_checker" in qualname:
|
||||||
markers.add(AUTHENTICATED)
|
markers.add(AUTHENTICATED)
|
||||||
elif "public_checker" in qualname:
|
elif "public_checker" in qualname:
|
||||||
@@ -254,6 +258,8 @@ def _classify_base(
|
|||||||
# Explicit route-level markers win, in order of specificity.
|
# Explicit route-level markers win, in order of specificity.
|
||||||
if ADMIN in markers:
|
if ADMIN in markers:
|
||||||
return ADMIN, admin_roles or ["admin"], None
|
return ADMIN, admin_roles or ["admin"], None
|
||||||
|
if ALL_CAMERAS in markers:
|
||||||
|
return ALL_CAMERAS, None, None
|
||||||
if CAMERA in markers:
|
if CAMERA in markers:
|
||||||
return CAMERA, None, None
|
return CAMERA, None, None
|
||||||
if AUTHENTICATED in markers:
|
if AUTHENTICATED in markers:
|
||||||
@@ -337,8 +343,8 @@ def security_for(level: str) -> list:
|
|||||||
return []
|
return []
|
||||||
if level == ADMIN:
|
if level == ADMIN:
|
||||||
return [{ADMIN_SCHEME: []}]
|
return [{ADMIN_SCHEME: []}]
|
||||||
# AUTHENTICATED and CAMERA both require any authenticated session; the
|
# AUTHENTICATED, CAMERA and ALL_CAMERAS all require any authenticated
|
||||||
# camera-specific scoping is conveyed in the note and x-required-role.
|
# session; the camera scoping is conveyed in the note and x-required-role.
|
||||||
return [{USER_SCHEME: []}]
|
return [{USER_SCHEME: []}]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -210,6 +210,78 @@ def generate_section_translation(config_class: type) -> dict[str, Any]:
|
|||||||
return extract_translations_from_schema(schema)
|
return extract_translations_from_schema(schema)
|
||||||
|
|
||||||
|
|
||||||
|
def get_detector_translations(
|
||||||
|
config_schema: dict[str, Any],
|
||||||
|
) -> tuple[dict[str, Any], dict[str, Any], set[str]]:
|
||||||
|
"""Build detector type translations with nested fields based on schema definitions.
|
||||||
|
|
||||||
|
Returns a tuple of (type_translations, shared_fields, nested_field_keys).
|
||||||
|
Shared fields (identical across all detector types) are returned separately
|
||||||
|
to avoid duplication in the output.
|
||||||
|
"""
|
||||||
|
defs = config_schema.get("$defs", {})
|
||||||
|
detector_schema = defs.get("DetectorConfig", {})
|
||||||
|
discriminator = detector_schema.get("discriminator", {})
|
||||||
|
mapping = discriminator.get("mapping", {})
|
||||||
|
|
||||||
|
# First pass: collect all nested fields per detector type
|
||||||
|
all_nested: dict[str, dict[str, Any]] = {}
|
||||||
|
type_meta: dict[str, dict[str, str]] = {}
|
||||||
|
|
||||||
|
for detector_type, ref in mapping.items():
|
||||||
|
if not isinstance(ref, str) or not ref.startswith("#/$defs/"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
ref_name = ref.split("/")[-1]
|
||||||
|
ref_schema = defs.get(ref_name, {})
|
||||||
|
if not ref_schema:
|
||||||
|
continue
|
||||||
|
|
||||||
|
meta: dict[str, str] = {}
|
||||||
|
title = ref_schema.get("title")
|
||||||
|
description = ref_schema.get("description")
|
||||||
|
if title:
|
||||||
|
meta["label"] = title
|
||||||
|
if description:
|
||||||
|
meta["description"] = description
|
||||||
|
type_meta[detector_type] = meta
|
||||||
|
|
||||||
|
nested = extract_translations_from_schema(ref_schema, defs=defs)
|
||||||
|
all_nested[detector_type] = {
|
||||||
|
k: v for k, v in nested.items() if k not in ("label", "description")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find fields that are identical across all types that have them
|
||||||
|
shared_fields: dict[str, Any] = {}
|
||||||
|
if all_nested:
|
||||||
|
# Collect all field keys across all types
|
||||||
|
all_keys: set[str] = set()
|
||||||
|
for nested in all_nested.values():
|
||||||
|
all_keys.update(nested.keys())
|
||||||
|
|
||||||
|
for key in all_keys:
|
||||||
|
values = [nested[key] for nested in all_nested.values() if key in nested]
|
||||||
|
if len(values) == len(all_nested) and all(v == values[0] for v in values):
|
||||||
|
shared_fields[key] = values[0]
|
||||||
|
|
||||||
|
# Build per-type translations with only unique (non-shared) fields
|
||||||
|
type_translations: dict[str, Any] = {}
|
||||||
|
nested_field_keys: set[str] = set()
|
||||||
|
for detector_type, nested in all_nested.items():
|
||||||
|
type_entry: dict[str, Any] = {}
|
||||||
|
type_entry.update(type_meta.get(detector_type, {}))
|
||||||
|
|
||||||
|
unique_fields = {k: v for k, v in nested.items() if k not in shared_fields}
|
||||||
|
if unique_fields:
|
||||||
|
type_entry.update(unique_fields)
|
||||||
|
nested_field_keys.update(unique_fields.keys())
|
||||||
|
|
||||||
|
if type_entry:
|
||||||
|
type_translations[detector_type] = type_entry
|
||||||
|
|
||||||
|
return type_translations, shared_fields, nested_field_keys
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main function to generate config translations."""
|
"""Main function to generate config translations."""
|
||||||
|
|
||||||
@@ -265,12 +337,6 @@ def main():
|
|||||||
if args and len(args) > 1:
|
if args and len(args) > 1:
|
||||||
field_type = args[1] # Get value type from Dict[key, value]
|
field_type = args[1] # Get value type from Dict[key, value]
|
||||||
|
|
||||||
# Handle List[SomeModel] - extract the item type
|
|
||||||
if origin is list:
|
|
||||||
args = get_args(field_type)
|
|
||||||
if args:
|
|
||||||
field_type = args[0]
|
|
||||||
|
|
||||||
# Start with field's top-level metadata (label, description)
|
# Start with field's top-level metadata (label, description)
|
||||||
section_data = get_field_translations(field_info)
|
section_data = get_field_translations(field_info)
|
||||||
|
|
||||||
@@ -285,6 +351,19 @@ def main():
|
|||||||
}
|
}
|
||||||
section_data.update(nested_without_root)
|
section_data.update(nested_without_root)
|
||||||
|
|
||||||
|
if field_name == "detectors":
|
||||||
|
detector_types, shared_fields, detector_field_keys = (
|
||||||
|
get_detector_translations(config_schema)
|
||||||
|
)
|
||||||
|
# Add shared fields at the base detectors level
|
||||||
|
section_data.update(shared_fields)
|
||||||
|
# Add per-type translations (only unique fields per type)
|
||||||
|
section_data.update(detector_types)
|
||||||
|
for key in detector_field_keys:
|
||||||
|
if key == "type":
|
||||||
|
continue
|
||||||
|
section_data.pop(key, None)
|
||||||
|
|
||||||
if field_name == "objects":
|
if field_name == "objects":
|
||||||
# Produce a parallel `filters_attribute` block alongside `filters`,
|
# Produce a parallel `filters_attribute` block alongside `filters`,
|
||||||
# with object-wording rewritten for attribute filters (face,
|
# with object-wording rewritten for attribute filters (face,
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class ProcessClip:
|
|||||||
self.camera_name,
|
self.camera_name,
|
||||||
self.frame_queue,
|
self.frame_queue,
|
||||||
self.frame_shape,
|
self.frame_shape,
|
||||||
self.config.model_for_camera(self.camera_name),
|
self.config.model,
|
||||||
self.camera_config.detect,
|
self.camera_config.detect,
|
||||||
self.frame_manager,
|
self.frame_manager,
|
||||||
motion_detector,
|
motion_detector,
|
||||||
@@ -248,7 +248,7 @@ def process(path, label, output, debug_path):
|
|||||||
|
|
||||||
json_config = {
|
json_config = {
|
||||||
"mqtt": {"enabled": False},
|
"mqtt": {"enabled": False},
|
||||||
"models": [{"devices": ["edgetpu:usb"]}],
|
"detectors": {"coral": {"type": "edgetpu", "device": "usb"}},
|
||||||
"cameras": {
|
"cameras": {
|
||||||
"camera": {
|
"camera": {
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -102,12 +102,11 @@ def generate_config():
|
|||||||
snapshot = config.model_dump()
|
snapshot = config.model_dump()
|
||||||
|
|
||||||
# Runtime-computed fields not in the Pydantic dump
|
# Runtime-computed fields not in the Pydantic dump
|
||||||
for model in snapshot.get("models", []):
|
all_attrs = set()
|
||||||
all_attrs = set()
|
for attrs in snapshot.get("model", {}).get("attributes_map", {}).values():
|
||||||
for attrs in model.get("attributes_map", {}).values():
|
all_attrs.update(attrs)
|
||||||
all_attrs.update(attrs)
|
snapshot["model"]["all_attributes"] = sorted(all_attrs)
|
||||||
model["all_attributes"] = sorted(all_attrs)
|
snapshot["model"]["colormap"] = {}
|
||||||
model["colormap"] = {}
|
|
||||||
|
|
||||||
return snapshot
|
return snapshot
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
"cough": "سُعَال",
|
"cough": "سُعَال",
|
||||||
"throat_clearing": "تَنْحِيم",
|
"throat_clearing": "تَنْحِيم",
|
||||||
"sneeze": "عُطَاس",
|
"sneeze": "عُطَاس",
|
||||||
"sniff": "شَمَّ",
|
"sniff": "كشف",
|
||||||
"run": "رَكْض",
|
"run": "رَكْض",
|
||||||
"shuffle": "خَلْط",
|
"shuffle": "خَلْط",
|
||||||
"footsteps": "خُطُوَات",
|
"footsteps": "خُطُوَات",
|
||||||
@@ -161,5 +161,43 @@
|
|||||||
"rumble": "الحلبة",
|
"rumble": "الحلبة",
|
||||||
"skateboard": "لوح تزلج",
|
"skateboard": "لوح تزلج",
|
||||||
"echo": "صدى الصوت",
|
"echo": "صدى الصوت",
|
||||||
"noise": "ازعاج"
|
"noise": "ازعاج",
|
||||||
|
"duck": "بطة",
|
||||||
|
"quack": "صوت البطة",
|
||||||
|
"goose": "وزة",
|
||||||
|
"honk": "نعيق الأوز",
|
||||||
|
"wild_animals": "حيوانات برية",
|
||||||
|
"roar": "زئير",
|
||||||
|
"chirp": "زقزقة",
|
||||||
|
"pigeon": "حمامة",
|
||||||
|
"crow": "غراب",
|
||||||
|
"roaring_cats": "قطط هائجة",
|
||||||
|
"squawk": "نعيق",
|
||||||
|
"coo": "هديل الحمام",
|
||||||
|
"mallet_percussion": "مطرقة إيقاعية",
|
||||||
|
"marimba": "ماريمبا",
|
||||||
|
"glockenspiel": "معزف الأجراس",
|
||||||
|
"vibraphone": "فيبرافون",
|
||||||
|
"steelpan": "طبل نحاسي",
|
||||||
|
"orchestra": "أوركسترا",
|
||||||
|
"brass_instrument": "آلة نحاسية",
|
||||||
|
"french_horn": "بوق فرنسي",
|
||||||
|
"trumpet": "بوق",
|
||||||
|
"trombone": "ترومبون",
|
||||||
|
"bowed_string_instrument": "آلة وترية مقوسة",
|
||||||
|
"string_section": "آلات وترية",
|
||||||
|
"violin": "كمان",
|
||||||
|
"pizzicato": "تقنية العزف بيزيكاتو",
|
||||||
|
"cello": "تشيلو",
|
||||||
|
"double_bass": "كمان كبير",
|
||||||
|
"wind_instrument": "آلة نفخية",
|
||||||
|
"flute": "فلوت",
|
||||||
|
"saxophone": "ساكسفون",
|
||||||
|
"clarinet": "كلارينيت",
|
||||||
|
"harp": "قيثارة",
|
||||||
|
"bell": "جرس",
|
||||||
|
"church_bell": "جرس الكنيسة",
|
||||||
|
"jingle_bell": "جرس جلجل",
|
||||||
|
"bicycle_bell": "جرس الدراجة",
|
||||||
|
"tuning_fork": "شوكة رنانة"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,9 +71,9 @@
|
|||||||
"batchSuccess_other": "S'han iniciat {{count}} exportacions. Obrint el cas ara.",
|
"batchSuccess_other": "S'han iniciat {{count}} exportacions. Obrint el cas ara.",
|
||||||
"batchPartial": "S'han iniciat {{successful}} de {{total}} exportacions. Càmeres fallides: {{failedCameras}}",
|
"batchPartial": "S'han iniciat {{successful}} de {{total}} exportacions. Càmeres fallides: {{failedCameras}}",
|
||||||
"batchFailed": "No s'han pogut iniciar {{total}} exportacions. Càmeres fallides: {{failedCameras}}",
|
"batchFailed": "No s'han pogut iniciar {{total}} exportacions. Càmeres fallides: {{failedCameras}}",
|
||||||
"batchQueuedSuccess_one": "Exporta a la cua 1. Obrint el cas ara.",
|
"batchQueuedSuccess_one": "Exporta a la cua 1.",
|
||||||
"batchQueuedSuccess_many": "{{count}} exportacions a la cua. Obrint el cas ara.",
|
"batchQueuedSuccess_many": "{{count}} exportacions a la cua.",
|
||||||
"batchQueuedSuccess_other": "{{count}} exportacions a la cua. Obrint el cas ara.",
|
"batchQueuedSuccess_other": "{{count}} exportacions a la cua.",
|
||||||
"batchQueuedPartial": "{{successful}} de {{total}} exportacions a la cua. Càmeres fallides: {{failedCameras}}",
|
"batchQueuedPartial": "{{successful}} de {{total}} exportacions a la cua. Càmeres fallides: {{failedCameras}}",
|
||||||
"batchQueueFailed": "No s'han pogut posar a la cua {{total}} exportacions. Càmeres fallides: {{failedCameras}}"
|
"batchQueueFailed": "No s'han pogut posar a la cua {{total}} exportacions. Càmeres fallides: {{failedCameras}}"
|
||||||
},
|
},
|
||||||
@@ -132,9 +132,9 @@
|
|||||||
"exportButton_other": "Exporta {{count}} ressenyes",
|
"exportButton_other": "Exporta {{count}} ressenyes",
|
||||||
"exportingButton": "S'està exportant...",
|
"exportingButton": "S'està exportant...",
|
||||||
"toast": {
|
"toast": {
|
||||||
"started_one": "S'ha iniciat l'exportació 1. Obrint el cas ara.",
|
"started_one": "S'ha iniciat l'exportació 1.",
|
||||||
"started_many": "S'han iniciat {{count}} exportacions. Obrint el cas ara.",
|
"started_many": "S'han iniciat {{count}} exportacions.",
|
||||||
"started_other": "S'han iniciat {{count}} exportacions. Obrint el cas ara.",
|
"started_other": "S'han iniciat {{count}} exportacions.",
|
||||||
"startedNoCase_one": "S'ha iniciat l'exportació 1.",
|
"startedNoCase_one": "S'ha iniciat l'exportació 1.",
|
||||||
"startedNoCase_many": "S'han iniciat {{count}} exportacions.",
|
"startedNoCase_many": "S'han iniciat {{count}} exportacions.",
|
||||||
"startedNoCase_other": "S'han iniciat {{count}} exportacions.",
|
"startedNoCase_other": "S'han iniciat {{count}} exportacions.",
|
||||||
|
|||||||
@@ -52,7 +52,8 @@
|
|||||||
"error": "No s'ha pogut iniciar la repetició de depuració: {{error}}",
|
"error": "No s'ha pogut iniciar la repetició de depuració: {{error}}",
|
||||||
"alreadyActive": "Ja hi ha activada una sessió de reproducció",
|
"alreadyActive": "Ja hi ha activada una sessió de reproducció",
|
||||||
"stopError": "No s'ha pogut aturar la repetició de depuració: {{error}}",
|
"stopError": "No s'ha pogut aturar la repetició de depuració: {{error}}",
|
||||||
"goToReplay": "Ves a la repetició"
|
"goToReplay": "Ves a la repetició",
|
||||||
|
"noRecordings": "No s'ha trobat cap enregistrament a l'interval de temps seleccionat"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "Reprodueix els enregistraments de la càmera per a la depuració. La llista d'objectes mostra un resum retardat en el temps dels objectes detectats i la pestanya Missatges mostra un flux de missatges interns de frigate a partir del metratge de reproducció."
|
"description": "Reprodueix els enregistraments de la càmera per a la depuració. La llista d'objectes mostra un resum retardat en el temps dels objectes detectats i la pestanya Missatges mostra un flux de missatges interns de frigate a partir del metratge de reproducció."
|
||||||
|
|||||||
@@ -265,7 +265,7 @@
|
|||||||
"rhythm_and_blues": "Rhythm and Blues",
|
"rhythm_and_blues": "Rhythm and Blues",
|
||||||
"soul_music": "Soulmusik",
|
"soul_music": "Soulmusik",
|
||||||
"reggae": "Reggae",
|
"reggae": "Reggae",
|
||||||
"country": "Country",
|
"country": "Land",
|
||||||
"disco": "Disko",
|
"disco": "Disko",
|
||||||
"classical_music": "Klassisk musik",
|
"classical_music": "Klassisk musik",
|
||||||
"electronic_music": "Elektronisk musik",
|
"electronic_music": "Elektronisk musik",
|
||||||
@@ -341,5 +341,7 @@
|
|||||||
"propeller": "Probel",
|
"propeller": "Probel",
|
||||||
"fixed-wing_aircraft": "Fastvingefly",
|
"fixed-wing_aircraft": "Fastvingefly",
|
||||||
"engine": "Motor",
|
"engine": "Motor",
|
||||||
"light_engine": "Lille motor"
|
"light_engine": "Lille motor",
|
||||||
|
"swing_music": "Swing musik",
|
||||||
|
"bluegrass": "Bluegrass"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,7 @@
|
|||||||
{}
|
{
|
||||||
|
"camera_ui": {
|
||||||
|
"review": {
|
||||||
|
"label": "Vis i gennemgang"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -170,7 +170,10 @@
|
|||||||
"title": "Rediger kategoriseringsmodel",
|
"title": "Rediger kategoriseringsmodel",
|
||||||
"descriptionState": "Rediger kategorierne for denne model til genstandstilstande. Ændringer kræver, at modellen trænes igen.",
|
"descriptionState": "Rediger kategorierne for denne model til genstandstilstande. Ændringer kræver, at modellen trænes igen.",
|
||||||
"descriptionObject": "Rediger genstandstypen og kategoriseringstypen for denne genstandskategoriseringsmodel.",
|
"descriptionObject": "Rediger genstandstypen og kategoriseringstypen for denne genstandskategoriseringsmodel.",
|
||||||
"stateClassesInfo": "Bemærk: Ændring af tilstandskategorier kræver, at modellen trænes igen med de opdaterede kategorier."
|
"stateClassesInfo": "Bemærk: Ændring af tilstandskategorier kræver, at modellen trænes igen med de opdaterede kategorier.",
|
||||||
|
"enabled": "Aktiveret",
|
||||||
|
"enabledDesc": "Kør denne model. Ved deaktivering stopper den med at køre og klassificerer ikke længere",
|
||||||
|
"saveAttempts": "Gem forsøg"
|
||||||
},
|
},
|
||||||
"deleteDatasetImages": {
|
"deleteDatasetImages": {
|
||||||
"title": "Slet billeder i datasættet",
|
"title": "Slet billeder i datasættet",
|
||||||
|
|||||||
@@ -28,5 +28,8 @@
|
|||||||
"detail": {
|
"detail": {
|
||||||
"aria": "Skift til detaljevisning"
|
"aria": "Skift til detaljevisning"
|
||||||
},
|
},
|
||||||
"timeline.aria": "Vælg tidslinje"
|
"timeline.aria": "Vælg tidslinje",
|
||||||
|
"motionPreviews": {
|
||||||
|
"crop": "Beskær til filter"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,9 @@
|
|||||||
{}
|
{
|
||||||
|
"metrics": {
|
||||||
|
"minutesSeconds": "{{minutes}}m {{seconds}}s",
|
||||||
|
"scanSummary": "{{segments}} segmentee · {{time}}"
|
||||||
|
},
|
||||||
|
"polygonControls": {
|
||||||
|
"moveMode": "Flyt"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,5 +16,31 @@
|
|||||||
"menu": {
|
"menu": {
|
||||||
"ui": "Brugergrænseflade",
|
"ui": "Brugergrænseflade",
|
||||||
"profiles": "Profiler"
|
"profiles": "Profiler"
|
||||||
|
},
|
||||||
|
"configMessages": {
|
||||||
|
"model": {
|
||||||
|
"optimizedFor320": "Frigate er optimeret til en 320x320 model, der er det bedste valg for de fleste konfigurationer. En 640x640 model er langsommere og hjælper kun i særlige scenarier"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"configForm": {
|
||||||
|
"cameraInputs": {
|
||||||
|
"sourceMode": {
|
||||||
|
"manual": "Manuel input sti"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cameraManagement": {
|
||||||
|
"clone": {
|
||||||
|
"footer": {
|
||||||
|
"restartNeeded": "Genstart er nødvendig for visse ændringer.",
|
||||||
|
"liveOnly": "Alle ændringer vil blive aktiveret umiddelbart uden genstart.",
|
||||||
|
"submit": "Klone",
|
||||||
|
"submitting": "Kloner…"
|
||||||
|
},
|
||||||
|
"toast": {
|
||||||
|
"success": "Indstillinger kopieret til {{cameraName}}",
|
||||||
|
"successWithRestart": "Indstillinger kopieret til {{cameraName}}. Genstart Frigate for at aktivere alle ændringer."
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,8 +78,8 @@
|
|||||||
"batchSuccess_other": "{{count}} Exports gestartet. Öffne den Fall jetzt.",
|
"batchSuccess_other": "{{count}} Exports gestartet. Öffne den Fall jetzt.",
|
||||||
"batchPartial": "{{successful}} von {{total}} Exporten gestartet. Fehlgeschlagene Kameras: {{failedCameras}}",
|
"batchPartial": "{{successful}} von {{total}} Exporten gestartet. Fehlgeschlagene Kameras: {{failedCameras}}",
|
||||||
"batchFailed": "Fehler beim Starten der {{total}} Exporte. Fehlgeschlagene Kameras: {{failedCameras}}",
|
"batchFailed": "Fehler beim Starten der {{total}} Exporte. Fehlgeschlagene Kameras: {{failedCameras}}",
|
||||||
"batchQueuedSuccess_one": "1 Export in die Warteschlange gestellt. Fall wird jetzt geöffnet.",
|
"batchQueuedSuccess_one": "1 Export in die Warteschlange gestellt.",
|
||||||
"batchQueuedSuccess_other": "{{count}} Exporte in der Warteschlange. Fall wird jetzt geöffnet.",
|
"batchQueuedSuccess_other": "{{count}} Exporte in der Warteschlange.",
|
||||||
"batchQueuedPartial": "{{successful}} von {{total}} Exporten in die Warteschlange gestellt. Fehlerhafte Kameras: {{failedCameras}}",
|
"batchQueuedPartial": "{{successful}} von {{total}} Exporten in die Warteschlange gestellt. Fehlerhafte Kameras: {{failedCameras}}",
|
||||||
"batchQueueFailed": "Fehler beim Einreihen von {{total}} Exporten in die Warteschlange. Fehlerhafte Kameras: {{failedCameras}}"
|
"batchQueueFailed": "Fehler beim Einreihen von {{total}} Exporten in die Warteschlange. Fehlerhafte Kameras: {{failedCameras}}"
|
||||||
},
|
},
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
"noCameras": "Keine Kameras verfügbar",
|
"noCameras": "Keine Kameras verfügbar",
|
||||||
"detectionCount_one": "1 verfolgtes Objekt",
|
"detectionCount_one": "1 verfolgtes Objekt",
|
||||||
"detectionCount_other": "{{count}} verfolgte Objekte",
|
"detectionCount_other": "{{count}} verfolgte Objekte",
|
||||||
"nameLabel": "Exportname",
|
"nameLabel": "Name exportieren",
|
||||||
"namePlaceholder": "Optionaler Basisname für diese Exporte",
|
"namePlaceholder": "Optionaler Basisname für diese Exporte",
|
||||||
"queueingButton": "Exporte werden in die Warteschlange gestellt...",
|
"queueingButton": "Exporte werden in die Warteschlange gestellt...",
|
||||||
"exportButton_one": "Export 1 Kamera",
|
"exportButton_one": "Export 1 Kamera",
|
||||||
@@ -135,8 +135,8 @@
|
|||||||
"exportButton_other": "{{count}} Bewertung exportieren",
|
"exportButton_other": "{{count}} Bewertung exportieren",
|
||||||
"exportingButton": "Exportieren...",
|
"exportingButton": "Exportieren...",
|
||||||
"toast": {
|
"toast": {
|
||||||
"started_one": "1 Export gestartet. Fall wird jetzt geöffnet.",
|
"started_one": "1 Export gestartet.",
|
||||||
"started_other": "{{count}} Exporte gestartet. Fall wird jetzt geöffnet.",
|
"started_other": "{{count}} Exporte gestartet.",
|
||||||
"startedNoCase_one": "1 Export gestartet.",
|
"startedNoCase_one": "1 Export gestartet.",
|
||||||
"startedNoCase_other": "{{count}} Exports gestartet.",
|
"startedNoCase_other": "{{count}} Exports gestartet.",
|
||||||
"partial": "{{successful}} von {{total}} Exporten gestartet. Fehlgeschlagen: {{failedItems}}",
|
"partial": "{{successful}} von {{total}} Exporten gestartet. Fehlgeschlagen: {{failedItems}}",
|
||||||
|
|||||||
@@ -547,7 +547,7 @@
|
|||||||
"description": "Maximale Anzahl der gleichzeitig zu verarbeitenden Exportaufträge."
|
"description": "Maximale Anzahl der gleichzeitig zu verarbeitenden Exportaufträge."
|
||||||
},
|
},
|
||||||
"chapters": {
|
"chapters": {
|
||||||
"label": "Kapitel-Metadaten zur Einbettung in exportierte Aufzeichnungen"
|
"label": "Kapitel-Metadaten, die in exportierte Aufzeichnungen eingebettet werden sollen"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"preview": {
|
"preview": {
|
||||||
@@ -772,7 +772,7 @@
|
|||||||
},
|
},
|
||||||
"dashboard": {
|
"dashboard": {
|
||||||
"label": "Im Live-Dashboard anzeigen",
|
"label": "Im Live-Dashboard anzeigen",
|
||||||
"description": "Legt fest, ob diese Kamera im Live-Dashboard ‚Alle Kameras‘ angezeigt wird. Die Kamera bleibt in allen anderen Bereichen der Benutzeroberfläche verfügbar, einschließlich Kamera-Gruppen und Einstellungen."
|
"description": "Legt fest, ob diese Kamera im Standard-Live-Dashboard „Alle Kameras“ angezeigt wird. Die Kamera bleibt in allen anderen Bereichen der Benutzeroberfläche verfügbar, einschließlich Kameragruppen und Einstellungen."
|
||||||
},
|
},
|
||||||
"review": {
|
"review": {
|
||||||
"label": "In der Überprüfung anzeigen",
|
"label": "In der Überprüfung anzeigen",
|
||||||
|
|||||||
@@ -539,7 +539,7 @@
|
|||||||
},
|
},
|
||||||
"network_bandwidth": {
|
"network_bandwidth": {
|
||||||
"label": "Netzwerk Bandbreite",
|
"label": "Netzwerk Bandbreite",
|
||||||
"description": "Aktivieren Sie die prozessbezogene Überwachung der Netzwerkbandbreite für Kamera-FFmpeg-Prozesse und Detektoren (erfordert entsprechende Funktionen)."
|
"description": "Prozessbezogene Überwachung der Netzwerkbandbreite für Kamera-FFmpeg-Prozesse und Detektoren aktivieren (erfordert entsprechende Funktionen)."
|
||||||
},
|
},
|
||||||
"intel_gpu_device": {
|
"intel_gpu_device": {
|
||||||
"label": "Intel GPU",
|
"label": "Intel GPU",
|
||||||
@@ -1402,7 +1402,7 @@
|
|||||||
"description": "Maximale Anzahl der gleichzeitig zu verarbeitenden Exportaufträge."
|
"description": "Maximale Anzahl der gleichzeitig zu verarbeitenden Exportaufträge."
|
||||||
},
|
},
|
||||||
"chapters": {
|
"chapters": {
|
||||||
"label": "Kapitel-Metadaten zur Einbettung in exportierte Aufzeichnungen"
|
"label": "Kapitel-Metadaten, die in exportierte Aufzeichnungen eingebettet werden sollen"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"preview": {
|
"preview": {
|
||||||
|
|||||||
@@ -126,6 +126,6 @@
|
|||||||
"baby_stroller": "Kinderwagen",
|
"baby_stroller": "Kinderwagen",
|
||||||
"rickshaw": "Rikscha",
|
"rickshaw": "Rikscha",
|
||||||
"rodent": "Nagetier",
|
"rodent": "Nagetier",
|
||||||
"garbage_truck": "Müllfahrzeug",
|
"garbage_truck": "Müllwagen",
|
||||||
"possum": "Possum"
|
"possum": "Opossum"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,9 +56,9 @@
|
|||||||
},
|
},
|
||||||
"deleteModel": {
|
"deleteModel": {
|
||||||
"title": "Klassifizierungsmodell löschen",
|
"title": "Klassifizierungsmodell löschen",
|
||||||
"single": "Möchten Sie {{name}} wirklich löschen? Dadurch werden alle zugehörigen Daten, einschließlich Bilder und Trainingsdaten, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",
|
"single": "{{name}} wirklich löschen? Dadurch werden alle zugehörigen Daten, einschließlich Bilder und Trainingsdaten, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",
|
||||||
"desc_one": "Möchtest du {{count}} Modell wirklich löschen? Dadurch werden alle zugehörigen Daten, einschließlich Bilder und Trainingsdaten, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",
|
"desc_one": "{{count}} Modell wirklich löschen? Dadurch werden alle zugehörigen Daten, einschließlich Bilder und Trainingsdaten, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",
|
||||||
"desc_other": "Möchtest du {{count}} Modelle wirklich löschen? Dadurch werden alle zugehörigen Daten, einschließlich Bilder und Trainingsdaten, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden."
|
"desc_other": "{{count}} Modelle wirklich löschen? Dadurch werden alle zugehörigen Daten, einschließlich Bilder und Trainingsdaten, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden."
|
||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"title": "Klassifikationsmodell bearbeiten",
|
"title": "Klassifikationsmodell bearbeiten",
|
||||||
@@ -75,19 +75,19 @@
|
|||||||
"intervalDesc": "Sekundenabstand zwischen regelmäßigen Klassifizierungsläufen. Leer lassen, um die Klassifizierung nur bei Bewegung auszuführen.",
|
"intervalDesc": "Sekundenabstand zwischen regelmäßigen Klassifizierungsläufen. Leer lassen, um die Klassifizierung nur bei Bewegung auszuführen.",
|
||||||
"intervalPlaceholder": "Kein Intervall",
|
"intervalPlaceholder": "Kein Intervall",
|
||||||
"errors": {
|
"errors": {
|
||||||
"saveAttemptsInvalid": "Sparversuche müssen eine ganze Zahl von 0 oder mehr sein",
|
"saveAttemptsInvalid": "Die Anzahl der Speicherversuche muss eine ganze Zahl sein, die größer oder gleich 0 ist",
|
||||||
"intervalInvalid": "Intervall muss eine ganze Nummer sein größer als 0"
|
"intervalInvalid": "Intervall muss eine ganze Zahl sein, die größer als 0 ist"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"deleteDatasetImages": {
|
"deleteDatasetImages": {
|
||||||
"title": "Datensatz Bilder löschen",
|
"title": "Datensatz Bilder löschen",
|
||||||
"desc_one": "Bist du sicher, dass {{count}} Bild von {{dataset}} gelöscht werden sollen? Diese Aktion kann nicht rückgängig gemacht werden und erfordert ein erneutes Trainieren des Modells.",
|
"desc_one": "Wirklich {{count}} Bild von {{dataset}} löschen? Diese Aktion kann nicht rückgängig gemacht werden und erfordert ein erneutes Trainieren des Modells.",
|
||||||
"desc_other": "Bist du sicher, dass {{count}} Bilder von {{dataset}} gelöscht werden sollen? Diese Aktion kann nicht rückgängig gemacht werden und erfordert ein erneutes Trainieren des Modells."
|
"desc_other": "Wirklich {{count}} Bilder von {{dataset}} löschen? Diese Aktion kann nicht rückgängig gemacht werden und erfordert ein erneutes Trainieren des Modells."
|
||||||
},
|
},
|
||||||
"deleteTrainImages": {
|
"deleteTrainImages": {
|
||||||
"title": "Trainingsbilder löschen",
|
"title": "Trainingsbilder löschen",
|
||||||
"desc_one": "Bist du sicher, dass du {{count}} Bild löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",
|
"desc_one": "Wirklich {{count}} Bild löschen? Diese Aktion kann nicht rückgängig gemacht werden.",
|
||||||
"desc_other": "Bist du sicher, dass du {{count}} Bilder löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden."
|
"desc_other": "Wirklich {{count}} Bilder löschen? Diese Aktion kann nicht rückgängig gemacht werden."
|
||||||
},
|
},
|
||||||
"renameCategory": {
|
"renameCategory": {
|
||||||
"title": "Klasse umbenennen",
|
"title": "Klasse umbenennen",
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
},
|
},
|
||||||
"train": {
|
"train": {
|
||||||
"title": "Neue Klassifizierungen",
|
"title": "Neue Klassifizierungen",
|
||||||
"titleShort": "frisch",
|
"titleShort": "Neu",
|
||||||
"aria": "Neue Klassifizierungen auswählen"
|
"aria": "Neue Klassifizierungen auswählen"
|
||||||
},
|
},
|
||||||
"categories": "Klassen",
|
"categories": "Klassen",
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
"menuItem": "Bewegungsvorschau anzeigen",
|
"menuItem": "Bewegungsvorschau anzeigen",
|
||||||
"title": "Bewegungsvorschau: {{camera}}",
|
"title": "Bewegungsvorschau: {{camera}}",
|
||||||
"mobileSettingsTitle": "Einstellungen für die Bewegungsvorschau",
|
"mobileSettingsTitle": "Einstellungen für die Bewegungsvorschau",
|
||||||
"mobileSettingsDesc": "Passen Sie die Wiedergabegeschwindigkeit und die Dimmung an und wählen Sie ein Datum aus, um Clips mit nur Bewegungen anzusehen.",
|
"mobileSettingsDesc": "Passen Sie die Wiedergabegeschwindigkeit, die Dimmung und den Zuschnitt an und wählen Sie ein Datum aus, um Clips mit ausschließlich erkannten Bewegungen zu überprüfen.",
|
||||||
"dim": "düster",
|
"dim": "düster",
|
||||||
"dimAria": "Dimmintensität einstellen",
|
"dimAria": "Dimmintensität einstellen",
|
||||||
"dimDesc": "Erhöhen Sie die Dimmung, um die Sichtbarkeit des Bewegungsbereichs zu verbessern.",
|
"dimDesc": "Erhöhen Sie die Dimmung, um die Sichtbarkeit des Bewegungsbereichs zu verbessern.",
|
||||||
@@ -89,6 +89,9 @@
|
|||||||
"seekAria": "{{camera}} Player suchen bis {{time}}",
|
"seekAria": "{{camera}} Player suchen bis {{time}}",
|
||||||
"filter": "Filter",
|
"filter": "Filter",
|
||||||
"filterDesc": "Wählen Sie Bereiche aus, um nur Clips mit Bewegungen in diesen Regionen anzuzeigen.",
|
"filterDesc": "Wählen Sie Bereiche aus, um nur Clips mit Bewegungen in diesen Regionen anzuzeigen.",
|
||||||
"filterClear": "Säubern"
|
"filterClear": "Säubern",
|
||||||
|
"crop": "Auf Filterbereich zuschneiden",
|
||||||
|
"cropAria": "Vorschauen auf die gefilterten Bereiche zuschneiden ein- oder ausschalten",
|
||||||
|
"cropDesc": "Zeigt eine vergrößerte Vorschau der ausgewählten Filterbereiche an, statt das vollständige Bild zu zeigen."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
"title": "Neueste Erkennungen",
|
"title": "Neueste Erkennungen",
|
||||||
"aria": "Wähle aktuelle Erkennungen",
|
"aria": "Wähle aktuelle Erkennungen",
|
||||||
"empty": "Es gibt keine aktuellen Versuche zur Gesichtserkennung",
|
"empty": "Es gibt keine aktuellen Versuche zur Gesichtserkennung",
|
||||||
"titleShort": "frisch",
|
"titleShort": "Neu",
|
||||||
"emptyNoLibrary": {
|
"emptyNoLibrary": {
|
||||||
"title": "Gesicht hinzufügen",
|
"title": "Gesicht hinzufügen",
|
||||||
"description": "Sie müssen mindestens ein Gesicht zur Bibliothek hinzufügen, damit die Gesichtserkennung funktioniert."
|
"description": "Sie müssen mindestens ein Gesicht zur Bibliothek hinzufügen, damit die Gesichtserkennung funktioniert."
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
"error": "Fehler beim Starten der Debug-Wiedergabe: {{error}}",
|
"error": "Fehler beim Starten der Debug-Wiedergabe: {{error}}",
|
||||||
"alreadyActive": "Eine Wiederholungssitzung ist bereits aktiv",
|
"alreadyActive": "Eine Wiederholungssitzung ist bereits aktiv",
|
||||||
"stopError": "Die Wiedergabe der Debug-Daten konnte nicht beendet werden: {{error}}",
|
"stopError": "Die Wiedergabe der Debug-Daten konnte nicht beendet werden: {{error}}",
|
||||||
"goToReplay": "Zur Aufzeichnung"
|
"goToReplay": "Zur Aufzeichnung",
|
||||||
|
"noRecordings": "Keine Aufnahmen im ausgewählten Zeitraum gefunden"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
|
|||||||
@@ -1383,7 +1383,7 @@
|
|||||||
"webuiUrlHelp": "URL, um die Web-Benutzeroberfläche der Kamera direkt aus der Debug-Ansicht aufzurufen. Lassen Sie das Feld leer, um den Link zu deaktivieren.",
|
"webuiUrlHelp": "URL, um die Web-Benutzeroberfläche der Kamera direkt aus der Debug-Ansicht aufzurufen. Lassen Sie das Feld leer, um den Link zu deaktivieren.",
|
||||||
"webuiUrlInvalid": "Es muss sich um eine gültige URL handeln (z. B. https://example.com).",
|
"webuiUrlInvalid": "Es muss sich um eine gültige URL handeln (z. B. https://example.com).",
|
||||||
"dashboardLabel": "Im Live-Dashboard anzeigen",
|
"dashboardLabel": "Im Live-Dashboard anzeigen",
|
||||||
"dashboardHelp": "Zeige diese Kamera auf dem Standard Alle Kameras live dashboard. Es bleibt überall verfügbar, einschließlich Kameragruppen.",
|
"dashboardHelp": "Diese Kamera im Standard Dashboard \"Alle Live Kameras\" anzeigen. Sie bleibt überall sonst verfügbar einschließlich Kameragruppen.",
|
||||||
"reviewLabel": "In der Überprüfung anzeigen",
|
"reviewLabel": "In der Überprüfung anzeigen",
|
||||||
"reviewHelp": "Zeige diese Kamera in der Übersicht an, einschließlich des Kamerafilters, der Bewegungsübersicht und der Verlaufsansicht."
|
"reviewHelp": "Zeige diese Kamera in der Übersicht an, einschließlich des Kamerafilters, der Bewegungsübersicht und der Verlaufsansicht."
|
||||||
},
|
},
|
||||||
@@ -1608,8 +1608,8 @@
|
|||||||
"overriddenInCameras": {
|
"overriddenInCameras": {
|
||||||
"label_one": "In {{count}} Kamera überschrieben",
|
"label_one": "In {{count}} Kamera überschrieben",
|
||||||
"label_other": "In {{count}} Kameras überschrieben",
|
"label_other": "In {{count}} Kameras überschrieben",
|
||||||
"tooltip_one": "Die Kamera mit der Nummer {{count}} überschreibt die Werte in diesem Abschnitt. Klicken Sie hier, um Details anzuzeigen.",
|
"tooltip_one": "Die Kamera mit der Nummer {{count}} überschreibt die Werte in diesem Abschnitt. Hier klicken, um Details anzuzeigen.",
|
||||||
"tooltip_other": "Die Kamera mit der Nummer {{count}} überschreibt die Werte in diesem Abschnitt. Klicken Sie hier, um Details anzuzeigen.",
|
"tooltip_other": "{{count}} Kameras überschreiben die Werte in diesem Abschnitt. Hier klicken, um Details anzuzeigen.",
|
||||||
"heading_one": "Dieser globale Abschnitt enthält Felder, die in {{count}} Kamera überschrieben werden.",
|
"heading_one": "Dieser globale Abschnitt enthält Felder, die in {{count}} Kamera überschrieben werden.",
|
||||||
"heading_other": "Dieser globale Abschnitt enthält Felder, die bei {{count}} Kameras überschrieben werden.",
|
"heading_other": "Dieser globale Abschnitt enthält Felder, die bei {{count}} Kameras überschrieben werden.",
|
||||||
"othersField_one": "{{count}} andere",
|
"othersField_one": "{{count}} andere",
|
||||||
@@ -1721,13 +1721,13 @@
|
|||||||
"valueLabel": "Wert",
|
"valueLabel": "Wert",
|
||||||
"keyPlaceholder": "Neuer Schlüssel",
|
"keyPlaceholder": "Neuer Schlüssel",
|
||||||
"remove": "Entfernen",
|
"remove": "Entfernen",
|
||||||
"providerNameLabel": "Name des Anbieters",
|
"providerNameLabel": "Anbietername",
|
||||||
"providerNamePlaceholder": "z.B. openai",
|
"providerNamePlaceholder": "z. B. openai",
|
||||||
"variableNameLabel": "Variabler Name",
|
"variableNameLabel": "Variablenname",
|
||||||
"variableNamePlaceholder": "z.B. MY_VARIABLE",
|
"variableNamePlaceholder": "z.B. MY_VARIABLE",
|
||||||
"loggerNameLabel": "Name des Loggers",
|
"loggerNameLabel": "Name des Loggers",
|
||||||
"loggerNamePlaceholder": "z.B. frigate.record",
|
"loggerNamePlaceholder": "z.B. frigate.record",
|
||||||
"keyPatternError": "Verwenden Sie nur Buchstaben, Zahlen, Bindestriche und Unterstriche (keine Leerzeichen)"
|
"keyPatternError": "Verwende nur Buchstaben, Zahlen, Bindestriche und Unterstriche (keine Leerzeichen)"
|
||||||
},
|
},
|
||||||
"timezone": {
|
"timezone": {
|
||||||
"defaultOption": "Zeitzone des Browsers verwenden"
|
"defaultOption": "Zeitzone des Browsers verwenden"
|
||||||
@@ -2142,7 +2142,8 @@
|
|||||||
"autotrackingNoZones": "Für die automatische Verfolgung ist mindestens eine Zone erforderlich. Definieren Sie unter „Masken / Zonen“ eine Zone für diese Kamera und legen Sie diese anschließend unten als erforderliche Zone fest."
|
"autotrackingNoZones": "Für die automatische Verfolgung ist mindestens eine Zone erforderlich. Definieren Sie unter „Masken / Zonen“ eine Zone für diese Kamera und legen Sie diese anschließend unten als erforderliche Zone fest."
|
||||||
},
|
},
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
"hwaccelManualNotRecommended": "Explizite Definitionen der Hardware-beschleunigungs Variablen sind nicht empfohlen. Wähle die Voreinstellung die zu deiner Hardware passt, außer wenn spezifische Anforderungen eine andere Konfiguration erfordern."
|
"hwaccelManualNotRecommended": "Explizite Definitionen der Hardware-beschleunigungs Variablen sind nicht empfohlen. Wähle die Voreinstellung die zu deiner Hardware passt, außer wenn spezifische Anforderungen eine andere Konfiguration erfordern.",
|
||||||
|
"inputsMissingGo2rtcStream": "Ein Eingabefeld unten verweist auf einen go2rtc-Restream, der nicht mehr existiert. Wählen Sie einen vorhandenen Restream aus oder geben Sie die URL der Kamera manuell ein. Andernfalls kann keine Verbindung zu dieser Kamera hergestellt werden."
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"optimizedFor320": "Frigate ist für ein 320x320-Modell optimiert, was für die meisten Konfigurationen die beste Wahl ist. Ein 640x640-Modell ist langsamer und bietet nur in bestimmten Szenarien Vorteile.",
|
"optimizedFor320": "Frigate ist für ein 320x320-Modell optimiert, was für die meisten Konfigurationen die beste Wahl ist. Ein 640x640-Modell ist langsamer und bietet nur in bestimmten Szenarien Vorteile.",
|
||||||
|
|||||||
@@ -71,24 +71,8 @@
|
|||||||
"description": "Enable or disable the Birdseye view feature."
|
"description": "Enable or disable the Birdseye view feature."
|
||||||
},
|
},
|
||||||
"mode": {
|
"mode": {
|
||||||
"label": "Activity types",
|
"label": "Tracking mode",
|
||||||
"description": "Activity types that include cameras in Birdseye.",
|
"description": "Mode for including cameras in Birdseye: 'objects', 'motion', or 'continuous'."
|
||||||
"continuous": {
|
|
||||||
"label": "Continuous",
|
|
||||||
"description": "Always include the camera in Birdseye."
|
|
||||||
},
|
|
||||||
"motion": {
|
|
||||||
"label": "Motion",
|
|
||||||
"description": "Include the camera in Birdseye when motion is detected."
|
|
||||||
},
|
|
||||||
"objects": {
|
|
||||||
"label": "Active objects",
|
|
||||||
"description": "Include the camera in Birdseye while an active object is tracked."
|
|
||||||
},
|
|
||||||
"stationary_objects": {
|
|
||||||
"label": "Stationary objects",
|
|
||||||
"description": "Include the camera in Birdseye while a stationary object is tracked."
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"order": {
|
"order": {
|
||||||
"label": "Position",
|
"label": "Position",
|
||||||
@@ -110,10 +94,6 @@
|
|||||||
"label": "Detect width",
|
"label": "Detect width",
|
||||||
"description": "Width (pixels) of frames used for the detect stream; leave empty to use the native stream resolution."
|
"description": "Width (pixels) of frames used for the detect stream; leave empty to use the native stream resolution."
|
||||||
},
|
},
|
||||||
"scene": {
|
|
||||||
"label": "Detect scene",
|
|
||||||
"description": "The environment this camera looks at, used to pick which of the configured models runs on it. Defaults to the model with a scene of 'all'."
|
|
||||||
},
|
|
||||||
"fps": {
|
"fps": {
|
||||||
"label": "Detect FPS",
|
"label": "Detect FPS",
|
||||||
"description": "Desired frames per second to run detection on; lower values reduce CPU usage (recommended value is 5, only set higher - at most 10 - if tracking extremely fast moving objects)."
|
"description": "Desired frames per second to run detection on; lower values reduce CPU usage (recommended value is 5, only set higher - at most 10 - if tracking extremely fast moving objects)."
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user