mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
Ensure object descriptions get claened up
This commit is contained in:
parent
f657020e99
commit
4582cfbbca
@ -131,6 +131,8 @@ class ObjectDescriptionProcessor(PostProcessorApi):
|
|||||||
)
|
)
|
||||||
):
|
):
|
||||||
self._process_genai_description(event, camera_config, thumbnail)
|
self._process_genai_description(event, camera_config, thumbnail)
|
||||||
|
else:
|
||||||
|
self.cleanup_event(event.id)
|
||||||
|
|
||||||
def __regenerate_description(self, event_id: str, source: str, force: bool) -> None:
|
def __regenerate_description(self, event_id: str, source: str, force: bool) -> None:
|
||||||
"""Regenerate the description for an event."""
|
"""Regenerate the description for an event."""
|
||||||
@ -204,6 +206,17 @@ class ObjectDescriptionProcessor(PostProcessorApi):
|
|||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def cleanup_event(self, event_id: str) -> None:
|
||||||
|
"""Clean up tracked event data to prevent memory leaks.
|
||||||
|
|
||||||
|
This should be called when an event ends, regardless of whether
|
||||||
|
genai processing is triggered.
|
||||||
|
"""
|
||||||
|
if event_id in self.tracked_events:
|
||||||
|
del self.tracked_events[event_id]
|
||||||
|
if event_id in self.early_request_sent:
|
||||||
|
del self.early_request_sent[event_id]
|
||||||
|
|
||||||
def _read_and_crop_snapshot(self, event: Event) -> bytes | None:
|
def _read_and_crop_snapshot(self, event: Event) -> bytes | None:
|
||||||
"""Read, decode, and crop the snapshot image."""
|
"""Read, decode, and crop the snapshot image."""
|
||||||
|
|
||||||
@ -299,9 +312,8 @@ class ObjectDescriptionProcessor(PostProcessorApi):
|
|||||||
),
|
),
|
||||||
).start()
|
).start()
|
||||||
|
|
||||||
# Delete tracked events based on the event_id
|
# Clean up tracked events and early request state
|
||||||
if event.id in self.tracked_events:
|
self.cleanup_event(event.id)
|
||||||
del self.tracked_events[event.id]
|
|
||||||
|
|
||||||
def _genai_embed_description(self, event: Event, thumbnails: list[bytes]) -> None:
|
def _genai_embed_description(self, event: Event, thumbnails: list[bytes]) -> None:
|
||||||
"""Embed the description for an event."""
|
"""Embed the description for an event."""
|
||||||
|
|||||||
@ -522,6 +522,8 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
)
|
)
|
||||||
elif isinstance(processor, ObjectDescriptionProcessor):
|
elif isinstance(processor, ObjectDescriptionProcessor):
|
||||||
if not updated_db:
|
if not updated_db:
|
||||||
|
# Still need to cleanup tracked events even if not processing
|
||||||
|
processor.cleanup_event(event_id)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
processor.process_data(
|
processor.process_data(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user