From ca1c98eab8f1f5e4690afcb602763c6f54a24bb6 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 17 Jul 2025 08:29:50 -0500 Subject: [PATCH] Fixes (#19125) * fix embeddings reindex - always increment processed objects to prevent division by zero - ensure description still gets processed even if there is no thumbnail * clean up * Add newer labels to default attribute map --------- Co-authored-by: Nicolas Mowen --- frigate/const.py | 2 ++ frigate/embeddings/embeddings.py | 17 +++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/frigate/const.py b/frigate/const.py index 183506a04..5b16a3677 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -26,6 +26,7 @@ DEFAULT_ATTRIBUTE_LABEL_MAP = { "car": [ "amazon", "an_post", + "canada_post", "dhl", "dpd", "fedex", @@ -35,6 +36,7 @@ DEFAULT_ATTRIBUTE_LABEL_MAP = { "postnl", "postnord", "purolator", + "royal_mail", "ups", "usps", ], diff --git a/frigate/embeddings/embeddings.py b/frigate/embeddings/embeddings.py index 30af15d8a..833ab9ab2 100644 --- a/frigate/embeddings/embeddings.py +++ b/frigate/embeddings/embeddings.py @@ -334,27 +334,24 @@ class Embeddings: .paginate(current_page, batch_size) ) - while len(events) > 0: + while events: event: Event batch_thumbs = {} batch_descs = {} for event in events: - thumbnail = get_event_thumbnail_bytes(event) - - if thumbnail is None: - continue - - batch_thumbs[event.id] = thumbnail - totals["thumbnails"] += 1 + totals["processed_objects"] += 1 if description := event.data.get("description", "").strip(): batch_descs[event.id] = description totals["descriptions"] += 1 - totals["processed_objects"] += 1 + if thumbnail := get_event_thumbnail_bytes(event): + batch_thumbs[event.id] = thumbnail + totals["thumbnails"] += 1 # run batch embedding - self.batch_embed_thumbnail(batch_thumbs) + if batch_thumbs: + self.batch_embed_thumbnail(batch_thumbs) if batch_descs: self.batch_embed_description(batch_descs)