From 17c26c9fa9068868d41416baaddcb03819d56ed4 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 3 Mar 2023 16:43:27 -0700 Subject: [PATCH 1/9] Sub label filter fixes (#5602) * Fix list access issue * Specifically include item when in list or individual only * Formatting * Sort sub labels to ensure consistent list --- frigate/http.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frigate/http.py b/frigate/http.py index 1649ab55e..01df6ed8a 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -322,7 +322,9 @@ def get_sub_labels(): sub_labels.remove(None) if split_joined: - for label in sub_labels: + original_labels = sub_labels.copy() + + for label in original_labels: if "," in label: sub_labels.remove(label) parts = label.split(",") @@ -331,6 +333,7 @@ def get_sub_labels(): if not (part.strip()) in sub_labels: sub_labels.append(part.strip()) + sub_labels.sort() return jsonify(sub_labels) @@ -638,7 +641,13 @@ def events(): sub_label_clauses.append((Event.sub_label.is_null())) for label in filtered_sub_labels: - sub_label_clauses.append((Event.sub_label.cast("text") % f"*{label}*")) + sub_label_clauses.append( + (Event.sub_label.cast("text") == label) + ) # include exact matches + + # include this label when part of a list + sub_label_clauses.append((Event.sub_label.cast("text") % f"*{label},*")) + sub_label_clauses.append((Event.sub_label.cast("text") % f"*, {label}*")) sub_label_clause = reduce(operator.or_, sub_label_clauses) clauses.append((sub_label_clause)) From 42eaa13402def795118420f3157f83244877c49e Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 3 Mar 2023 16:43:50 -0700 Subject: [PATCH 2/9] Enable CORS for go2rtc by default (#5610) * Enable CORS for go2rtc by default * Fix typo --- docker/rootfs/usr/local/go2rtc/create_config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker/rootfs/usr/local/go2rtc/create_config.py b/docker/rootfs/usr/local/go2rtc/create_config.py index d034e044b..d201eb381 100644 --- a/docker/rootfs/usr/local/go2rtc/create_config.py +++ b/docker/rootfs/usr/local/go2rtc/create_config.py @@ -30,6 +30,12 @@ elif config_file.endswith(".json"): go2rtc_config: dict[str, any] = config.get("go2rtc", {}) +# Need to enable CORS for go2rtc so the frigate integration / card work automatically +if go2rtc_config.get("api") is None: + go2rtc_config["api"] = {"origin": "*"} +elif go2rtc_config["api"].get("origin") is None: + go2rtc_config["api"]["origin"] = "*" + # we want to ensure that logs are easy to read if go2rtc_config.get("log") is None: go2rtc_config["log"] = {"format": "text"} From 161e7b3fd75a9065fa6cbba082746b22708ed38f Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 3 Mar 2023 23:44:17 +0000 Subject: [PATCH 3/9] Allow using full tensorflow in cpu/edgetpu detector plugins (#5611) It supports the same entrypoints, given that tflite is a small cut-out of the big tensorflow picture. This patch was created for downstream usage in nixpkgs, where we don't have the tflite python package, but do have the full tensorflow package. --- frigate/detectors/plugins/cpu_tfl.py | 8 ++++++-- frigate/detectors/plugins/edgetpu_tfl.py | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/frigate/detectors/plugins/cpu_tfl.py b/frigate/detectors/plugins/cpu_tfl.py index 9e24cb1f4..fb9cbbfae 100644 --- a/frigate/detectors/plugins/cpu_tfl.py +++ b/frigate/detectors/plugins/cpu_tfl.py @@ -5,7 +5,11 @@ from frigate.detectors.detection_api import DetectionApi from frigate.detectors.detector_config import BaseDetectorConfig from typing import Literal from pydantic import Extra, Field -import tflite_runtime.interpreter as tflite + +try: + from tflite_runtime.interpreter import Interpreter +except ModuleNotFoundError: + from tensorflow.lite.python.interpreter import Interpreter logger = logging.getLogger(__name__) @@ -22,7 +26,7 @@ class CpuTfl(DetectionApi): type_key = DETECTOR_KEY def __init__(self, detector_config: CpuDetectorConfig): - self.interpreter = tflite.Interpreter( + self.interpreter = Interpreter( model_path=detector_config.model.path or "/cpu_model.tflite", num_threads=detector_config.num_threads or 3, ) diff --git a/frigate/detectors/plugins/edgetpu_tfl.py b/frigate/detectors/plugins/edgetpu_tfl.py index 024e6574b..840d41f66 100644 --- a/frigate/detectors/plugins/edgetpu_tfl.py +++ b/frigate/detectors/plugins/edgetpu_tfl.py @@ -5,8 +5,11 @@ from frigate.detectors.detection_api import DetectionApi from frigate.detectors.detector_config import BaseDetectorConfig from typing import Literal from pydantic import Extra, Field -import tflite_runtime.interpreter as tflite -from tflite_runtime.interpreter import load_delegate + +try: + from tflite_runtime.interpreter import Interpreter, load_delegate +except ModuleNotFoundError: + from tensorflow.lite.python.interpreter import Interpreter, load_delegate logger = logging.getLogger(__name__) @@ -33,7 +36,7 @@ class EdgeTpuTfl(DetectionApi): logger.info(f"Attempting to load TPU as {device_config['device']}") edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config) logger.info("TPU found") - self.interpreter = tflite.Interpreter( + self.interpreter = Interpreter( model_path=detector_config.model.path or "/edgetpu_model.tflite", experimental_delegates=[edge_tpu_delegate], ) From 7ed715b371f4d649c27b6a36abf13623a37e87e8 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 3 Mar 2023 16:44:32 -0700 Subject: [PATCH 4/9] Make note of other supervised limitations (#5627) --- docs/docs/frigate/installation.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/docs/frigate/installation.md b/docs/docs/frigate/installation.md index f5afc37c9..03481cfd7 100644 --- a/docs/docs/frigate/installation.md +++ b/docs/docs/frigate/installation.md @@ -163,7 +163,10 @@ docker run -d \ :::caution -Due to limitations in Home Assistant Operating System, utilizing external storage for recordings or snapshots requires [modifying udev rules manually](https://community.home-assistant.io/t/solved-mount-usb-drive-in-hassio-to-be-used-on-the-media-folder-with-udev-customization/258406/46). +There are important limitations in Home Assistant Operating System to be aware of: +- Utilizing external storage for recordings or snapshots requires [modifying udev rules manually](https://community.home-assistant.io/t/solved-mount-usb-drive-in-hassio-to-be-used-on-the-media-folder-with-udev-customization/258406/46). +- AMD GPUs are not supported because HA OS does not include the mesa driver. +- Nvidia GPUs are not supported because addons do not support the nvidia runtime. ::: @@ -194,6 +197,13 @@ There are several versions of the addon available: ## Home Assistant Supervised +:::caution + +There are important limitations in Home Assistant Supervised to be aware of: +- Nvidia GPUs are not supported because addons do not support the nvidia runtime. + +::: + :::tip If possible, it is recommended to run Frigate standalone in Docker and use [Frigate's Proxy Addon](https://github.com/blakeblackshear/frigate-hass-addons/blob/main/frigate_proxy/README.md). From c4ebafe777e1c2f259d44e55e2dcfce9c02cbe06 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 3 Mar 2023 16:44:58 -0700 Subject: [PATCH 5/9] Fix plus menu not showing (#5606) * Set end time for download event * Set the value --- web/src/routes/Events.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index e303e1e2e..ec50ca782 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -66,6 +66,7 @@ export default function Events({ path, ...props }) { has_clip: false, has_snapshot: false, plus_id: undefined, + end_time: null, }); const [deleteFavoriteState, setDeleteFavoriteState] = useState({ deletingFavoriteEventId: null, @@ -190,6 +191,7 @@ export default function Events({ path, ...props }) { has_clip: event.has_clip, has_snapshot: event.has_snapshot, plus_id: event.plus_id, + end_time: event.end_time, })); downloadButton.current = e.target; setState({ ...state, showDownloadMenu: true }); From a5e561c81ddec5fac2ded287b2e534b0c5cb9468 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 3 Mar 2023 16:45:25 -0700 Subject: [PATCH 6/9] Restrict menu height to ensure it does not overflow (#5601) --- web/src/components/MultiSelect.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/components/MultiSelect.jsx b/web/src/components/MultiSelect.jsx index 99412e938..226316966 100644 --- a/web/src/components/MultiSelect.jsx +++ b/web/src/components/MultiSelect.jsx @@ -13,9 +13,11 @@ export default function MultiSelect({ className, title, options, selection, onTo const [state, setState] = useState({ showMenu: false, }); - + const isOptionSelected = (item) => { return selection == "all" || selection.split(',').indexOf(item) > -1; } - + + const menuHeight = Math.round(window.innerHeight * 0.55); + return (
{state.showMenu ? ( - setState({ showMenu: false })}> + setState({ showMenu: false })}>
{title}