Compare commits

...
24 Commits
Author SHA1 Message Date
Josh Hawkins 6fce18f156 update network requirements docs 2026-09-22 12:29:40 -05:00
Josh Hawkins 7001623ba2 fixes 2026-09-22 12:15:33 -05:00
Josh Hawkins f8c180319c change wording 2026-09-22 11:03:24 -05:00
Josh Hawkins 8b5dc77891 Document anonymous analytics 2026-09-22 08:34:34 -05:00
Josh Hawkins 3990a64988 Show the analytics preview in telemetry settings 2026-09-22 08:31:00 -05:00
Josh Hawkins f185e64379 Record the image variant in each Dockerfile 2026-09-22 08:25:58 -05:00
Josh Hawkins 635aee552e Generate the analytics schema and check it in CI 2026-09-22 08:24:01 -05:00
Josh Hawkins 1834d9a22e Add the analytics preview API 2026-09-22 08:22:45 -05:00
Josh Hawkins f0d070899f Send the daily analytics report from the main process 2026-09-22 08:20:24 -05:00
Josh Hawkins 92e2a8b444 Add the analytics report transport 2026-09-22 08:18:03 -05:00
Josh Hawkins a8ed8b8592 Build analytics reports from the section collectors 2026-09-22 08:17:01 -05:00
Josh Hawkins 7f2fd71d12 Add the health analytics collector 2026-09-22 08:16:01 -05:00
Josh Hawkins 274277b85e Add the features analytics collector 2026-09-22 08:15:19 -05:00
Josh Hawkins faa0b68bc4 Add the cameras analytics collector 2026-09-22 08:14:20 -05:00
Josh Hawkins c252e07ffb Add the detection analytics collector 2026-09-22 08:13:13 -05:00
Josh Hawkins 90e1fa756d Add the install and hardware analytics collectors 2026-09-22 08:12:37 -05:00
Josh Hawkins ab43524fe2 Add the analytics state file 2026-09-22 08:10:10 -05:00
Josh Hawkins 51eb5058b3 Add the analytics report schema 2026-09-22 08:09:44 -05:00
Josh Hawkins aa72e555f5 Add analytics opt-in setting, prompt notice kind, and notice watermarks 2026-09-22 08:08:23 -05:00
A. AhmetGitHubgreptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
af0ba19196 Feat/deepx npu detector (#24336)
CI / AMD64 Build (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s
* feat(deepx): add DEEPX NPU detector and runtime integration.

* feat(deepx): enforce model_format requirement when ppu is enabled and add integrity checks for driver installation

* Update frigate/detectors/plugins/deepx.py

Public method lacks docstring

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Refactor DEEPX detector tests, support SSD and DAMO-YOLO

* feat(deepx): add anchor-free output decoding and corresponding tests

* Add tests and updates for DEEPX detector and refactor DEEPX accelerator code structure.

* fix: enhance model type validation and update documentation for DEEPX detector

* fix: add support for customizable score and NMS thresholds

* refactor: infer YOLO layout from the model, drop per-detector options and the dxrtd placeholder

* fix: keep only the anchor-free PPU verdict, re-read anchor-based each frame

* Update latency data for DEEPX NPU

* Expanding PPU support for DEEPX and set yolo-generic as default.

* enhance scale count resolution logic

* Extend PPU layout handling and YOLOX support to DEEPX detector

* fix: assume the largest PPU anchor table when the .dxnn has no layout

* Improve PPU decoding and introduce strides handling

* Improve PPU scope and fix box format mismatch

* Fix unnamed node issue that breaks traversal

* fix: update object detection model type description to remove outdated architecture

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-09-21 07:50:44 -05:00
Josh HawkinsandGitHub 52f50a7396 Tweaks (#24418)
CI / AMD64 Build (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s
* don't display audio transcription provider message as health notice

* show remote provider for audio transcription in health pane

* adjust trigger and notifications messages to be consistent with the rest of the settings UI

* disable save buttons when there are no changes in config editor

* fix audio manager crash when a camera is added at runtime

The audio processor and the camera maintainer both poll the same `add` config update on their own one second timers, and the maintainer is what creates `camera_metrics[name]`. When the audio processor got there first it looked the new camera up before that entry existed, and the `KeyError` took down the whole `frigate.audio_manager` process. Whether it happens depends purely on which poll fires first, so cloning a camera from the UI fails or succeeds at random. `spawn_if_needed` now skips a camera whose metrics aren't there yet and picks it up on the next poll, the same way it already waits on a late ffmpeg update.

`AudioEventMaintainer` holds the `CameraMetrics` object now instead of indexing the manager dict on every audio chunk, which drops the IPC round trips and means a removed camera can't `KeyError` out of `detect_audio` after the maintainer pops the entry. The audio process is also registered with the watchdog, since a crash there previously left audio detection dead for every camera until a full restart, and it now receives the shared `DataProcessorMetrics` so `AudioTranscriptionRealTimeProcessor` gets the same type as the other real time processors.

* fix stationary max_frames dropping other tracked objects

When `max_frames` was set for a label, deregistering one object rebuilt norfair's list with a filter that kept an object only if it was both not the target and already on its way out, so every other healthy object of that label was dropped along with it. Any car leaving the frame took the rest of the cars with it and they came back as new tracked objects a few frames later. The filter now removes only the target, and objects that are expiring are still reaped by norfair on the next update.

* fix test

* fix skip_motion_threshold permanently disabling motion detection

The skip check returned before the two `accumulateWeighted` calls at the end of `detect`, so a skipped frame never made it into the background and setting `calibrating` there only picked a faster alpha for calls that never ran. `avg_frame` starts as an all zero image and a normally lit scene differs from black across nearly the whole frame, so the cameras I tested measure 0.84 to 0.98 against it. Any `skip_motion_threshold` below that number skips the first frame, leaves the background black, and skips every frame after it. Motion detection is dead for that camera until the setting is removed or Frigate restarts, with no motion boxes, no motion recordings, and no regions for the tracker since the detector stays calibrating.

Startup isn't the only way in. `update_mask` zeroes the background on any motion config change, and once a camera has calibrated the first IR switch or PTZ move freezes the background on the old scene, so it can't transition to the new one, which is the case the option exists for. The frame is now blended in before the early return at the same 0.2 alpha the calibrating path uses elsewhere, so a large scene change is still suppressed while the background catches up, about a second on a 5 fps camera, and then motion comes back.

* dump ffmpeg logs on every restart

The record watchdog restarted ffmpeg without flushing its `LogPipe`, so a camera whose recording segments went stale never showed a single line of ffmpeg output. The dump now happens in `start_or_restart_ffmpeg` right after the stop, which covers the stale record path, the record crash path, and the audio restart. `reset_capture_thread` and the audio `log_and_restart` fallback keep their own dumps since both pass `ffmpeg_process=None`.

* dump ffmpeg logs once per restart

The audio restart path dumped the log pipe itself before calling the helper, so the restart dump printed a second "last 100 lines" heading over an already drained deque and split the tail that `stop_ffmpeg` flushed into its own section. The heading is now only printed when there's something under it, and the audio path leaves the dump to the restart so each failure produces one section.

* keep all logpipe dumps consistent
2026-09-20 12:45:24 -06:00
+11 285dd5a461 Translations update from Hosted Weblate (#24333)
CI / AMD64 Build (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s
* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Thai)

Currently translated at 86.0% (430 of 500 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: วรรณรุจ บุญแสง <wan.ball@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/audio/th/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/audio
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (66 of 66 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 57.7% (436 of 755 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 57.7% (436 of 755 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 58.8% (83 of 141 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (129 of 129 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (24 of 24 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 57.4% (434 of 755 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (506 of 506 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 49.6% (70 of 141 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 49.8% (134 of 269 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 38.4% (518 of 1348 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (39 of 39 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (118 of 118 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (264 of 264 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (500 of 500 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Marco Cordeiro <marcoecordeiro@gmail.com>
Co-authored-by: webmaster mvfc <webmaster@mvfc.com.br>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/audio/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-cameras/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-global/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-validation/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/objects/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-chat/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-classificationmodel/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-settings/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-system/pt_BR/
Translation: Frigate NVR/Config - Cameras
Translation: Frigate NVR/Config - Global
Translation: Frigate NVR/Config - Validation
Translation: Frigate NVR/audio
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-player
Translation: Frigate NVR/objects
Translation: Frigate NVR/views-chat
Translation: Frigate NVR/views-classificationmodel
Translation: Frigate NVR/views-settings
Translation: Frigate NVR/views-system

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Danish)

Currently translated at 69.4% (347 of 500 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Martin Grüner <mrenurg@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/audio/da/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/audio
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Translated using Weblate (Estonian)

Currently translated at 19.4% (148 of 759 strings)

Translated using Weblate (Estonian)

Currently translated at 14.7% (75 of 508 strings)

Translated using Weblate (Estonian)

Currently translated at 100.0% (35 of 35 strings)

Translated using Weblate (Estonian)

Currently translated at 100.0% (264 of 264 strings)

Translated using Weblate (Estonian)

Currently translated at 69.4% (347 of 500 strings)

Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Estonian)

Currently translated at 14.1% (20 of 141 strings)

Translated using Weblate (Estonian)

Currently translated at 100.0% (66 of 66 strings)

Translated using Weblate (Estonian)

Currently translated at 100.0% (24 of 24 strings)

Translated using Weblate (Estonian)

Currently translated at 29.5% (399 of 1348 strings)

Translated using Weblate (Estonian)

Currently translated at 100.0% (68 of 68 strings)

Translated using Weblate (Estonian)

Currently translated at 69.2% (27 of 39 strings)

Translated using Weblate (Estonian)

Currently translated at 100.0% (118 of 118 strings)

Translated using Weblate (Estonian)

Currently translated at 90.9% (240 of 264 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Kaius Karon <kaiuskaron@gmail.com>
Co-authored-by: Priit Jõerüüt <jrthwlate@users.noreply.hosted.weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/audio/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-cameras/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-global/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-validation/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-chat/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-classificationmodel/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-events/et/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-settings/et/
Translation: Frigate NVR/Config - Cameras
Translation: Frigate NVR/Config - Global
Translation: Frigate NVR/Config - Validation
Translation: Frigate NVR/audio
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-player
Translation: Frigate NVR/views-chat
Translation: Frigate NVR/views-classificationmodel
Translation: Frigate NVR/views-events
Translation: Frigate NVR/views-settings

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Russian)

Currently translated at 90.9% (240 of 264 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Павел Фролов <armagedetz@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/ru/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/common
Translation: Frigate NVR/components-player

* Translated using Weblate (Romanian)

Currently translated at 100.0% (66 of 66 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (24 of 24 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (759 of 759 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (508 of 508 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (269 of 269 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (1366 of 1366 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (119 of 119 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (87 of 87 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (68 of 68 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (35 of 35 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (118 of 118 strings)

Translated using Weblate (Romanian)

Currently translated at 100.0% (264 of 264 strings)

Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: lukasig <lukasig@hotmail.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-cameras/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-global/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-validation/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-chat/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-events/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-exports/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-live/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-settings/ro/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-system/ro/
Translation: Frigate NVR/Config - Cameras
Translation: Frigate NVR/Config - Global
Translation: Frigate NVR/Config - Validation
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-player
Translation: Frigate NVR/views-chat
Translation: Frigate NVR/views-events
Translation: Frigate NVR/views-exports
Translation: Frigate NVR/views-live
Translation: Frigate NVR/views-settings
Translation: Frigate NVR/views-system

* Translated using Weblate (Belarusian)

Currently translated at 100.0% (264 of 264 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (269 of 269 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (1348 of 1348 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (119 of 119 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (60 of 60 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (87 of 87 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (68 of 68 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (66 of 66 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (24 of 24 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (755 of 755 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (506 of 506 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (35 of 35 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (118 of 118 strings)

Translated using Weblate (Belarusian)

Currently translated at 100.0% (264 of 264 strings)

Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Uladz Maltsau <wldyslw@icloud.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-cameras/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-global/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-validation/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-chat/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-events/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-exports/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-facelibrary/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-live/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-settings/be/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-system/be/
Translation: Frigate NVR/Config - Cameras
Translation: Frigate NVR/Config - Global
Translation: Frigate NVR/Config - Validation
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-player
Translation: Frigate NVR/views-chat
Translation: Frigate NVR/views-events
Translation: Frigate NVR/views-exports
Translation: Frigate NVR/views-facelibrary
Translation: Frigate NVR/views-live
Translation: Frigate NVR/views-settings
Translation: Frigate NVR/views-system

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Ukrainian)

Currently translated at 90.5% (239 of 264 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Павел Фролов <armagedetz@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/uk/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/common
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Translated using Weblate (Catalan)

Currently translated at 100.0% (759 of 759 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (508 of 508 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (1366 of 1366 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (118 of 118 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (757 of 757 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (508 of 508 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (1350 of 1350 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (119 of 119 strings)

Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Catalan)

Currently translated at 100.0% (66 of 66 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (755 of 755 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (24 of 24 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (506 of 506 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (269 of 269 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (1348 of 1348 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (87 of 87 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (68 of 68 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (39 of 39 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (118 of 118 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Eduardo Pastor Fernández <123eduardoneko123@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-cameras/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-global/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-validation/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-chat/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-events/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-exports/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-live/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-settings/ca/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-system/ca/
Translation: Frigate NVR/Config - Cameras
Translation: Frigate NVR/Config - Global
Translation: Frigate NVR/Config - Validation
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-player
Translation: Frigate NVR/views-chat
Translation: Frigate NVR/views-events
Translation: Frigate NVR/views-exports
Translation: Frigate NVR/views-live
Translation: Frigate NVR/views-settings
Translation: Frigate NVR/views-system

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Translated using Weblate (Polish)

Currently translated at 92.4% (244 of 264 strings)

Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: An Pa <andrzej.pasterczyk@googlemail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/pl/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/common
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Italian)

Currently translated at 92.1% (696 of 755 strings)

Translated using Weblate (Italian)

Currently translated at 90.9% (240 of 264 strings)

Translated using Weblate (Italian)

Currently translated at 92.0% (695 of 755 strings)

Translated using Weblate (Italian)

Currently translated at 94.1% (1269 of 1348 strings)

Translated using Weblate (Italian)

Currently translated at 91.5% (108 of 118 strings)

Co-authored-by: Gringo <ita.translations@tiscali.it>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/it/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/it/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-global/it/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-settings/it/
Translation: Frigate NVR/Config - Global
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-player
Translation: Frigate NVR/views-settings

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Indonesian)

Currently translated at 17.7% (134 of 755 strings)

Translated using Weblate (Indonesian)

Currently translated at 30.4% (154 of 506 strings)

Translated using Weblate (Indonesian)

Currently translated at 97.4% (38 of 39 strings)

Translated using Weblate (Indonesian)

Currently translated at 100.0% (74 of 74 strings)

Translated using Weblate (Indonesian)

Currently translated at 99.1% (117 of 118 strings)

Translated using Weblate (Indonesian)

Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Catto <sisharyadi@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/id/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/id/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-filter/id/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/id/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-cameras/id/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-global/id/
Translation: Frigate NVR/Config - Cameras
Translation: Frigate NVR/Config - Global
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-filter
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Dutch)

Currently translated at 73.5% (64 of 87 strings)

Translated using Weblate (Dutch)

Currently translated at 98.3% (116 of 118 strings)

Translated using Weblate (Dutch)

Currently translated at 100.0% (264 of 264 strings)

Translated using Weblate (Dutch)

Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Herik <wvdh2002@hotmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Rémon <remon@megelink.net>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/nl/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/nl/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-exports/nl/
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-player
Translation: Frigate NVR/views-exports

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Spanish)

Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Santiago Burgues <santibur06@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/es/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/common
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Swedish)

Currently translated at 95.0% (251 of 264 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Simon <simon.lappas2000@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/sv/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/common
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Korean)

Currently translated at 100.0% (66 of 66 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (24 of 24 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (755 of 755 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (506 of 506 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (269 of 269 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (1348 of 1348 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (68 of 68 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (87 of 87 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (39 of 39 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (118 of 118 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: sinfancy <yujsjs@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-dialog/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-cameras/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-global/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/config-validation/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-chat/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-events/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-exports/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-settings/ko/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-system/ko/
Translation: Frigate NVR/Config - Cameras
Translation: Frigate NVR/Config - Global
Translation: Frigate NVR/Config - Validation
Translation: Frigate NVR/common
Translation: Frigate NVR/components-dialog
Translation: Frigate NVR/components-player
Translation: Frigate NVR/views-chat
Translation: Frigate NVR/views-events
Translation: Frigate NVR/views-exports
Translation: Frigate NVR/views-settings
Translation: Frigate NVR/views-system

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translation: Frigate NVR/components-player

* Update translation files

Updated by "Cleanup translation files" add-on in Weblate.

Translated using Weblate (Cantonese (Traditional Han script))

Currently translated at 47.7% (643 of 1348 strings)

Translated using Weblate (Cantonese (Traditional Han script))

Currently translated at 92.0% (243 of 264 strings)

Co-authored-by: ERK <sunnytse1@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/common/yue_Hant/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/components-player/
Translate-URL: https://hosted.weblate.org/projects/frigate-nvr/views-settings/yue_Hant/
Translation: Frigate NVR/common
Translation: Frigate NVR/components-player
Translation: Frigate NVR/views-settings

---------

Co-authored-by: วรรณรุจ บุญแสง <wan.ball@gmail.com>
Co-authored-by: Marco Cordeiro <marcoecordeiro@gmail.com>
Co-authored-by: webmaster mvfc <webmaster@mvfc.com.br>
Co-authored-by: Martin Grüner <mrenurg@gmail.com>
Co-authored-by: Kaius Karon <kaiuskaron@gmail.com>
Co-authored-by: Priit Jõerüüt <jrthwlate@users.noreply.hosted.weblate.org>
Co-authored-by: Павел Фролов <armagedetz@gmail.com>
Co-authored-by: lukasig <lukasig@hotmail.com>
Co-authored-by: Uladz Maltsau <wldyslw@icloud.com>
Co-authored-by: Eduardo Pastor Fernández <123eduardoneko123@gmail.com>
Co-authored-by: An Pa <andrzej.pasterczyk@googlemail.com>
Co-authored-by: Gringo <ita.translations@tiscali.it>
Co-authored-by: Catto <sisharyadi@gmail.com>
Co-authored-by: Herik <wvdh2002@hotmail.com>
Co-authored-by: Rémon <remon@megelink.net>
Co-authored-by: Santiago Burgues <santibur06@gmail.com>
Co-authored-by: Simon <simon.lappas2000@gmail.com>
Co-authored-by: sinfancy <yujsjs@gmail.com>
Co-authored-by: ERK <sunnytse1@gmail.com>
2026-09-19 07:16:00 -05:00
Josh HawkinsandGitHub 3d08bbe520 Miscellaneous fixes (#24402)
CI / AMD64 Build (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s
* check for a valid frame before using its shape

With the camera offline, no preview frame, and `camera-error.jpg` missing, `latest_frame` read `frame.shape` before its `frame is None` check, so it raised `AttributeError` and answered 500 with a traceback instead of the intended "Unable to get valid frame". The check now runs first.

* fix the has_clip self-heal for events with no recordings

`vod_event` looked for a `(body, 404)` tuple, but `vod_ts` returns a `JSONResponse`, so the check never matched and an old event whose recordings are gone kept offering a clip that can't play. It now checks the response status code.

* return 403 for a snapshot or thumbnail on another camera

The broad `except Exception` handlers in `event_snapshot` and `event_thumbnail` caught the `HTTPException` from `require_camera_access`, so a restricted user asking for another camera's snapshot got a 404 instead of a 403, and for an object still being tracked the snapshot was rendered before the check ran. Both endpoints now look up the event and check access in their own block, the way the other endpoints do, so a denial propagates.

* find DST transitions to the second

`get_dst_transitions` probed the offset once every 24 hours from the start time and reported a change at the first probe after it, up to a day late, so events, review items and recordings near a transition were grouped into days with the old offset. A transition after the last daily probe wasn't found at all. The end of the range is probed too now, and a probe that sees the offset change bisects the interval to the second of the transition.

* don't run page shortcuts for keys a dialog already handled

Radix dismisses a dialog on Escape from a capture-phase keydown listener and calls `preventDefault()` without stopping propagation, so `useKeyboardListener` still ran the page's Escape shortcut: cancelling the delete dialog in the face library or a classification model also cleared the whole selection. Keys another shortcut hook handled still get through, since their listener order changes with every render.

* fix train image filtering for a class with a dash

The backend writes a class with a `-` as `_` in train file names, since it splits those names on `-`, while a dataset folder keeps the dash. Filtering the Train grid by `half-open` compared it with `half_open` and hid every attempt. Both sides are normalized the same way now.

* don't edit a chat message while a reply streams

The edit button stayed active while a reply streamed. `submitConversation` returns early while loading, but the message bubble still closed its editor, so the edit was silently lost. The edit button is hidden while a reply streams, and an editor that's already open keeps its draft with send disabled until the reply ends.

* fix restart failing under non-root

restart_frigate() called psutil.Process(1).terminate() to signal s6-svscan, but s6-svscan runs as root while frigate runs as uid 1000, so the call raised AccessDenied. That exception escaped every caller: the UI restart button dropped its websocket client, MQTT restart and Save & Restart just logged and did nothing, and the watchdog crashed its own monitoring thread on a dead detector. This catches AccessDenied and falls through to the existing SIGINT branch, which exits the process for s6 to restart it.

* show runtime overrides in the settings form

The settings form read a camera section's saved config value, but its dependent warnings (audio transcription requiring audio detection, snapshots requiring detect, etc.) read the live config instead. A runtime toggle from the live view, MQTT, or an active profile can turn a section off without touching yaml, and that override persists across restarts, so the Enable switch showed on while the warning said the feature wasn't enabled. This adds an "Overridden (Live)" badge to any field whose live value differs from what's saved, and swaps the affected warnings to runtime-specific wording when a runtime override is the actual cause instead of the config.

* fix mobile overflowing icons in system due to new health pane

* fix genai settings keeping a stale model and dropping roles after save

Switching a GenAI entry's provider left the previous provider's model selected, so saving wrote a model the new provider doesn't serve. llama.cpp can't find that model in `/v1/models`, so the backend reported every capability as false for the entry, and once the save refetched `genai/models` the roles widget stripped `transcribe` from the form on its own. The section showed unsaved changes right after saving, and saving again would have dropped the role. Switching provider now clears the model, and the roles widget only strips a role for a model or provider picked in the form, since the entry-level capability flags only describe the saved model. A selected role stays visible when the provider can't confirm it, so it can still be switched off. The llama.cpp model list also no longer repeats a model whose alias matches its id, which is what `--alias` produces.

* close onvif sessions on shutdown

`OnvifController.close()` only stopped its event loop, so the aiohttp sessions each `ONVIFCamera` holds and the `_poll_config_updates` task were left to be garbage collected during interpreter shutdown, when their warnings can no longer be logged. Every restart ended with a run of `Unclosed client session` and `Task was destroyed but it is pending!` logging errors, which only became visible once restart started exiting the process itself under non-root. `close()` now closes each camera's client and cancels the tasks on the loop before stopping it.

* fixes

* fixes
2026-09-18 07:33:23 -06:00
Nick DaviesandGitHub 0ca5cbbb63 Fix --validate-config exit code (#24398)
Validate config exists 0 regardless of if the config is valid or not.
This makes it not very useful for CI

Tiny fix to bail non-zero if the config is invalid
2026-09-18 07:52:39 -05:00
252 changed files with 12227 additions and 911 deletions
+2
View File
@@ -124,5 +124,7 @@ jobs:
run: devcontainer exec --workspace-folder . bash -lc "python3 -u -m mypy --config-file frigate/mypy.ini frigate" run: devcontainer exec --workspace-folder . bash -lc "python3 -u -m mypy --config-file frigate/mypy.ini frigate"
- name: Check API spec is up to date - name: Check API spec is up to date
run: devcontainer exec --workspace-folder . bash -lc "python3 generate_api_auth_spec.py --check" run: devcontainer exec --workspace-folder . bash -lc "python3 generate_api_auth_spec.py --check"
- name: Check analytics schema is up to date
run: devcontainer exec --workspace-folder . bash -lc "python3 generate_analytics_schema.py --check"
- name: Run unit tests in devcontainer - name: Run unit tests in devcontainer
run: devcontainer exec --workspace-folder . bash -lc "python3 -u -m unittest" run: devcontainer exec --workspace-folder . bash -lc "python3 -u -m unittest"
+1
View File
@@ -5,3 +5,4 @@
/docker/rockchip/ @MarcA711 /docker/rockchip/ @MarcA711
/docker/rocm/ @harakas /docker/rocm/ @harakas
/docker/hailo8l/ @spanner3003 /docker/hailo8l/ @spanner3003
/docker/deepx/ @sixfab
+131
View File
@@ -0,0 +1,131 @@
#!/bin/bash
# Installs the DEEPX NPU kernel driver and the DX-RT runtime on the Docker host,
# then enables the vendor's dxrt.service. A container cannot load kernel
# modules, so this runs outside the image; the driver creates the /dev/dxrt*
# nodes and the daemon multiplexes the NPU across host and container.
#
# Driver, runtime and firmware versions must agree or inference hangs instead
# of failing at startup. The set this script installs is pinned in
# driver_version, runtime_version and firmware_version below; move them
# together, never one at a time.
#
# DEEPX NPU support in Frigate is maintained by Sixfab (https://sixfab.com).
set -euo pipefail
driver_version="v2.6.0"
# the commit the tag resolves to, since DEEPX signs neither tags nor releases
# and this is compiled and installed as root. Update both together
driver_commit="7074748e7104f470b02f517583abba652b3f05fa"
firmware_version="v2.7.4"
sudo apt-get update
sudo apt-get install -y git build-essential "linux-headers-$(uname -r)" pciutils wget
if ! lspci -d 1ff4: | grep -q .; then
echo "No DEEPX device found on the PCIe bus (lspci -d 1ff4:)."
echo "Check that the module is seated correctly before continuing."
exit 1
fi
# fetch the pinned commit rather than cloning the tag, so a retag cannot swap
# in different source. The build directory is reused so a second run after a
# failure does not stop on the directory already being there
mkdir -p dx_rt_npu_linux_driver
cd dx_rt_npu_linux_driver
git init -q
git remote get-url origin > /dev/null 2>&1 ||
git remote add origin https://github.com/DEEPX-AI/dx_rt_npu_linux_driver.git
git fetch --depth 1 origin "${driver_commit}"
git checkout -q FETCH_HEAD
fetched_commit=$(git rev-parse HEAD)
if [[ "${fetched_commit}" != "${driver_commit}" ]]; then
echo "Fetched commit ${fetched_commit} does not match pinned driver_commit ${driver_commit}."
echo "Refusing to build unverified driver source."
exit 1
fi
cd modules
sudo ./build.sh -c install --reload
sudo depmod -A
# dx_dma is the PCIe transport, dxrt_driver the NPU driver on top of it
for module in dx_dma dxrt_driver; do
if ! sudo modprobe "${module}"; then
echo "Unable to load the ${module} kernel module, common reasons are:"
echo "- Secure Boot is enabled and is rejecting the unsigned module."
echo "- The running kernel does not match the installed linux-headers."
exit 1
fi
done
if ! compgen -G "/dev/dxrt*" > /dev/null; then
echo "Modules loaded but no /dev/dxrt* device node appeared."
echo "Run ./sanity_check.sh from the driver repo to diagnose."
exit 1
fi
runtime_version="v3.4.0"
declare -A runtime_sha256=(
[amd64]="736cfef009ce9e974ab1ab610d867239d19d72a426a53e367ddcbd53297b6e20"
[arm64]="eb6107f5f02f2ad76ae89f414e8b5f346f34fbc6f0888236136853a26be6f6a0"
)
runtime_release="${runtime_version#v}"
deb_arch=$(dpkg --print-architecture)
deb_file="/tmp/libdxrt-bin_${runtime_release}_${deb_arch}.deb"
wget -qO "${deb_file}" \
"https://raw.githubusercontent.com/DEEPX-AI/dx_rt/${runtime_version}/release/${runtime_release}/libdxrt-bin_${runtime_release}_${deb_arch}.deb"
expected_sha256="${runtime_sha256[${deb_arch}]:-}"
if [[ -z "${expected_sha256}" ]]; then
echo "No pinned SHA-256 for architecture ${deb_arch}; refusing to install."
exit 1
fi
if [[ "$(sha256sum "${deb_file}" | cut -d' ' -f1)" != "${expected_sha256}" ]]; then
echo "SHA-256 mismatch for ${deb_file}; refusing to install."
exit 1
fi
sudo dpkg -i "${deb_file}"
sudo ldconfig
rm -f "${deb_file}"
sudo cp /usr/share/libdxrt-bin/service/dxrt.service /etc/systemd/system/
# With an endpoint set, dxrtd binds that path only, so the socket goes in a
# directory Frigate can mount (kept across restarts so the mount stays valid)
# and a symlink at the default /tmp path keeps host tools that do not set the
# variable working through their own fallback.
sudo mkdir -p /etc/systemd/system/dxrt.service.d
sudo tee /etc/systemd/system/dxrt.service.d/frigate.conf > /dev/null <<'UNIT'
[Service]
RuntimeDirectory=dxrt
RuntimeDirectoryMode=0755
RuntimeDirectoryPreserve=yes
Environment=DXRT_DYNAMIC_IPC_ENDPOINT=/run/dxrt/dxrt_dynamic_ipc.sock
ExecStartPost=/bin/ln -sfn /run/dxrt/dxrt_dynamic_ipc.sock /tmp/dxrt_dynamic_ipc.sock
UNIT
sudo systemctl daemon-reload
sudo systemctl enable dxrt.service
sudo systemctl restart dxrt.service
if ! sudo systemctl is-active --quiet dxrt.service; then
echo "dxrt.service did not start. Check: sudo journalctl -u dxrt.service"
exit 1
fi
echo "DEEPX driver and runtime installation complete."
echo "Driver version: $(modinfo -F version dxrt_driver) (expected ${driver_version#v})"
echo "Runtime version: ${runtime_release}"
echo "Device node(s): $(echo /dev/dxrt*)"
echo
echo "This driver expects NPU firmware ${firmware_version}. Check it with:"
echo " dxrt-cli --status"
echo "Update the module if it does not match before starting Frigate."
+1
View File
@@ -381,6 +381,7 @@ FROM deps AS frigate
WORKDIR /opt/frigate/ WORKDIR /opt/frigate/
COPY --from=rootfs / / COPY --from=rootfs / /
ENV FRIGATE_IMAGE_VARIANT=standard
# Pre-compile bytecode so a read-only rootfs doesn't force re-parsing the # Pre-compile bytecode so a read-only rootfs doesn't force re-parsing the
# source tree on every boot (pip-installed packages are already compiled) # source tree on every boot (pip-installed packages are already compiled)
@@ -37,6 +37,7 @@ device_globs=(
"/dev/nvmap" "/dev/nvmap"
"/dev/nvidia*" "/dev/nvidia*"
"/dev/memx*" "/dev/memx*"
"/dev/dxrt*"
) )
IFS=',' read -ra extra_globs <<< "${DEVICE_ACL_PATHS:-}" IFS=',' read -ra extra_globs <<< "${DEVICE_ACL_PATHS:-}"
+1
View File
@@ -25,6 +25,7 @@ RUN --mount=type=bind,from=rk-wheels,source=/rk-wheels,target=/deps/rk-wheels \
WORKDIR /opt/frigate/ WORKDIR /opt/frigate/
COPY --from=rootfs / / COPY --from=rootfs / /
ENV FRIGATE_IMAGE_VARIANT=rk
COPY docker/rockchip/COCO /COCO COPY docker/rockchip/COCO /COCO
COPY docker/rockchip/conv2rknn.py /opt/conv2rknn.py COPY docker/rockchip/conv2rknn.py /opt/conv2rknn.py
+1
View File
@@ -44,6 +44,7 @@ RUN echo "deb http://deb.debian.org/debian trixie main" > /etc/apt/sources.list.
WORKDIR /opt/frigate WORKDIR /opt/frigate
COPY --from=rootfs / / COPY --from=rootfs / /
ENV FRIGATE_IMAGE_VARIANT=rocm
RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \ RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \
&& sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \ && sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \
+1
View File
@@ -15,3 +15,4 @@ ENV INCLUDED_FFMPEG_VERSIONS="${DEFAULT_FFMPEG_VERSION}:${INCLUDED_FFMPEG_VERSIO
WORKDIR /opt/frigate/ WORKDIR /opt/frigate/
COPY --from=rootfs / / COPY --from=rootfs / /
ENV FRIGATE_IMAGE_VARIANT=rpi
+1
View File
@@ -22,6 +22,7 @@ pip3 install --no-deps -U /deps/synap-wheels/*.whl
WORKDIR /opt/frigate/ WORKDIR /opt/frigate/
COPY --from=rootfs / / COPY --from=rootfs / /
ENV FRIGATE_IMAGE_VARIANT=synaptics
COPY --from=synap1680-wheels /rootfs/usr/local/lib/*.so /usr/lib COPY --from=synap1680-wheels /rootfs/usr/local/lib/*.so /usr/lib
+1
View File
@@ -25,6 +25,7 @@ RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels
&& pip3 install -U /deps/trt-wheels/*.whl && pip3 install -U /deps/trt-wheels/*.whl
COPY --from=rootfs / / COPY --from=rootfs / /
ENV FRIGATE_IMAGE_VARIANT=tensorrt
COPY docker/tensorrt/detector/rootfs/etc/ld.so.conf.d /etc/ld.so.conf.d COPY docker/tensorrt/detector/rootfs/etc/ld.so.conf.d /etc/ld.so.conf.d
RUN ldconfig RUN ldconfig
+1
View File
@@ -151,6 +151,7 @@ RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels
WORKDIR /opt/frigate/ WORKDIR /opt/frigate/
COPY --from=rootfs / / COPY --from=rootfs / /
ENV FRIGATE_IMAGE_VARIANT=tensorrt-jp6
# Fixes "Error importing detector runtime: /usr/lib/aarch64-linux-gnu/libstdc++.so.6: cannot allocate memory in static TLS block" # Fixes "Error importing detector runtime: /usr/lib/aarch64-linux-gnu/libstdc++.so.6: cannot allocate memory in static TLS block"
ENV LD_PRELOAD /usr/lib/aarch64-linux-gnu/libstdc++.so.6 ENV LD_PRELOAD /usr/lib/aarch64-linux-gnu/libstdc++.so.6
+59
View File
@@ -967,6 +967,65 @@ memryx:
# The .zip file must contain: # The .zip file must contain:
# ├── ssdlite_mobilenet.dfp (a file ending with .dfp) # ├── ssdlite_mobilenet.dfp (a file ending with .dfp)
# └── ssdlite_mobilenet_post.onnx (optional; only if the model includes a cropped post-processing network) # └── ssdlite_mobilenet_post.onnx (optional; only if the model includes a cropped post-processing network)
deepx:
title: DEEPX NPU
models:
- key: yolo
label: YOLO
recommended: true
download: No model is bundled with Frigate. Download a pre-compiled YOLO `.dxnn` model from the [DEEPX ModelZoo](https://developer.deepx.ai/modelzoo) or compile your own with DX-COM, then bind-mount it into the container and point the model's `path` at it. The recommended model is `yolox-s_640x640_ppu.dxnn`. Its Post-Processing Unit (PPU) compile moves candidate selection onto the NPU, which makes it the fastest ModelZoo model measured through Frigate (about 13 ms on a DX-M1). The output layout is read from the compiled model, so anchor-based, anchor-free, NMS-in-head and PPU models (anchor-based or anchor-free) all need no extra configuration; prefer a `PPU` variant whenever the ModelZoo offers one. PPU models must be compiled with DX-COM 2.4.0 or later, which writes the head layout Frigate reads into the file.
ui: |-
Navigate to **Settings > System > Detection models** and select **DEEPX NPU** from the **Hardware** dropdown. Then, on the same model, open the **Custom Model** tab and configure:
| Field | Value |
| ---------------------------------------- | ---------------------------------------------------- |
| **Custom object detector model path** | `/config/model_cache/deepx/yolox-s_640x640_ppu.dxnn` |
| **Label map for custom object detector** | `/labelmap/coco-80.txt` |
| **Object detection model input width** | `640` |
| **Object detection model input height** | `640` |
| **Model Input Pixel Color Format** | `rgb` (Frigate's default value) |
| **Model Input Tensor Shape** | `nhwc` (Frigate's default value) |
| **Model Input D Type** | `int` (Frigate's default value) |
| **Object Detection Model Type** | `yolo-generic` |
Quantization is baked into the compiled model, so no normalization is applied on the host and the input defaults do not need to be overridden.
yaml: |-
models:
- devices:
- deepx:PCIe:0
path: /config/model_cache/deepx/yolox-s_640x640_ppu.dxnn
labelmap_path: /labelmap/coco-80.txt
model_type: yolo-generic
width: 640
height: 640
- key: yolox
label: YOLOX
recommended: false
download: No model is bundled with Frigate. Download a pre-compiled YOLOX `.dxnn` model from the [DEEPX ModelZoo](https://developer.deepx.ai/modelzoo), then bind-mount it into the container and point the model's `path` at it. The `_ppu` variant is faster and also works with the `yolo-generic` model type; the plain export needs `yolox` so its raw head is decoded.
ui: |-
Navigate to **Settings > System > Detection models** and select **DEEPX NPU** from the **Hardware** dropdown. Then, on the same model, open the **Custom Model** tab and configure:
| Field | Value |
| ---------------------------------------- | ---------------------------------------- |
| **Custom object detector model path** | `/config/model_cache/deepx/yolox-s_640x640.dxnn`|
| **Label map for custom object detector** | `/labelmap/coco-80.txt` |
| **Object detection model input width** | `640` |
| **Object detection model input height** | `640` |
| **Model Input Pixel Color Format** | `rgb` (Frigate's default value) |
| **Model Input Tensor Shape** | `nhwc` (Frigate's default value) |
| **Model Input D Type** | `int` (Frigate's default value) |
| **Object Detection Model Type** | `yolox` |
The width and height must match the resolution the `.dxnn` file was compiled for.
yaml: |-
models:
- devices:
- deepx:PCIe:0
path: /config/model_cache/deepx/yolox-s_640x640.dxnn
labelmap_path: /labelmap/coco-80.txt
model_type: yolox
width: 640
height: 640
tensorrt: tensorrt:
title: TensorRT title: TensorRT
models: models:
@@ -0,0 +1,41 @@
---
id: analytics
title: Anonymous Analytics
---
import AnalyticsFields from "@site/src/components/AnalyticsFields";
import NavPath from "@site/src/components/NavPath";
Frigate can send one anonymous usage report a day. The reports show the maintainers which hardware to support, which features people use, and how releases perform. Sharing is off until you turn it on.
## Turning it on
Enable **Share anonymous analytics** at <NavPath path="Settings > System > Telemetry" />, or set it in your config:
```yaml
telemetry:
analytics: true
```
The same page has a **Preview the report** button that shows exactly what the next report contains.
## How it's sent
- Once a day, as a JSON POST to `https://analytics.frigate.video/report`
- The server looks up your country and region from your IP address and never stores the address
- Raw reports are kept for 60 days; only aggregate totals are published
- A random install ID, stored in `/config/.analytics.json`, keeps your install from being counted twice. Turning sharing off deletes it
## What's never sent
- Camera, zone, group, profile, or user names
- Object labels, face names, or license plate text
- IP addresses, hostnames, URLs, or stream paths
- Credentials or API keys
- Events, recordings, or anything from them
## Every field
Fields marked public appear in the published totals. The machine-readable schema is [frigate-analytics-schema.json](pathname:///frigate-analytics-schema.json).
<AnalyticsFields />
@@ -1194,6 +1194,9 @@ ui:
# Optional: Telemetry configuration # Optional: Telemetry configuration
telemetry: telemetry:
# Optional: Share one anonymous usage report a day (default: shown below)
# NOTE: See https://docs.frigate.video/configuration/advanced/analytics for what is sent
analytics: False
# Optional: Enabled network interfaces for bandwidth stats monitoring (default: empty list, let nethogs search all) # Optional: Enabled network interfaces for bandwidth stats monitoring (default: empty list, let nethogs search all)
network_interfaces: network_interfaces:
- eth - eth
@@ -24,6 +24,7 @@ Frigate supports multiple different detectors that work on different types of ha
- [Coral EdgeTPU](#edge-tpu-detector): The Google Coral EdgeTPU is available in USB, Mini PCIe, and m.2 formats allowing for a wide range of compatibility with devices. - [Coral EdgeTPU](#edge-tpu-detector): The Google Coral EdgeTPU is available in USB, Mini PCIe, and m.2 formats allowing for a wide range of compatibility with devices.
- [Hailo](#hailo): The Hailo-8, Hailo-8L and Hailo-8R AI Acceleration modules are available in m.2 format with a HAT for RPi devices, offering a wide range of compatibility with devices. - [Hailo](#hailo): The Hailo-8, Hailo-8L and Hailo-8R AI Acceleration modules are available in m.2 format with a HAT for RPi devices, offering a wide range of compatibility with devices.
- <CommunityBadge /> [MemryX](#memryx-mx3): The MX3 Acceleration module is available in m.2 format, offering broad compatibility across various platforms. - <CommunityBadge /> [MemryX](#memryx-mx3): The MX3 Acceleration module is available in m.2 format, offering broad compatibility across various platforms.
- <CommunityBadge /> [DEEPX](#deepx-npu): The DEEPX NPU is available in m.2 format and as a HAT+ for the Raspberry Pi 5, offering broad compatibility across various platforms.
**AMD** **AMD**
@@ -612,6 +613,63 @@ For detailed instructions on compiling models, refer to the [MemryX Compiler](ht
--- ---
## DEEPX NPU
This detector is available for use with the DEEPX NPU, both the DX-M1 M.2 module and the DX-M1M on the Sixfab AI HAT+ for the Raspberry Pi 5. The configuration below applies unchanged to either form factor. DEEPX NPU support in Frigate is developed and maintained by [Sixfab](https://sixfab.com).
See the [installation docs](../frigate/installation.md#deepx-npu) for information on installing the DEEPX kernel driver and runtime on the host and passing the NPU through to the container.
To run a model on a DEEPX NPU, list a `deepx` device on that model.
:::info
The DX-RT Python bindings are not part of the Frigate image. They are downloaded and installed into `/config/.local` the first time a DEEPX device is configured, verified against pinned checksums, and updated automatically when a Frigate release pins a new version. If the container has no internet access, see [Detector runtimes](/frigate/network_requirements#detector-runtimes) for how to provide the files yourself.
:::
### Configuration {#configuration-deepx}
<ModelConfigDropdown detectorTitle="DEEPX" models={objectDetectorsModels.deepx.models} />
Frigate does not bundle a model for this detector. Models must be compiled to DEEPX's `.dxnn` format. Two model types are supported:
- `yolo-generic` for YOLO object detection models, the recommended default. The detector reads the model's output layout from the compiled file, so anchor-based, anchor-free and NMS-in-head models all work with the same configuration, as do models compiled with DEEPX's Post-Processing Unit (PPU) support.
- `yolox` for YOLOX models compiled without PPU support, whose raw head needs Frigate's YOLOX decoder. A YOLOX model compiled with PPU support works under either `yolox` or `yolo-generic`.
The quickest way to get one is the [DEEPX ModelZoo](https://developer.deepx.ai/modelzoo), which publishes pre-compiled `.dxnn` files for a range of YOLO object detection models. Download the `.dxnn`, bind-mount it into the container, and point the model's `path` at it. Alternatively, compile your own model with the DX-COM compiler. The recommended starting point is `yolox-s_640x640_ppu.dxnn`, the fastest ModelZoo model measured through Frigate:
```yaml
models:
- devices:
- deepx:PCIe:0
path: /config/model_cache/deepx/yolox-s_640x640_ppu.dxnn
labelmap_path: /labelmap/coco-80.txt
model_type: yolo-generic
width: 640
height: 640
```
For PPU models, use a `.dxnn` compiled with DX-COM 2.4.0 or later. Frigate reads the PPU head layout the compiler writes into the file and refuses to load a PPU model without it.
`model_type` must be set to `yolo-generic` or `yolox` to match the model; `yolo-generic` is the recommended default unless the model is a raw YOLOX export. Frigate defaults it to `ssd`, which this detector does not support, so the detector refuses to start on a model that leaves it unset.
`width` and `height` must match the resolution the model was compiled for. Quantization parameters are baked into the `.dxnn` file at compile time, so no normalization is applied on the host and Frigate's default `input_tensor`, `input_pixel_format`, and `input_dtype` values do not need to be overridden.
A DEEPX device is `PCIe:<index>`, as reported on the detector settings page. The NPU daemon multiplexes across processes, so the same device may be listed more than once to run additional inference processes against it:
```yaml
models:
- devices:
- deepx:PCIe:0
- deepx:PCIe:0
```
#### Label maps
The object detection models in the DEEPX ModelZoo are trained on the standard 80-class COCO label set, so `labelmap_path` must be set to `/labelmap/coco-80.txt`. Frigate's default label map uses an extended 91-class COCO scheme, and leaving it in place will cause detections to be reported as the wrong object type. For `yolo-generic` models the label map is also what the detector uses to tell the output layout, so a label map with the wrong number of classes is reported as an error at startup.
---
## NVidia TensorRT Detector ## NVidia TensorRT Detector
Nvidia Jetson devices may be used for object detection using the TensorRT libraries. Due to the size of the additional libraries, this detector is only provided in images with the `-tensorrt-jp6` tag suffix, e.g. `ghcr.io/blakeblackshear/frigate:stable-tensorrt-jp6`. This detector is designed to work with Yolo models for object detection. Nvidia Jetson devices may be used for object detection using the TensorRT libraries. Due to the size of the additional libraries, this detector is only provided in images with the `-tensorrt-jp6` tag suffix, e.g. `ghcr.io/blakeblackshear/frigate:stable-tensorrt-jp6`. This detector is designed to work with Yolo models for object detection.
+31
View File
@@ -65,6 +65,11 @@ Frigate supports multiple different detectors that work on different types of ha
- [Supports many model architectures](../../configuration/object_detectors#memryx-mx3) - [Supports many model architectures](../../configuration/object_detectors#memryx-mx3)
- Runs best with tiny, small, or medium-size models - Runs best with tiny, small, or medium-size models
- <CommunityBadge /> [DEEPX](#deepx-npu): The DEEPX NPU is available in m.2 format and as a HAT+ for the Raspberry Pi 5, allowing for a wide range of compatibility with devices.
- [Supports YOLO model architectures](../../configuration/object_detectors#deepx-npu)
- Runs best with tiny or small size models
- Runs efficiently on low power hardware
**AMD** **AMD**
- [ROCm](#rocm---amd-gpu): ROCm can run on AMD Discrete GPUs to provide efficient object detection - [ROCm](#rocm---amd-gpu): ROCm can run on AMD Discrete GPUs to provide efficient object detection
@@ -257,6 +262,32 @@ The MX3 is a pipelined architecture, where the maximum frames per second support
Inference speeds may vary depending on the host platform. The above data was measured on an **Intel 13700 CPU**. Platforms like Raspberry Pi, Orange Pi, and other ARM-based SBCs have different levels of processing capability, which may limit total FPS. Inference speeds may vary depending on the host platform. The above data was measured on an **Intel 13700 CPU**. Platforms like Raspberry Pi, Orange Pi, and other ARM-based SBCs have different levels of processing capability, which may limit total FPS.
### DEEPX NPU
Frigate supports the DEEPX NPU in both of its form factors: the **DX-M1** M.2 module, which works on x86 (Intel/AMD) and ARM-based SBCs such as the Raspberry Pi 5, and the **DX-M1M** on the [Sixfab AI HAT+](https://docs.sixfab.com/docs/ai-hat-plus-raspberry-pi-5-quickstart) for the Raspberry Pi 5. Both use the same driver and runtime, so the configuration is identical for either one. DEEPX NPU support in Frigate is developed and maintained by [Sixfab](https://sixfab.com).
The DEEPX driver and runtime run on the Docker host rather than inside the Frigate container and must be installed before the NPU can be used. See the [installation docs](installation.md#deepx-npu) for the setup steps and [the detector docs](/configuration/object_detectors#deepx-npu) for the configuration.
Frigate does not bundle a model for this detector. Models use DEEPX's `.dxnn` format, and pre-compiled YOLO models can be downloaded from the [DEEPX ModelZoo](https://developer.deepx.ai/modelzoo). Prefer a model with a `_ppu` suffix whenever one is available for the architecture you want: these run part of the post-processing on the NPU itself and are considerably faster, roughly 2.5x for the same architecture and input size. **YOLOX-S with PPU is the recommended starting point.**
Inference times for a few recommended models, measured through Frigate's own stats on a DX-M1:
| Model | Input Size | DX-M1 Inference Time |
| ----------------- | ---------- | -------------------- |
| YOLOX-S (PPU) | 640 | ~ 13 ms |
| YOLOv9-t (PPU) | 640 | ~ 18 ms |
| YOLOv4 (PPU) | 512 | ~ 20 ms |
| YOLOX-S | 640 | ~ 34 ms |
| YOLOv9-s | 640 | ~ 39 ms |
Other ModelZoo YOLO variants are also supported but have not been measured. Inference speeds vary with the host platform, so a slower host such as a Raspberry Pi 5 will report higher times than those above.
:::note
A few ModelZoo models can not be used with Frigate: SSD models (they are trained on Pascal VOC, so their labels do not match Frigate's), DAMO-YOLO models, face and pose models, and the PPU builds of YOLOv7.
:::
### Nvidia Jetson ### Nvidia Jetson
Jetson devices are supported via the TensorRT or ONNX detectors when running Jetpack 6. It will [make use of the Jetson's hardware media engine](/configuration/hardware_acceleration_video#nvidia-jetson) when configured with the [appropriate presets](/configuration/ffmpeg_presets#hwaccel-presets), and will make use of the Jetson's GPU and DLA for object detection when configured with the [TensorRT detector](/configuration/object_detectors#nvidia-tensorrt-detector). Jetson devices are supported via the TensorRT or ONNX detectors when running Jetpack 6. It will [make use of the Jetson's hardware media engine](/configuration/hardware_acceleration_video#nvidia-jetson) when configured with the [appropriate presets](/configuration/ffmpeg_presets#hwaccel-presets), and will make use of the Jetson's GPU and DLA for object detection when configured with the [TensorRT detector](/configuration/object_detectors#nvidia-tensorrt-detector).
+93
View File
@@ -381,6 +381,99 @@ If you can't use Docker Compose, you can run the container with something simila
Finally, configure [hardware object detection](/configuration/object_detectors#memryx-mx3) to complete the setup. Finally, configure [hardware object detection](/configuration/object_detectors#memryx-mx3) to complete the setup.
### DEEPX NPU
The DEEPX NPU is available in two form factors, and Frigate supports both:
- **DX-M1** in the M.2 2280 form factor (like an NVMe SSD), for x86 (Intel/AMD) PCs, the Raspberry Pi 5, and other ARM SBCs with an exposed PCIe M.2 slot.
- **DX-M1M** on the [Sixfab AI HAT+](https://docs.sixfab.com/docs/ai-hat-plus-raspberry-pi-5-quickstart), a HAT+ board that connects to the Raspberry Pi 5 over PCIe Gen 3 x1.
Both present the NPU through the same PCIe driver and DX-RT runtime, so the setup below and the detector configuration are identical for either one. Nothing needs to change when moving between them.
DEEPX NPU support in Frigate is developed and maintained by [Sixfab](https://sixfab.com).
#### Versions
A DEEPX install has several separately versioned pieces, and they all have to agree. The driver, the runtime, and the daemon live on the Docker host; Frigate itself carries only the Python bindings, which it downloads on first start:
| Component | Version | Installed on | Installed by |
| -------------- | -------- | ------------ | ------------------------- |
| Kernel driver | `v2.6.0` | Host | `user_installation.sh` |
| DX-RT runtime | `v3.4.0` | Host | `user_installation.sh` |
| NPU firmware | `v2.7.4` | The module | Flashed from the host |
| DX-RT bindings | `v3.4.0` | Frigate | Downloaded at first start |
:::warning
A version mismatch does not produce a startup error. It typically shows up as inference requests that are accepted but never return a result, so detections simply stop appearing while Frigate looks healthy. If that happens after a Frigate upgrade, check every version in the table before anything else.
:::
The installation script installs the DX-RT runtime on the host and enables `dxrt.service`, so the daemon starts at boot and any other program on the host can share the NPU with Frigate. Check the firmware version with `dxrt-cli --status` and update the module if it does not match the table above.
#### Installation
The DEEPX kernel driver must be installed on the host rather than in the container, because containers share the host kernel and cannot load kernel modules. Installing it creates the `/dev/dxrt*` device nodes that are passed through to Frigate. The same script installs the DX-RT runtime and enables `dxrt.service`, the daemon that owns the NPU and hands work to it on behalf of Frigate and anything else on the host.
1. Copy or download [this script](https://github.com/blakeblackshear/frigate/blob/dev/docker/deepx/user_installation.sh).
2. Ensure it has execution permissions with `sudo chmod +x user_installation.sh`
3. Run the script with `./user_installation.sh`
4. **Restart your computer** to complete driver installation.
Confirm the NPU is visible before continuing:
```bash
ls /dev/dxrt*
```
Then confirm the daemon is running and listening in `/run/dxrt`:
```bash
systemctl is-active dxrt.service
ls /run/dxrt/
```
#### Setup
To set up Frigate, follow the default installation instructions, for example: `ghcr.io/blakeblackshear/frigate:stable`
#### Docker configuration
Frigate needs the NPU device node and the directory holding the daemon's socket:
```yaml
services:
frigate:
devices:
- /dev/dxrt0:/dev/dxrt0
volumes:
- /run/dxrt:/run/dxrt
```
If you can't use Docker Compose, add `--device /dev/dxrt0:/dev/dxrt0 -v /run/dxrt:/run/dxrt` to your `docker run` command.
Add one `--device` per NPU, contiguously from `/dev/dxrt0`, since the client stops enumerating at the first gap.
The installation script configures `dxrt.service` to place its socket in `/run/dxrt` through a systemd drop-in. Mounting the directory rather than the socket file means the container sees the new socket after `dxrt.service` is restarted, rather than holding on to a deleted one.
`dxrtd` listens on an abstract socket as well, but that one does not cross into a container, so Frigate names the filesystem socket through `DXRT_DYNAMIC_IPC_ENDPOINT` on your behalf. Set that variable on the container yourself only if the daemon listens somewhere else, which means you also set it for `dxrtd` through its own systemd drop-in. The script writes `/etc/systemd/system/dxrt.service.d/frigate.conf` for exactly that, and has `dxrt.service` link the socket to `/tmp/dxrt_dynamic_ipc.sock` when it starts, so the host's own `dxrt-cli` and `dxtop` keep finding it at the default path they fall back to.
:::note
The DX-RT client exits when `dxrt.service` stops, so restart the Frigate container after restarting `dxrt.service`.
:::
The device node is needed as well as the socket, because the client opens the NPU directly even though the daemon arbitrates access. Without it, inference fails with `Device not found`.
`/dev/shm` does not need sharing.
The DX-RT python bindings are not shipped in the Frigate image. Frigate downloads them on first start when a DEEPX detector is configured, and caches them under `/config`.
#### Configuration
Finally, configure [hardware object detection](/configuration/object_detectors#deepx-npu) to complete the setup.
### Rockchip platform ### Rockchip platform
Make sure that you use a linux distribution that comes with the rockchip BSP kernel 5.10 or 6.1 and necessary drivers (especially rkvdec2 and rknpu). To check, enter the following commands: Make sure that you use a linux distribution that comes with the rockchip BSP kernel 5.10 or 6.1 and necessary drivers (especially rkvdec2 and rknpu). To check, enter the following commands:
+10 -1
View File
@@ -134,6 +134,15 @@ telemetry:
version_check: false version_check: false
``` ```
### Anonymous Analytics
If [anonymous analytics](/configuration/advanced/analytics) sharing is turned on, Frigate sends one report a day to `https://analytics.frigate.video`. It's off by default, so no outbound connection happens unless you enable it:
```yaml
telemetry:
analytics: true
```
### Push Notifications ### Push Notifications
When [notifications](/configuration/notifications) are enabled and users have registered for push notifications in the web UI, Frigate sends push messages through the browser vendor's push service (e.g., Google FCM, Mozilla autopush). This requires internet access from the Frigate server to these push endpoints. When [notifications](/configuration/notifications) are enabled and users have registered for push notifications in the web UI, Frigate sends push messages through the browser vendor's push service (e.g., Google FCM, Mozilla autopush). This requires internet access from the Frigate server to these push endpoints.
@@ -170,7 +179,7 @@ To run Frigate in an air-gapped or offline environment:
2. **Pre-download the training base weights**: If you plan to train custom classification models, set `TF_KERAS_MOBILENET_V2_WEIGHTS_URL` before training, then run one training job while online. Without this variable the base weights are cached outside `/config/` and are lost whenever the container is recreated, so a later training run will fail offline. If the machine never has internet access, copy the weights in manually as described below. 2. **Pre-download the training base weights**: If you plan to train custom classification models, set `TF_KERAS_MOBILENET_V2_WEIGHTS_URL` before training, then run one training job while online. Without this variable the base weights are cached outside `/config/` and are lost whenever the container is recreated, so a later training run will fail offline. If the machine never has internet access, copy the weights in manually as described below.
3. **Disable version check**: Set `telemetry.version_check: false` in your configuration. 3. **Disable version check**: Set `telemetry.version_check: false` in your configuration.
4. **Block outbound model requests**: Set the `HF_HUB_OFFLINE=1` and `TRANSFORMERS_OFFLINE=1` environment variables to prevent HuggingFace and Transformers from attempting any network requests. 4. **Block outbound model requests**: Set the `HF_HUB_OFFLINE=1` and `TRANSFORMERS_OFFLINE=1` environment variables to prevent HuggingFace and Transformers from attempting any network requests.
5. **Avoid cloud features**: Do not configure Frigate+, Generative AI providers that require internet, or cloud MQTT brokers. 5. **Avoid cloud features**: Do not configure Frigate+, Generative AI providers that require internet, or cloud MQTT brokers, and leave anonymous analytics off (its default).
6. **Use local model mirrors**: If limited internet is available, set the `HF_ENDPOINT`, `GITHUB_ENDPOINT`, `GITHUB_RAW_ENDPOINT`, and `TF_KERAS_MOBILENET_V2_WEIGHTS_URL` environment variables to point to local mirrors. 6. **Use local model mirrors**: If limited internet is available, set the `HF_ENDPOINT`, `GITHUB_ENDPOINT`, `GITHUB_RAW_ENDPOINT`, and `TF_KERAS_MOBILENET_V2_WEIGHTS_URL` environment variables to point to local mirrors.
After these steps, Frigate will operate with no outbound internet connections. After these steps, Frigate will operate with no outbound internet connections.
+1
View File
@@ -130,6 +130,7 @@ const sidebars: SidebarsConfig = {
label: "Advanced Configuration", label: "Advanced Configuration",
items: [ items: [
"configuration/advanced/system", "configuration/advanced/system",
"configuration/advanced/analytics",
"configuration/advanced/reference", "configuration/advanced/reference",
{ {
type: "link", type: "link",
@@ -0,0 +1,60 @@
import React from "react";
import schema from "@site/static/frigate-analytics-schema.json";
function resolve(node) {
if (!node) return node;
if (node.$ref) return schema.$defs[node.$ref.split("/").pop()];
if (node.anyOf) {
const inner = node.anyOf.find((option) => option.type !== "null");
return inner ? resolve(inner) : node;
}
return node;
}
function rows(properties, prefix = "") {
return Object.entries(properties).flatMap(([name, field]) => {
const path = prefix ? `${prefix}.${name}` : name;
const row = {
path,
description: field.description,
isPublic: field["x-public"],
};
const target = resolve(field);
if (target?.properties) return [row, ...rows(target.properties, path)];
const values = resolve(target?.additionalProperties);
if (values?.properties)
return [row, ...rows(values.properties, `${path}.<key>`)];
const items = resolve(target?.items);
if (items?.properties) return [row, ...rows(items.properties, `${path}[]`)];
return [row];
});
}
export default function AnalyticsFields() {
return (
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
<th>Public</th>
</tr>
</thead>
<tbody>
{rows(schema.properties).map((row) => (
<tr key={row.path}>
<td>
<code>{row.path}</code>
</td>
<td>{row.description}</td>
<td>{row.isPublic ? "Yes" : "No"}</td>
</tr>
))}
</tbody>
</table>
);
}
File diff suppressed because it is too large Load Diff
+19
View File
@@ -10,6 +10,25 @@ servers:
- url: https://demo.frigate.video/api - url: https://demo.frigate.video/api
- url: http://localhost:5001/api - url: http://localhost:5001/api
paths: paths:
/analytics/preview:
get:
tags:
- Analytics
summary: Get Analytics Preview
description: |-
**Access:** Admin role required.
Get the analytics report Frigate would send next, without sending it.
operationId: get_analytics_preview_analytics_preview_get
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
security:
- frigateAdminAuth: []
x-required-role: admin
/auth/first_time_login: /auth/first_time_login:
get: get:
tags: tags:
+4
View File
@@ -99,6 +99,10 @@ def main() -> None:
print("*** End Config Validation Errors ***") print("*** End Config Validation Errors ***")
print("*************************************************************") print("*************************************************************")
# force a non-zero exit code for config failures
if args.validate_config:
sys.exit(1)
# attempt to start Frigate in recovery mode # attempt to start Frigate in recovery mode
try: try:
config = FrigateConfig.load(install=True, safe_load=True) config = FrigateConfig.load(install=True, safe_load=True)
+1
View File
@@ -0,0 +1 @@
"""Opt-in anonymous analytics reports."""
+1
View File
@@ -0,0 +1 @@
"""One collector per report section."""
+223
View File
@@ -0,0 +1,223 @@
"""Cameras section: counts and histograms across cameras, never per camera."""
from collections import Counter
from typing import Any
from urllib.parse import urlsplit
from frigate.analytics.collectors.common import closed, histogram
from frigate.analytics.context import ReportContext
from frigate.analytics.schema import (
CamerasSection,
ConnectionQuality,
FpsBucket,
HeightBucket,
HwaccelKey,
InputPresetKey,
RetainBucket,
RetainDays,
)
from frigate.config import CameraConfig
from frigate.config.camera.camera import CameraTypeEnum
from frigate.config.camera.ffmpeg import CameraInput, CameraRoleEnum
from frigate.const import REPLAY_CAMERA_PREFIX
# the upper edge of every height bucket but the last
HEIGHT_BUCKETS = (
(360, HeightBucket.le_360),
(540, HeightBucket.h480),
(900, HeightBucket.h720),
(1260, HeightBucket.h1080),
(1800, HeightBucket.h1440),
)
RESTREAM_HOSTS = frozenset({"127.0.0.1", "localhost"})
RESTREAM_PORT = 8554
QUALITIES = frozenset(ConnectionQuality)
def height_bucket(height: int) -> HeightBucket:
for limit, bucket in HEIGHT_BUCKETS:
if height <= limit:
return bucket
return HeightBucket.ge_2160
def fps_bucket(fps: int) -> FpsBucket:
if fps <= 5:
return FpsBucket.le_5
if fps <= 10:
return FpsBucket.f6_10
return FpsBucket.gt_10
def retain_bucket(days: float) -> RetainBucket:
if days <= 0:
return RetainBucket.zero
if days <= 7:
return RetainBucket.d1_7
if days <= 30:
return RetainBucket.d8_30
return RetainBucket.gt_30
def preset_key(args: str | list[str], enum: Any) -> Any:
"""The preset's name, custom for hand written args, or none."""
if not args:
return enum("none")
if isinstance(args, str) and args.startswith("preset-"):
return closed(enum, args.removeprefix("preset-"), enum("custom"))
return enum("custom")
def is_restream(path: str) -> bool:
try:
url = urlsplit(path)
return url.hostname in RESTREAM_HOSTS and url.port == RESTREAM_PORT
except ValueError:
return False
def role_input(camera: CameraConfig, role: CameraRoleEnum) -> CameraInput | None:
return next((i for i in camera.ffmpeg.inputs if role in i.roles), None)
def object_masks(camera: CameraConfig) -> int:
# parsing copies camera-wide masks into every filter as global_<id>
own = sum(1 for mask in camera.objects.mask.values() if mask is not None)
per_label = sum(
1
for label_filter in camera.objects.filters.values()
for mask_id, mask in label_filter.mask.items()
if mask is not None and not mask_id.startswith("global_")
)
return own + per_label
def collect(ctx: ReportContext) -> CamerasSection:
cameras = {
name: camera
for name, camera in ctx.config.cameras.items()
if not name.startswith(REPLAY_CAMERA_PREFIX)
}
camera_stats = ctx.stats.get("cameras", {})
flags: Counter[str] = Counter()
types: Counter[CameraTypeEnum] = Counter()
heights: Counter[HeightBucket] = Counter()
fps: Counter[FpsBucket] = Counter()
hwaccel: Counter[Any] = Counter()
input_presets: Counter[Any] = Counter()
quality: Counter[ConnectionQuality] = Counter()
retain: dict[str, Counter[RetainBucket]] = {
period: Counter() for period in ("continuous", "motion", "alerts", "detections")
}
for name, camera in cameras.items():
detect_input = role_input(camera, CameraRoleEnum.detect)
record_input = role_input(camera, CameraRoleEnum.record)
# config validation requires a detect input, so this never skips
if detect_input is None:
continue
types[camera.type] += 1
fps[fps_bucket(camera.detect.fps)] += 1
hwaccel[
preset_key(
detect_input.hwaccel_args or camera.ffmpeg.hwaccel_args, HwaccelKey
)
] += 1
input_presets[
preset_key(
detect_input.input_args or camera.ffmpeg.input_args, InputPresetKey
)
] += 1
if camera.detect.height:
heights[height_bucket(camera.detect.height)] += 1
state = camera_stats.get(name, {}).get("connection_quality")
if state in QUALITIES:
quality[ConnectionQuality(state)] += 1
if camera.record.enabled:
retain["continuous"][retain_bucket(camera.record.continuous.days)] += 1
retain["motion"][retain_bucket(camera.record.motion.days)] += 1
retain["alerts"][retain_bucket(camera.record.alerts.retain.days)] += 1
retain["detections"][
retain_bucket(camera.record.detections.retain.days)
] += 1
zones = len(camera.zones)
flags["enabled"] += camera.enabled
flags["go2rtc_restream"] += any(
is_restream(i.path) for i in camera.ffmpeg.inputs
)
flags["separate_detect_stream"] += (
record_input is not None and record_input.path != detect_input.path
)
flags["detect"] += camera.detect.enabled
flags["record"] += camera.record.enabled
flags["sub_stream_record"] += camera.record.sub.enabled
flags["snapshots"] += camera.snapshots.enabled
flags["audio"] += camera.audio.enabled
flags["audio_transcription"] += camera.audio_transcription.enabled
flags["birdseye"] += camera.birdseye.enabled
flags["onvif"] += bool(camera.onvif.host)
flags["autotracking"] += camera.onvif.autotracking.enabled
flags["face_recognition"] += camera.face_recognition.enabled
flags["lpr"] += camera.lpr.enabled
flags["review_genai"] += camera.review.genai.enabled
flags["object_genai"] += camera.objects.genai.enabled
flags["notifications"] += camera.notifications.enabled
flags["zones"] += zones
flags["cameras_with_zones"] += zones > 0
flags["motion_masks"] += sum(
1 for mask in camera.motion.mask.values() if mask is not None
)
flags["object_masks"] += object_masks(camera)
return CamerasSection(
total=len(cameras),
enabled=flags["enabled"],
types=histogram(types),
detect_height=histogram(heights),
detect_fps=histogram(fps),
hwaccel=histogram(hwaccel),
input_preset=histogram(input_presets),
go2rtc_restream=flags["go2rtc_restream"],
separate_detect_stream=flags["separate_detect_stream"],
detect=flags["detect"],
record=flags["record"],
sub_stream_record=flags["sub_stream_record"],
snapshots=flags["snapshots"],
audio=flags["audio"],
audio_transcription=flags["audio_transcription"],
birdseye=flags["birdseye"],
onvif=flags["onvif"],
autotracking=flags["autotracking"],
face_recognition=flags["face_recognition"],
lpr=flags["lpr"],
review_genai=flags["review_genai"],
object_genai=flags["object_genai"],
notifications=flags["notifications"],
zones=flags["zones"],
cameras_with_zones=flags["cameras_with_zones"],
motion_masks=flags["motion_masks"],
object_masks=flags["object_masks"],
connection_quality=histogram(quality),
retain_days=RetainDays(
continuous=histogram(retain["continuous"]),
motion=histogram(retain["motion"]),
alerts=histogram(retain["alerts"]),
detections=histogram(retain["detections"]),
),
)
+37
View File
@@ -0,0 +1,37 @@
"""Helpers the section collectors share."""
import math
from collections import Counter
from enum import Enum
from typing import Any, TypeVar
E = TypeVar("E", bound=Enum)
def closed(enum: type[E], value: Any, fallback: E) -> E:
"""The member for a value, or the fallback for one the enum doesn't know."""
try:
return enum(str(value))
except ValueError:
return fallback
def rate(value: Any) -> float:
"""A finite, non-negative number rounded to 2 decimals, else 0.
A NaN would serialize as null and fail the schema's number type.
"""
try:
number = float(value)
except (TypeError, ValueError):
return 0.0
if not math.isfinite(number):
return 0.0
return round(max(number, 0.0), 2)
def histogram(counter: "Counter[E]") -> dict[E, int]:
"""Drop the empty buckets, since an absent key means zero."""
return {key: total for key, total in counter.items() if total > 0}
+65
View File
@@ -0,0 +1,65 @@
"""Detection section: models, the detectors they run on, and inference speed."""
import os
from frigate.analytics.collectors.common import rate
from frigate.analytics.context import ReportContext
from frigate.analytics.schema import DetectionModel, DetectionSection, ModelSource
from frigate.config.config import DEFAULT_MODEL
from frigate.const import MODEL_CACHE_DIR
from frigate.detectors.detector_config import SceneEnum
from frigate.detectors.detector_types import DetectorTypeEnum
from frigate.detectors.device import runner_names
# the paths FrigateConfig fills in for a model that sets none
BUNDLED_MODEL_PATHS = frozenset(
{"/cpu_model.tflite", "/edgetpu_model.tflite", str(DEFAULT_MODEL["path"])}
)
def model_source(path: str | None) -> ModelSource:
"""Default, Frigate+ (a cached model next to its info file), or custom.
Parsing rewrites plus://<id> to the model cache, so the prefix is gone by now.
"""
if path is None or path in BUNDLED_MODEL_PATHS:
return ModelSource.default
if path.startswith(f"{MODEL_CACHE_DIR}/") and os.path.isfile(f"{path}.json"):
return ModelSource.plus
return ModelSource.custom
def collect(ctx: ReportContext) -> DetectionSection:
config = ctx.config
detectors = ctx.stats.get("detectors", {})
model_specs = [(model, config.devices_for_model(model)) for model in config.models]
# FrigateApp.start_detectors names the processes in this same order
names = iter(runner_names([spec for _, specs in model_specs for spec in specs]))
models: dict[SceneEnum, DetectionModel] = {}
for model, specs in model_specs:
speeds: list[float] = []
for _ in specs:
speed = detectors.get(next(names), {}).get("inference_speed")
if isinstance(speed, int | float) and speed > 0:
speeds.append(float(speed))
models[model.scene] = DetectionModel(
detector=DetectorTypeEnum(specs[0].detector),
devices=len(specs),
model_type=model.model_type,
input=f"{model.width}x{model.height}",
source=model_source(model.path),
inference_ms=rate(sum(speeds) / len(speeds)) if speeds else None,
)
return DetectionSection(
models=models,
detection_fps=rate(ctx.stats.get("detection_fps")),
skipped_fps=rate(ctx.stats.get("skipped_fps")),
)
+145
View File
@@ -0,0 +1,145 @@
"""Features section: enrichments, GenAI, integrations, and users."""
from collections import Counter
from frigate.analytics.collectors.common import closed, histogram
from frigate.analytics.context import ReportContext
from frigate.analytics.schema import (
BirdseyeUsage,
ClassificationUsage,
EnrichmentDevice,
EnrichmentUsage,
FeaturesSection,
GenAIUsage,
SemanticSearchModel,
SemanticSearchUsage,
TranscriptionModel,
TranscriptionUsage,
UserRole,
)
from frigate.config.camera.genai import GenAIProviderEnum, GenAIRoleEnum
from frigate.const import REPLAY_CAMERA_PREFIX
from frigate.models import User
RUNTIME_DEVICES = {
"cpu": EnrichmentDevice.cpu,
"cuda": EnrichmentDevice.cuda,
"tensorrt": EnrichmentDevice.tensorrt,
"migraphx": EnrichmentDevice.migraphx,
}
OPENVINO_DEVICES = {
"cpu": EnrichmentDevice.openvino_cpu,
"gpu": EnrichmentDevice.openvino_gpu,
"npu": EnrichmentDevice.openvino_npu,
}
def enrichment_device(label: object) -> EnrichmentDevice | None:
"""Map a runner's device label, like "CUDA" or "OpenVINO GPU.0,CPU"."""
if not isinstance(label, str) or not label:
return None
runtime, _, target = label.partition(" ")
if runtime == "OpenVINO":
first = target.split(",")[0].split(".")[0].strip().lower()
return OPENVINO_DEVICES.get(first, EnrichmentDevice.other)
return RUNTIME_DEVICES.get(label.lower(), EnrichmentDevice.other)
def model_name(model: object) -> str | None:
if model is None:
return None
return str(getattr(model, "value", model))
def semantic_model(model: object) -> SemanticSearchModel | None:
# any string that isn't a built-in model names a GenAI provider
name = model_name(model)
if name is None:
return None
if name in ("jinav1", "jinav2"):
return SemanticSearchModel(name)
return SemanticSearchModel.genai
def transcription_model(model: object) -> TranscriptionModel | None:
name = model_name(model)
if name is None:
return None
return TranscriptionModel.whisper if name == "whisper" else TranscriptionModel.genai
def users() -> dict[UserRole, int]:
roles: Counter[UserRole] = Counter(
closed(UserRole, user.role, UserRole.custom) for user in User.select(User.role)
)
return histogram(roles)
def collect(ctx: ReportContext) -> FeaturesSection:
config = ctx.config
devices = ctx.stats.get("embeddings", {}).get("devices", {})
cameras = [
camera
for name, camera in config.cameras.items()
if not name.startswith(REPLAY_CAMERA_PREFIX)
]
providers: Counter[GenAIProviderEnum] = Counter(
genai.provider for genai in config.genai.values()
)
roles: Counter[GenAIRoleEnum] = Counter(
role for genai in config.genai.values() for role in genai.roles
)
custom = list(config.classification.custom.values())
return FeaturesSection(
face_recognition=EnrichmentUsage(
enabled=config.face_recognition.enabled,
model_size=config.face_recognition.model_size,
device=enrichment_device(devices.get("face_recognition")),
),
lpr=EnrichmentUsage(
enabled=config.lpr.enabled,
model_size=config.lpr.model_size,
device=enrichment_device(devices.get("lpr")),
),
semantic_search=SemanticSearchUsage(
enabled=config.semantic_search.enabled,
model=semantic_model(config.semantic_search.model),
model_size=config.semantic_search.model_size,
device=enrichment_device(devices.get("semantic_search")),
triggers=sum(len(camera.semantic_search.triggers) for camera in cameras),
),
audio_transcription=TranscriptionUsage(
enabled=config.audio_transcription.enabled,
model=transcription_model(config.audio_transcription.model),
model_size=config.audio_transcription.model_size,
),
genai=GenAIUsage(providers=histogram(providers), roles=histogram(roles)),
classification_models=ClassificationUsage(
state=sum(1 for model in custom if model.state_config is not None),
object=sum(1 for model in custom if model.object_config is not None),
),
birdseye=BirdseyeUsage(
enabled=config.birdseye.enabled,
modes=list(config.birdseye.modes),
restream=config.birdseye.restream,
),
mqtt=config.mqtt.enabled,
notifications=config.notifications.enabled,
auth=config.auth.enabled,
proxy_auth=config.proxy.header_map.user is not None,
tls=config.tls.enabled,
users=users(),
camera_groups=len(config.camera_groups),
profiles=len(config.profiles),
plus_api_key=config.plus_api.is_active(),
)
+107
View File
@@ -0,0 +1,107 @@
"""Hardware section: CPU, memory, GPUs, decode and detection hardware, storage."""
import os
from collections import Counter
from typing import Any
import psutil
from frigate.analytics.collectors.common import closed, histogram
from frigate.analytics.context import ReportContext
from frigate.analytics.schema import (
DecodeFamily,
GpuInfo,
GpuVendor,
HardwareKey,
HardwareSection,
StorageInfo,
)
from frigate.const import RECORD_DIR
from frigate.detectors.hardware import hardware_prober
from frigate.util.hwaccel import hwaccel_options
DEVICE_TREE_MODEL = "/proc/device-tree/model"
CPUINFO = "/proc/cpuinfo"
def cpu_model() -> str:
"""The board model on ARM boards, else the CPU's model name."""
try:
with open(DEVICE_TREE_MODEL) as f:
board = f.read().strip("\x00\n ")
if board:
return board[:64]
except OSError:
pass
try:
with open(CPUINFO) as f:
for line in f:
key, _, value = line.partition(":")
if key.strip() == "model name" and value.strip():
return value.strip()[:64]
except OSError:
pass
return "unknown"
def gpus(stats: dict[str, Any]) -> list[GpuInfo]:
found: list[GpuInfo] = []
for name, entry in stats.get("gpu_usages", {}).items():
vendor = entry.get("vendor") if isinstance(entry, dict) else None
found.append(
GpuInfo(
vendor=closed(GpuVendor, vendor, GpuVendor.other),
name=str(name)[:64],
)
)
return found
def decode_families() -> list[DecodeFamily]:
_, available = hwaccel_options()
families = [
closed(DecodeFamily, family.key, DecodeFamily.other) for family in available
]
return list(dict.fromkeys(families))
def detection_hardware() -> dict[HardwareKey, int]:
units: Counter[HardwareKey] = Counter()
for found in hardware_prober.probe():
units[closed(HardwareKey, found.key, HardwareKey.other)] += found.count
return histogram(units)
def storage(stats: dict[str, Any]) -> StorageInfo:
# stats report sizes in MB
entry = stats.get("service", {}).get("storage", {}).get(RECORD_DIR) or {}
total_mb = float(entry.get("total") or 0)
used_mb = float(entry.get("used") or 0)
return StorageInfo(
record_fs=str(entry.get("mount_type") or "unknown")[:16],
record_total_gb=round(total_mb / 1024),
record_used_pct=min(round(used_mb / total_mb * 100), 100)
if total_mb > 0
else 0,
)
def collect(ctx: ReportContext) -> HardwareSection:
return HardwareSection(
cpu_model=cpu_model(),
cpu_cores=os.cpu_count() or 0,
memory_gb=round(psutil.virtual_memory().total / 2**30),
gpus=gpus(ctx.stats),
decode_families=decode_families(),
detection_hardware=detection_hardware(),
storage=storage(ctx.stats),
)
+59
View File
@@ -0,0 +1,59 @@
"""Health section: uptime, CPU, enrichment speed, and notice counts."""
from typing import Any
from frigate.analytics.collectors.common import rate
from frigate.analytics.context import ReportContext
from frigate.analytics.schema import (
EnrichmentTiming,
HealthSection,
NoticeCounts,
NoticeKindKey,
)
TIMING_STATS = {
EnrichmentTiming.face: "face_recognition_speed",
EnrichmentTiming.lpr: "plate_recognition_speed",
EnrichmentTiming.plate_detection: "yolov9_plate_detection_speed",
EnrichmentTiming.image_embedding: "image_embedding_speed",
EnrichmentTiming.text_embedding: "text_embedding_speed",
EnrichmentTiming.review_description: "review_description_speed",
EnrichmentTiming.object_description: "object_description_speed",
}
REPORTABLE_KINDS = frozenset(key.value for key in NoticeKindKey)
def notice_deltas(notice_stats: list[dict[str, Any]]) -> dict[Any, NoticeCounts]:
"""What changed since the last accepted report, per reportable kind."""
deltas: dict[Any, NoticeCounts] = {}
for row in notice_stats:
if row["kind"] not in REPORTABLE_KINDS:
continue
occurrences = max(row["occurrences"] - row["reported_occurrences"], 0)
dismissals = max(row["dismissals"] - row["reported_dismissals"], 0)
if occurrences or dismissals:
deltas[NoticeKindKey(row["kind"])] = NoticeCounts(
occurrences=occurrences, dismissals=dismissals
)
return deltas
def collect(ctx: ReportContext) -> HealthSection:
service = ctx.stats.get("service", {})
embeddings = ctx.stats.get("embeddings", {})
cpu = ctx.stats.get("cpu_usages", {}).get("frigate.full_system", {}).get("cpu")
timings = {
timing: rate(embeddings.get(key)) for timing, key in TIMING_STATS.items()
}
return HealthSection(
uptime_hours=int(rate(service.get("uptime")) // 3600),
cpu_percent=min(round(rate(cpu)), 100),
enrichment_ms={timing: value for timing, value in timings.items() if value > 0},
retention_unmet=bool(service.get("retention_unmet", False)),
notices=notice_deltas(ctx.notice_stats),
)
+63
View File
@@ -0,0 +1,63 @@
"""Install section: version, image variant, install type, platform."""
import os
import platform
import re
from frigate.analytics.collectors.common import closed
from frigate.analytics.context import ReportContext
from frigate.analytics.schema import Arch, ImageVariant, InstallSection, InstallType
from frigate.version import VERSION
KERNEL_PATTERN = re.compile(r"^(\d{1,3})\.(\d{1,3})")
def image_variant(value: str | None) -> ImageVariant:
"""The published image from the build-time FRIGATE_IMAGE_VARIANT, dev when unset."""
if not value:
return ImageVariant.dev
return closed(ImageVariant, value, ImageVariant.other)
def install_type() -> InstallType:
# the add-on is a container too, so it has to be checked first
if os.path.isfile("/data/options.json"):
return InstallType.ha_addon
if os.environ.get("KUBERNETES_SERVICE_HOST"):
return InstallType.kubernetes
if os.path.exists("/run/.containerenv"):
return InstallType.podman
if os.path.exists("/.dockerenv"):
return InstallType.docker
return InstallType.unknown
def arch(machine: str) -> Arch:
match machine.lower():
case "x86_64" | "amd64":
return Arch.x86_64
case "aarch64" | "arm64":
return Arch.aarch64
case _:
return Arch.other
def kernel(release: str) -> str:
match = KERNEL_PATTERN.match(release)
return f"{match.group(1)}.{match.group(2)}" if match else "unknown"
def collect(ctx: ReportContext) -> InstallSection:
return InstallSection(
version=VERSION[:32],
image_variant=image_variant(os.environ.get("FRIGATE_IMAGE_VARIANT")),
install_type=install_type(),
arch=arch(platform.machine()),
kernel=kernel(platform.release()),
run_as_root=os.geteuid() == 0,
)
+13
View File
@@ -0,0 +1,13 @@
"""What the collectors read, gathered once per report."""
from dataclasses import dataclass, field
from typing import Any
from frigate.config import FrigateConfig
@dataclass(frozen=True)
class ReportContext:
config: FrigateConfig
stats: dict[str, Any]
notice_stats: list[dict[str, Any]] = field(default_factory=list)
+88
View File
@@ -0,0 +1,88 @@
"""Build a report from the section collectors."""
import logging
import time
from collections.abc import Callable
from typing import TYPE_CHECKING, Any
from uuid import uuid4
from pydantic import BaseModel
from frigate.analytics.collectors import (
cameras,
detection,
features,
hardware,
health,
install,
)
from frigate.analytics.context import ReportContext
from frigate.analytics.schema import SCHEMA_VERSION, AnalyticsReport
from frigate.analytics.state import load_state
from frigate.config import FrigateConfig
if TYPE_CHECKING:
from frigate.notices.registry import NoticeRegistry
from frigate.stats.emitter import StatsEmitter
logger = logging.getLogger(__name__)
COLLECTORS: dict[str, Callable[[ReportContext], BaseModel | None]] = {
"install": install.collect,
"hardware": hardware.collect,
"detection": detection.collect,
"cameras": cameras.collect,
"features": features.collect,
"health": health.collect,
}
# shown in the preview until the first report creates a real ID
PREVIEW_INSTALL_ID = "0" * 32
def build_report(
ctx: ReportContext, install_id: str, sent_at: int | None = None
) -> AnalyticsReport:
"""Run every collector; one that fails sends its section as null."""
sections: dict[str, Any] = {}
for name, collect in COLLECTORS.items():
try:
sections[name] = collect(ctx)
except Exception:
# a collector bug must cost one section, never the whole report
logger.warning("Analytics %s section failed", name, exc_info=True)
sections[name] = None
return AnalyticsReport.model_validate(
{
"schema_version": SCHEMA_VERSION,
"install_id": install_id,
"report_id": str(uuid4()),
"sent_at": int(time.time()) if sent_at is None else sent_at,
**sections,
}
)
def gather_context(
config: FrigateConfig,
stats_emitter: "StatsEmitter | None",
notice_registry: "NoticeRegistry | None",
) -> ReportContext:
return ReportContext(
config=config,
stats=stats_emitter.get_latest_stats() if stats_emitter is not None else {},
notice_stats=notice_registry.stats() if notice_registry is not None else [],
)
def preview_report(
config: FrigateConfig,
stats_emitter: "StatsEmitter | None",
notice_registry: "NoticeRegistry | None",
) -> AnalyticsReport:
"""The report the next send would carry, without sending it."""
state = load_state()
ctx = gather_context(config, stats_emitter, notice_registry)
return build_report(ctx, state.install_id if state else PREVIEW_INSTALL_ID)
+177
View File
@@ -0,0 +1,177 @@
"""Send one analytics report a day while the admin has opted in."""
import logging
import random
import threading
import time
from collections.abc import Callable
from multiprocessing.synchronize import Event as MpEvent
from typing import TYPE_CHECKING
from frigate.analytics.context import ReportContext
from frigate.analytics.report import build_report
from frigate.analytics.state import (
STATE_PATH,
AnalyticsState,
delete_state,
load_state,
new_state,
save_state,
)
from frigate.analytics.transport import SendOutcome, send_report
from frigate.config import FrigateConfig
from frigate.config.holder import ConfigHolder
from frigate.const import ANALYTICS_URL
from frigate.notices import raise_notice, resolve_notice
if TYPE_CHECKING:
from frigate.notices.registry import NoticeRegistry
from frigate.stats.emitter import StatsEmitter
logger = logging.getLogger(__name__)
WAKE_S = 10 * 60
INTERVAL_S = 24 * 60 * 60
JITTER_S = 60 * 60
FIRST_DELAY_S = (15 * 60, 45 * 60)
PROMPT_KIND = "analytics_prompt"
class AnalyticsReporter(threading.Thread):
"""Follows the live config, so a settings save needs no restart."""
def __init__(
self,
config_holder: ConfigHolder,
stats_emitter: "StatsEmitter",
notice_registry: "NoticeRegistry",
stop_event: MpEvent | threading.Event,
*,
state_path: str = STATE_PATH,
url: str = ANALYTICS_URL,
send: Callable[[str, str], SendOutcome] = send_report,
clock: Callable[[], float] = time.time,
rng: random.Random | None = None,
) -> None:
super().__init__(name="analytics_reporter", daemon=True)
self.config_holder = config_holder
self.stats_emitter = stats_emitter
self.notice_registry = notice_registry
self.stop_event = stop_event
self.state_path = state_path
self.url = url
self.send = send
self.clock = clock
self.rng = rng or random.Random()
self.first_due = clock() + self.rng.uniform(*FIRST_DELAY_S)
self.interval = self._next_interval()
self.opted_in: bool | None = None
self.warned_unwritable = False
# a settings save runs on an API thread while a wake may be mid-attempt
self._lock = threading.Lock()
config_holder.subscribe(self._on_config)
def _next_interval(self) -> float:
return INTERVAL_S + self.rng.uniform(-JITTER_S, JITTER_S)
def run(self) -> None:
while True:
try:
self.tick()
except Exception:
logger.exception("Analytics reporter failed")
if self.stop_event.wait(WAKE_S):
break
def _on_config(self, config: FrigateConfig) -> None:
# a save can turn sharing off and back on between two wakes, so an
# opt-out is handled when it's saved rather than at the next wake
with self._lock:
if not config.safe_mode:
self._apply_consent(config.telemetry.analytics)
def _apply_consent(self, opted_in: bool) -> None:
# called with the lock held
if opted_in == self.opted_in:
return
self.opted_in = opted_in
if opted_in:
resolve_notice(PROMPT_KIND)
else:
raise_notice(PROMPT_KIND)
delete_state(self.state_path)
def tick(self) -> None:
with self._lock:
config = self.config_holder.config
# safe mode parses a default config where analytics reads as off,
# and handling that as an opt-out would delete the install ID
if config.safe_mode:
return
self._apply_consent(config.telemetry.analytics)
if not config.telemetry.analytics:
return
now = self.clock()
if now < self.first_due:
return
state = load_state(self.state_path) or new_state()
if not self._due(state.last_attempt_at, now):
return
# saved before sending, so a failing endpoint or a crash mid-send
# still waits a full interval; without saved state every boot would
# send under a new install ID
if not save_state(AnalyticsState(state.install_id, now), self.state_path):
if not self.warned_unwritable:
logger.warning(
"Analytics is on, but %s isn't writable, so no report is sent",
self.state_path,
)
self.warned_unwritable = True
return
self.interval = self._next_interval()
# the lock stays free during the request, so a save never waits on it
self._send(state.install_id, now)
def _due(self, last_attempt_at: float, now: float) -> bool:
# a last attempt stamped in the future came from a wrong clock
return (
now >= last_attempt_at + self.interval or last_attempt_at > now + INTERVAL_S
)
def _send(self, install_id: str, now: float) -> None:
notice_stats = self.notice_registry.stats()
ctx = ReportContext(
config=self.config_holder.config,
stats=self.stats_emitter.get_latest_stats(),
notice_stats=notice_stats,
)
report = build_report(ctx, install_id, sent_at=int(now))
body = report.model_dump_json()
# consent can be withdrawn while the report builds
if not self.config_holder.config.telemetry.analytics:
return
if self.send(self.url, body) is not SendOutcome.accepted:
return
# a failed health section sent no notice counts, so they stay pending
if report.health is not None:
self.notice_registry.mark_reported(notice_stats)
logger.info("Sent the daily analytics report")
logger.debug("Analytics report: %s", body)
+407
View File
@@ -0,0 +1,407 @@
"""Models for the analytics report, the contract with the ingest endpoint.
Every field carries a description and an x-public flag, and no field accepts
user-entered text, so a report can't carry camera names or other free text.
"""
from enum import StrEnum
from typing import Any
from pydantic import BaseModel, ConfigDict, Field
from frigate.config.camera.birdseye import BirdseyeModeEnum
from frigate.config.camera.camera import CameraTypeEnum
from frigate.config.camera.genai import GenAIProviderEnum, GenAIRoleEnum
from frigate.config.classification import ModelSizeEnum
from frigate.detectors.detector_config import ModelTypeEnum, SceneEnum
from frigate.detectors.detector_types import DetectorTypeEnum
from frigate.ffmpeg_presets import PRESETS_HW_ACCEL_DECODE, PRESETS_INPUT
from frigate.notices.types import NOTICE_KINDS
SCHEMA_VERSION = 1
class ImageVariant(StrEnum):
standard = "standard"
rpi = "rpi"
tensorrt = "tensorrt"
tensorrt_jp6 = "tensorrt-jp6"
rocm = "rocm"
rk = "rk"
synaptics = "synaptics"
dev = "dev"
other = "other"
class InstallType(StrEnum):
ha_addon = "ha_addon"
docker = "docker"
podman = "podman"
kubernetes = "kubernetes"
unknown = "unknown"
class Arch(StrEnum):
x86_64 = "x86_64"
aarch64 = "aarch64"
other = "other"
class GpuVendor(StrEnum):
intel = "intel"
amd = "amd"
nvidia = "nvidia"
rockchip = "rockchip"
rpi = "rpi"
other = "other"
class DecodeFamily(StrEnum):
nvidia = "nvidia"
vaapi = "vaapi"
rkmpp = "rkmpp"
intel_qsv = "intel-qsv"
jetson = "jetson"
rpi = "rpi"
other = "other"
class HardwareKey(StrEnum):
edgetpu_pci = "edgetpu:pci"
edgetpu_usb = "edgetpu:usb"
openvino_gpu = "openvino:GPU"
openvino_npu = "openvino:NPU"
onnx_amd = "onnx:amd"
onnx_nvidia = "onnx:nvidia"
tensorrt = "tensorrt"
hailo = "hailo"
memryx = "memryx"
deepx = "deepx"
rknn = "rknn"
axengine = "axengine"
synaptics = "synaptics"
cpu = "cpu"
other = "other"
class ModelSource(StrEnum):
default = "default"
plus = "plus"
custom = "custom"
class HeightBucket(StrEnum):
le_360 = "le_360"
h480 = "480"
h720 = "720"
h1080 = "1080"
h1440 = "1440"
ge_2160 = "ge_2160"
class FpsBucket(StrEnum):
le_5 = "le_5"
f6_10 = "6_10"
gt_10 = "gt_10"
class RetainBucket(StrEnum):
zero = "0"
d1_7 = "1_7"
d8_30 = "8_30"
gt_30 = "gt_30"
class ConnectionQuality(StrEnum):
excellent = "excellent"
fair = "fair"
poor = "poor"
unusable = "unusable"
class EnrichmentDevice(StrEnum):
cpu = "cpu"
cuda = "cuda"
tensorrt = "tensorrt"
migraphx = "migraphx"
openvino_cpu = "openvino_cpu"
openvino_gpu = "openvino_gpu"
openvino_npu = "openvino_npu"
other = "other"
class SemanticSearchModel(StrEnum):
jinav1 = "jinav1"
jinav2 = "jinav2"
genai = "genai"
class TranscriptionModel(StrEnum):
whisper = "whisper"
genai = "genai"
class UserRole(StrEnum):
admin = "admin"
viewer = "viewer"
custom = "custom"
class EnrichmentTiming(StrEnum):
face = "face"
lpr = "lpr"
plate_detection = "plate_detection"
image_embedding = "image_embedding"
text_embedding = "text_embedding"
review_description = "review_description"
object_description = "object_description"
def _preset_keys(presets: dict[str, Any]) -> dict[str, str]:
keys = [name.removeprefix("preset-") for name in presets]
return {key: key for key in [*keys, "custom", "none"]}
# built from the registries they mirror, so a new preset or notice kind reaches
# the schema through generate_analytics_schema.py instead of a hand edit
HwaccelKey = StrEnum("HwaccelKey", _preset_keys(PRESETS_HW_ACCEL_DECODE)) # type: ignore[misc]
InputPresetKey = StrEnum("InputPresetKey", _preset_keys(PRESETS_INPUT)) # type: ignore[misc]
NoticeKindKey = StrEnum( # type: ignore[misc]
"NoticeKindKey",
{key: key for key, kind in NOTICE_KINDS.items() if kind.reportable},
)
class AnalyticsModel(BaseModel):
model_config = ConfigDict(extra="forbid")
def metric(description: str, *, public: bool = True, **kwargs: Any) -> Any:
"""Declare a report field; the description and flag land in the schema."""
return Field(
description=description, json_schema_extra={"x-public": public}, **kwargs
)
def count(description: str) -> Any:
return metric(description, ge=0)
class InstallSection(AnalyticsModel):
version: str = metric("Frigate version string", max_length=32)
image_variant: ImageVariant = metric("Published image the install runs")
install_type: InstallType = metric("How Frigate is installed")
arch: Arch = metric("CPU architecture")
kernel: str = metric(
"Host kernel as major.minor", pattern=r"^(\d{1,3}\.\d{1,3}|unknown)$"
)
run_as_root: bool = metric("Whether the main process runs as root")
class GpuInfo(AnalyticsModel):
vendor: GpuVendor = metric("GPU vendor")
name: str = metric("GPU name as the hardware reports it", max_length=64)
class StorageInfo(AnalyticsModel):
record_fs: str = metric("Filesystem of the recordings volume", max_length=16)
record_total_gb: int = count("Size of the recordings volume in GB")
record_used_pct: int = metric(
"Percent of the recordings volume in use", ge=0, le=100
)
class HardwareSection(AnalyticsModel):
cpu_model: str = metric(
"CPU or board model as the hardware reports it", max_length=64
)
cpu_cores: int = count("Logical CPU count")
memory_gb: int = count("Total memory in GB")
gpus: list[GpuInfo] = metric("GPUs the stats collector found")
decode_families: list[DecodeFamily] = metric(
"Hardware decode families this system can use"
)
detection_hardware: dict[HardwareKey, int] = metric(
"Detection hardware found, as unit counts by kind"
)
storage: StorageInfo = metric("Recordings storage")
class DetectionModel(AnalyticsModel):
detector: DetectorTypeEnum = metric("Detector type the model runs on")
devices: int = count("Devices the model runs on")
model_type: ModelTypeEnum = metric("Model architecture")
input: str = metric("Model input size as WxH", pattern=r"^\d{1,5}x\d{1,5}$")
source: ModelSource = metric("Where the model came from", public=False)
inference_ms: float | None = metric(
"Mean inference time across the model's detector processes, null before the first stats",
ge=0,
)
class DetectionSection(AnalyticsModel):
models: dict[SceneEnum, DetectionModel] = metric("Detection models keyed by scene")
detection_fps: float = metric("Detections per second across cameras", ge=0)
skipped_fps: float = metric("Frames per second skipped across cameras", ge=0)
class RetainDays(AnalyticsModel):
continuous: dict[RetainBucket, int] = metric(
"Recording cameras by continuous retention in days"
)
motion: dict[RetainBucket, int] = metric(
"Recording cameras by motion retention in days"
)
alerts: dict[RetainBucket, int] = metric(
"Recording cameras by alert retention in days"
)
detections: dict[RetainBucket, int] = metric(
"Recording cameras by detection retention in days"
)
class CamerasSection(AnalyticsModel):
total: int = count("Configured cameras")
enabled: int = count("Enabled cameras")
types: dict[CameraTypeEnum, int] = metric("Cameras by type")
detect_height: dict[HeightBucket, int] = metric(
"Cameras by detect resolution height"
)
detect_fps: dict[FpsBucket, int] = metric("Cameras by detect fps")
hwaccel: dict[HwaccelKey, int] = metric(
"Cameras by the resolved hwaccel preset of the detect input"
)
input_preset: dict[InputPresetKey, int] = metric(
"Cameras by the input preset of the detect input"
)
go2rtc_restream: int = count("Cameras with an input from the go2rtc restream")
separate_detect_stream: int = count(
"Cameras whose detect input differs from their record input"
)
detect: int = count("Cameras with detection on")
record: int = count("Cameras with recording on")
sub_stream_record: int = count("Cameras with sub stream recording on")
snapshots: int = count("Cameras with snapshots on")
audio: int = count("Cameras with audio detection on")
audio_transcription: int = count("Cameras with audio transcription on")
birdseye: int = count("Cameras in birdseye")
onvif: int = count("Cameras with an ONVIF host")
autotracking: int = count("Cameras with PTZ autotracking on")
face_recognition: int = count("Cameras with face recognition on")
lpr: int = count("Cameras with license plate recognition on")
review_genai: int = count("Cameras with GenAI review summaries on")
object_genai: int = count("Cameras with GenAI object descriptions on")
notifications: int = count("Cameras with notifications on")
zones: int = count("Zones across cameras")
cameras_with_zones: int = count("Cameras with at least one zone")
motion_masks: int = count("Motion masks across cameras")
object_masks: int = count("Object masks across cameras")
connection_quality: dict[ConnectionQuality, int] = metric(
"Cameras by connection quality at send time"
)
retain_days: RetainDays = metric("Recording retention")
class EnrichmentUsage(AnalyticsModel):
enabled: bool = metric("Whether the enrichment is on")
model_size: ModelSizeEnum = metric("Configured model size")
device: EnrichmentDevice | None = metric(
"Device the model loaded on, null when it isn't loaded"
)
class SemanticSearchUsage(AnalyticsModel):
enabled: bool = metric("Whether semantic search is on")
model: SemanticSearchModel | None = metric(
"Embedding model, genai for a GenAI provider"
)
model_size: ModelSizeEnum = metric("Configured model size")
device: EnrichmentDevice | None = metric(
"Device the model loaded on, null when it isn't loaded"
)
triggers: int = count("Semantic search triggers across cameras")
class TranscriptionUsage(AnalyticsModel):
enabled: bool = metric("Whether audio transcription is on")
model: TranscriptionModel | None = metric(
"Transcription model, genai for a GenAI provider"
)
model_size: ModelSizeEnum = metric("Configured model size")
class GenAIUsage(AnalyticsModel):
providers: dict[GenAIProviderEnum, int] = metric(
"Configured GenAI providers by type"
)
roles: dict[GenAIRoleEnum, int] = metric("Configured GenAI providers by role")
class ClassificationUsage(AnalyticsModel):
state: int = count("Custom state classification models")
object: int = count("Custom object classification models")
class BirdseyeUsage(AnalyticsModel):
enabled: bool = metric("Whether birdseye is on")
modes: list[BirdseyeModeEnum] = metric("Birdseye modes")
restream: bool = metric("Whether birdseye is restreamed")
class FeaturesSection(AnalyticsModel):
face_recognition: EnrichmentUsage = metric("Face recognition")
lpr: EnrichmentUsage = metric("License plate recognition")
semantic_search: SemanticSearchUsage = metric("Semantic search")
audio_transcription: TranscriptionUsage = metric("Audio transcription")
genai: GenAIUsage = metric("Generative AI providers")
classification_models: ClassificationUsage = metric("Custom classification models")
birdseye: BirdseyeUsage = metric("Birdseye")
mqtt: bool = metric("Whether MQTT is on")
notifications: bool = metric("Whether web push notifications are on")
auth: bool = metric("Whether authentication is on")
proxy_auth: bool = metric("Whether a proxy supplies the user header")
tls: bool = metric("Whether TLS is on")
users: dict[UserRole, int] = metric("Users by role")
camera_groups: int = count("Camera groups")
profiles: int = count("Profiles")
plus_api_key: bool = metric("Whether a Frigate+ API key is set", public=False)
class NoticeCounts(AnalyticsModel):
occurrences: int = count("Occurrences since the last accepted report")
dismissals: int = count("Dismissals since the last accepted report")
class HealthSection(AnalyticsModel):
uptime_hours: int = count("Hours since Frigate started")
cpu_percent: int = metric("System CPU use at send time", ge=0, le=100)
enrichment_ms: dict[EnrichmentTiming, float] = metric(
"Mean enrichment inference times in milliseconds"
)
retention_unmet: bool = metric(
"Whether storage can't keep the configured retention"
)
notices: dict[NoticeKindKey, NoticeCounts] = metric(
"Notice counts by kind since the last accepted report", public=False
)
class AnalyticsReport(AnalyticsModel):
schema_version: int = metric("Report format version", ge=1)
install_id: str = metric(
"Random install identifier", public=False, pattern=r"^[0-9a-f]{32}$"
)
report_id: str = metric(
"Random identifier of this report",
public=False,
pattern=r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
)
sent_at: int = count("Unix time the report was built")
install: InstallSection | None = metric("Install, null if its collector failed")
hardware: HardwareSection | None = metric("Hardware, null if its collector failed")
detection: DetectionSection | None = metric(
"Object detection, null if its collector failed"
)
cameras: CamerasSection | None = metric("Cameras, null if its collector failed")
features: FeaturesSection | None = metric("Features, null if its collector failed")
health: HealthSection | None = metric("Health, null if its collector failed")
+85
View File
@@ -0,0 +1,85 @@
"""The install's analytics identity and last attempt time, kept under /config."""
import json
import logging
import os
import re
from dataclasses import dataclass
from uuid import uuid4
from frigate.const import CONFIG_DIR
logger = logging.getLogger(__name__)
STATE_PATH = os.path.join(CONFIG_DIR, ".analytics.json")
INSTALL_ID_PATTERN = re.compile(r"[0-9a-f]{32}")
@dataclass(frozen=True)
class AnalyticsState:
install_id: str
last_attempt_at: float
def new_state() -> AnalyticsState:
return AnalyticsState(install_id=uuid4().hex, last_attempt_at=0.0)
def load_state(path: str = STATE_PATH) -> AnalyticsState | None:
"""The saved state, or None when the file is missing or unusable."""
try:
with open(path) as f:
data = json.load(f)
except FileNotFoundError:
return None
except (OSError, ValueError):
logger.warning("Ignoring unreadable analytics state at %s", path)
return None
if not isinstance(data, dict):
return None
install_id = data.get("install_id")
last_attempt_at = data.get("last_attempt_at")
if (
not isinstance(install_id, str)
or not INSTALL_ID_PATTERN.fullmatch(install_id)
or isinstance(last_attempt_at, bool)
or not isinstance(last_attempt_at, int | float)
):
logger.warning("Ignoring invalid analytics state at %s", path)
return None
return AnalyticsState(install_id=install_id, last_attempt_at=float(last_attempt_at))
def save_state(state: AnalyticsState, path: str = STATE_PATH) -> bool:
"""Write the state atomically, returning False when it can't be written."""
temp_path = f"{path}.tmp"
try:
with open(temp_path, "w") as f:
json.dump(
{
"install_id": state.install_id,
"last_attempt_at": state.last_attempt_at,
},
f,
)
os.replace(temp_path, path)
except OSError:
return False
return True
def delete_state(path: str = STATE_PATH) -> None:
"""Forget the install ID, so a later opt-in starts a fresh identity."""
try:
os.remove(path)
except FileNotFoundError:
pass
except OSError:
logger.warning("Unable to delete analytics state at %s", path)
+54
View File
@@ -0,0 +1,54 @@
"""POST a report to the ingest endpoint."""
import logging
from enum import Enum
import requests
from frigate.version import VERSION
logger = logging.getLogger(__name__)
TIMEOUT_S = 30
class SendOutcome(Enum):
accepted = "accepted"
rejected = "rejected"
rate_limited = "rate_limited"
failed = "failed"
def send_report(url: str, body: str) -> SendOutcome:
"""Send one report. Never raises; the outcome says what happened."""
try:
# a redirect would turn the POST into a GET, so it counts as a failure
response = requests.post(
url,
data=body.encode(),
headers={
"Content-Type": "application/json",
"User-Agent": f"Frigate/{VERSION}",
},
timeout=TIMEOUT_S,
allow_redirects=False,
)
except requests.RequestException as err:
logger.warning("Unable to send the analytics report: %s", err)
return SendOutcome.failed
status = response.status_code
if 200 <= status < 300:
return SendOutcome.accepted
if status == 400:
logger.warning("The analytics report was rejected: %s", response.text[:200])
return SendOutcome.rejected
if status == 429:
logger.debug("The analytics endpoint is rate limiting this install")
return SendOutcome.rate_limited
logger.warning("The analytics endpoint returned %s", status)
return SendOutcome.failed
+25
View File
@@ -0,0 +1,25 @@
"""Analytics APIs."""
import logging
from fastapi import APIRouter, Depends, Request
from fastapi.responses import JSONResponse
from frigate.analytics.report import preview_report
from frigate.api.auth import require_role
from frigate.api.defs.tags import Tags
logger = logging.getLogger(__name__)
router = APIRouter(tags=[Tags.analytics])
@router.get("/analytics/preview", dependencies=[Depends(require_role(["admin"]))])
def get_analytics_preview(request: Request) -> JSONResponse:
"""Get the analytics report Frigate would send next, without sending it."""
report = preview_report(
request.app.frigate_config,
request.app.stats_emitter,
request.app.notice_registry,
)
return JSONResponse(content=report.model_dump(mode="json"))
+1
View File
@@ -2,6 +2,7 @@ from enum import Enum
class Tags(Enum): class Tags(Enum):
analytics = "Analytics"
app = "App" app = "App"
auth = "Auth" auth = "Auth"
camera = "Camera" camera = "Camera"
+3 -1
View File
@@ -12,8 +12,8 @@ from slowapi.middleware import SlowAPIMiddleware
from starlette_context import middleware, plugins from starlette_context import middleware, plugins
from starlette_context.plugins import Plugin from starlette_context.plugins import Plugin
from frigate.api import app as main_app
from frigate.api import ( from frigate.api import (
analytics,
auth, auth,
camera, camera,
chat, chat,
@@ -30,6 +30,7 @@ from frigate.api import (
record, record,
review, review,
) )
from frigate.api import app as main_app
from frigate.api.auth import get_jwt_secret, limiter, require_admin_by_default from frigate.api.auth import get_jwt_secret, limiter, require_admin_by_default
from frigate.comms.dispatcher import Dispatcher from frigate.comms.dispatcher import Dispatcher
from frigate.comms.event_metadata_updater import ( from frigate.comms.event_metadata_updater import (
@@ -140,6 +141,7 @@ def create_fastapi_app(
# Routes # Routes
# Order of include_router matters: https://fastapi.tiangolo.com/tutorial/path-params/#order-matters # Order of include_router matters: https://fastapi.tiangolo.com/tutorial/path-params/#order-matters
app.include_router(analytics.router)
app.include_router(auth.router) app.include_router(auth.router)
app.include_router(camera.router) app.include_router(camera.router)
app.include_router(chat.router) app.include_router(chat.router)
+82 -61
View File
@@ -258,15 +258,15 @@ async def latest_frame(
frame = request.app.camera_error_image frame = request.app.camera_error_image
height = int(params.height or str(frame.shape[0]))
width = int(height * frame.shape[1] / frame.shape[0])
if frame is None: if frame is None:
return JSONResponse( return JSONResponse(
content={"success": False, "message": "Unable to get valid frame"}, content={"success": False, "message": "Unable to get valid frame"},
status_code=500, status_code=500,
) )
height = int(params.height or str(frame.shape[0]))
width = int(height * frame.shape[1] / frame.shape[0])
if height < 1 or width < 1: if height < 1 or width < 1:
return JSONResponse( return JSONResponse(
content="Invalid height / width requested :: {} / {}".format( content="Invalid height / width requested :: {} / {}".format(
@@ -886,9 +886,8 @@ async def vod_event(
# If the recordings are not found and the event started more than 5 minutes ago, set has_clip to false # If the recordings are not found and the event started more than 5 minutes ago, set has_clip to false
if ( if (
event.start_time < datetime.now().timestamp() - 300 event.start_time < datetime.now().timestamp() - 300
and type(vod_response) is tuple and isinstance(vod_response, JSONResponse)
and len(vod_response) == 2 and vod_response.status_code == 404
and vod_response[1] == 404
): ):
Event.update(has_clip=False).where(Event.id == event_id).execute() Event.update(has_clip=False).where(Event.id == event_id).execute()
@@ -956,64 +955,80 @@ async def event_snapshot(
event_complete = False event_complete = False
jpg_bytes = None jpg_bytes = None
frame_time = 0 frame_time = 0
try: try:
event = Event.get(Event.id == event_id, Event.end_time != None) event = Event.get(Event.id == event_id, Event.end_time != None)
event_complete = True
await require_camera_access(event.camera, request=request) await require_camera_access(event.camera, request=request)
except DoesNotExist:
event = None
if event is not None:
event_complete = True
if not event.has_snapshot: if not event.has_snapshot:
return JSONResponse( return JSONResponse(
content={"success": False, "message": "Snapshot not available"}, content={"success": False, "message": "Snapshot not available"},
status_code=404, status_code=404,
) )
snapshot_settings = _resolve_snapshot_settings(
request.app.frigate_config.cameras[event.camera].snapshots, params
)
jpg_bytes, frame_time = get_event_snapshot_bytes(
event,
ext="jpg",
timestamp=snapshot_settings["timestamp"],
bounding_box=snapshot_settings["bounding_box"],
crop=snapshot_settings["crop"],
height=snapshot_settings["height"],
quality=snapshot_settings["quality"],
timestamp_style=request.app.frigate_config.cameras[
event.camera
].timestamp_style,
colormap=request.app.frigate_config.model_for_camera(event.camera).colormap,
)
except DoesNotExist:
# see if the object is currently being tracked
try: try:
camera_states: list[CameraState] = ( snapshot_settings = _resolve_snapshot_settings(
request.app.detected_frames_processor.get_camera_states() request.app.frigate_config.cameras[event.camera].snapshots, params
)
jpg_bytes, frame_time = get_event_snapshot_bytes(
event,
ext="jpg",
timestamp=snapshot_settings["timestamp"],
bounding_box=snapshot_settings["bounding_box"],
crop=snapshot_settings["crop"],
height=snapshot_settings["height"],
quality=snapshot_settings["quality"],
timestamp_style=request.app.frigate_config.cameras[
event.camera
].timestamp_style,
colormap=request.app.frigate_config.model_for_camera(
event.camera
).colormap,
) )
for camera_state in camera_states:
if event_id in camera_state.tracked_objects:
tracked_obj = camera_state.tracked_objects.get(event_id)
if tracked_obj is not None:
snapshot_settings = _resolve_snapshot_settings(
camera_state.camera_config.snapshots, params
)
jpg_bytes, frame_time = tracked_obj.get_img_bytes(
ext="jpg",
timestamp=snapshot_settings["timestamp"],
bounding_box=snapshot_settings["bounding_box"],
crop=snapshot_settings["crop"],
height=snapshot_settings["height"],
quality=snapshot_settings["quality"],
)
await require_camera_access(camera_state.name, request=request)
except Exception: except Exception:
return JSONResponse( return JSONResponse(
content={"success": False, "message": "Ongoing event not found"}, content={"success": False, "message": "Unknown error occurred"},
status_code=404, status_code=404,
) )
except Exception: else:
return JSONResponse( # see if the object is currently being tracked
content={"success": False, "message": "Unknown error occurred"}, camera_states: list[CameraState] = (
status_code=404, request.app.detected_frames_processor.get_camera_states()
) )
for camera_state in camera_states:
tracked_obj = camera_state.tracked_objects.get(event_id)
if tracked_obj is None:
continue
await require_camera_access(camera_state.name, request=request)
try:
snapshot_settings = _resolve_snapshot_settings(
camera_state.camera_config.snapshots, params
)
jpg_bytes, frame_time = tracked_obj.get_img_bytes(
ext="jpg",
timestamp=snapshot_settings["timestamp"],
bounding_box=snapshot_settings["bounding_box"],
crop=snapshot_settings["crop"],
height=snapshot_settings["height"],
quality=snapshot_settings["quality"],
)
except Exception:
return JSONResponse(
content={"success": False, "message": "Ongoing event not found"},
status_code=404,
)
break
if jpg_bytes is None: if jpg_bytes is None:
return JSONResponse( return JSONResponse(
content={"success": False, "message": "Live frame not available"}, content={"success": False, "message": "Live frame not available"},
@@ -1062,19 +1077,25 @@ async def event_thumbnail(
if not thumbnail_bytes: if not thumbnail_bytes:
# see if the object is currently being tracked # see if the object is currently being tracked
try: camera_states = request.app.detected_frames_processor.get_camera_states()
camera_states = request.app.detected_frames_processor.get_camera_states()
for camera_state in camera_states: for camera_state in camera_states:
if event_id in camera_state.tracked_objects: tracked_obj = camera_state.tracked_objects.get(event_id)
tracked_obj = camera_state.tracked_objects.get(event_id)
if tracked_obj is not None: if tracked_obj is None:
await require_camera_access(camera_state.name, request=request) continue
thumbnail_bytes = tracked_obj.get_thumbnail(extension.value)
except Exception: await require_camera_access(camera_state.name, request=request)
return JSONResponse(
content={"success": False, "message": "Event not found"}, try:
status_code=404, thumbnail_bytes = tracked_obj.get_thumbnail(extension.value)
) except Exception:
return JSONResponse(
content={"success": False, "message": "Event not found"},
status_code=404,
)
break
if not thumbnail_bytes: if not thumbnail_bytes:
return JSONResponse( return JSONResponse(
+25 -2
View File
@@ -15,6 +15,7 @@ import uvicorn
from peewee_migrate import Router from peewee_migrate import Router
from playhouse.sqlite_ext import SqliteExtDatabase from playhouse.sqlite_ext import SqliteExtDatabase
from frigate.analytics.reporter import AnalyticsReporter
from frigate.api.auth import hash_password from frigate.api.auth import hash_password
from frigate.api.fastapi_app import create_fastapi_app from frigate.api.fastapi_app import create_fastapi_app
from frigate.camera import CameraMetrics, PTZMetrics from frigate.camera import CameraMetrics, PTZMetrics
@@ -483,7 +484,7 @@ class FrigateApp:
def start_audio_processor(self) -> None: def start_audio_processor(self) -> None:
self.audio_process = AudioProcessor( self.audio_process = AudioProcessor(
self.config, self.camera_metrics, self.stop_event self.config, self.camera_metrics, self.embeddings_metrics, self.stop_event
) )
self.audio_process.start() self.audio_process.start()
self.processes["audio_detector"] = self.audio_process.pid or 0 self.processes["audio_detector"] = self.audio_process.pid or 0
@@ -529,6 +530,15 @@ class FrigateApp:
) )
self.stats_emitter.start() self.stats_emitter.start()
def start_analytics_reporter(self) -> None:
self.analytics_reporter = AnalyticsReporter(
self.config_holder,
self.stats_emitter,
self.notice_registry,
self.stop_event,
)
self.analytics_reporter.start()
def start_watchdog(self) -> None: def start_watchdog(self) -> None:
self.frigate_watchdog = FrigateWatchdog(self.detectors, self.stop_event) self.frigate_watchdog = FrigateWatchdog(self.detectors, self.stop_event)
@@ -556,10 +566,20 @@ class FrigateApp:
"output", "output",
lambda: OutputProcess(self.config, self.stop_event), lambda: OutputProcess(self.config, self.stop_event),
), ),
(
"audio_process",
"audio_detector",
lambda: AudioProcessor(
self.config,
self.camera_metrics,
self.embeddings_metrics,
self.stop_event,
),
),
] ]
for attr, key, factory in specs: for attr, key, factory in specs:
if not hasattr(self, attr): if getattr(self, attr, None) is None:
continue continue
def on_restart( def on_restart(
@@ -670,6 +690,7 @@ class FrigateApp:
self.start_audio_processor() self.start_audio_processor()
self.start_storage_maintainer() self.start_storage_maintainer()
self.start_stats_emitter() self.start_stats_emitter()
self.start_analytics_reporter()
self.start_timeline_processor() self.start_timeline_processor()
self.start_event_processor() self.start_event_processor()
self.start_event_cleanup() self.start_event_cleanup()
@@ -769,6 +790,8 @@ class FrigateApp:
self.event_cleanup.join() self.event_cleanup.join()
self.record_cleanup.join() self.record_cleanup.join()
self.stats_emitter.join() self.stats_emitter.join()
# a send in flight can hold the thread for the whole request timeout
self.analytics_reporter.join(timeout=5)
self.frigate_watchdog.join() self.frigate_watchdog.join()
self.camera_maintainer.join() self.camera_maintainer.join()
self.db.stop() self.db.stop()
+17
View File
@@ -1,9 +1,14 @@
"""Shared handle on the config object that is current for this instance.""" """Shared handle on the config object that is current for this instance."""
import logging
from collections.abc import Callable
from .config import FrigateConfig from .config import FrigateConfig
__all__ = ["ConfigHolder"] __all__ = ["ConfigHolder"]
logger = logging.getLogger(__name__)
class ConfigHolder: class ConfigHolder:
"""Indirection for the most recently parsed config. """Indirection for the most recently parsed config.
@@ -23,12 +28,24 @@ class ConfigHolder:
def __init__(self, config: FrigateConfig) -> None: def __init__(self, config: FrigateConfig) -> None:
self._config = config self._config = config
self._listeners: list[Callable[[FrigateConfig], None]] = []
@property @property
def config(self) -> FrigateConfig: def config(self) -> FrigateConfig:
"""The config as of the most recent successful save.""" """The config as of the most recent successful save."""
return self._config return self._config
def subscribe(self, listener: Callable[[FrigateConfig], None]) -> None:
"""Call listener on the saving thread with each config installed later."""
self._listeners.append(listener)
def set(self, config: FrigateConfig) -> None: def set(self, config: FrigateConfig) -> None:
"""Install a freshly parsed config as the current one.""" """Install a freshly parsed config as the current one."""
self._config = config self._config = config
for listener in self._listeners:
try:
listener(config)
except Exception:
# a listener bug must not fail the save that has already applied
logger.exception("Config listener failed")
+5
View File
@@ -29,6 +29,11 @@ class StatsConfig(FrigateBaseModel):
class TelemetryConfig(FrigateBaseModel): class TelemetryConfig(FrigateBaseModel):
analytics: bool = Field(
default=False,
title="Share anonymous analytics",
description="Send one anonymous usage report a day to help the Frigate maintainers decide what to support. Nothing is sent until this is on.",
)
network_interfaces: list[str] = Field( network_interfaces: list[str] = Field(
default=[], default=[],
title="Network interfaces", title="Network interfaces",
+3
View File
@@ -101,6 +101,9 @@ MAX_WAL_SIZE = 10 # MB
DEFAULT_FFMPEG_VERSION = os.environ.get("DEFAULT_FFMPEG_VERSION", "") DEFAULT_FFMPEG_VERSION = os.environ.get("DEFAULT_FFMPEG_VERSION", "")
INCLUDED_FFMPEG_VERSIONS = os.environ.get("INCLUDED_FFMPEG_VERSIONS", "").split(":") INCLUDED_FFMPEG_VERSIONS = os.environ.get("INCLUDED_FFMPEG_VERSIONS", "").split(":")
ANALYTICS_URL = os.environ.get(
"FRIGATE_ANALYTICS_URL", "https://analytics.frigate.video/report"
)
LIBAVFORMAT_VERSION_MAJOR = int(os.environ.get("LIBAVFORMAT_VERSION_MAJOR", "59")) LIBAVFORMAT_VERSION_MAJOR = int(os.environ.get("LIBAVFORMAT_VERSION_MAJOR", "59"))
FFMPEG_HWACCEL_NVIDIA = "preset-nvidia" FFMPEG_HWACCEL_NVIDIA = "preset-nvidia"
FFMPEG_HWACCEL_VAAPI = "preset-vaapi" FFMPEG_HWACCEL_VAAPI = "preset-vaapi"
+11
View File
@@ -273,6 +273,16 @@ def detect_memryx() -> DetectionHardware | None:
return _hardware("memryx", "memryx", "MemryX MX3", units) return _hardware("memryx", "memryx", "MemryX MX3", units)
def detect_deepx() -> DetectionHardware | None:
"""Find DEEPX NPUs by their device nodes."""
units = _dev_units("dxrt*", "deepx:PCIe:{index}", "PCIe")
if not units:
return None
return _hardware("deepx", "deepx", "DEEPX NPU", units)
def detect_rockchip() -> DetectionHardware | None: def detect_rockchip() -> DetectionHardware | None:
"""Find a Rockchip NPU by reading the SoC from the device tree.""" """Find a Rockchip NPU by reading the SoC from the device tree."""
compatible = _read(f"{PROC_ROOT}/device-tree/compatible") compatible = _read(f"{PROC_ROOT}/device-tree/compatible")
@@ -319,6 +329,7 @@ PROBES = (
detect_coral_usb, detect_coral_usb,
detect_hailo, detect_hailo,
detect_memryx, detect_memryx,
detect_deepx,
detect_intel_npu, detect_intel_npu,
detect_intel_gpu, detect_intel_gpu,
detect_nvidia_gpu, detect_nvidia_gpu,
File diff suppressed because it is too large Load Diff
+46 -31
View File
@@ -11,6 +11,7 @@ from typing import Any
import numpy as np import numpy as np
from frigate.camera import CameraMetrics
from frigate.comms.detections_updater import DetectionPublisher, DetectionTypeEnum from frigate.comms.detections_updater import DetectionPublisher, DetectionTypeEnum
from frigate.comms.inter_process import InterProcessRequestor from frigate.comms.inter_process import InterProcessRequestor
from frigate.config import CameraConfig, CameraInput, FrigateConfig from frigate.config import CameraConfig, CameraInput, FrigateConfig
@@ -36,6 +37,7 @@ from frigate.data_processing.common.audio_transcription.model import (
from frigate.data_processing.real_time.audio_transcription import ( from frigate.data_processing.real_time.audio_transcription import (
AudioTranscriptionRealTimeProcessor, AudioTranscriptionRealTimeProcessor,
) )
from frigate.data_processing.types import DataProcessorMetrics
from frigate.ffmpeg_presets import parse_preset_input from frigate.ffmpeg_presets import parse_preset_input
from frigate.log import LogPipe, suppress_stderr_during from frigate.log import LogPipe, suppress_stderr_during
from frigate.util.builtin import get_ffmpeg_arg_list, load_labels from frigate.util.builtin import get_ffmpeg_arg_list, load_labels
@@ -86,6 +88,7 @@ class AudioProcessor(FrigateProcess):
self, self,
config: FrigateConfig, config: FrigateConfig,
camera_metrics: DictProxy, camera_metrics: DictProxy,
embeddings_metrics: DataProcessorMetrics,
stop_event: MpEvent, stop_event: MpEvent,
): ):
super().__init__( super().__init__(
@@ -93,8 +96,38 @@ class AudioProcessor(FrigateProcess):
) )
self.camera_metrics = camera_metrics self.camera_metrics = camera_metrics
self.embeddings_metrics = embeddings_metrics
self.config = config self.config = config
def spawn_if_needed(self, camera: CameraConfig) -> None:
"""Start an audio maintainer for the camera once everything it needs
has arrived. Returning early leaves the camera for the next poll."""
name = camera.name
if name is None or name in self.audio_threads:
return
if not camera.enabled or not camera.audio.enabled:
return
# ffmpeg update may not have arrived yet
if not any("audio" in i.roles for i in camera.ffmpeg.inputs):
return
# the camera maintainer creates metrics on its own poll of the same
# add update and may not have gotten there yet
metrics = self.camera_metrics.get(name)
if metrics is None:
return
thread = AudioEventMaintainer(
camera,
self.config,
metrics,
self.embeddings_metrics,
self.transcription_model_runner,
self.stop_event, # type: ignore[arg-type]
self.genai_manager,
)
self.audio_threads[name] = thread
thread.start()
self.logger.info(f"Audio maintainer started for {name}")
def __stop_audio_thread(self, camera: str) -> None: def __stop_audio_thread(self, camera: str) -> None:
thread = self.audio_threads.pop(camera, None) thread = self.audio_threads.pop(camera, None)
if thread is None: if thread is None:
@@ -150,29 +183,8 @@ class AudioProcessor(FrigateProcess):
], ],
) )
def spawn_if_needed(camera: CameraConfig) -> None:
name = camera.name
if name is None or name in self.audio_threads:
return
if not camera.enabled or not camera.audio.enabled:
return
# ffmpeg update may not have arrived yet; wait for next poll
if not any("audio" in i.roles for i in camera.ffmpeg.inputs):
return
thread = AudioEventMaintainer(
camera,
self.config,
self.camera_metrics,
self.transcription_model_runner,
self.stop_event, # type: ignore[arg-type]
self.genai_manager,
)
self.audio_threads[name] = thread
thread.start()
self.logger.info(f"Audio maintainer started for {name}")
for camera in self.config.cameras.values(): for camera in self.config.cameras.values():
spawn_if_needed(camera) self.spawn_if_needed(camera)
self.logger.info(f"Audio processor started (pid: {self.pid})") self.logger.info(f"Audio processor started (pid: {self.pid})")
@@ -182,15 +194,14 @@ class AudioProcessor(FrigateProcess):
updated_topics = config_subscriber.check_for_updates() updated_topics = config_subscriber.check_for_updates()
# stop maintainers for removed cameras so their ffmpeg process is # stop maintainers for removed cameras so their ffmpeg process is
# torn down and they stop touching camera_metrics (which the camera # torn down
# maintainer has already popped for the removed camera)
for removed_camera in updated_topics.get( for removed_camera in updated_topics.get(
CameraConfigUpdateEnum.remove.name, [] CameraConfigUpdateEnum.remove.name, []
): ):
self.__stop_audio_thread(removed_camera) self.__stop_audio_thread(removed_camera)
for camera in self.config.cameras.values(): for camera in self.config.cameras.values():
spawn_if_needed(camera) self.spawn_if_needed(camera)
config_subscriber.stop() config_subscriber.stop()
@@ -212,7 +223,8 @@ class AudioEventMaintainer(threading.Thread):
self, self,
camera: CameraConfig, camera: CameraConfig,
config: FrigateConfig, config: FrigateConfig,
camera_metrics: DictProxy, metrics: CameraMetrics,
embeddings_metrics: DataProcessorMetrics,
audio_transcription_model_runner: AudioTranscriptionModelRunner | None, audio_transcription_model_runner: AudioTranscriptionModelRunner | None,
stop_event: threading.Event, stop_event: threading.Event,
genai_manager: Any = None, genai_manager: Any = None,
@@ -221,7 +233,11 @@ class AudioEventMaintainer(threading.Thread):
self.config = config self.config = config
self.camera_config = camera self.camera_config = camera
self.camera_metrics = camera_metrics # hold the metrics object rather than indexing the manager dict per
# chunk, which costs an IPC round trip and breaks once the camera
# maintainer pops the entry on removal
self.metrics = metrics
self.embeddings_metrics = embeddings_metrics
self.stop_event = stop_event self.stop_event = stop_event
# per-camera stop signal so a single maintainer can be torn down at # per-camera stop signal so a single maintainer can be torn down at
# runtime (e.g. on camera removal) without stopping the whole process # runtime (e.g. on camera removal) without stopping the whole process
@@ -265,7 +281,7 @@ class AudioEventMaintainer(threading.Thread):
camera_config=self.camera_config, camera_config=self.camera_config,
requestor=self.requestor, requestor=self.requestor,
model_runner=self.audio_transcription_model_runner, model_runner=self.audio_transcription_model_runner,
metrics=self.camera_metrics[self.camera_config.name], metrics=self.embeddings_metrics,
stop_event=self.stop_event, stop_event=self.stop_event,
genai_manager=self.genai_manager, genai_manager=self.genai_manager,
) )
@@ -291,8 +307,8 @@ class AudioEventMaintainer(threading.Thread):
audio_as_float: np.ndarray = audio.astype(np.float32) audio_as_float: np.ndarray = audio.astype(np.float32)
rms, dBFS = self.calculate_audio_levels(audio_as_float) rms, dBFS = self.calculate_audio_levels(audio_as_float)
self.camera_metrics[self.camera_config.name].audio_rms.value = rms self.metrics.audio_rms.value = rms
self.camera_metrics[self.camera_config.name].audio_dBFS.value = dBFS self.metrics.audio_dBFS.value = dBFS
audio_detections: list[tuple[str, float]] = [] audio_detections: list[tuple[str, float]] = []
@@ -377,7 +393,6 @@ class AudioEventMaintainer(threading.Thread):
return return
time.sleep(self.camera_config.ffmpeg.retry_interval) time.sleep(self.camera_config.ffmpeg.retry_interval)
self.logpipe.dump()
self.start_or_restart_ffmpeg() self.start_or_restart_ffmpeg()
if self.audio_listener is None or self.audio_listener.stdout is None: if self.audio_listener is None or self.audio_listener.stdout is None:
+4 -5
View File
@@ -560,13 +560,12 @@ class LlamaCppClient(GenAIClient):
def list_models(self) -> list[str]: def list_models(self) -> list[str]:
"""Return available model IDs from the llama.cpp server.""" """Return available model IDs from the llama.cpp server."""
models = [] models: set[str] = set()
# llama-server lists the id among the aliases when --alias is set
for m in self._fetch_models_data(): for m in self._fetch_models_data():
models.append(m.get("id", "unknown")) models.add(m.get("id", "unknown"))
models.update(m.get("aliases", []))
for alias in m.get("aliases", []):
models.append(alias)
return sorted(models) return sorted(models)
+8
View File
@@ -144,6 +144,14 @@ class LogPipe(threading.Thread):
self.pipeReader.close() self.pipeReader.close()
def dump(self) -> None: def dump(self) -> None:
if not self.deque:
return
self.logger.log(
self.level,
"The following ffmpeg logs include the last 100 lines prior to exit.",
)
while len(self.deque) > 0: while len(self.deque) > 0:
self.logger.log(self.level, self.deque.popleft()) self.logger.log(self.level, self.deque.popleft())
+5 -1
View File
@@ -188,8 +188,12 @@ class ImprovedMotionDetector(MotionDetector):
self.config.skip_motion_threshold is not None self.config.skip_motion_threshold is not None
and pct_motion > self.config.skip_motion_threshold and pct_motion > self.config.skip_motion_threshold
): ):
# force a recalibration so we transition to the new background # recalibrate so we transition to the new background. the frame
# still has to be blended in here, otherwise the background stays
# frozen and every subsequent frame skips as well
self.calibrating = True self.calibrating = True
cv2.accumulateWeighted(resized_frame, self.avg_frame, 0.2)
self.motion_frame_count = 0
return [] return []
# once the motion is less than 5% and the number of contours is < 4, assume its calibrated # once the motion is less than 5% and the number of contours is < 4, assume its calibrated
+13
View File
@@ -319,6 +319,19 @@ class NoticeRegistry:
if row.kind in NOTICE_KINDS if row.kind in NOTICE_KINDS
] ]
def mark_reported(self, snapshot: list[dict[str, Any]]) -> None:
"""Move the analytics watermarks to the counts a sent report was built from.
Using the snapshot rather than the current counts sends anything raised
while the report was in flight with the next one.
"""
with self._lock:
for row in snapshot:
NoticeStats.update(
reported_occurrences=row["occurrences"],
reported_dismissals=row["dismissals"],
).where(NoticeStats.kind == row["kind"]).execute()
def _write_repeats( def _write_repeats(
self, self,
row: Notice, row: Notice,
+10
View File
@@ -86,6 +86,16 @@ _KINDS = (
link="https://github.com/blakeblackshear/frigate/releases/tag/v{version}", link="https://github.com/blakeblackshear/frigate/releases/tag/v{version}",
counts_repeats=False, counts_repeats=False,
keep_latest=1, keep_latest=1,
reportable=False,
),
# raised while analytics is off; the row keeps a dismissal across restarts
NoticeKind(
"analytics_prompt",
NoticeSeverity.info,
"system",
link="/settings?page=systemTelemetry",
counts_repeats=False,
reportable=False,
), ),
) )
+22
View File
@@ -1120,6 +1120,18 @@ class OnvifController:
f"Camera {camera_name} is still in ONVIF 'MOVING' status." f"Camera {camera_name} is still in ONVIF 'MOVING' status."
) )
async def _shutdown(self) -> None:
"""Close the camera sessions and cancel the tasks running on the loop."""
for cam_name in list(self.cams):
await self._close_camera(cam_name)
tasks = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]
for task in tasks:
task.cancel()
await asyncio.gather(*tasks, return_exceptions=True)
def close(self) -> None: def close(self) -> None:
"""Gracefully shut down the ONVIF controller.""" """Gracefully shut down the ONVIF controller."""
if not hasattr(self, "loop") or self.loop.is_closed(): if not hasattr(self, "loop") or self.loop.is_closed():
@@ -1127,6 +1139,16 @@ class OnvifController:
return return
logger.info("Exiting ONVIF controller...") logger.info("Exiting ONVIF controller...")
# anything left open here is garbage collected during interpreter
# shutdown, where its warnings can no longer be logged cleanly
try:
asyncio.run_coroutine_threadsafe(self._shutdown(), self.loop).result(
timeout=5
)
except TimeoutError:
logger.debug("Timed out closing ONVIF sessions")
self.config_subscriber.stop() self.config_subscriber.stop()
def stop_and_cleanup(): def stop_and_cleanup():
+36
View File
@@ -0,0 +1,36 @@
"""Shared fixtures for the analytics tests."""
from typing import Any
from frigate.analytics.context import ReportContext
from frigate.config import FrigateConfig
FRONT_CAMERA: dict[str, Any] = {
"ffmpeg": {"inputs": [{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}]},
"detect": {"height": 720, "width": 1280, "fps": 5},
}
def make_config(config: dict[str, Any] | None = None) -> FrigateConfig:
"""A parsed config; top-level keys in config replace the defaults here.
hwaccel_args is set so parsing never probes the test host's GPU.
"""
base: dict[str, Any] = {
"mqtt": {"host": "mqtt"},
"ffmpeg": {"hwaccel_args": []},
"cameras": {"front": FRONT_CAMERA},
}
return FrigateConfig(**{**base, **(config or {})})
def make_context(
config: FrigateConfig | None = None,
stats: dict[str, Any] | None = None,
notice_stats: list[dict[str, Any]] | None = None,
) -> ReportContext:
return ReportContext(
config=config or make_config(),
stats=stats or {},
notice_stats=notice_stats or [],
)
@@ -0,0 +1,49 @@
"""Tests for the analytics preview API."""
from unittest.mock import Mock, patch
from frigate.analytics import report
from frigate.analytics.collectors import hardware
from frigate.models import Notice, NoticeStats, User
from frigate.notices.registry import NoticeRegistry
from frigate.test.http_api.base_http_test import AuthTestClient, BaseTestHttp
class TestHttpAnalytics(BaseTestHttp):
def setUp(self):
super().setUp([Notice, NoticeStats, User])
stats = Mock()
stats.get_latest_stats.return_value = self.test_stats
self.app = self.create_app(stats=stats, notice_registry=NoticeRegistry())
for target, name, value in (
(report, "load_state", None),
(hardware.hardware_prober, "probe", []),
(hardware, "hwaccel_options", ("", [])),
):
patcher = patch.object(target, name, return_value=value)
patcher.start()
self.addCleanup(patcher.stop)
def test_preview_returns_the_report_without_sending_it(self):
with (
patch("frigate.analytics.transport.requests.post") as post,
AuthTestClient(self.app) as client,
):
response = client.get("/analytics/preview")
self.assertEqual(response.status_code, 200)
body = response.json()
self.assertEqual(body["install_id"], report.PREVIEW_INSTALL_ID)
self.assertEqual(body["schema_version"], 1)
self.assertEqual(body["cameras"]["total"], 1)
post.assert_not_called()
def test_preview_is_admin_only(self):
with AuthTestClient(self.app) as client:
response = client.get(
"/analytics/preview",
headers={"remote-user": "viewer", "remote-role": "viewer"},
)
self.assertEqual(response.status_code, 403)
@@ -0,0 +1,112 @@
"""Tests for the cameras collector."""
import unittest
from frigate.analytics.collectors import cameras
from frigate.analytics.schema import HeightBucket, HwaccelKey, RetainBucket
from frigate.test.analytics_helpers import make_config, make_context
MASK = {"coordinates": "0,0,1,0,1,1"}
CONFIG = {
"record": {
"enabled": True,
"continuous": {"days": 3},
"alerts": {"retain": {"days": 14}},
"detections": {"retain": {"days": 45}},
},
"cameras": {
"front": {
"ffmpeg": {
"hwaccel_args": "preset-vaapi",
"inputs": [
{
"path": "rtsp://127.0.0.1:8554/front_sub",
"roles": ["detect"],
"input_args": "preset-rtsp-restream",
},
{"path": "rtsp://127.0.0.1:8554/front", "roles": ["record"]},
],
},
"detect": {"enabled": True, "height": 720, "width": 1280, "fps": 5},
"zones": {"porch": MASK, "yard": MASK},
"motion": {"mask": {"tree": MASK}},
"objects": {
"mask": {"sign": MASK},
"filters": {"person": {"mask": {"bush": MASK}}},
},
"onvif": {"host": "10.0.0.9"},
},
"garage": {
"enabled": False,
"type": "lpr",
"ffmpeg": {
"hwaccel_args": ["-hwaccel", "vaapi"],
"inputs": [
{"path": "rtsp://10.0.0.5/stream", "roles": ["detect", "record"]}
],
},
"detect": {"height": 2160, "width": 3840, "fps": 15},
"record": {"enabled": False},
},
"_replay_front": {
"ffmpeg": {
"inputs": [{"path": "rtsp://10.0.0.1/replay", "roles": ["detect"]}]
},
"detect": {"height": 1080, "width": 1920, "fps": 5},
},
},
}
STATS = {
"cameras": {
"front": {"connection_quality": "excellent"},
"garage": {"connection_quality": "offline"},
"_replay_front": {"connection_quality": "fair"},
}
}
class TestCamerasCollector(unittest.TestCase):
def test_aggregates_cameras_and_skips_replays(self):
section = cameras.collect(make_context(make_config(CONFIG), STATS))
self.assertEqual((section.total, section.enabled), (2, 1))
self.assertEqual(section.types, {"generic": 1, "lpr": 1})
self.assertEqual(section.detect_height, {"720": 1, "ge_2160": 1})
self.assertEqual(section.detect_fps, {"le_5": 1, "gt_10": 1})
self.assertEqual(section.hwaccel, {"vaapi": 1, "custom": 1})
self.assertEqual(section.input_preset, {"rtsp-restream": 1, "rtsp-generic": 1})
self.assertEqual(section.go2rtc_restream, 1)
self.assertEqual(section.separate_detect_stream, 1)
self.assertEqual((section.detect, section.record, section.onvif), (1, 1, 1))
self.assertEqual((section.zones, section.cameras_with_zones), (2, 1))
self.assertEqual((section.motion_masks, section.object_masks), (1, 2))
self.assertEqual(section.connection_quality, {"excellent": 1})
self.assertEqual(section.retain_days.continuous, {"1_7": 1})
self.assertEqual(section.retain_days.motion, {"0": 1})
self.assertEqual(section.retain_days.alerts, {"8_30": 1})
self.assertEqual(section.retain_days.detections, {"gt_30": 1})
def test_buckets(self):
self.assertEqual(cameras.height_bucket(360), HeightBucket.le_360)
self.assertEqual(cameras.height_bucket(361), HeightBucket.h480)
self.assertEqual(cameras.height_bucket(1080), HeightBucket.h1080)
self.assertEqual(cameras.height_bucket(1440), HeightBucket.h1440)
self.assertEqual(cameras.height_bucket(2160), HeightBucket.ge_2160)
self.assertEqual(cameras.retain_bucket(0.5), RetainBucket.d1_7)
self.assertEqual(cameras.retain_bucket(0), RetainBucket.zero)
def test_preset_key(self):
self.assertEqual(cameras.preset_key([], HwaccelKey), "none")
self.assertEqual(cameras.preset_key("", HwaccelKey), "none")
self.assertEqual(cameras.preset_key("preset-bogus", HwaccelKey), "custom")
self.assertEqual(cameras.preset_key("-hwaccel vaapi", HwaccelKey), "custom")
self.assertEqual(cameras.preset_key("preset-nvidia", HwaccelKey), "nvidia")
def test_is_restream(self):
self.assertTrue(cameras.is_restream("rtsp://127.0.0.1:8554/front"))
self.assertTrue(cameras.is_restream("rtsp://localhost:8554/front"))
self.assertFalse(cameras.is_restream("rtsp://10.0.0.5:8554/front"))
self.assertFalse(cameras.is_restream("rtsp://[bad"))
self.assertFalse(cameras.is_restream("rtsp://127.0.0.1:notaport/x"))
@@ -0,0 +1,61 @@
"""Tests for the detection collector."""
import os
import tempfile
import unittest
from unittest.mock import patch
from frigate.analytics.collectors import detection
from frigate.analytics.schema import ModelSource
from frigate.detectors.detector_config import SceneEnum
from frigate.test.analytics_helpers import make_config, make_context
class TestDetectionCollector(unittest.TestCase):
def test_reports_each_model_with_its_mean_inference_speed(self):
config = make_config({"models": [{"devices": ["cpu", "cpu"]}]})
stats = {
"detectors": {
"cpu": {"inference_speed": 10.0},
"cpu#2": {"inference_speed": 20.0},
},
"detection_fps": 12.346,
"skipped_fps": 0,
}
section = detection.collect(make_context(config, stats))
model = section.models[SceneEnum.all]
self.assertEqual(model.detector, "cpu")
self.assertEqual(model.devices, 2)
self.assertEqual(model.model_type, "ssd")
self.assertEqual(model.input, "320x320")
self.assertEqual(model.source, ModelSource.default)
self.assertEqual(model.inference_ms, 15.0)
self.assertEqual(section.detection_fps, 12.35)
self.assertEqual(section.skipped_fps, 0.0)
def test_inference_is_null_before_the_first_stats(self):
section = detection.collect(make_context())
self.assertIsNone(section.models[SceneEnum.all].inference_ms)
def test_model_source(self):
with tempfile.TemporaryDirectory() as cache:
plus_model = os.path.join(cache, "abc123")
open(f"{plus_model}.json", "w").close()
with patch.object(detection, "MODEL_CACHE_DIR", cache):
self.assertEqual(detection.model_source(plus_model), ModelSource.plus)
self.assertEqual(
detection.model_source(os.path.join(cache, "no_info")),
ModelSource.custom,
)
self.assertEqual(detection.model_source(None), ModelSource.default)
self.assertEqual(
detection.model_source("/cpu_model.tflite"), ModelSource.default
)
self.assertEqual(
detection.model_source("/config/yolo.onnx"), ModelSource.custom
)
@@ -0,0 +1,128 @@
"""Tests for the features collector."""
import logging
import os
import unittest
from peewee_migrate import Router
from playhouse.sqlite_ext import SqliteExtDatabase
from playhouse.sqliteq import SqliteQueueDatabase
from frigate.analytics.collectors import features
from frigate.analytics.schema import EnrichmentDevice, SemanticSearchModel
from frigate.models import User
from frigate.test.analytics_helpers import FRONT_CAMERA, make_config, make_context
from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
CONFIG = {
"mqtt": {"host": "mqtt", "enabled": True},
"genai": {
"local": {
"provider": "ollama",
"model": "llava",
"base_url": "http://ollama:11434",
"roles": ["descriptions", "embeddings"],
}
},
"semantic_search": {"enabled": True, "model": "local"},
"face_recognition": {"enabled": True, "model_size": "large"},
"birdseye": {"enabled": True, "modes": ["motion", "alerts"], "restream": True},
"proxy": {"header_map": {"user": "x-forwarded-user"}},
"camera_groups": {"outside": {"cameras": ["front"], "icon": "LuCar", "order": 0}},
"cameras": {
"front": {
**FRONT_CAMERA,
"semantic_search": {
"triggers": {
"cat": {
"type": "description",
"data": "a cat",
"threshold": 0.8,
"actions": ["notification"],
}
}
},
}
},
}
class TestFeaturesCollector(unittest.TestCase):
def setUp(self):
migrate_db = SqliteExtDatabase(TEST_DB)
del logging.getLogger("peewee_migrate").handlers[:]
Router(migrate_db).run()
migrate_db.close()
self.db = SqliteQueueDatabase(TEST_DB)
self.db.bind([User])
def tearDown(self):
# close() leaves the queue's writer thread running against the deleted file
self.db.stop()
if not self.db.is_closed():
self.db.close()
for file in TEST_DB_CLEANUPS:
try:
os.remove(file)
except OSError:
pass
def test_collects_enrichments_genai_integrations_and_users(self):
for username, role in (("a", "admin"), ("v", "viewer"), ("o", "operator")):
User.create(
username=username, role=role, password_hash="x", notification_tokens=[]
)
stats = {
"embeddings": {
"devices": {
"face_recognition": "OpenVINO GPU.0",
"semantic_search": "CUDA",
}
}
}
section = features.collect(make_context(make_config(CONFIG), stats))
self.assertEqual(section.face_recognition.device, EnrichmentDevice.openvino_gpu)
self.assertEqual(section.face_recognition.model_size, "large")
self.assertIsNone(section.lpr.device)
self.assertEqual(section.semantic_search.model, SemanticSearchModel.genai)
self.assertEqual(section.semantic_search.device, EnrichmentDevice.cuda)
self.assertEqual(section.semantic_search.triggers, 1)
self.assertEqual(section.genai.providers, {"ollama": 1})
self.assertEqual(section.genai.roles, {"descriptions": 1, "embeddings": 1})
self.assertEqual(section.birdseye.modes, ["motion", "alerts"])
self.assertTrue(section.mqtt)
self.assertTrue(section.proxy_auth)
self.assertEqual(section.users, {"admin": 1, "viewer": 1, "custom": 1})
self.assertEqual((section.camera_groups, section.profiles), (1, 0))
self.assertFalse(section.plus_api_key)
class TestFeatureMappings(unittest.TestCase):
def test_enrichment_device_labels(self):
cases = {
"CPU": EnrichmentDevice.cpu,
"MIGraphX": EnrichmentDevice.migraphx,
"OpenVINO NPU": EnrichmentDevice.openvino_npu,
"OpenVINO GPU.0,CPU": EnrichmentDevice.openvino_gpu,
"OpenVINO": EnrichmentDevice.other,
"CoreML": EnrichmentDevice.other,
}
for label, device in cases.items():
with self.subTest(label=label):
self.assertEqual(features.enrichment_device(label), device)
self.assertIsNone(features.enrichment_device(None))
def test_models_named_after_a_provider_are_genai(self):
self.assertEqual(features.semantic_model("jinav2"), SemanticSearchModel.jinav2)
self.assertEqual(
features.semantic_model("my-ollama"), SemanticSearchModel.genai
)
self.assertIsNone(features.semantic_model(None))
self.assertEqual(features.transcription_model("openai"), "genai")
@@ -0,0 +1,65 @@
"""Tests for the health collector."""
import unittest
from frigate.analytics.collectors import health
from frigate.test.analytics_helpers import make_context
class TestHealthCollector(unittest.TestCase):
def test_collects_uptime_cpu_timings_and_notice_deltas(self):
stats = {
"service": {"uptime": 7300, "retention_unmet": True},
"cpu_usages": {"frigate.full_system": {"cpu": "23.6", "mem": "40"}},
"embeddings": {
"face_recognition_speed": 41.234,
"text_embedding_speed": 0,
"devices": {},
},
}
notice_stats = [
{
"kind": "detector_stuck",
"occurrences": 5,
"dismissals": 1,
"reported_occurrences": 3,
"reported_dismissals": 1,
},
{
"kind": "shm_too_low",
"occurrences": 2,
"dismissals": 0,
"reported_occurrences": 2,
"reported_dismissals": 0,
},
{
"kind": "update_available",
"occurrences": 4,
"dismissals": 0,
"reported_occurrences": 0,
"reported_dismissals": 0,
},
]
section = health.collect(make_context(stats=stats, notice_stats=notice_stats))
self.assertEqual(section.uptime_hours, 2)
self.assertEqual(section.cpu_percent, 24)
self.assertEqual(section.enrichment_ms, {"face": 41.23})
self.assertTrue(section.retention_unmet)
self.assertEqual(
{
kind: (c.occurrences, c.dismissals)
for kind, c in section.notices.items()
},
{"detector_stuck": (2, 0)},
)
def test_missing_stats_give_zeros(self):
section = health.collect(make_context())
self.assertEqual(
(section.uptime_hours, section.cpu_percent, section.enrichment_ms),
(0, 0, {}),
)
self.assertEqual(section.notices, {})
@@ -0,0 +1,188 @@
"""Tests for the install and hardware collectors."""
import os
import tempfile
import unittest
from collections import Counter
from types import SimpleNamespace
from unittest.mock import patch
from frigate.analytics.collectors import hardware, install
from frigate.analytics.collectors.common import closed, histogram, rate
from frigate.analytics.schema import (
Arch,
DecodeFamily,
GpuVendor,
HardwareKey,
ImageVariant,
InstallType,
)
from frigate.const import RECORD_DIR
from frigate.test.analytics_helpers import make_context
class TestCommon(unittest.TestCase):
def test_closed_falls_back_for_unknown_values(self):
self.assertEqual(closed(Arch, "x86_64", Arch.other), Arch.x86_64)
self.assertEqual(closed(Arch, "sparc", Arch.other), Arch.other)
self.assertEqual(closed(Arch, None, Arch.other), Arch.other)
def test_rate_rounds_and_rejects_bad_numbers(self):
self.assertEqual(rate("12.346"), 12.35)
self.assertEqual(rate(-3), 0.0)
self.assertEqual(rate(float("nan")), 0.0)
self.assertEqual(rate(float("inf")), 0.0)
self.assertEqual(rate(None), 0.0)
def test_histogram_drops_empty_buckets(self):
self.assertEqual(
histogram(Counter({Arch.x86_64: 2, Arch.other: 0})), {"x86_64": 2}
)
class TestInstallCollector(unittest.TestCase):
def test_collects_version_variant_and_platform(self):
with (
patch.dict(os.environ, {"FRIGATE_IMAGE_VARIANT": "tensorrt-jp6"}),
patch.object(install, "install_type", return_value=InstallType.docker),
patch("platform.machine", return_value="aarch64"),
patch("platform.release", return_value="6.8.0-45-generic"),
patch("os.geteuid", return_value=1000),
):
section = install.collect(make_context())
self.assertEqual(section.image_variant, ImageVariant.tensorrt_jp6)
self.assertEqual(section.install_type, InstallType.docker)
self.assertEqual(section.arch, Arch.aarch64)
self.assertEqual(section.kernel, "6.8")
self.assertFalse(section.run_as_root)
def test_image_variant_is_dev_when_unset_and_other_when_unknown(self):
self.assertEqual(install.image_variant(None), ImageVariant.dev)
self.assertEqual(install.image_variant(""), ImageVariant.dev)
self.assertEqual(install.image_variant("h8l"), ImageVariant.other)
def test_install_type_checks_the_add_on_first(self):
with patch("os.path.isfile", return_value=True):
self.assertEqual(install.install_type(), InstallType.ha_addon)
with (
patch("os.path.isfile", return_value=False),
patch.dict(os.environ, {"KUBERNETES_SERVICE_HOST": "10.0.0.1"}),
):
self.assertEqual(install.install_type(), InstallType.kubernetes)
env = {k: v for k, v in os.environ.items() if k != "KUBERNETES_SERVICE_HOST"}
with (
patch("os.path.isfile", return_value=False),
patch.dict(os.environ, env, clear=True),
patch("os.path.exists", side_effect=lambda path: path == "/.dockerenv"),
):
self.assertEqual(install.install_type(), InstallType.docker)
def test_kernel_and_arch_fall_back(self):
self.assertEqual(install.kernel("weird"), "unknown")
self.assertEqual(install.arch("armv7l"), Arch.other)
self.assertEqual(install.arch("amd64"), Arch.x86_64)
class TestHardwareCollector(unittest.TestCase):
def setUp(self):
self.dir = tempfile.TemporaryDirectory()
self.addCleanup(self.dir.cleanup)
def write(self, name: str, content: str) -> str:
path = os.path.join(self.dir.name, name)
with open(path, "w") as f:
f.write(content)
return path
def test_cpu_model_prefers_the_board_model(self):
board = self.write("model", "Raspberry Pi 5 Model B Rev 1.0\x00")
cpuinfo = self.write("cpuinfo", "model name\t: Cortex-A76\n")
with (
patch.object(hardware, "DEVICE_TREE_MODEL", board),
patch.object(hardware, "CPUINFO", cpuinfo),
):
self.assertEqual(hardware.cpu_model(), "Raspberry Pi 5 Model B Rev 1.0")
def test_cpu_model_reads_cpuinfo_and_truncates(self):
cpuinfo = self.write("cpuinfo", "processor\t: 0\nmodel name\t: " + "x" * 80)
with (
patch.object(hardware, "DEVICE_TREE_MODEL", self.dir.name + "/none"),
patch.object(hardware, "CPUINFO", cpuinfo),
):
self.assertEqual(hardware.cpu_model(), "x" * 64)
def test_collects_gpus_decode_detection_and_storage(self):
stats = {
"gpu_usages": {
"NVIDIA GeForce RTX 3060": {"vendor": "nvidia"},
"mystery": {},
},
"service": {
"storage": {
RECORD_DIR: {
"total": 2048000.0,
"used": 512000.0,
"mount_type": "nfs4",
}
}
},
}
probed = [
SimpleNamespace(key="edgetpu:usb", count=2),
SimpleNamespace(key="new:thing", count=1),
SimpleNamespace(key="cpu", count=1),
]
families = [
SimpleNamespace(key="vaapi"),
SimpleNamespace(key="intel-qsv"),
SimpleNamespace(key="future"),
]
with (
patch.object(hardware.hardware_prober, "probe", return_value=probed),
patch.object(hardware, "hwaccel_options", return_value=("vaapi", families)),
patch.object(hardware, "cpu_model", return_value="Intel(R) N100"),
patch("os.cpu_count", return_value=4),
patch(
"psutil.virtual_memory", return_value=SimpleNamespace(total=16 * 2**30)
),
):
section = hardware.collect(make_context(stats=stats))
self.assertEqual(section.cpu_model, "Intel(R) N100")
self.assertEqual(section.cpu_cores, 4)
self.assertEqual(section.memory_gb, 16)
self.assertEqual(
[(gpu.vendor, gpu.name) for gpu in section.gpus],
[
(GpuVendor.nvidia, "NVIDIA GeForce RTX 3060"),
(GpuVendor.other, "mystery"),
],
)
self.assertEqual(
section.decode_families,
[DecodeFamily.vaapi, DecodeFamily.intel_qsv, DecodeFamily.other],
)
self.assertEqual(
section.detection_hardware,
{HardwareKey.edgetpu_usb: 2, HardwareKey.other: 1, HardwareKey.cpu: 1},
)
self.assertEqual(section.storage.record_fs, "nfs4")
self.assertEqual(section.storage.record_total_gb, 2000)
self.assertEqual(section.storage.record_used_pct, 25)
def test_storage_without_stats_is_unknown_and_empty(self):
section = hardware.storage({})
self.assertEqual(
(section.record_fs, section.record_total_gb, section.record_used_pct),
("unknown", 0, 0),
)
+107
View File
@@ -0,0 +1,107 @@
"""Tests for building a report from the collectors."""
import json
import logging
import os
import unittest
from unittest.mock import Mock, patch
from peewee_migrate import Router
from playhouse.sqlite_ext import SqliteExtDatabase
from playhouse.sqliteq import SqliteQueueDatabase
from frigate.analytics import report
from frigate.analytics.collectors import hardware
from frigate.analytics.schema import AnalyticsReport, InstallSection
from frigate.models import User
from frigate.test.analytics_helpers import make_context
from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
INSTALL = InstallSection(
version="0.19.0",
image_variant="dev",
install_type="docker",
arch="x86_64",
kernel="6.8",
run_as_root=False,
)
class TestBuildReport(unittest.TestCase):
def test_a_failing_collector_nulls_only_its_section(self):
collectors = {
"install": lambda ctx: INSTALL,
"hardware": Mock(side_effect=RuntimeError("boom")),
"detection": lambda ctx: None,
"cameras": lambda ctx: None,
"features": lambda ctx: None,
"health": lambda ctx: None,
}
with patch.dict(report.COLLECTORS, collectors):
built = report.build_report(make_context(), "a" * 32, sent_at=1790000000)
self.assertEqual(built.install, INSTALL)
self.assertIsNone(built.hardware)
self.assertEqual(built.schema_version, 1)
self.assertEqual(built.sent_at, 1790000000)
self.assertRegex(built.report_id, r"^[0-9a-f-]{36}$")
class TestRealCollectors(unittest.TestCase):
def setUp(self):
migrate_db = SqliteExtDatabase(TEST_DB)
del logging.getLogger("peewee_migrate").handlers[:]
Router(migrate_db).run()
migrate_db.close()
self.db = SqliteQueueDatabase(TEST_DB)
self.db.bind([User])
def tearDown(self):
# close() leaves the queue's writer thread running against the deleted file
self.db.stop()
if not self.db.is_closed():
self.db.close()
for file in TEST_DB_CLEANUPS:
try:
os.remove(file)
except OSError:
pass
def test_every_section_builds_and_round_trips_through_json(self):
with (
patch.object(hardware.hardware_prober, "probe", return_value=[]),
patch.object(hardware, "hwaccel_options", return_value=("", [])),
):
built = report.build_report(make_context(), "a" * 32)
body = built.model_dump_json()
parsed = json.loads(body)
for section in (
"install",
"hardware",
"detection",
"cameras",
"features",
"health",
):
with self.subTest(section=section):
self.assertIsNotNone(parsed[section])
self.assertEqual(AnalyticsReport.model_validate_json(body), built)
def test_preview_uses_a_placeholder_id_before_the_first_report(self):
stats_emitter = Mock()
stats_emitter.get_latest_stats.return_value = {}
with (
patch.object(report, "load_state", return_value=None),
patch.object(hardware.hardware_prober, "probe", return_value=[]),
patch.object(hardware, "hwaccel_options", return_value=("", [])),
):
built = report.preview_report(make_context().config, stats_emitter, None)
self.assertEqual(built.install_id, report.PREVIEW_INSTALL_ID)
+227
View File
@@ -0,0 +1,227 @@
"""Tests for the analytics reporter's schedule and consent handling."""
import os
import tempfile
import threading
import unittest
from unittest.mock import Mock, patch
from frigate.analytics import reporter as reporter_module
from frigate.analytics.reporter import (
FIRST_DELAY_S,
INTERVAL_S,
JITTER_S,
PROMPT_KIND,
WAKE_S,
AnalyticsReporter,
)
from frigate.analytics.state import AnalyticsState, load_state, save_state
from frigate.analytics.transport import SendOutcome
from frigate.config.holder import ConfigHolder
from frigate.test.analytics_helpers import make_config
SNAPSHOT = [
{
"kind": "detector_stuck",
"occurrences": 3,
"dismissals": 0,
"reported_occurrences": 1,
"reported_dismissals": 0,
}
]
class TestAnalyticsReporter(unittest.TestCase):
def setUp(self):
self.dir = tempfile.TemporaryDirectory()
self.addCleanup(self.dir.cleanup)
self.path = os.path.join(self.dir.name, ".analytics.json")
self.now = 1_790_000_000.0
self.send = Mock(return_value=SendOutcome.accepted)
self.registry = Mock()
self.registry.stats.return_value = SNAPSHOT
self.stats = Mock()
self.stats.get_latest_stats.return_value = {}
self.holder = ConfigHolder(make_config({"telemetry": {"analytics": True}}))
for name in ("raise_notice", "resolve_notice"):
patcher = patch.object(reporter_module, name)
setattr(self, name, patcher.start())
self.addCleanup(patcher.stop)
self.built = Mock()
self.built.model_dump_json.return_value = '{"report": 1}'
patcher = patch.object(reporter_module, "build_report", return_value=self.built)
self.build_report = patcher.start()
self.addCleanup(patcher.stop)
def reporter(self, path: str | None = None) -> AnalyticsReporter:
# uniform(a, b) returns a: the shortest startup delay and interval
rng = Mock()
rng.uniform.side_effect = lambda low, high: low
return AnalyticsReporter(
self.holder,
self.stats,
self.registry,
threading.Event(),
state_path=path or self.path,
url="https://example.test/report",
send=self.send,
clock=lambda: self.now,
rng=rng,
)
def advance(self, seconds: float) -> None:
self.now += seconds
def test_waits_for_the_startup_delay_then_sends(self):
reporter = self.reporter()
reporter.tick()
self.send.assert_not_called()
self.advance(FIRST_DELAY_S[0])
reporter.tick()
self.send.assert_called_once_with(
"https://example.test/report", '{"report": 1}'
)
self.registry.mark_reported.assert_called_once_with(SNAPSHOT)
self.assertEqual(load_state(self.path).last_attempt_at, self.now)
def test_sends_once_per_interval(self):
reporter = self.reporter()
self.advance(FIRST_DELAY_S[0])
reporter.tick()
self.advance(WAKE_S)
reporter.tick()
self.assertEqual(self.send.call_count, 1)
self.advance(INTERVAL_S - JITTER_S)
reporter.tick()
self.assertEqual(self.send.call_count, 2)
def test_a_restart_inside_the_interval_does_not_send(self):
save_state(AnalyticsState("a" * 32, self.now), self.path)
reporter = self.reporter()
self.advance(FIRST_DELAY_S[0])
reporter.tick()
self.send.assert_not_called()
def test_a_failed_send_keeps_watermarks_and_waits_a_full_interval(self):
self.send.return_value = SendOutcome.failed
reporter = self.reporter()
self.advance(FIRST_DELAY_S[0])
reporter.tick()
self.advance(WAKE_S)
reporter.tick()
self.assertEqual(self.send.call_count, 1)
self.registry.mark_reported.assert_not_called()
def test_an_accepted_report_without_health_keeps_the_watermarks(self):
self.built.health = None
reporter = self.reporter()
self.advance(FIRST_DELAY_S[0])
reporter.tick()
self.send.assert_called_once()
self.registry.mark_reported.assert_not_called()
def test_consent_withdrawn_while_the_report_builds_stops_the_send(self):
reporter = self.reporter()
self.advance(FIRST_DELAY_S[0])
def withdraw(*args, **kwargs):
self.holder.set(make_config())
return self.built
self.build_report.side_effect = withdraw
reporter.tick()
self.send.assert_not_called()
self.assertFalse(os.path.exists(self.path))
def test_turning_sharing_off_and_on_between_wakes_starts_a_fresh_identity(self):
save_state(AnalyticsState("a" * 32, 0.0), self.path)
reporter = self.reporter()
reporter.tick()
self.holder.set(make_config())
self.holder.set(make_config({"telemetry": {"analytics": True}}))
self.advance(FIRST_DELAY_S[0])
reporter.tick()
self.raise_notice.assert_called_once_with(PROMPT_KIND)
self.assertNotEqual(load_state(self.path).install_id, "a" * 32)
def test_opting_out_raises_the_prompt_once_and_deletes_the_state(self):
self.holder.set(make_config())
save_state(AnalyticsState("a" * 32, 0.0), self.path)
reporter = self.reporter()
reporter.tick()
reporter.tick()
self.raise_notice.assert_called_once_with(PROMPT_KIND)
self.assertFalse(os.path.exists(self.path))
self.send.assert_not_called()
def test_opting_in_resolves_the_prompt(self):
self.holder.set(make_config())
reporter = self.reporter()
reporter.tick()
self.holder.set(make_config({"telemetry": {"analytics": True}}))
reporter.tick()
self.resolve_notice.assert_called_once_with(PROMPT_KIND)
def test_safe_mode_touches_nothing(self):
self.holder.set(make_config({"safe_mode": True}))
save_state(AnalyticsState("a" * 32, 0.0), self.path)
reporter = self.reporter()
self.advance(FIRST_DELAY_S[0])
reporter.tick()
self.raise_notice.assert_not_called()
self.assertTrue(os.path.exists(self.path))
self.send.assert_not_called()
def test_an_unwritable_config_dir_skips_sending_and_warns_once(self):
reporter = self.reporter(os.path.join(self.dir.name, "missing", "x.json"))
self.advance(FIRST_DELAY_S[0])
with self.assertLogs("frigate.analytics.reporter", "WARNING") as logs:
reporter.tick()
self.advance(WAKE_S)
reporter.tick()
self.send.assert_not_called()
self.assertEqual(len(logs.output), 1)
def test_a_last_attempt_in_the_future_is_ignored(self):
save_state(AnalyticsState("a" * 32, self.now + 10 * INTERVAL_S), self.path)
reporter = self.reporter()
self.advance(FIRST_DELAY_S[0])
reporter.tick()
self.send.assert_called_once()
def test_the_loop_survives_a_failing_tick(self):
reporter = self.reporter()
reporter.stop_event.set()
with (
patch.object(reporter, "tick", side_effect=RuntimeError("boom")),
self.assertLogs("frigate.analytics.reporter", "ERROR"),
):
reporter.run()
+137
View File
@@ -0,0 +1,137 @@
"""Tests for the analytics report schema."""
import inspect
import re
import unittest
from enum import Enum
from typing import Any, get_args, get_origin
from pydantic import BaseModel
import frigate.detectors.hardware as detection_hardware
import frigate.util.hwaccel as hwaccel
from frigate.analytics.schema import (
AnalyticsReport,
DecodeFamily,
HardwareKey,
HwaccelKey,
InputPresetKey,
NoticeKindKey,
)
from frigate.ffmpeg_presets import PRESETS_HW_ACCEL_DECODE, PRESETS_INPUT
from frigate.notices.types import NOTICE_KINDS
from frigate.util.hwaccel import HwaccelFamily
# the only str fields: generated ids and strings the hardware reports
ALLOWED_STRINGS = {
("AnalyticsReport", "install_id"),
("AnalyticsReport", "report_id"),
("InstallSection", "version"),
("InstallSection", "kernel"),
("HardwareSection", "cpu_model"),
("GpuInfo", "name"),
("StorageInfo", "record_fs"),
("DetectionModel", "input"),
}
def nested_models(annotation: Any) -> list[type[BaseModel]]:
if isinstance(annotation, type) and issubclass(annotation, BaseModel):
return [annotation]
return [model for arg in get_args(annotation) for model in nested_models(arg)]
def all_models(
model: type[BaseModel], seen: set[type[BaseModel]] | None = None
) -> list[type[BaseModel]]:
seen = set() if seen is None else seen
if model in seen:
return []
seen.add(model)
found = [model]
for field in model.model_fields.values():
for nested in nested_models(field.annotation):
found += all_models(nested, seen)
return found
def dict_key_types(annotation: Any) -> list[Any]:
keys = [get_args(annotation)[0]] if get_origin(annotation) is dict else []
return keys + [key for arg in get_args(annotation) for key in dict_key_types(arg)]
class TestSchemaDiscipline(unittest.TestCase):
def test_every_field_has_a_description_and_public_flag(self):
for model in all_models(AnalyticsReport):
for name, field in model.model_fields.items():
with self.subTest(field=f"{model.__name__}.{name}"):
self.assertTrue(field.description)
self.assertIsInstance(field.json_schema_extra, dict)
self.assertIsInstance(field.json_schema_extra.get("x-public"), bool)
def test_strings_are_limited_to_ids_and_hardware_names(self):
for model in all_models(AnalyticsReport):
properties = model.model_json_schema()["properties"]
for name, field in model.model_fields.items():
if field.annotation is not str:
continue
with self.subTest(field=f"{model.__name__}.{name}"):
self.assertIn((model.__name__, name), ALLOWED_STRINGS)
self.assertTrue(
"maxLength" in properties[name] or "pattern" in properties[name]
)
def test_map_keys_are_enums(self):
for model in all_models(AnalyticsReport):
for name, field in model.model_fields.items():
for key_type in dict_key_types(field.annotation):
with self.subTest(field=f"{model.__name__}.{name}"):
self.assertTrue(issubclass(key_type, Enum))
class TestEnumsTrackTheirSources(unittest.TestCase):
def test_hardware_keys_cover_every_probe(self):
probed = set(
re.findall(
r'_hardware\(\s*"([^"]+)"', inspect.getsource(detection_hardware)
)
)
self.assertTrue(probed)
self.assertLessEqual(probed, {key.value for key in HardwareKey})
def test_decode_families_cover_every_hwaccel_family(self):
families = {
value.key
for value in vars(hwaccel).values()
if isinstance(value, HwaccelFamily)
}
self.assertTrue(families)
self.assertLessEqual(families, {family.value for family in DecodeFamily})
def test_preset_keys_mirror_the_presets(self):
for enum, presets in (
(HwaccelKey, PRESETS_HW_ACCEL_DECODE),
(InputPresetKey, PRESETS_INPUT),
):
with self.subTest(enum=enum.__name__):
self.assertEqual(
{key.value for key in enum},
{name.removeprefix("preset-") for name in presets}
| {"custom", "none"},
)
def test_notice_keys_are_the_reportable_kinds(self):
self.assertEqual(
{key.value for key in NoticeKindKey},
{key for key, kind in NOTICE_KINDS.items() if kind.reportable},
)
self.assertNotIn("analytics_prompt", {key.value for key in NoticeKindKey})
+64
View File
@@ -0,0 +1,64 @@
"""Tests for the analytics state file."""
import os
import tempfile
import unittest
from frigate.analytics.state import (
AnalyticsState,
delete_state,
load_state,
new_state,
save_state,
)
class TestAnalyticsState(unittest.TestCase):
def setUp(self):
self.dir = tempfile.TemporaryDirectory()
self.addCleanup(self.dir.cleanup)
self.path = os.path.join(self.dir.name, ".analytics.json")
def write(self, content: str) -> None:
with open(self.path, "w") as f:
f.write(content)
def test_missing_file_loads_as_none(self):
self.assertIsNone(load_state(self.path))
def test_save_then_load_round_trips(self):
state = AnalyticsState(install_id="a" * 32, last_attempt_at=1790000000.5)
self.assertTrue(save_state(state, self.path))
self.assertEqual(load_state(self.path), state)
def test_unusable_files_load_as_none(self):
for content in (
"{not json",
'["a"]',
'{"install_id": "short", "last_attempt_at": 1}',
'{"install_id": "' + "a" * 32 + '"}',
'{"install_id": "' + "a" * 32 + '", "last_attempt_at": true}',
):
with self.subTest(content=content):
self.write(content)
self.assertIsNone(load_state(self.path))
def test_save_reports_failure_instead_of_raising(self):
missing = os.path.join(self.dir.name, "missing", ".analytics.json")
self.assertFalse(save_state(new_state(), missing))
def test_new_state_has_a_hex_id_and_no_attempt(self):
state = new_state()
self.assertRegex(state.install_id, r"^[0-9a-f]{32}$")
self.assertEqual(state.last_attempt_at, 0.0)
def test_delete_removes_the_file_and_tolerates_a_missing_one(self):
save_state(new_state(), self.path)
delete_state(self.path)
delete_state(self.path)
self.assertFalse(os.path.exists(self.path))
+60
View File
@@ -0,0 +1,60 @@
"""Tests for sending a report."""
import unittest
from unittest.mock import Mock, patch
import requests
from frigate.analytics.transport import TIMEOUT_S, SendOutcome, send_report
from frigate.version import VERSION
URL = "https://example.test/report"
def post(status: int = 204, text: str = "", side_effect: Exception | None = None):
return patch(
"frigate.analytics.transport.requests.post",
return_value=Mock(status_code=status, text=text),
side_effect=side_effect,
)
class TestSendReport(unittest.TestCase):
def test_posts_the_body_as_json_with_a_user_agent(self):
with post() as mock_post:
outcome = send_report(URL, '{"a":1}')
self.assertIs(outcome, SendOutcome.accepted)
args, kwargs = mock_post.call_args
self.assertEqual(args[0], URL)
self.assertEqual(kwargs["data"], b'{"a":1}')
self.assertEqual(kwargs["headers"]["Content-Type"], "application/json")
self.assertEqual(kwargs["headers"]["User-Agent"], f"Frigate/{VERSION}")
self.assertFalse(kwargs["allow_redirects"])
self.assertEqual(kwargs["timeout"], TIMEOUT_S)
def test_maps_statuses_to_outcomes(self):
cases = (
(200, SendOutcome.accepted),
(400, SendOutcome.rejected),
(429, SendOutcome.rate_limited),
(302, SendOutcome.failed),
(500, SendOutcome.failed),
)
for status, outcome in cases:
with self.subTest(status=status), post(status):
self.assertIs(send_report(URL, "{}"), outcome)
def test_logs_the_rejection_reason(self):
with (
post(400, "install_id: bad"),
self.assertLogs("frigate.analytics.transport", "WARNING") as logs,
):
send_report(URL, "{}")
self.assertIn("install_id: bad", logs.output[0])
def test_a_network_error_fails_without_raising(self):
with post(side_effect=requests.ConnectionError("down")):
self.assertIs(send_report(URL, "{}"), SendOutcome.failed)
+90
View File
@@ -0,0 +1,90 @@
"""Tests for audio maintainer spawning on runtime camera adds."""
import threading
import unittest
from unittest.mock import MagicMock, patch
from frigate.config import FrigateConfig
from frigate.events.audio import AudioProcessor
def _build_config() -> FrigateConfig:
return FrigateConfig(
**{
"mqtt": {"host": "mqtt"},
"cameras": {
"front_door": {
"ffmpeg": {
"inputs": [
{
"path": "rtsp://10.0.0.1:554/video",
"roles": ["detect", "audio"],
}
]
},
"audio": {"enabled": True},
}
},
}
)
class TestAudioSpawnIfNeeded(unittest.TestCase):
def _processor(self, config: FrigateConfig, camera_metrics: dict) -> AudioProcessor:
processor = AudioProcessor.__new__(AudioProcessor)
processor.config = config
processor.camera_metrics = camera_metrics
processor.embeddings_metrics = MagicMock()
processor.audio_threads = {}
processor.transcription_model_runner = None
processor.genai_manager = None
processor.stop_event = threading.Event()
processor.logger = MagicMock()
return processor
def test_skips_camera_whose_metrics_have_not_been_created_yet(self):
"""The camera maintainer creates metrics on its own poll of the add
update, so the audio processor can see the camera first."""
config = _build_config()
processor = self._processor(config, {})
with patch("frigate.events.audio.AudioEventMaintainer") as maintainer:
processor.spawn_if_needed(config.cameras["front_door"])
maintainer.assert_not_called()
assert processor.audio_threads == {}
def test_spawns_once_metrics_exist_and_passes_the_metrics_object(self):
config = _build_config()
metrics = object()
processor = self._processor(config, {"front_door": metrics})
with patch("frigate.events.audio.AudioEventMaintainer") as maintainer:
processor.spawn_if_needed(config.cameras["front_door"])
assert maintainer.call_args.args[2] is metrics
assert "front_door" in processor.audio_threads
maintainer.return_value.start.assert_called_once()
def test_does_not_respawn_for_a_camera_already_running(self):
config = _build_config()
processor = self._processor(config, {"front_door": object()})
processor.audio_threads["front_door"] = MagicMock()
with patch("frigate.events.audio.AudioEventMaintainer") as maintainer:
processor.spawn_if_needed(config.cameras["front_door"])
maintainer.assert_not_called()
def test_skips_camera_whose_ffmpeg_update_has_not_arrived_yet(self):
"""The add update carries the camera before its ffmpeg inputs are
applied, so the audio role can be briefly missing."""
config = _build_config()
camera = config.cameras["front_door"]
camera.ffmpeg.inputs[0].roles = ["detect"]
processor = self._processor(config, {"front_door": object()})
with patch("frigate.events.audio.AudioEventMaintainer") as maintainer:
processor.spawn_if_needed(camera)
maintainer.assert_not_called()
+5
View File
@@ -17,6 +17,11 @@ from frigate.util.builtin import deep_merge
class TestConfig(unittest.TestCase): class TestConfig(unittest.TestCase):
def test_analytics_is_off_by_default(self):
frigate_config = FrigateConfig(**self.minimal)
self.assertFalse(frigate_config.telemetry.analytics)
def setUp(self): def setUp(self):
self.minimal = { self.minimal = {
"mqtt": {"host": "mqtt"}, "mqtt": {"host": "mqtt"},
+25
View File
@@ -82,5 +82,30 @@ class TestSwapRuntimeConfig(unittest.TestCase):
app.genai_manager.update_config.assert_called_once_with(config) app.genai_manager.update_config.assert_called_once_with(config)
class TestConfigHolder(unittest.TestCase):
def test_set_passes_the_new_config_to_subscribers(self) -> None:
holder = ConfigHolder(MagicMock(name="boot_config"))
listener = MagicMock()
holder.subscribe(listener)
config = MagicMock(name="new_config")
holder.set(config)
listener.assert_called_once_with(config)
def test_a_failing_subscriber_does_not_block_the_swap(self) -> None:
holder = ConfigHolder(MagicMock(name="boot_config"))
after = MagicMock()
holder.subscribe(MagicMock(side_effect=RuntimeError("boom")))
holder.subscribe(after)
config = MagicMock(name="new_config")
with self.assertLogs("frigate.config.holder", "ERROR"):
holder.set(config)
self.assertIs(holder.config, config)
after.assert_called_once_with(config)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
+896
View File
@@ -0,0 +1,896 @@
"""Tests for the DEEPX detector."""
import json
import os
import struct
import sys
import tempfile
import unittest
from unittest.mock import MagicMock, patch
import numpy as np
from pydantic import ValidationError
from frigate.detectors.detector_config import ModelConfig, ModelTypeEnum
from frigate.detectors.device import (
DeviceParseError,
build_detector_config,
parse_device,
)
from frigate.detectors.plugins.deepx import (
DEEPX_MANIFEST,
DXRT_VERSION,
PPU_RECORD_SIZE,
DeepxDetector,
DeepxDetectorConfig,
PpuLayout,
YoloLayout,
class_count,
decode_raw_anchor,
decode_raw_nms_in_head,
infer_yolo_layout,
read_ppu_layout,
resolve_device,
validate_yolox_outputs,
)
def model_with_type(model_type) -> ModelConfig:
return ModelConfig(
model_type=model_type,
labelmap_path=None,
labelmap={79: "toothbrush"},
width=640,
height=640,
)
def build_ppu_record(box, score=0.9, label=0, grid=(7, 9, 2, 2)) -> np.ndarray:
record = np.zeros(PPU_RECORD_SIZE, dtype=np.uint8)
record[0:16] = np.array(box, dtype=np.float32).view(np.uint8)
record[16:20] = grid
record[20:24] = np.array([score], dtype=np.float32).view(np.uint8)
record[24:28] = np.array([label], dtype=np.uint32).view(np.uint8)
return record.reshape(1, 1, PPU_RECORD_SIZE)
# compile_config.ppu as DX-COM writes it for the two head kinds
ANCHOR_BASED_PPU = {"type": 0, "num_classes": 80, "activation": "Sigmoid"}
ANCHOR_FREE_PPU = {"type": 1, "num_classes": 80}
PPU_BBOX_NODE = "/head/Mul_2"
# (grid_w, grid_h, entries) per scale, finest first; the grids give the
# strides at a 640 input
THREE_SCALE_ANCHORS = [(80, 80, 3), (40, 40, 3), (20, 20, 3)]
TWO_SCALE_ANCHORS = [(40, 40, 3), (20, 20, 3)]
FOUR_SCALE_ANCHORS = [(160, 160, 3), (80, 80, 3), (40, 40, 3), (20, 20, 3)]
THREE_SCALE_FREE = [(80, 80, 1), (40, 40, 1), (20, 20, 1)]
ONE_SCALE_FREE = [(100, 84, 1)]
def proto_varint(value: int) -> bytes:
out = bytearray()
while True:
byte = value & 0x7F
value >>= 7
out.append(byte | (0x80 if value else 0))
if not value:
return bytes(out)
def proto_bytes(field: int, payload: bytes) -> bytes:
return proto_varint(field << 3 | 2) + proto_varint(len(payload)) + payload
def proto_number(field: int, value: int) -> bytes:
return proto_varint(field << 3) + proto_varint(value)
def onnx_node(op_type: str, name: str, inputs: list, outputs: list) -> bytes:
body = b"".join(proto_bytes(1, tensor.encode()) for tensor in inputs)
body += b"".join(proto_bytes(2, tensor.encode()) for tensor in outputs)
return body + proto_bytes(3, name.encode()) + proto_bytes(4, op_type.encode())
def onnx_box_graph(box_format: str) -> bytes:
if box_format == "broken":
return proto_varint(1 << 3 | 3)
unnamed = box_format == "unnamed"
def graph_node(op_type: str, name: str, inputs: list, outputs: list) -> bytes:
return onnx_node(op_type, "" if unnamed else name, inputs, outputs)
nodes = [
graph_node("Split", "dfl_split", ["dfl", "sizes"], ["lt", "rb"]),
graph_node("Sub", "corner_min", ["anchors", "lt"], ["x1y1"]),
graph_node("Add", "corner_max", ["rb", "anchors"], ["x2y2"]),
]
if box_format in ("centre", "unnamed"):
nodes += [
graph_node("Add", "corner_sum", ["x1y1", "x2y2"], ["sum"]),
graph_node("Mul", "corner_mean", ["sum", "half"], ["cxy"]),
graph_node("Sub", "corner_span", ["x2y2", "x1y1"], ["wh"]),
graph_node("Concat", "box_concat", ["cxy", "wh"], ["box"]),
]
elif box_format == "corner":
nodes.append(graph_node("Concat", "box_concat", ["x1y1", "x2y2"], ["box"]))
else:
nodes.append(graph_node("Concat", "box_concat", ["x1y1", "x1y1"], ["box"]))
box = "box"
if unnamed:
box = "box_flat"
nodes.append(graph_node("Reshape", "box_reshape", ["shape", "box"], [box]))
nodes.append(onnx_node("Mul", PPU_BBOX_NODE, [box, "strides"], ["bbox_out"]))
graph = b"".join(proto_bytes(1, node) for node in nodes)
graph += proto_bytes(5, b"weights")
return (
proto_number(1, 10) # ir_version
+ proto_bytes(2, b"onnx_frontend_compiler") # producer_name
+ proto_bytes(7, graph)
)
def write_dxnn(
directory, ppu, layers, name="model.dxnn", table=True, box_format=None
) -> str:
"""A minimal .dxnn as DX-RT's parsers read it: the container header, a
compile_config carrying `ppu`, and either the PPU tensor table with one
entry per (layer, anchor) as a v8 file has, or with `table` False only
the rmap_info listing of the PPU output tensors, as a v7 file has.
`layers` is (grid_w, grid_h, entries) per scale, finest first; an
anchor-free scale has one entry, and grid_h 1 means a flattened
(1, cells, channels) tensor. `box_format`, "centre" or "corner", adds
the compiled graph that says how the head writes its boxes, along with
the compile_config layer naming the node the PPU reads them from."""
if box_format is not None and "layer" not in ppu:
ppu = dict(ppu, layer=[{"bbox": PPU_BBOX_NODE, "cls_conf": "/head/Sigmoid"}])
compile_config = json.dumps({"compile_version": "2.4.0", "ppu": ppu}).encode()
graph = onnx_box_graph(box_format) if box_format is not None else b""
if table:
part = bytearray(struct.pack("<BBBB", 1, sum(n for _, _, n in layers), 0, 0))
for conv, (grid_w, grid_h, entries) in enumerate(layers):
for anchor in range(entries):
part += struct.pack(
"<HHfBBBBBBBB",
128,
80,
0.001,
conv,
anchor,
0,
1,
0,
grid_w,
grid_h,
0,
)
else:
outputs = []
for conv, (grid_w, grid_h, entries) in enumerate(layers):
for anchor in range(entries):
name_ = f"PPU_Transpose_Output_{conv}"
if entries > 1:
name_ += f"_anchor_{anchor}"
shape = [1, grid_w, 127] if grid_h == 1 else [1, grid_h, grid_w, 128]
outputs.append({"name": name_, "shape": shape, "layout": "PPU_YOLO"})
part = json.dumps({"inputs": [], "outputs": outputs}).encode()
data = {
"compile_config": {
"type": "str",
"offset": 0,
"size": len(compile_config),
},
"compiled_data": {
"M1A_4K": {
"npu_0": {
"rmap": {"type": "bytes", "offset": 0, "size": 0},
"ppu" if table else "rmap_info": {
"type": "bytes" if table else "str",
"offset": len(compile_config),
"size": len(part),
},
}
}
},
}
if graph:
data["vis_npu_models"] = {
"npu_0": {
"type": "bytes",
"offset": len(compile_config) + len(part),
"size": len(graph),
}
}
index = json.dumps(
{
"version": 8 if table else 7,
"signature": "DXNN",
"size": 8192,
"data": data,
}
).encode()
path = os.path.join(directory, name)
with open(path, "wb") as model:
model.write(b"DXNN" + struct.pack("<I", 8))
model.write(index.ljust(8192 - 8, b"\0"))
model.write(compile_config + part + graph)
return path
def layout_of(shapes, num_classes, ppu=False, dynamic_output=False) -> YoloLayout:
return infer_yolo_layout(shapes, num_classes, ppu, dynamic_output).layout
class TestDeepxModelFile(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup)
def layout(self, ppu, layers, **kwargs) -> PpuLayout | None:
return read_ppu_layout(write_dxnn(self.tmp.name, ppu, layers, **kwargs))
def test_the_head_kind_and_one_grid_per_scale_are_read(self):
cases = {
"anchor-based: three anchors per scale collapse to one grid each": (
(ANCHOR_BASED_PPU, THREE_SCALE_ANCHORS, {}),
PpuLayout(anchor_based=True, grids=((80, 80), (40, 40), (20, 20))),
),
"anchor-free, one scale flattened into a single tensor": (
(ANCHOR_FREE_PPU, ONE_SCALE_FREE, {"box_format": "centre"}),
PpuLayout(anchor_based=False, grids=((100, 84),), centre_boxes=True),
),
"a head kind the compiler does not name still yields the scales": (
({"type": 7}, [(80, 80, 3), (40, 40, 3)], {}),
PpuLayout(anchor_based=None, grids=((80, 80), (40, 40))),
),
"no table: the per-anchor split says anchor-based": (
({"num_classes": 80}, THREE_SCALE_ANCHORS, {"table": False}),
PpuLayout(anchor_based=True, grids=((80, 80), (40, 40), (20, 20))),
),
"no table: compile_config places the scales ahead of the names": (
(
{
"type": 1,
"outputs": {
f"PPU_Transpose_Output_{i}": {"conv_idx": 2 - i}
for i in range(3)
},
},
[(20, 20, 1), (40, 40, 1), (80, 80, 1)],
{"table": False},
),
PpuLayout(anchor_based=False, grids=((80, 80), (40, 40), (20, 20))),
),
"no table: every scale in one (1, cells, channels) tensor": (
(ANCHOR_FREE_PPU, [(8400, 1, 1)], {"table": False}),
PpuLayout(anchor_based=False, grids=((8400, 1),)),
),
}
for head, ((ppu, layers, kwargs), expected) in cases.items():
with self.subTest(head=head):
self.assertEqual(self.layout(ppu, layers, **kwargs), expected)
def test_the_box_format_comes_from_the_compiled_graph(self):
for box_format, centre in (
("centre", True),
("corner", False),
("unnamed", True),
):
with self.subTest(box_format=box_format):
self.assertEqual(
self.layout(ANCHOR_FREE_PPU, ONE_SCALE_FREE, box_format=box_format),
PpuLayout(
anchor_based=False, grids=((100, 84),), centre_boxes=centre
),
)
def test_a_box_format_the_graph_does_not_answer_is_left_open(self):
cases = {
"no compiled graph at all": (ANCHOR_FREE_PPU, ONE_SCALE_FREE, {}),
"a graph without the node compile_config names": (
dict(ANCHOR_FREE_PPU, layer=[{"bbox": "/head/Missing"}]),
ONE_SCALE_FREE,
{"box_format": "centre"},
),
"a graph that builds its boxes from neither shape": (
ANCHOR_FREE_PPU,
ONE_SCALE_FREE,
{"box_format": "neither"},
),
"a graph section the reader cannot make sense of": (
ANCHOR_FREE_PPU,
ONE_SCALE_FREE,
{"box_format": "broken"},
),
"a grid-decoded head, where the question does not arise": (
ANCHOR_FREE_PPU,
THREE_SCALE_FREE,
{"box_format": "centre"},
),
}
for graph, (ppu, layers, kwargs) in cases.items():
with self.subTest(graph=graph):
self.assertIsNone(self.layout(ppu, layers, **kwargs).centre_boxes)
def test_nothing_is_read_from_a_model_without_ppu_metadata(self):
self.assertIsNone(read_ppu_layout(os.path.join(self.tmp.name, "missing")))
path = write_dxnn(self.tmp.name, None, [(80, 80, 3)])
self.assertIsNone(read_ppu_layout(path))
with open(path, "wb") as model:
model.write(b"ONNX" + b"\0" * 100)
self.assertIsNone(read_ppu_layout(path))
path = write_dxnn(self.tmp.name, ANCHOR_BASED_PPU, [(80, 80, 3), (40, 40, 3)])
os.truncate(path, os.path.getsize(path) - 40)
self.assertIsNone(read_ppu_layout(path))
class TestDeepxLayoutInference(unittest.TestCase):
def test_a_shape_and_class_count_pick_one_layout(self):
cases = {
"anchor-free, four columns ahead of the classes": (
[(1, 84, 8400)],
80,
YoloLayout.anchor_free,
84,
),
"anchor-free, row-major": ([(1, 8400, 84)], 80, YoloLayout.anchor_free, 84),
"anchor-based, an objectness column as well": (
[(1, 25200, 85)],
80,
YoloLayout.anchor,
85,
),
"anchor-based, channel-major": (
[(1, 85, 25200)],
80,
YoloLayout.anchor,
85,
),
"NMS in the head, a fixed run of corner records": (
[(1, 300, 6)],
80,
YoloLayout.nms_in_head,
None,
),
# only the label map can tell these two apart
"85 columns with 81 classes is anchor-free": (
[(1, 8400, 85)],
81,
YoloLayout.anchor_free,
85,
),
"85 columns with 80 classes is anchor-based": (
[(1, 8400, 85)],
80,
YoloLayout.anchor,
85,
),
# 6 columns is all three layouts, told apart by the row count
"6 columns and thousands of rows, one class": (
[(1, 25200, 6)],
1,
YoloLayout.anchor,
6,
),
"6 columns and thousands of rows, two classes": (
[(1, 8400, 6)],
2,
YoloLayout.anchor_free,
6,
),
"6 columns and a few hundred rows, one class": (
[(1, 300, 6)],
1,
YoloLayout.nms_in_head,
None,
),
"7 columns with two classes is only anchor-based": (
[(1, 8400, 7)],
2,
YoloLayout.anchor,
7,
),
# a square output matches the same width on both axes, which must
# not read as two candidate layouts
"a square output is not ambiguous with itself": (
[(1, 85, 85)],
80,
YoloLayout.anchor,
85,
),
"three NCHW maps with 255 channels are feature maps": (
[(1, 255, 80, 80), (1, 255, 40, 40), (1, 255, 20, 20)],
80,
YoloLayout.multipart,
None,
),
}
for head, (shapes, num_classes, layout, columns) in cases.items():
with self.subTest(head=head):
output = infer_yolo_layout(shapes, num_classes, False, False)
self.assertIs(output.layout, layout)
if columns is not None:
self.assertEqual(output.columns, columns)
def test_the_runtime_flags_outrank_the_shapes(self):
self.assertIs(layout_of([(8400,)], 80, ppu=True), YoloLayout.ppu)
self.assertIs(
layout_of([(1, -1, 6)], 80, dynamic_output=True), YoloLayout.nms_in_head
)
def test_a_shape_no_layout_fits_is_refused_with_the_reason(self):
cases = {
"fits two layouts": ([(1, 84, 6)], 80),
"labelmap_path": ([(1, 8400, 84)], 91),
"no output tensor": ([], 80),
"255 channels": (
[(1, 80, 80, 255), (1, 40, 40, 255), (1, 20, 20, 255)],
80,
),
"feature maps": ([(1, 8400, 80), (1, 8400, 4)], 80),
"80-class": ([(1, 24, 80, 80), (1, 24, 40, 40), (1, 24, 20, 20)], 3),
}
for reason, (shapes, num_classes) in cases.items():
with (
self.subTest(reason=reason),
self.assertRaisesRegex(ValueError, reason),
):
layout_of(shapes, num_classes)
class TestDeepxOutputValidation(unittest.TestCase):
def test_the_raw_yolox_head_is_read_for_the_configured_input(self):
for shapes, size in (
([(1, 8400, 85)], 640),
([(1, 85, 8400)], 640),
# 52*52 + 26*26 + 13*13 cells at 416
([(1, 3549, 85)], 416),
):
with self.subTest(shapes=shapes, size=size):
self.assertEqual(validate_yolox_outputs(shapes, 80, size, size), 85)
def test_another_head_under_yolox_is_refused_with_the_reason(self):
cases = {
"width and height": ([(1, 8400, 85)], 80, 416),
"labelmap_path": ([(1, 8400, 85)], 91, 640),
"yolo-generic": ([(1, 8400, 80), (1, 8400, 4)], 80, 640),
}
for reason, (shapes, num_classes, size) in cases.items():
with (
self.subTest(reason=reason),
self.assertRaisesRegex(ValueError, reason),
):
validate_yolox_outputs(shapes, num_classes, size, size)
def test_the_label_map_bounds_the_class_count(self):
self.assertEqual(class_count({0: "person", 79: "toothbrush"}), 80)
with self.assertRaisesRegex(ValueError, "labelmap_path"):
class_count({})
class TestDeepxRawDecode(unittest.TestCase):
def anchor_rows(self, rows) -> list:
out = np.zeros((1, len(rows), 85), dtype=np.float32)
for i, (cx, cy, w, h, obj, label, score) in enumerate(rows):
out[0, i, 0:4] = [cx, cy, w, h]
out[0, i, 4] = obj
out[0, i, 5 + label] = score
return [out]
def test_an_anchor_based_head_becomes_normalized_corners(self):
outputs = self.anchor_rows([(320.0, 160.0, 64.0, 32.0, 0.8, 3, 0.5)])
detections = decode_raw_anchor(outputs, 640, 640, 0.25, 0.45)
self.assertEqual(detections[0][0], 3)
self.assertAlmostEqual(detections[0][1], 0.4, places=5)
self.assertAlmostEqual(detections[0][2], 144 / 640, places=5)
self.assertAlmostEqual(detections[0][3], 288 / 640, places=5)
self.assertAlmostEqual(detections[0][4], 176 / 640, places=5)
self.assertAlmostEqual(detections[0][5], 352 / 640, places=5)
def test_a_channel_major_export_is_read_by_column_count(self):
outputs = self.anchor_rows([(320.0, 160.0, 64.0, 32.0, 1.0, 3, 0.9)])
detections = decode_raw_anchor(
[np.swapaxes(outputs[0], 1, 2)], 640, 640, 0.25, 0.45, columns=85
)
self.assertEqual(detections[0][0], 3)
self.assertAlmostEqual(detections[0][3], 288 / 640, places=5)
def test_rows_below_the_combined_threshold_are_dropped(self):
# 0.4 * 0.5 = 0.2, under the threshold both parts clear on their own
outputs = self.anchor_rows([(320.0, 320.0, 40.0, 80.0, 0.4, 3, 0.5)])
self.assertTrue(np.all(decode_raw_anchor(outputs, 640, 640, 0.25, 0.45) == 0))
def test_at_most_twenty_detections_are_returned(self):
rows = [(20.0 + 24 * i, 320.0, 16.0, 16.0, 1.0, i % 80, 0.9) for i in range(25)]
detections = decode_raw_anchor(self.anchor_rows(rows), 640, 640, 0.25, 0.45)
self.assertEqual(detections.shape, (20, 6))
self.assertEqual(int((detections[:, 1] > 0).sum()), 20)
def test_an_nms_in_head_output_is_read_without_running_nms(self):
out = np.array(
[
[
[100.0, 100.0, 200.0, 200.0, 0.9, 2.0],
[102.0, 102.0, 202.0, 202.0, 0.8, 2.0],
[300.0, 300.0, 400.0, 400.0, 0.1, 5.0],
]
],
dtype=np.float32,
)
detections = decode_raw_nms_in_head([out], 640, 640, 0.25)
self.assertEqual(detections[0][0], 2)
self.assertAlmostEqual(detections[0][1], 0.9, places=5)
self.assertAlmostEqual(detections[0][3], 100 / 640, places=5)
self.assertEqual(detections[1][0], 2)
self.assertAlmostEqual(detections[1][1], 0.8, places=5)
self.assertTrue(np.all(detections[2] == 0))
empty = np.zeros((1, 0, 6), dtype=np.float32)
self.assertTrue(np.all(decode_raw_nms_in_head([empty], 640, 640, 0.25) == 0))
class TestDeepxConfig(unittest.TestCase):
def test_a_device_string_resolves_to_an_npu_index(self):
for configured, index in (("PCIe:1", 1), ("2", 2), ("", 0)):
with self.subTest(device=configured):
self.assertEqual(resolve_device(configured), index)
def test_a_device_that_is_not_an_index_is_rejected(self):
"""The whole string has to be an index. Reading only the tail would
take the 1 out of "PCIe:0,PCIe:1" and bind to an NPU the config never
named, and several NPUs are configured as separate devices entries."""
for configured in (
"PCIe:the-fast-one",
"PCIe:0,PCIe:1",
"0,1",
"PCIe:0 PCIe:1",
"PCIe:-1",
"PCIe:",
):
with self.subTest(device=configured):
with self.assertRaises(ValueError):
resolve_device(configured)
with self.assertRaises(ValidationError):
DeepxDetectorConfig(type="deepx", device=configured)
def test_a_bad_device_is_refused_where_the_config_is_parsed(self):
"""parse_device builds the detector config to surface a bad device at
startup, so the comma-separated form fails there rather than binding a
detector process to the wrong NPU."""
self.assertEqual(parse_device("deepx:PCIe:1").device, "PCIe:1")
for raw in ("deepx:PCIe:0,PCIe:1", "deepx:the-fast-one"):
with self.subTest(raw=raw), self.assertRaises(DeviceParseError):
parse_device(raw)
def test_a_device_string_builds_this_detector_config(self):
"""Frigate turns a `deepx:PCIe:0` entry into the detector config with
the model already attached, which is the path app.py takes; a bare
constructor call does not exercise it."""
config = build_detector_config(
parse_device("deepx:PCIe:0"), model_with_type(ModelTypeEnum.yologeneric)
)
self.assertIsInstance(config, DeepxDetectorConfig)
self.assertEqual(config.device, "PCIe:0")
self.assertEqual(config.model.model_type, ModelTypeEnum.yologeneric)
def test_the_runtime_manifest_pins_its_wheels_to_the_version(self):
"""A PyPI path carries a per-file digest, so bumping DXRT_VERSION has
to rewrite the whole URL; a stale one installs the old wheel and fails
the sha256 on every user's first start."""
self.assertEqual(DEEPX_MANIFEST.version, DXRT_VERSION)
for artifact in DEEPX_MANIFEST.artifacts:
with self.subTest(url=artifact.url):
self.assertIn(f"dx_engine-{DXRT_VERSION}-", artifact.url)
def test_a_model_less_config_still_validates(self):
config = DeepxDetectorConfig(type="deepx")
self.assertIsNone(config.model)
class DeepxDetectorTestCase(unittest.TestCase):
def detector(
self,
model_type=ModelTypeEnum.yologeneric,
outputs_info=None,
ppu=False,
dynamic=False,
model_path="/nonexistent/model.dxnn",
) -> DeepxDetector:
dx_engine = MagicMock()
dx_engine.Configuration.ITEM.SERVICE = object()
session = dx_engine.InferenceEngine.return_value
session.get_output_tensors_info.return_value = (
[{"shape": [8400]}] if ppu else outputs_info or []
)
session.is_ppu.return_value = ppu
session.has_dynamic_output.return_value = dynamic
config = DeepxDetectorConfig(type="deepx")
config.model = model_with_type(model_type)
config.model.path = model_path
with (
# the detector writes the endpoint into the environment, which the
# rest of the suite shares when it runs in one process
patch.dict(os.environ),
patch.dict(sys.modules, {"dx_engine": dx_engine}),
patch.object(DeepxDetector, "activate_dependencies"),
patch("os.path.isfile", return_value=True),
):
return DeepxDetector(config)
def ppu_detector(
self, ppu, layers, model_type=ModelTypeEnum.yologeneric, box_format=None
) -> DeepxDetector:
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
return self.detector(
model_type,
ppu=True,
model_path=write_dxnn(tmp.name, ppu, layers, box_format=box_format),
)
def detect(self, detector, outputs) -> np.ndarray:
detector.session.run.return_value = outputs
return detector.detect_raw(np.zeros((1, 640, 640, 3), np.uint8))
class TestDeepxModelType(DeepxDetectorTestCase):
def test_a_model_type_with_no_decoder_is_rejected(self):
for model_type in (ModelTypeEnum.ssd, ModelTypeEnum.dfine):
with (
self.subTest(model_type=model_type),
self.assertRaisesRegex(ValueError, model_type.value),
):
self.detector(model_type)
def test_supported_model_types_are_accepted(self):
for model_type, outputs_info in (
(ModelTypeEnum.yologeneric, [{"shape": [1, 84, 8400]}]),
(ModelTypeEnum.yolox, [{"shape": [1, 8400, 85]}]),
):
with self.subTest(model_type=model_type):
detector = self.detector(model_type, outputs_info)
self.assertEqual(detector.model_type, model_type)
class TestDeepxDetectorLoad(DeepxDetectorTestCase):
def test_the_layout_is_settled_at_load(self):
detector = self.detector(ModelTypeEnum.yologeneric, [{"shape": [1, 84, 8400]}])
self.assertIs(detector.output.layout, YoloLayout.anchor_free)
self.assertEqual(detector.output.columns, 84)
detector = self.detector(ModelTypeEnum.yolox, [{"shape": [1, 8400, 85]}])
self.assertIs(detector.output.layout, YoloLayout.yolox)
for model_type in (ModelTypeEnum.yologeneric, ModelTypeEnum.yolox):
with self.subTest(model_type=model_type):
detector = self.ppu_detector(
ANCHOR_FREE_PPU, THREE_SCALE_FREE, model_type=model_type
)
self.assertIs(detector.output.layout, YoloLayout.ppu)
self.assertEqual(detector.ppu_layout.scale_count, 3)
def test_a_model_the_detector_cannot_decode_is_refused_at_load(self):
cases = {
"Cannot decode DEEPX model": lambda: self.detector(
ModelTypeEnum.yologeneric, [{"shape": [1, 8400, 7]}]
),
"DX-COM 2.4.0": lambda: self.detector(ModelTypeEnum.yologeneric, ppu=True),
"face and pose": lambda: self.ppu_detector({"type": 2}, [(80, 80, 1)]),
"centre and size or as two corners": lambda: self.ppu_detector(
ANCHOR_FREE_PPU, ONE_SCALE_FREE
),
}
for reason, load in cases.items():
with (
self.subTest(reason=reason),
self.assertRaisesRegex(ValueError, reason),
):
load()
class TestDeepxDetectRaw(DeepxDetectorTestCase):
def test_a_ppu_record_decodes_by_the_head_in_the_model(self):
cases = {
"anchor-based, layer 2 of 3 at stride 32, the 373x326 anchor": (
(ANCHOR_BASED_PPU, THREE_SCALE_ANCHORS, None),
build_ppu_record((0.6, 0.4, 0.3, 0.7), label=5),
(5, (0.0, 0.380094, 0.864187, 0.589906)),
),
"anchor-based, layer 0 of 3 at stride 8, the 16x30 anchor": (
(ANCHOR_BASED_PPU, THREE_SCALE_ANCHORS, None),
build_ppu_record((0.6, 0.4, 0.3, 0.7), grid=(7, 9, 1, 0)),
(0, (None, 0.116750, None, None)),
),
"anchor-based, two scales: layer 0 is stride 16, not stride 8": (
(ANCHOR_BASED_PPU, TWO_SCALE_ANCHORS, None),
build_ppu_record((0.6, 0.4, 0.3, 0.7), grid=(7, 9, 1, 0)),
(0, (0.141156, 0.236031, 0.223844, 0.248969)),
),
"anchor-free, three scales: cell (10, 9) of stride 32": (
(ANCHOR_FREE_PPU, THREE_SCALE_FREE, None),
build_ppu_record((1.2, 0.5, 1.0, 0.5), grid=(9, 10, 0, 2), label=7),
(7, (0.433782, 0.492043, 0.516218, 0.627957)),
),
"anchor-free, one scale: the box fields are already pixels": (
(ANCHOR_FREE_PPU, ONE_SCALE_FREE, "centre"),
build_ppu_record((320.0, 160.0, 64.0, 32.0), label=3),
(3, (144 / 640, 288 / 640, 176 / 640, 352 / 640)),
),
"anchor-free, one scale: a sub-pixel box stays sub-pixel": (
(ANCHOR_FREE_PPU, ONE_SCALE_FREE, "centre"),
build_ppu_record((0.6, 0.4, 0.3, 0.7)),
(0, (None, 0.45 / 640, None, None)),
),
"a corner-format head reads the record as two corners": (
(ANCHOR_FREE_PPU, ONE_SCALE_FREE, "corner"),
build_ppu_record((100.0, 50.0, 300.0, 250.0), label=2),
(2, (50 / 640, 100 / 640, 250 / 640, 300 / 640)),
),
"a centre-format head reads it as a centre and size": (
(ANCHOR_FREE_PPU, ONE_SCALE_FREE, "centre"),
build_ppu_record((100.0, 50.0, 300.0, 250.0), label=2),
(2, (0.0, 0.0, 175 / 640, 250 / 640)),
),
}
for head, ((ppu, layers, box_format), record, (label, box)) in cases.items():
with self.subTest(head=head):
detector = self.ppu_detector(ppu, layers, box_format=box_format)
detections = self.detect(detector, [record])
self.assertEqual(detections[0][0], label)
for i, expected in enumerate(box, start=2):
if expected is not None:
self.assertAlmostEqual(detections[0][i], expected, places=5)
def test_the_strides_come_from_the_grids_in_the_model(self):
detector = self.ppu_detector(
ANCHOR_FREE_PPU, [(40, 40, 1), (20, 20, 1), (10, 10, 1)]
)
detections = self.detect(
detector,
[build_ppu_record((1.2, 0.5, 1.0, 0.5), grid=(9, 10, 0, 0), label=7)],
)
# layer 0 is stride 16: centre (11.2, 9.5) * 16, size e * 16 x sqrt(e) * 16
self.assertEqual(detections[0][0], 7)
self.assertAlmostEqual(detections[0][2], (152 - np.exp(0.5) * 8) / 640, 5)
self.assertAlmostEqual(detections[0][3], (179.2 - np.exp(1.0) * 8) / 640, 5)
def test_the_head_stays_what_the_model_said_across_frames(self):
detector = self.ppu_detector(ANCHOR_BASED_PPU, THREE_SCALE_ANCHORS)
first = self.detect(
detector, [build_ppu_record((0.6, 0.4, 0.3, 0.7), grid=(7, 9, 1, 0))]
)
# layer 0 of 3: stride 8, anchor 16x30
self.assertAlmostEqual(first[0][3], 0.116750, places=5)
second = self.detect(
detector, [build_ppu_record((0.5, 0.5, 0.4, 0.4), grid=(3, 4, 0, 1))]
)
# layer 1 of 3: stride 16, anchor 30x61, not layer 1 of 2
self.assertAlmostEqual(second[0][3], 0.0975, places=5)
detector = self.ppu_detector(
ANCHOR_FREE_PPU, ONE_SCALE_FREE, box_format="centre"
)
record = [build_ppu_record((100.0, 50.0, 300.0, 250.0), label=2)]
# centre (100, 50), size 300 x 250: the right edge lands at 250
for frame in range(2):
with self.subTest(frame=frame):
self.assertAlmostEqual(
self.detect(detector, record)[0][5], 250 / 640, places=5
)
def test_records_the_head_cannot_place_come_back_empty(self):
cases = {
"a level or box the anchor table does not carry": (
THREE_SCALE_ANCHORS,
[build_ppu_record((0.6, 0.4, 0.3, 0.7), grid=(7, 9, 2, 5))],
),
"a scale count Frigate has no anchor table for": (
FOUR_SCALE_ANCHORS,
[build_ppu_record((0.6, 0.4, 0.3, 0.7))],
),
"a record below the score threshold": (
THREE_SCALE_ANCHORS,
[build_ppu_record((0.6, 0.4, 0.3, 0.7), score=0.1)],
),
"an unexpected record width": (
THREE_SCALE_ANCHORS,
[np.zeros((1, 3, 16), dtype=np.uint8)],
),
**{
f"no records at all, shaped {shape}": (
THREE_SCALE_ANCHORS,
[np.zeros(shape, dtype=np.uint8)],
)
for shape in ((1, 0, PPU_RECORD_SIZE), (0, PPU_RECORD_SIZE), (0,))
},
}
for output, (layers, outputs) in cases.items():
with self.subTest(output=output):
detector = self.ppu_detector(ANCHOR_BASED_PPU, layers)
self.assertTrue(np.all(self.detect(detector, outputs) == 0))
def test_a_yolox_raw_head_is_decoded_through_the_grid(self):
detector = self.detector(ModelTypeEnum.yolox, [{"shape": [1, 8400, 85]}])
# cell (x 10, y 5) of the stride-8 grid is row 5 * 80 + 10
tensor = np.zeros((1, 8400, 85), np.float32)
tensor[0, 410, :5] = [0.5, 0.5, np.log(4.0), np.log(2.0), 0.9]
tensor[0, 410, 5 + 7] = 0.8
detections = self.detect(detector, [tensor])
# centre (84, 44), size 32 x 16
self.assertEqual(detections[0][0], 7)
self.assertAlmostEqual(detections[0][1], 0.72, places=5)
self.assertAlmostEqual(detections[0][2], 36 / 640, places=5)
self.assertAlmostEqual(detections[0][3], 68 / 640, places=5)
self.assertAlmostEqual(detections[0][4], 52 / 640, places=5)
self.assertAlmostEqual(detections[0][5], 100 / 640, places=5)
detector = self.detector(ModelTypeEnum.yolox, [{"shape": [1, 85, 8400]}])
detections = self.detect(detector, [np.swapaxes(tensor, 1, 2)])
self.assertAlmostEqual(detections[0][5], 100 / 640, places=5)
def test_a_raw_head_comes_back_as_frigates_detection_rows(self):
detector = self.detector(ModelTypeEnum.yologeneric, [{"shape": [1, 84, 8400]}])
output = np.zeros((1, 84, 8400), dtype=np.float32)
output[0, 0:4, 0] = [320.0, 160.0, 64.0, 32.0]
output[0, 4 + 2, 0] = 0.9
detections = self.detect(detector, [output])
self.assertEqual(detections.shape, (20, 6))
self.assertEqual(detections[0][0], 2)
self.assertAlmostEqual(detections[0][1], 0.9, places=5)
self.assertAlmostEqual(detections[0][3], 288 / 640, places=5)
+20
View File
@@ -184,6 +184,26 @@ class TestAccelerators(HardwareProbeTestCase):
) )
self.assertFalse(memryx.unlimited) self.assertFalse(memryx.unlimited)
def test_each_deepx_node_is_a_unit(self):
write(os.path.join(self.dev_root, "dxrt0"))
write(os.path.join(self.dev_root, "dxrt1"))
deepx = self.probe()["deepx"]
self.assertEqual(
[unit.device for unit in deepx.units],
["deepx:PCIe:0", "deepx:PCIe:1"],
)
def test_a_deepx_npu_is_unlimited(self):
# the host daemon multiplexes, so one module takes several processes
write(os.path.join(self.dev_root, "dxrt0"))
self.assertTrue(self.probe()["deepx"].unlimited)
def test_no_deepx_is_reported_without_a_node(self):
self.assertNotIn("deepx", self.probe())
def test_a_supported_rockchip_soc_is_reported(self): def test_a_supported_rockchip_soc_is_reported(self):
write( write(
os.path.join(self.proc_root, "device-tree", "compatible"), os.path.join(self.proc_root, "device-tree", "compatible"),
+54
View File
@@ -0,0 +1,54 @@
"""Tests for get_dst_transitions."""
import datetime
import unittest
from frigate.util.time import get_dst_transitions
class TestDstTransitions(unittest.TestCase):
def test_dst_transition_splits_periods_at_the_transition(self):
start = datetime.datetime(2026, 3, 7, 12, tzinfo=datetime.UTC).timestamp()
end = start + 2 * 86400
spring = datetime.datetime(2026, 3, 8, 7, tzinfo=datetime.UTC).timestamp()
self.assertEqual(
get_dst_transitions("America/New_York", start, end),
[(start, spring, -18000), (spring, end, -14400)],
)
def test_dst_transition_is_not_reported_a_day_late(self):
# local midnight on the day of the change used to report the
# transition a full day after it actually happened
start = datetime.datetime(2024, 3, 10, 5, tzinfo=datetime.UTC).timestamp()
end = start + 3 * 86400
spring = datetime.datetime(2024, 3, 10, 7, tzinfo=datetime.UTC).timestamp()
self.assertEqual(
get_dst_transitions("America/New_York", start, end),
[(start, spring, -18000), (spring, end, -14400)],
)
def test_dst_transition_after_the_last_daily_probe_is_found(self):
start = datetime.datetime(2024, 11, 2, 12, tzinfo=datetime.UTC).timestamp()
end = datetime.datetime(2024, 11, 3, 10, tzinfo=datetime.UTC).timestamp()
fall = datetime.datetime(2024, 11, 3, 6, tzinfo=datetime.UTC).timestamp()
self.assertEqual(
get_dst_transitions("America/New_York", start, end),
[(start, fall, -14400), (fall, end, -18000)],
)
def test_no_transition_returns_a_single_period(self):
start = datetime.datetime(2026, 6, 1, tzinfo=datetime.UTC).timestamp()
end = start + 5 * 86400
self.assertEqual(
get_dst_transitions("America/New_York", start, end),
[(start, end, -14400)],
)
def test_invalid_zone_retains_utc_fallback(self):
self.assertEqual(
get_dst_transitions("Invalid/Timezone", 100, 200), [(100, 200, 0)]
)
if __name__ == "__main__":
unittest.main(verbosity=2)
+9
View File
@@ -580,6 +580,15 @@ class TestLlamaCppProvider(unittest.TestCase):
client = self._validated_client(4096, {"context_size": 32768}) client = self._validated_client(4096, {"context_size": 32768})
self.assertEqual(client.get_context_size(), 32768) self.assertEqual(client.get_context_size(), 32768)
def test_list_models_dedupes_alias_matching_id(self):
client = self._client()
models_data = [
{"id": "qwen3-asr", "aliases": ["qwen3-asr"]},
{"id": "gemma", "aliases": ["gemma", "g4"]},
]
with patch.object(client, "_fetch_models_data", return_value=models_data):
self.assertEqual(client.list_models(), ["g4", "gemma", "qwen3-asr"])
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# transcribe role # transcribe role
+29
View File
@@ -73,6 +73,35 @@ class TestImprovedMotionDetector(unittest.TestCase):
"Motion boxes should be empty when scene change exceeds skip threshold", "Motion boxes should be empty when scene change exceeds skip threshold",
) )
def _bright_frame(self, offset: int) -> np.ndarray:
"""Produce a bright frame with a small dark object that moves."""
frame = np.full((self.frame_shape[0], self.frame_shape[1]), 200, dtype=np.uint8)
x = 10 + (offset * 5) % 60
frame[40:60, x : x + 15] = 20
return frame
def test_skip_motion_threshold_recovers_after_skip(self):
"""Skipped frames must still be blended into the background.
A bright scene differs from the zeroed background across the whole
frame, so the first frames are skipped. The background has to catch up
anyway, otherwise motion detection never returns.
"""
self.config.skip_motion_threshold = 0.5
self.config.improve_contrast = False
self.detector.config = self.config
self.detector.update_mask()
boxes = [len(self.detector.detect(self._bright_frame(i))) for i in range(40)]
self.assertEqual(boxes[0], 0, "First frame should exceed the skip threshold")
self.assertGreater(
self.detector.avg_frame.max(),
0,
"Background was never updated while frames were skipped",
)
self.assertTrue(any(boxes), "Motion detection never recovered after a skip")
def test_skip_motion_threshold_does_not_affect_calibration(self): def test_skip_motion_threshold_does_not_affect_calibration(self):
"""Even when skipping, the detector should go into calibrating state.""" """Even when skipping, the detector should go into calibrating state."""
self.config.skip_motion_threshold = 0.4 self.config.skip_motion_threshold = 0.4
+28
View File
@@ -48,6 +48,16 @@ class TestNoticeKinds(unittest.TestCase):
self.assertIsNone(kind.link_for({"version": "0.19.1"})) self.assertIsNone(kind.link_for({"version": "0.19.1"}))
def test_analytics_prompt_links_to_telemetry_settings(self):
kind = NOTICE_KINDS["analytics_prompt"]
self.assertEqual(kind.link_for({}), "/settings?page=systemTelemetry")
self.assertFalse(kind.counts_repeats)
self.assertFalse(kind.reportable)
def test_update_available_is_not_reported(self):
self.assertFalse(NOTICE_KINDS["update_available"].reportable)
class RegistryTestCase(unittest.TestCase): class RegistryTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
@@ -278,6 +288,24 @@ class TestNoticeRegistry(RegistryTestCase):
self.assertEqual(dismissals["detector_stuck"], 1) self.assertEqual(dismissals["detector_stuck"], 1)
class TestMarkReported(RegistryTestCase):
def test_moves_watermarks_to_the_snapshot_not_the_current_count(self):
self.registry.raise_notice(
"detector_stuck", scope="ov", params={"detector": "ov"}
)
snapshot = self.registry.stats()
self.registry.raise_notice(
"detector_stuck", scope="ov", params={"detector": "ov"}
)
self.registry.mark_reported(snapshot)
row = self.registry.stats()[0]
self.assertEqual(row["occurrences"], 2)
self.assertEqual(row["reported_occurrences"], 1)
self.assertEqual(row["reported_dismissals"], 0)
class TestApply(RegistryTestCase): class TestApply(RegistryTestCase):
def test_each_action_reaches_its_method(self): def test_each_action_reaches_its_method(self):
self.registry.apply( self.registry.apply(
+37
View File
@@ -15,6 +15,8 @@ Also covers the inverse direction: the ptz movement timestamps must not be writt
for a camera that has autotracking off, because nothing clears them back out. for a camera that has autotracking off, because nothing clears them back out.
""" """
import asyncio
import threading
import unittest import unittest
from unittest.mock import AsyncMock, MagicMock from unittest.mock import AsyncMock, MagicMock
@@ -234,5 +236,40 @@ class TestManualRelativeMoveMetrics(unittest.IsolatedAsyncioTestCase):
) )
class TestOnvifClose(unittest.TestCase):
"""close() must release everything on the loop, since whatever it leaves is
garbage collected during interpreter shutdown, where the resulting warnings
fail to log and fill the shutdown output with logging errors."""
def setUp(self) -> None:
self.controller = _make_controller(autotracking_enabled=False)
self.onvif = self.controller.cams[CAMERA]["onvif"]
self.onvif.close = AsyncMock()
self.controller.config_subscriber = MagicMock()
self.controller.loop = asyncio.new_event_loop()
self.controller.loop_thread = threading.Thread(
target=self.controller._run_event_loop, daemon=True
)
self.controller.loop_thread.start()
self.addCleanup(self.controller.loop.close)
def test_close_closes_camera_sessions(self) -> None:
self.controller.close()
self.onvif.close.assert_awaited_once()
def test_close_cancels_tasks_left_on_the_loop(self) -> None:
async def forever() -> None:
while True:
await asyncio.sleep(1)
poll = asyncio.run_coroutine_threadsafe(forever(), self.controller.loop)
self.controller.close()
self.assertTrue(poll.cancelled())
self.assertFalse(self.controller.loop_thread.is_alive())
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
+55
View File
@@ -0,0 +1,55 @@
"""Tests for restarting frigate under s6."""
import signal
import unittest
from unittest.mock import MagicMock, patch
import psutil
from frigate.util.services import restart_frigate
class TestRestartFrigate(unittest.TestCase):
def _s6_process(self) -> MagicMock:
proc = MagicMock()
proc.name.return_value = "s6-svscan"
return proc
@patch("frigate.util.services.os.kill")
@patch("frigate.util.services.psutil.Process")
def test_terminates_s6_when_permitted(self, mock_process, mock_kill):
proc = self._s6_process()
mock_process.return_value = proc
restart_frigate()
proc.terminate.assert_called_once()
mock_kill.assert_not_called()
@patch("frigate.util.services.os.getpid", return_value=99)
@patch("frigate.util.services.os.kill")
@patch("frigate.util.services.psutil.Process")
def test_exits_self_when_s6_signal_is_denied(
self, mock_process, mock_kill, _mock_getpid
):
"""Running unprivileged, frigate cannot signal root's s6-svscan."""
proc = self._s6_process()
proc.terminate.side_effect = psutil.AccessDenied(pid=1, name="s6-svscan")
mock_process.return_value = proc
restart_frigate()
mock_kill.assert_called_once_with(99, signal.SIGINT)
@patch("frigate.util.services.os.getpid", return_value=99)
@patch("frigate.util.services.os.kill")
@patch("frigate.util.services.psutil.Process")
def test_exits_self_without_s6(self, mock_process, mock_kill, _mock_getpid):
proc = MagicMock()
proc.name.return_value = "init"
mock_process.return_value = proc
restart_frigate()
proc.terminate.assert_not_called()
mock_kill.assert_called_once_with(99, signal.SIGINT)
+1 -3
View File
@@ -324,9 +324,7 @@ class NorfairTracker(ObjectTracker):
): ):
tracker = self.get_tracker(obj["label"]) tracker = self.get_tracker(obj["label"])
tracker.tracked_objects = [ tracker.tracked_objects = [
o o for o in tracker.tracked_objects if str(o.global_id) != track_id
for o in tracker.tracked_objects
if str(o.global_id) != track_id and o.hit_counter < 0
] ]
del self.track_id_map[track_id] del self.track_id_map[track_id]
+3
View File
@@ -49,6 +49,9 @@ def start_or_restart_ffmpeg(
if ffmpeg_process is not None: if ffmpeg_process is not None:
stop_ffmpeg(ffmpeg_process, logger) stop_ffmpeg(ffmpeg_process, logger)
# flush after the stop so the logs cover ffmpeg's output up to exit
logpipe.dump()
if frame_size is None: if frame_size is None:
process = sp.Popen( process = sp.Popen(
ffmpeg_cmd, ffmpeg_cmd,
+10 -3
View File
@@ -35,12 +35,19 @@ logger = logging.getLogger(__name__)
def restart_frigate(): def restart_frigate():
proc = psutil.Process(1) proc = psutil.Process(1)
# if this is running via s6, sigterm pid 1 # if this is running via s6, sigterm pid 1
if proc.name() == "s6-svscan": if proc.name() == "s6-svscan":
proc.terminate() try:
proc.terminate()
return
except psutil.AccessDenied:
# frigate runs unprivileged, so it cannot signal root's s6-svscan.
# exiting this process instead runs frigate/finish, which halts s6
logger.debug("Not permitted to signal s6-svscan, exiting instead")
# otherwise, just try and exit frigate # otherwise, just try and exit frigate
else: os.kill(os.getpid(), signal.SIGINT)
os.kill(os.getpid(), signal.SIGINT)
def print_stack(sig, frame): def print_stack(sig, frame):
+40 -19
View File
@@ -2,6 +2,7 @@
import datetime import datetime
import logging import logging
import math
from zoneinfo import ZoneInfoNotFoundError from zoneinfo import ZoneInfoNotFoundError
import pytz import pytz
@@ -43,9 +44,33 @@ def is_current_hour(timestamp: int) -> bool:
return timestamp < start_of_next_hour return timestamp < start_of_next_hour
def _utc_offset(tz: datetime.tzinfo, timestamp: float) -> float:
dt = datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)
return dt.astimezone(tz).utcoffset().total_seconds()
def _find_transition(
tz: datetime.tzinfo, lo: float, hi: float, lo_offset: float
) -> float:
"""Bisect (lo, hi] to the second where the UTC offset first differs from lo_offset."""
# whole seconds, so the midpoint always advances (a fractional bound can
# otherwise leave the midpoint sitting on lo) and lands on the transition
low = math.floor(lo)
high = math.ceil(hi)
while high - low > 1:
mid = (low + high) // 2
if _utc_offset(tz, mid) == lo_offset:
low = mid
else:
high = mid
return float(high)
def get_dst_transitions( def get_dst_transitions(
tz_name: str, start_time: float, end_time: float tz_name: str, start_time: float, end_time: float
) -> list[tuple[float, float]]: ) -> list[tuple[float, float, float]]:
""" """
Find DST transition points and return time periods with consistent offsets. Find DST transition points and return time periods with consistent offsets.
@@ -66,28 +91,24 @@ def get_dst_transitions(
periods = [] periods = []
current = start_time current = start_time
# Get initial offset
dt = datetime.datetime.utcfromtimestamp(current).replace(tzinfo=pytz.UTC)
local_dt = dt.astimezone(tz)
prev_offset = local_dt.utcoffset().total_seconds()
period_start = start_time period_start = start_time
prev_offset = _utc_offset(tz, current)
# Check each day for offset changes # Probe at most a day ahead, capped at end_time so a transition after the
while current <= end_time: # last full day is still seen instead of silently kept in the last period.
dt = datetime.datetime.utcfromtimestamp(current).replace(tzinfo=pytz.UTC) while current < end_time:
local_dt = dt.astimezone(tz) next_probe = min(current + 86400, end_time)
current_offset = local_dt.utcoffset().total_seconds() next_offset = _utc_offset(tz, next_probe)
if current_offset != prev_offset: if next_offset != prev_offset:
# Found a transition - close previous period transition = _find_transition(tz, current, next_probe, prev_offset)
periods.append((period_start, current, prev_offset)) periods.append((period_start, transition, prev_offset))
period_start = current period_start = transition
prev_offset = current_offset prev_offset = _utc_offset(tz, transition)
current = transition
else:
current = next_probe
current += 86400 # Check daily
# Add final period
periods.append((period_start, end_time, prev_offset)) periods.append((period_start, end_time, prev_offset))
return periods return periods
-4
View File
@@ -319,9 +319,6 @@ class CameraWatchdog(threading.Thread):
f"Capture thread for {self.config.name} did not exit in time" f"Capture thread for {self.config.name} did not exit in time"
) )
self.logger.error(
"The following ffmpeg logs include the last 100 lines prior to exit."
)
self.logpipe.dump() self.logpipe.dump()
self.logger.info("Restarting ffmpeg...") self.logger.info("Restarting ffmpeg...")
self.start_ffmpeg_detect() self.start_ffmpeg_detect()
@@ -543,7 +540,6 @@ class CameraWatchdog(threading.Thread):
f"{self.config.name}/status/{role.value}", "offline" f"{self.config.name}/status/{role.value}", "offline"
) )
p["logpipe"].dump()
p["process"] = start_or_restart_ffmpeg( p["process"] = start_or_restart_ffmpeg(
p["cmd"], self.logger, p["logpipe"], ffmpeg_process=p["process"] p["cmd"], self.logger, p["logpipe"], ffmpeg_process=p["process"]
) )
+59
View File
@@ -0,0 +1,59 @@
"""Generate the analytics report JSON Schema from the Pydantic models.
The committed docs/static/frigate-analytics-schema.json documents every field
for the ingest Worker's aggregation job and the docs page. It is exact for this
version only, so the Worker validates just the envelope against it. Never edit
it by hand, and never run a formatter over it.
Usage (from the repository root):
python3 generate_analytics_schema.py # write the schema
python3 generate_analytics_schema.py --check # CI guard: fail if stale
"""
import argparse
import json
import sys
from pathlib import Path
from frigate.analytics.schema import SCHEMA_VERSION, AnalyticsReport
OUTPUT = Path(__file__).parent / "docs" / "static" / "frigate-analytics-schema.json"
def render() -> str:
schema = AnalyticsReport.model_json_schema()
schema["$schema"] = "https://json-schema.org/draft/2020-12/schema"
schema["$id"] = "https://docs.frigate.video/frigate-analytics-schema.json"
schema["x-schema-version"] = SCHEMA_VERSION
return json.dumps(schema, indent=2, sort_keys=True) + "\n"
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument(
"--check", action="store_true", help="fail if the committed schema is stale"
)
args = parser.parse_args()
rendered = render()
if args.check:
current = OUTPUT.read_text() if OUTPUT.exists() else ""
if current != rendered:
print(
f"{OUTPUT} is out of date, run python3 generate_analytics_schema.py",
file=sys.stderr,
)
return 1
print(f"{OUTPUT} is up to date")
return 0
OUTPUT.write_text(rendered)
print(f"Wrote {OUTPUT}")
return 0
if __name__ == "__main__":
sys.exit(main())
+3 -1
View File
@@ -47,8 +47,8 @@ from fastapi.routing import APIRoute
from ruamel.yaml import YAML from ruamel.yaml import YAML
from ruamel.yaml.scalarstring import LiteralScalarString from ruamel.yaml.scalarstring import LiteralScalarString
from frigate.api import app as main_app
from frigate.api import ( from frigate.api import (
analytics,
auth, auth,
camera, camera,
chat, chat,
@@ -65,6 +65,7 @@ from frigate.api import (
record, record,
review, review,
) )
from frigate.api import app as main_app
from frigate.api.auth import require_admin_by_default from frigate.api.auth import require_admin_by_default
logging.basicConfig(level=logging.INFO, format="%(message)s") logging.basicConfig(level=logging.INFO, format="%(message)s")
@@ -145,6 +146,7 @@ def build_app() -> FastAPI:
""" """
app = FastAPI() app = FastAPI()
routers = [ routers = [
analytics.router,
auth.router, auth.router,
camera.router, camera.router,
chat.router, chat.router,
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+11
View File
@@ -56,3 +56,14 @@ export async function waitForErrorMarker(
.poll(() => hasErrorMarkers(page), { timeout: timeoutMs }) .poll(() => hasErrorMarkers(page), { timeout: timeoutMs })
.toBe(true); .toBe(true);
} }
/**
* Append a trailing comment so the editor content differs from the
* loaded config. The save buttons are disabled until then.
*/
export async function makeMonacoEdit(page: Page): Promise<void> {
const editor = page.locator(".monaco-editor").first();
await editor.click();
await page.keyboard.press("ControlOrMeta+End");
await page.keyboard.type("# edited by e2e", { delay: 0 });
}
+5
View File
@@ -11,6 +11,7 @@ import { installWsFrameCapture, waitForWsFrame } from "../helpers/ws-frames";
import { grantClipboardPermissions, readClipboard } from "../helpers/clipboard"; import { grantClipboardPermissions, readClipboard } from "../helpers/clipboard";
import { import {
getMonacoVisibleText, getMonacoVisibleText,
makeMonacoEdit,
replaceMonacoValue, replaceMonacoValue,
waitForErrorMarker, waitForErrorMarker,
} from "../helpers/monaco"; } from "../helpers/monaco";
@@ -71,6 +72,7 @@ test.describe("Config Editor — Save @medium", () => {
await expect(frigateApp.page.locator(".monaco-editor").first()).toBeVisible( await expect(frigateApp.page.locator(".monaco-editor").first()).toBeVisible(
{ timeout: 15_000 }, { timeout: 15_000 },
); );
await makeMonacoEdit(frigateApp.page);
await frigateApp.page.getByLabel("Save Only").click(); await frigateApp.page.getByLabel("Save Only").click();
await expect await expect
.poll(() => capture.capturedUrl(), { timeout: 5_000 }) .poll(() => capture.capturedUrl(), { timeout: 5_000 })
@@ -92,6 +94,7 @@ test.describe("Config Editor — Save @medium", () => {
await expect(frigateApp.page.locator(".monaco-editor").first()).toBeVisible( await expect(frigateApp.page.locator(".monaco-editor").first()).toBeVisible(
{ timeout: 15_000 }, { timeout: 15_000 },
); );
await makeMonacoEdit(frigateApp.page);
await frigateApp.page.getByLabel("Save Only").click(); await frigateApp.page.getByLabel("Save Only").click();
await expect(frigateApp.page.getByText(/Invalid field/i)).toBeVisible({ await expect(frigateApp.page.getByText(/Invalid field/i)).toBeVisible({
timeout: 5_000, timeout: 5_000,
@@ -117,6 +120,7 @@ test.describe("Config Editor — Save and Restart @medium", () => {
{ timeout: 15_000 }, { timeout: 15_000 },
); );
await makeMonacoEdit(frigateApp.page);
await frigateApp.page.getByLabel("Save & Restart").click(); await frigateApp.page.getByLabel("Save & Restart").click();
const dialog = frigateApp.page.getByRole("alertdialog"); const dialog = frigateApp.page.getByRole("alertdialog");
await expect(dialog).toBeVisible({ timeout: 5_000 }); await expect(dialog).toBeVisible({ timeout: 5_000 });
@@ -140,6 +144,7 @@ test.describe("Config Editor — Save and Restart @medium", () => {
{ timeout: 15_000 }, { timeout: 15_000 },
); );
await makeMonacoEdit(frigateApp.page);
await frigateApp.page.getByLabel("Save & Restart").click(); await frigateApp.page.getByLabel("Save & Restart").click();
const dialog = frigateApp.page.getByRole("alertdialog"); const dialog = frigateApp.page.getByRole("alertdialog");
await expect(dialog).toBeVisible({ timeout: 5_000 }); await expect(dialog).toBeVisible({ timeout: 5_000 });
+216
View File
@@ -0,0 +1,216 @@
/**
* Generative AI provider settings tests -- MEDIUM tier.
*
* A model name belongs to its provider, so switching provider clears the model
* field. The roles widget strips a role only for a model or provider picked in
* the form, never when capability data arrives for the saved entry, which would
* dirty the section on load and silently drop the role on the next save.
*/
import { readFileSync } from "node:fs";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { test, expect } from "../../fixtures/frigate-test";
import type { Page } from "@playwright/test";
import { configFactory } from "../../fixtures/mock-data/config";
const __dirname = dirname(fileURLToPath(import.meta.url));
const CONFIG_SCHEMA = JSON.parse(
readFileSync(
resolve(__dirname, "../../fixtures/mock-data/config-schema.json"),
"utf-8",
),
);
const ENTRY = "audio";
const SETTINGS_URL = "/settings?page=integrationGenerativeAi";
const UNSAVED = "You have unsaved changes";
const MODEL_PLACEHOLDER = "Select or enter a model…";
type Entry = {
provider: string;
model: string;
base_url?: string;
roles: string[];
};
type ProviderInfo = {
models: string[];
supports_transcription: boolean;
model_capabilities?: Record<string, { supports_transcription?: boolean }>;
};
async function installRoutes(page: Page, entry: Entry, info: ProviderInfo) {
const config = configFactory({ genai: { [ENTRY]: entry } });
await page.route("**/api/config/schema.json", (route) =>
route.fulfill({ json: CONFIG_SCHEMA }),
);
await page.route("**/api/config", (route) => {
if (route.request().method() === "GET") {
return route.fulfill({ json: config });
}
return route.fulfill({ json: { success: true } });
});
await page.route("**/api/config/raw_paths", (route) =>
route.fulfill({ json: { genai: { [ENTRY]: entry } } }),
);
await page.route("**/api/genai/models", (route) =>
route.fulfill({
json: {
[ENTRY]: {
roles: entry.roles,
supports_toggleable_thinking: false,
supports_embeddings: true,
model_capabilities: {},
...info,
},
},
}),
);
}
function roleSwitch(page: Page, role: string) {
return page.locator(`#root_${ENTRY}_roles-${role}`);
}
test.describe("genai provider settings @medium", () => {
test("a saved role the provider cannot confirm stays and is not dirty", async ({
frigateApp,
}) => {
// The server does not serve the saved model, so the backend reports every
// capability as false for the entry.
await installRoutes(
frigateApp.page,
{
provider: "llamacpp",
model: "stale-model",
base_url: "http://llama:8080",
roles: ["transcribe"],
},
{ models: ["qwen3-asr"], supports_transcription: false },
);
await frigateApp.goto(SETTINGS_URL);
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeVisible();
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeChecked();
// Give any stripping effect time to fire, then confirm the section stayed
// clean.
await frigateApp.page.waitForTimeout(1000);
await expect(frigateApp.page.getByText(UNSAVED)).toBeHidden();
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeChecked();
});
test("switching provider clears the model", async ({ frigateApp }) => {
await installRoutes(
frigateApp.page,
{
provider: "openai",
model: "gpt-4o",
roles: ["descriptions"],
},
{ models: ["gpt-4o"], supports_transcription: true },
);
await frigateApp.goto(SETTINGS_URL);
const model = frigateApp.page.locator(`#root_${ENTRY}_model`);
await expect(model).toHaveText("gpt-4o");
await frigateApp.page.locator(`#root_${ENTRY}_provider`).click();
await frigateApp.page.getByRole("option", { name: "llamacpp" }).click();
await expect(model).toHaveText(MODEL_PLACEHOLDER);
await expect(frigateApp.page.getByText(UNSAVED)).toBeVisible();
});
test("switching back to the saved provider drops the other provider's model", async ({
frigateApp,
}) => {
await installRoutes(
frigateApp.page,
{
provider: "openai",
model: "gpt-4o",
roles: ["descriptions"],
},
{ models: ["gpt-4o", "qwen3"], supports_transcription: true },
);
await frigateApp.goto(SETTINGS_URL);
const model = frigateApp.page.locator(`#root_${ENTRY}_model`);
const provider = frigateApp.page.locator(`#root_${ENTRY}_provider`);
await expect(model).toHaveText("gpt-4o");
await provider.click();
await frigateApp.page.getByRole("option", { name: "llamacpp" }).click();
await model.click();
await frigateApp.page.getByRole("option", { name: "qwen3" }).click();
await expect(model).toHaveText("qwen3");
// the model picked for llamacpp must not carry over to openai, and the
// saved one isn't filled back in since the endpoint may have changed
await provider.click();
await frigateApp.page
.getByRole("option", { name: "openai", exact: true })
.click();
await expect(model).toHaveText(MODEL_PLACEHOLDER);
});
test("undo after switching provider brings back the saved model", async ({
frigateApp,
}) => {
await installRoutes(
frigateApp.page,
{
provider: "openai",
model: "gpt-4o",
roles: ["descriptions"],
},
{ models: ["gpt-4o"], supports_transcription: true },
);
await frigateApp.goto(SETTINGS_URL);
const model = frigateApp.page.locator(`#root_${ENTRY}_model`);
await frigateApp.page.locator(`#root_${ENTRY}_provider`).click();
await frigateApp.page.getByRole("option", { name: "llamacpp" }).click();
await expect(model).toHaveText(MODEL_PLACEHOLDER);
await frigateApp.page.getByRole("button", { name: "Undo" }).click();
await expect(model).toHaveText("gpt-4o");
await expect(frigateApp.page.getByText(UNSAVED)).toBeHidden();
});
test("picking a model that cannot transcribe strips the role", async ({
frigateApp,
}) => {
await installRoutes(
frigateApp.page,
{
provider: "llamacpp",
model: "qwen3-asr",
base_url: "http://llama:8080",
roles: ["transcribe"],
},
{
models: ["qwen3-asr", "text-only"],
supports_transcription: true,
model_capabilities: {
"qwen3-asr": { supports_transcription: true },
"text-only": { supports_transcription: false },
},
},
);
await frigateApp.goto(SETTINGS_URL);
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeChecked();
await frigateApp.page.locator(`#root_${ENTRY}_model`).click();
await frigateApp.page.getByRole("option", { name: "text-only" }).click();
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeHidden();
await expect(frigateApp.page.getByText(UNSAVED)).toBeVisible();
});
});
@@ -0,0 +1,117 @@
/**
* Runtime override tests -- MEDIUM tier.
*
* Live view, MQTT, and Home Assistant toggles change a camera's running config
* without touching yaml, and the change persists across restarts. The settings
* form edits yaml, so it keeps showing the saved value. Without a marker on the
* field and runtime-aware wording on dependent warnings, the two read as a
* contradiction: "audio detection is not enabled" next to a switch that is on.
*/
import { readFileSync } from "node:fs";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { test, expect } from "../../fixtures/frigate-test";
import type { Page } from "@playwright/test";
import { configFactory } from "../../fixtures/mock-data/config";
const __dirname = dirname(fileURLToPath(import.meta.url));
const CONFIG_SCHEMA = JSON.parse(
readFileSync(
resolve(__dirname, "../../fixtures/mock-data/config-schema.json"),
"utf-8",
),
);
const CAMERA = "front_door";
const TRANSCRIPTION_URL = `/settings?page=cameraAudioTranscription&camera=${CAMERA}`;
const AUDIO_URL = `/settings?page=cameraAudioEvents&camera=${CAMERA}`;
const CONFIG_DISABLED = /Audio detection is not enabled for this camera/;
const RUNTIME_DISABLED =
/Audio detection is enabled in your config, but it is currently turned off/;
type AudioState = { enabled: boolean; enabled_in_config: boolean };
async function installRoutes(page: Page, audio: AudioState) {
const config = configFactory({
cameras: {
[CAMERA]: {
audio,
// audio detection only runs on a stream carrying the audio role
ffmpeg: {
inputs: [
{
path: "rtsp://user:pass@host/front",
roles: ["record", "detect", "audio"],
},
],
},
audio_transcription: { enabled: true, enabled_in_config: true },
},
},
});
await page.route("**/api/config/raw_paths", (route) =>
route.fulfill({
json: { cameras: { [CAMERA]: { ffmpeg: { inputs: [] } } } },
}),
);
await page.route("**/api/config/schema.json", (route) =>
route.fulfill({ json: CONFIG_SCHEMA }),
);
await page.route("**/api/config", (route) => {
if (route.request().method() === "GET") {
return route.fulfill({ json: config });
}
return route.fulfill({ json: { success: true } });
});
}
test.describe("runtime overrides @medium", () => {
test("a runtime-only toggle gets its own wording and a field marker", async ({
frigateApp,
}) => {
await installRoutes(frigateApp.page, {
enabled: false,
enabled_in_config: true,
});
await frigateApp.goto(TRANSCRIPTION_URL);
await expect(frigateApp.page.getByText(RUNTIME_DISABLED)).toBeVisible();
await expect(frigateApp.page.getByText(CONFIG_DISABLED)).toBeHidden();
// The audio section still shows the saved value, so the switch stays on and
// the marker carries the live state.
await frigateApp.goto(AUDIO_URL);
await expect(
frigateApp.page.getByRole("switch", { name: "Enable audio detection" }),
).toHaveAttribute("data-state", "checked");
// the boolean layout renders a mobile and a desktop label block, so only
// one of the two badges is on screen
await expect(
frigateApp.page.getByText("Overridden (Live)").filter({ visible: true }),
).toHaveCount(1);
});
test("a config-disabled section keeps the original wording", async ({
frigateApp,
}) => {
await installRoutes(frigateApp.page, {
enabled: false,
enabled_in_config: false,
});
await frigateApp.goto(TRANSCRIPTION_URL);
await expect(frigateApp.page.getByText(CONFIG_DISABLED)).toBeVisible();
await expect(frigateApp.page.getByText(RUNTIME_DISABLED)).toBeHidden();
await frigateApp.goto(AUDIO_URL);
await expect(
frigateApp.page.getByRole("switch", { name: "Enable audio detection" }),
).toHaveAttribute("data-state", "unchecked");
await expect(
frigateApp.page.getByText("Overridden (Live)").filter({ visible: true }),
).toHaveCount(0);
});
});
@@ -0,0 +1,54 @@
/**
* Telemetry settings: the analytics preview shows the report Frigate would
* send, fetched only when opened.
*/
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { test, expect } from "../../fixtures/frigate-test";
const __dirname = dirname(fileURLToPath(import.meta.url));
const CONFIG_SCHEMA = JSON.parse(
readFileSync(
resolve(__dirname, "../../fixtures/mock-data/config-schema.json"),
"utf-8",
),
);
const PREVIEW = {
schema_version: 1,
install_id: "0".repeat(32),
install: { version: "0.19.0-test" },
};
test.describe("telemetry settings: analytics preview @medium", () => {
test("shows the report on demand", async ({ frigateApp }) => {
let requests = 0;
const page = frigateApp.page;
await page.route("**/api/config/schema.json", (route) =>
route.fulfill({ json: CONFIG_SCHEMA }),
);
await page.route("**/api/config/raw_paths", (route) =>
route.fulfill({ json: { telemetry: {} } }),
);
await page.route("**/api/analytics/preview", (route) => {
requests += 1;
return route.fulfill({ json: PREVIEW });
});
await frigateApp.goto("/settings?page=systemTelemetry");
const button = page.getByRole("button", { name: "Preview the report" });
await expect(button).toBeVisible();
expect(requests).toBe(0);
await button.click();
await expect(page.getByTestId("analytics-preview")).toContainText(
'"schema_version": 1',
);
expect(requests).toBe(1);
});
});
+50 -1
View File
@@ -72,7 +72,15 @@ test.describe("System — tabs @medium", () => {
{ timeout: 15_000 }, { timeout: 15_000 },
); );
await expect(frigateApp.page.getByText("0.15.0-test")).toBeVisible(); await expect(frigateApp.page.getByText("0.15.0-test")).toBeVisible();
await expect(frigateApp.page.getByText(/Last refreshed/)).toBeVisible();
if (frigateApp.isMobile) {
// the "Last refreshed" label is dropped on mobile so the timestamp
// clears the centered logo
await expect(frigateApp.page.getByText(/Last refreshed/)).toHaveCount(0);
await expect(frigateApp.page.getByText(/Just now|ago/)).toBeVisible();
} else {
await expect(frigateApp.page.getByText(/Last refreshed/)).toBeVisible();
}
}); });
test("storage tab renders content after switching", async ({ test("storage tab renders content after switching", async ({
@@ -234,4 +242,45 @@ test.describe("System — mobile @medium @mobile", () => {
{ timeout: 5_000 }, { timeout: 5_000 },
); );
}); });
test("header controls leave the logo uncovered on a narrow phone", async ({
frigateApp,
}) => {
await frigateApp.goto("/system#general");
await expect(frigateApp.page.getByLabel("Select general")).toHaveAttribute(
"data-state",
"on",
{ timeout: 15_000 },
);
await frigateApp.page.setViewportSize({ width: 320, height: 740 });
const logo = frigateApp.page.locator("svg.fill-current").first();
const tabs = frigateApp.page
.locator("[data-radix-scroll-area-viewport]")
.filter({ has: frigateApp.page.getByLabel("Select general") });
const refreshed = frigateApp.page.getByText(/Just now|ago/);
const logoBox = await logo.boundingBox();
const tabsBox = await tabs.boundingBox();
const refreshedBox = await refreshed.boundingBox();
expect(tabsBox!.x + tabsBox!.width).toBeLessThanOrEqual(logoBox!.x + 1);
expect(refreshedBox!.x).toBeGreaterThanOrEqual(logoBox!.x + logoBox!.width);
// the clipped tabs stay reachable by scrolling
const overflow = await tabs.evaluate((el) => ({
scroll: el.scrollWidth,
client: el.clientWidth,
}));
expect(overflow.scroll).toBeGreaterThan(overflow.client);
await tabs.evaluate((el) => {
el.scrollLeft = el.scrollWidth;
});
await frigateApp.page.getByLabel("Select cameras").click();
await expect(frigateApp.page.getByLabel("Select cameras")).toHaveAttribute(
"data-state",
"on",
{ timeout: 5_000 },
);
});
}); });
@@ -15,10 +15,6 @@
"bandwidth": { "bandwidth": {
"title": "العرض الترددي:", "title": "العرض الترددي:",
"short": "العرض الترددي" "short": "العرض الترددي"
},
"latency": {
"title": "التأخير:",
"value": "{{seconds}} ثانية"
} }
}, },
"streamOffline": { "streamOffline": {
+40 -6
View File
@@ -21,8 +21,8 @@
"1hour": "1 гадзіна", "1hour": "1 гадзіна",
"12hours": "12 гадзін", "12hours": "12 гадзін",
"24hours": "24 гадзіны", "24hours": "24 гадзіны",
"pm": "вечара", "pm": "pm",
"am": "раніцы", "am": "am",
"yr": "{{time}} г", "yr": "{{time}} г",
"year_one": "{{time}} год", "year_one": "{{time}} год",
"year_few": "{{time}} гады", "year_few": "{{time}} гады",
@@ -168,13 +168,16 @@
"saveAll": "Захаваць усё", "saveAll": "Захаваць усё",
"savingAll": "Захаванне ўсяго…", "savingAll": "Захаванне ўсяго…",
"undoAll": "Адрабіць усё", "undoAll": "Адрабіць усё",
"retry": "Паўтарыць" "retry": "Паўтарыць",
"expand": "Разгарнуць",
"collapse": "Згарнуць",
"reload": "Перазагрузіць"
}, },
"menu": { "menu": {
"system": "Сістэма", "system": "Сістэма",
"systemMetrics": "Сістэмныя метрыкі", "systemMetrics": "Стан і метрыкі",
"configuration": "Канфігурацыя", "configuration": "Канфігурацыя",
"systemLogs": "Журналы сістэмы", "systemLogs": "Журналы",
"profiles": "Профілі", "profiles": "Профілі",
"settings": "Налады", "settings": "Налады",
"configurationEditor": "Рэдактар канфігурацыі", "configurationEditor": "Рэдактар канфігурацыі",
@@ -225,7 +228,7 @@
"withSystem": { "withSystem": {
"label": "Выкарыстоўваць мову з налад сістэмы" "label": "Выкарыстоўваць мову з налад сістэмы"
}, },
"be": "Беларуская" "be": "Беларуская (беларуская)"
}, },
"appearance": "Выгляд", "appearance": "Выгляд",
"darkMode": { "darkMode": {
@@ -328,5 +331,36 @@
"validation_errors": "Памылкі праверкі", "validation_errors": "Памылкі праверкі",
"credentialField": { "credentialField": {
"savedPlaceholder": "Захавана - пакіньце пустым, каб не мяняць" "savedPlaceholder": "Захавана - пакіньце пустым, каб не мяняць"
},
"error": {
"title": "Гэтая старонка перастала працаваць",
"desc": "На старонцы адбылася нечаканая памылка. Звычайна дапамагае перазагрузка. Калі гэта паўтараецца, скапіюйце падрабязнасці і дадайце іх да абмеркавання на GitHub.",
"staleTitle": "Патрэбна перазагрузка",
"staleDesc": "Частка інтэрфейсу не загрузілася - звычайна гэта значыць, што Frigate абнавіўся, пакуль гэтая ўкладка была адкрытая. Перазагрузіце, каб атрымаць новую версію.",
"partial": "Частка інтэрфейсу перастала працаваць.",
"copyDetails": "Скапіяваць падрабязнасці",
"copyFailed": "Не ўдалося скапіяваць падрабязнасці ў буфер абмену"
},
"commandMenu": {
"title": "Меню каманд",
"description": "Пошук старонак, камер, налад і дзеянняў",
"placeholder": "Пошук старонак, камер, налад і дзеянняў",
"empty": "Няма супадзенняў",
"hint": "{{key}} або / каб адкрыць, Enter каб выканаць",
"section": {
"recent": "Апошнія",
"pages": "Старонкі",
"cameras": "Камеры",
"cameraGroups": "Групы камер",
"settings": "Налады",
"actions": "Дзеянні"
},
"camera": {
"live": "Эфір",
"review": "Разгляд"
},
"action": {
"toggleTheme": "Пераключыць светлы і цёмны рэжым"
}
} }
} }
+17 -1
View File
@@ -137,6 +137,15 @@
"queueingExport": "Экспарт ставіцца ў чаргу…", "queueingExport": "Экспарт ставіцца ў чаргу…",
"previewExport": "Перадпрагляд экспарту", "previewExport": "Перадпрагляд экспарту",
"useThisRange": "Ужыць гэты прамежак" "useThisRange": "Ужыць гэты прамежак"
},
"stream": {
"label": "Якасць",
"auto": "Аўта",
"main": "Зыходная",
"sub": "Нізкая",
"autoDesc": "Выкарыстоўвае асноўную плынь, а дзе яна недаступная - пераходзіць на дадатковую плынь ніжэйшай якасці.",
"mainDesc": "Экспартуе толькі асноўную плынь зыходнай якасці. Прамежкі часу, дзе асноўная плынь недаступная, будуць адсутнічаць.",
"subDesc": "Экспартуе толькі дадатковую плынь ніжэйшай якасці. Прамежкі часу, дзе дадатковая плынь недаступная, будуць адсутнічаць."
} }
}, },
"streaming": { "streaming": {
@@ -190,7 +199,14 @@
"export": "Экспарт", "export": "Экспарт",
"markAsReviewed": "Пазначыць як разгледжанае", "markAsReviewed": "Пазначыць як разгледжанае",
"markAsUnreviewed": "Пазначыць як неразгледжанае", "markAsUnreviewed": "Пазначыць як неразгледжанае",
"deleteNow": "Выдаліць зараз" "deleteNow": "Выдаліць зараз",
"generateDescription": "Стварыць апісанне"
},
"genaiDescription": {
"toast": {
"success": "Апісанне GenAI запытана для гэтага элемента разгляду.",
"error": "Не ўдалося запытаць апісанне: {{error}}"
}
} }
}, },
"imagePicker": { "imagePicker": {
+16 -9
View File
@@ -22,14 +22,6 @@
"title": "Паласа прапускання:", "title": "Паласа прапускання:",
"short": "Паласа" "short": "Паласа"
}, },
"latency": {
"title": "Затрымка:",
"value": "{{seconds}} сек",
"short": {
"title": "Затрымка",
"value": "{{seconds}} с"
}
},
"totalFrames": "Усяго кадраў:", "totalFrames": "Усяго кадраў:",
"droppedFrames": { "droppedFrames": {
"title": "Страчаныя кадры:", "title": "Страчаныя кадры:",
@@ -46,7 +38,22 @@
"submittedFrigatePlus": "Кадр паспяхова адпраўлены ў Frigate+" "submittedFrigatePlus": "Кадр паспяхова адпраўлены ў Frigate+"
}, },
"error": { "error": {
"submitFrigatePlusFailed": "Не ўдалося адправіць кадр у Frigate+" "submitFrigatePlusFailed": "Не ўдалося адправіць кадр у Frigate+",
"playRecordingsFailed": "Не ўдалося прайграць запісы (памылка {{code}}): {{message}}"
} }
},
"quality": {
"auto": "Аўта",
"autoLow": "Прайграецца нізкая якасць (абмежаваная паласа прапускання)",
"autoLowCodec": "Прайграецца нізкая якасць (зыходная не падтрымліваецца гэтым браўзерам)",
"autoLowSaveData": "Прайграецца нізкая якасць (эканомія трафіку)",
"main": "Зыходная",
"sub": "Нізкая",
"notSupportedBrowser": "Не падтрымліваецца гэтым браўзерам",
"label": "Якасць",
"noAudio": "Без гуку",
"audioRate": "Гук {{rate}} кГц",
"audioCodecRate": "{{codec}} {{rate}} кГц",
"noRecordings": "Няма запісаў у гэтым прамежку часу"
} }
} }
+69 -1
View File
@@ -70,7 +70,7 @@
}, },
"objects": { "objects": {
"label": "Аб'екты-трыгеры", "label": "Аб'екты-трыгеры",
"description": "Спіс тыпаў аб'ектаў (з labelmap), якія могуць спрацаваць у гэтай зоне. Можа быць радком або спісам радкоў. Калі пуста, улічваюцца ўсе аб'екты." "description": "Спіс тыпаў аб'ектаў (з карты метак), якія могуць спрацаваць у гэтай зоне. Можа быць радком або спісам радкоў. Калі пуста, улічваюцца ўсе аб'екты."
} }
}, },
"label": "CameraConfig", "label": "CameraConfig",
@@ -120,6 +120,10 @@
"num_threads": { "num_threads": {
"label": "Патокі дэтэктавання", "label": "Патокі дэтэктавання",
"description": "Колькасць патокаў для апрацоўкі дэтэктавання гуку." "description": "Колькасць патокаў для апрацоўкі дэтэктавання гуку."
},
"labelmap": {
"label": "Змяненне карты метак гуку",
"description": "Перавызначэнні або пераназначэнні, якія аб'ядноўваюцца са стандартнай картай метак гуку."
} }
}, },
"audio_transcription": { "audio_transcription": {
@@ -147,6 +151,10 @@
"order": { "order": {
"label": "Пазіцыя", "label": "Пазіцыя",
"description": "Лічбавае становішча, якое вызначае парадак камеры ў раскладцы Birdseye." "description": "Лічбавае становішча, якое вызначае парадак камеры ў раскладцы Birdseye."
},
"modes": {
"label": "Тыпы актыўнасці",
"description": "Тыпы актыўнасці, пры якіх камеры паказваюцца ў Birdseye."
} }
}, },
"detect": { "detect": {
@@ -207,6 +215,10 @@
"annotation_offset": { "annotation_offset": {
"label": "Зрух анатацый", "label": "Зрух анатацый",
"description": "На колькі мілісекунд зрушыць прамавугольнікі аб'ектаў, каб яны супадалі з запісаным відэа: плыні «detect» і «record» рэдка ідэальна сінхронныя. Можа быць дадатным або адмоўным." "description": "На колькі мілісекунд зрушыць прамавугольнікі аб'ектаў, каб яны супадалі з запісаным відэа: плыні «detect» і «record» рэдка ідэальна сінхронныя. Можа быць дадатным або адмоўным."
},
"scene": {
"label": "Сцэна дэтэктавання",
"description": "Асяроддзе, на якое глядзіць гэтая камера; паводле яго выбіраецца, якая з наладжаных мадэлей на ёй працуе. Камеры са значэннем «all» выкарыстоўваюць мадэль, наладжаную са сцэнай «all»."
} }
}, },
"face_recognition": { "face_recognition": {
@@ -250,6 +262,10 @@
"record": { "record": {
"label": "Выходныя аргументы для record", "label": "Выходныя аргументы для record",
"description": "Прадвызначаныя выходныя аргументы для плыняў з роляй «record»." "description": "Прадвызначаныя выходныя аргументы для плыняў з роляй «record»."
},
"record_sub": {
"label": "Выходныя аргументы запісу дадатковай плыні",
"description": "Выходныя аргументы для плыняў з роляй «record_sub». Калі не зададзена, выкарыстоўваюцца выходныя аргументы запісу."
} }
}, },
"retry_interval": { "retry_interval": {
@@ -579,6 +595,54 @@
"enabled_in_config": { "enabled_in_config": {
"label": "Зыходны стан запісу", "label": "Зыходны стан запісу",
"description": "Паказвае, ці быў запіс уключаны ў зыходнай статычнай канфігурацыі." "description": "Паказвае, ці быў запіс уключаны ў зыходнай статычнай канфігурацыі."
},
"sub": {
"label": "Запіс дадатковай плыні",
"description": "Налады запісу другой плыні ніжэйшай якасці.",
"enabled": {
"label": "Уключыць запіс дадатковай плыні",
"description": "Уключыць запіс другой плыні ніжэйшай якасці для прайгравання з адаптыўнай якасцю і падоўжанага захоўвання."
},
"continuous": {
"label": "Бесперапыннае захоўванне дадатковай плыні",
"description": "Колькасць дзён захоўвання запісаў дадатковай плыні незалежна ад аб'ектаў пад адсочваннем або руху.",
"days": {
"label": "Дні захоўвання",
"description": "Дзён захоўвання запісаў."
}
},
"motion": {
"label": "Захоўванне дадатковай плыні па руху",
"description": "Колькасць дзён захоўвання запісаў дадатковай плыні, выкліканых рухам.",
"days": {
"label": "Дні захоўвання",
"description": "Дзён захоўвання запісаў."
}
},
"alerts": {
"label": "Захоўванне абвестак дадатковай плыні",
"description": "Налады захоўвання запісаў абвестак дадатковай плыні.",
"days": {
"label": "Дні захоўвання",
"description": "Колькасць дзён захоўвання запісаў падзей дэтэктавання."
},
"mode": {
"label": "Рэжым захоўвання",
"description": "Рэжым захоўвання: all (усе сегменты), motion (сегменты з рухам) або active_objects (сегменты з актыўнымі аб'ектамі)."
}
},
"detections": {
"label": "Захоўванне дэтэктаванняў дадатковай плыні",
"description": "Налады захоўвання запісаў дэтэктаванняў дадатковай плыні.",
"days": {
"label": "Дні захоўвання",
"description": "Колькасць дзён захоўвання запісаў падзей дэтэктавання."
},
"mode": {
"label": "Рэжым захоўвання",
"description": "Рэжым захоўвання: all (усе сегменты), motion (сегменты з рухам) або active_objects (сегменты з актыўнымі аб'ектамі)."
}
}
} }
}, },
"review": { "review": {
@@ -670,6 +734,10 @@
"activity_context_prompt": { "activity_context_prompt": {
"label": "Прампт кантэксту актыўнасці", "label": "Прампт кантэксту актыўнасці",
"description": "Уласны прампт, які апісвае, якая актыўнасць падазроная, а якая не, каб даць кантэкст для зводак GenAI." "description": "Уласны прампт, які апісвае, якая актыўнасць падазроная, а якая не, каб даць кантэкст для зводак GenAI."
},
"response_style": {
"label": "Стыль адказу",
"description": "Гатовы стыль пісьма для створаных апісанняў разгляду. Гатовыя стылі наладжваюць тон і падрабязнасць загалоўка, зводкі і апісання сцэны, якія бачыць карыстальнік; «default» пакідае ўбудаваны прампт без змен."
} }
} }
}, },
+123 -3
View File
@@ -33,7 +33,11 @@
"label": "Патокі дэтэктавання", "label": "Патокі дэтэктавання",
"description": "Колькасць патокаў для апрацоўкі дэтэктавання гуку." "description": "Колькасць патокаў для апрацоўкі дэтэктавання гуку."
}, },
"description": "Налады дэтэктавання падзей па гуку для ўсіх камер. Можна перавызначыць для кожнай камеры." "description": "Налады дэтэктавання падзей па гуку для ўсіх камер. Можна перавызначыць для кожнай камеры.",
"labelmap": {
"label": "Змяненне карты метак гуку",
"description": "Перавызначэнні або пераназначэнні, якія аб'ядноўваюцца са стандартнай картай метак гуку."
}
}, },
"audio_transcription": { "audio_transcription": {
"label": "Транскрыпцыя гуку", "label": "Транскрыпцыя гуку",
@@ -105,6 +109,10 @@
"idle_heartbeat_fps": { "idle_heartbeat_fps": {
"label": "FPS сігналу пры прастоі", "label": "FPS сігналу пры прастоі",
"description": "Колькі разоў на секунду паўтараць апошні кадр Birdseye пры прастоі. 0 адключае." "description": "Колькі разоў на секунду паўтараць апошні кадр Birdseye пры прастоі. 0 адключае."
},
"modes": {
"label": "Тыпы актыўнасці",
"description": "Тыпы актыўнасці, пры якіх камеры паказваюцца ў Birdseye."
} }
}, },
"detect": { "detect": {
@@ -165,6 +173,10 @@
"annotation_offset": { "annotation_offset": {
"label": "Зрух анатацый", "label": "Зрух анатацый",
"description": "На колькі мілісекунд зрушыць прамавугольнікі аб'ектаў, каб яны супадалі з запісаным відэа: плыні «detect» і «record» рэдка ідэальна сінхронныя. Можа быць дадатным або адмоўным." "description": "На колькі мілісекунд зрушыць прамавугольнікі аб'ектаў, каб яны супадалі з запісаным відэа: плыні «detect» і «record» рэдка ідэальна сінхронныя. Можа быць дадатным або адмоўным."
},
"scene": {
"label": "Сцэна дэтэктавання",
"description": "Асяроддзе, на якое глядзіць гэтая камера; паводле яго выбіраецца, якая з наладжаных мадэлей на ёй працуе. Камеры са значэннем «all» выкарыстоўваюць мадэль, наладжаную са сцэнай «all»."
} }
}, },
"face_recognition": { "face_recognition": {
@@ -238,6 +250,10 @@
"record": { "record": {
"label": "Выходныя аргументы для record", "label": "Выходныя аргументы для record",
"description": "Прадвызначаныя выходныя аргументы для плыняў з роляй «record»." "description": "Прадвызначаныя выходныя аргументы для плыняў з роляй «record»."
},
"record_sub": {
"label": "Выходныя аргументы запісу дадатковай плыні",
"description": "Выходныя аргументы для плыняў з роляй «record_sub». Калі не зададзена, выкарыстоўваюцца выходныя аргументы запісу."
} }
}, },
"retry_interval": { "retry_interval": {
@@ -650,7 +666,55 @@
"label": "Зыходны стан запісу", "label": "Зыходны стан запісу",
"description": "Паказвае, ці быў запіс уключаны ў зыходнай статычнай канфігурацыі." "description": "Паказвае, ці быў запіс уключаны ў зыходнай статычнай канфігурацыі."
}, },
"description": "Налады запісу і захоўвання для камер, калі яны не перавызначаны асобна." "description": "Налады запісу і захоўвання для камер, калі яны не перавызначаны асобна.",
"sub": {
"label": "Запіс дадатковай плыні",
"description": "Налады запісу другой плыні ніжэйшай якасці.",
"enabled": {
"label": "Уключыць запіс дадатковай плыні",
"description": "Уключыць запіс другой плыні ніжэйшай якасці для прайгравання з адаптыўнай якасцю і падоўжанага захоўвання."
},
"continuous": {
"label": "Бесперапыннае захоўванне дадатковай плыні",
"description": "Колькасць дзён захоўвання запісаў дадатковай плыні незалежна ад аб'ектаў пад адсочваннем або руху.",
"days": {
"label": "Дні захоўвання",
"description": "Дзён захоўвання запісаў."
}
},
"motion": {
"label": "Захоўванне дадатковай плыні па руху",
"description": "Колькасць дзён захоўвання запісаў дадатковай плыні, выкліканых рухам.",
"days": {
"label": "Дні захоўвання",
"description": "Дзён захоўвання запісаў."
}
},
"alerts": {
"label": "Захоўванне абвестак дадатковай плыні",
"description": "Налады захоўвання запісаў абвестак дадатковай плыні.",
"days": {
"label": "Дні захоўвання",
"description": "Колькасць дзён захоўвання запісаў падзей дэтэктавання."
},
"mode": {
"label": "Рэжым захоўвання",
"description": "Рэжым захоўвання: all (усе сегменты), motion (сегменты з рухам) або active_objects (сегменты з актыўнымі аб'ектамі)."
}
},
"detections": {
"label": "Захоўванне дэтэктаванняў дадатковай плыні",
"description": "Налады захоўвання запісаў дэтэктаванняў дадатковай плыні.",
"days": {
"label": "Дні захоўвання",
"description": "Колькасць дзён захоўвання запісаў падзей дэтэктавання."
},
"mode": {
"label": "Рэжым захоўвання",
"description": "Рэжым захоўвання: all (усе сегменты), motion (сегменты з рухам) або active_objects (сегменты з актыўнымі аб'ектамі)."
}
}
}
}, },
"review": { "review": {
"label": "Разгляд", "label": "Разгляд",
@@ -740,6 +804,10 @@
"activity_context_prompt": { "activity_context_prompt": {
"label": "Прампт кантэксту актыўнасці", "label": "Прампт кантэксту актыўнасці",
"description": "Уласны прампт, які апісвае, якая актыўнасць падазроная, а якая не, каб даць кантэкст для зводак GenAI." "description": "Уласны прампт, які апісвае, якая актыўнасць падазроная, а якая не, каб даць кантэкст для зводак GenAI."
},
"response_style": {
"label": "Стыль адказу",
"description": "Гатовы стыль пісьма для створаных апісанняў разгляду. Гатовыя стылі наладжваюць тон і падрабязнасць загалоўка, зводкі і апісання сцэны, якія бачыць карыстальнік; «default» пакідае ўбудаваны прампт без змен."
} }
}, },
"description": "Налады, якія кіруюць абвесткамі, дэтэктаваннямі і зводкамі разгляду GenAI для інтэрфейсу і сховішча." "description": "Налады, якія кіруюць абвесткамі, дэтэктаваннямі і зводкамі разгляду GenAI для інтэрфейсу і сховішча."
@@ -1173,7 +1241,7 @@
}, },
"default_role": { "default_role": {
"label": "Прадвызначаная роля", "label": "Прадвызначаная роля",
"description": "Роля, якая прызначаецца карыстальнікам, аўтарызаваным праз проксі, калі супастаўленне роляў не спрацавала." "description": "Роля, якая прызначаецца карыстальнікам, аўтарызаваным праз проксі, калі супастаўленне роляў не спрацавала. Задайце «none», каб адмовіць у доступе карыстальнікам без супастаўлення."
}, },
"separator": { "separator": {
"label": "Сімвал-раздзяляльнік", "label": "Сімвал-раздзяляльнік",
@@ -1399,5 +1467,57 @@
"label": "Паказваць у разглядзе", "label": "Паказваць у разглядзе",
"description": "Ці бачная гэта камера ў разглядзе (старонка разгляду і яе фільтр камер, разгляд руху і выгляд гісторыі)." "description": "Ці бачная гэта камера ў разглядзе (старонка разгляду і яе фільтр камер, разгляд руху і выгляд гісторыі)."
} }
},
"models": {
"label": "Мадэлі дэтэктавання",
"description": "Мадэлі дэтэктавання аб'ектаў і абсталяванне, на якім працуе кожная з іх. Камера выбірае мадэль, супастаўляючы свой detect.scene са сцэнай мадэлі.",
"scene": {
"label": "Сцэна мадэлі",
"description": "Асяроддзе камеры, для якога прызначана гэтая мадэль. Камера выбірае мадэль, задаючы detect.scene з адпаведным значэннем, а «all» выкарыстоўвае любая камера, якая нічога не задала."
},
"devices": {
"label": "Абсталяванне дэтэктавання",
"description": "Абсталяванне, на якім працуе гэтая мадэль, у выглядзе «<detector>» або «<detector>:<device>» (напрыклад «edgetpu:pci:0» ці «openvino:GPU»). Калі адна прылада пазначана некалькі разоў, на ёй запускаюцца дадатковыя працэсы вывядзення."
},
"path": {
"label": "Шлях да мадэлі свайго дэтэктара аб'ектаў",
"description": "Шлях да файла свае мадэлі дэтэктавання (або plus://<model_id> для мадэлей Frigate+)."
},
"labelmap_path": {
"label": "Карта метак для свайго дэтэктара аб'ектаў",
"description": "Шлях да файла карты метак, які супастаўляе лікавыя класы з тэкставымі меткамі для дэтэктара."
},
"width": {
"label": "Шырыня ўваходу мадэлі дэтэктавання аб'ектаў",
"description": "Шырыня ўваходнага тэнзара мадэлі ў пікселях."
},
"height": {
"label": "Вышыня ўваходу мадэлі дэтэктавання аб'ектаў",
"description": "Вышыня ўваходнага тэнзара мадэлі ў пікселях."
},
"labelmap": {
"label": "Змяненне карты метак",
"description": "Перавызначэнні або пераназначэнні, якія аб'ядноўваюцца са стандартнай картай метак."
},
"attributes_map": {
"label": "Карта метак аб'ектаў да іх метак атрыбутаў",
"description": "Супастаўленне метак аб'ектаў з меткамі атрыбутаў, якія дадаюць метаданыя (напрыклад «car» -> ['license_plate'])."
},
"input_tensor": {
"label": "Форма ўваходнага тэнзара мадэлі",
"description": "Фармат тэнзара, якога чакае мадэль: «nhwc» або «nchw»."
},
"input_pixel_format": {
"label": "Фармат колеру пікселяў на ўваходзе мадэлі",
"description": "Каляровая прастора пікселяў, якой чакае мадэль: «rgb», «bgr» або «yuv»."
},
"input_dtype": {
"label": "Тып даных на ўваходзе мадэлі",
"description": "Тып даных уваходнага тэнзара мадэлі (напрыклад «float32»)."
},
"model_type": {
"label": "Тып мадэлі дэтэктавання аб'ектаў",
"description": "Тып архітэктуры мадэлі дэтэктара (ssd, yolox, yolonas, yolo-generic, rfdetr, dfine), які некаторыя дэтэктары выкарыстоўваюць для аптымізацыі."
}
} }
} }
@@ -31,5 +31,8 @@
}, },
"detect": { "detect": {
"dimensionMustBeEven": "Мусіць быць цотным лікам." "dimensionMustBeEven": "Мусіць быць цотным лікам."
},
"models": {
"defaultRequired": "Адна мадэль мусіць выкарыстоўваць сцэну «All cameras». Без гэтага камера, якая не выбрала сцэну, не мае мадэлі, да якой можна вярнуцца."
} }
} }

Some files were not shown because too many files have changed in this diff Show More