Skip to content

NVR with realtime local object detection for IP cameras

Misc bugfixes and improvements (#14460)

Josh Hawkins6c70e560598c
diff --git a/frigate/embeddings/maintainer.py b/frigate/embeddings/maintainer.py
index c7060b9a6a..7ce63e7f81 100644
--- a/frigate/embeddings/maintainer.py
+++ b/frigate/embeddings/maintainer.py
@@ -31,6 +31,8 @@ from .embeddings import Embeddings
logger = logging.getLogger(__name__)
+MAX_THUMBNAILS = 10
+
class EmbeddingMaintainer(threading.Thread):
"""Handle embedding queue and post event updates."""
@@ -117,6 +119,15 @@ class EmbeddingMaintainer(threading.Thread):
return
camera_config = self.config.cameras[camera]
+ # no need to save our own thumbnails if genai is not enabled
+ # or if the object has become stationary
+ if (
+ not camera_config.genai.enabled
+ or self.genai_client is None
+ or data["stationary"]
+ ):
+ return
+
if data["id"] not in self.tracked_events:
self.tracked_events[data["id"]] = []
@@ -127,7 +138,14 @@ class EmbeddingMaintainer(threading.Thread):
if yuv_frame is not None:
data["thumbnail"] = self._create_thumbnail(yuv_frame, data["box"])
+
+ # Limit the number of thumbnails saved
+ if len(self.tracked_events[data["id"]]) >= MAX_THUMBNAILS:
+ # Always keep the first thumbnail for the event
+ self.tracked_events[data["id"]].pop(1)
+
self.tracked_events[data["id"]].append(data)
+
self.frame_manager.close(frame_id)
except FileNotFoundError:
pass
diff --git a/frigate/util/model.py b/frigate/util/model.py
index 685cd34ec3..b1c85b1006 100644
--- a/frigate/util/model.py
+++ b/frigate/util/model.py
@@ -85,8 +85,14 @@ class ONNXModelRunner:
else:
# Use ONNXRuntime
self.type = "ort"
+ options = ort.SessionOptions()
+ if device == "CPU":
+ options.enable_cpu_mem_arena = False
self.ort = ort.InferenceSession(
- model_path, providers=providers, provider_options=options
+ model_path,
+ sess_options=options,
+ providers=providers,
+ provider_options=options,
)
def get_input_names(self) -> list[str]:
diff --git a/web/src/views/settings/SearchSettingsView.tsx b/web/src/views/settings/SearchSettingsView.tsx
index a088166757..e002019461 100644
--- a/web/src/views/settings/SearchSettingsView.tsx
+++ b/web/src/views/settings/SearchSettingsView.tsx
@@ -84,7 +84,10 @@ export default function SearchSettingsView({
axios
.put(
- `config/set?semantic_search.enabled=${searchSettings.enabled}&semantic_search.reindex=${searchSettings.reindex}&semantic_search.model_size=${searchSettings.model_size}`,
+ `config/set?semantic_search.enabled=${searchSettings.enabled ? "True" : "False"}&semantic_search.reindex=${searchSettings.reindex ? "True" : "False"}&semantic_search.model_size=${searchSettings.model_size}`,
+ {
+ requires_restart: 0,
+ },
)
.then((res) => {
if (res.status === 200) {