mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-04 06:33:45 +00:00
Actual config usage
This commit is contained in:
parent
82fd9d3063
commit
35693e73f4
@ -610,6 +610,10 @@ class FrigateConfig(FrigateBaseModel):
|
||||
camera_config.objects.genai.enabled_in_config = (
|
||||
camera_config.objects.genai.enabled
|
||||
)
|
||||
camera_config.review.genai.enabled_in_config = (
|
||||
camera_config.review.genai.alerts
|
||||
or camera_config.review.genai.detections
|
||||
)
|
||||
|
||||
# Add default filters
|
||||
object_keys = camera_config.objects.track
|
||||
|
||||
@ -7,8 +7,7 @@ import cv2
|
||||
|
||||
from frigate.config import FrigateConfig
|
||||
from frigate.data_processing.types import PostProcessDataEnum
|
||||
from frigate.genai import GenAIConfig
|
||||
from frigate.genai.ollama import OllamaClient
|
||||
from frigate.genai import GenAIClient
|
||||
|
||||
from ..post.api import PostProcessorApi
|
||||
|
||||
@ -16,14 +15,10 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ReviewDescriptionProcessor(PostProcessorApi):
|
||||
def __init__(self, config: FrigateConfig, metrics):
|
||||
def __init__(self, config: FrigateConfig, metrics, client: GenAIClient):
|
||||
super().__init__(config, metrics, None)
|
||||
self.tracked_review_items: dict[str, list[tuple[int, bytes]]] = {}
|
||||
self.genai_client = OllamaClient(
|
||||
GenAIConfig(
|
||||
enabled=True, model="qwen2.5vl:3b", base_url="http://192.168.50.107:11434"
|
||||
)
|
||||
)
|
||||
self.genai_client = client
|
||||
|
||||
def process_data(self, data, data_type):
|
||||
if data_type != PostProcessDataEnum.review:
|
||||
@ -63,10 +58,16 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
||||
final_data = data["after"]
|
||||
camera = final_data["camera"]
|
||||
|
||||
if data["type"] == "alert" and not self.config.cameras[camera].review.genai.alerts:
|
||||
if (
|
||||
data["type"] == "alert"
|
||||
and not self.config.cameras[camera].review.genai.alerts
|
||||
):
|
||||
self.tracked_review_items.pop(id)
|
||||
return
|
||||
elif data["type"] == "detection" and not self.config.cameras[camera].review.detections:
|
||||
elif (
|
||||
data["type"] == "detection"
|
||||
and not self.config.cameras[camera].review.detections
|
||||
):
|
||||
self.tracked_review_items.pop(id)
|
||||
return
|
||||
|
||||
|
||||
@ -151,6 +151,7 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
self.frame_manager = SharedMemoryFrameManager()
|
||||
|
||||
self.detected_license_plates: dict[str, dict[str, Any]] = {}
|
||||
self.genai_client = get_genai_client(config)
|
||||
|
||||
# model runners to share between realtime and post processors
|
||||
if self.config.lpr.enabled:
|
||||
@ -206,9 +207,10 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
# post processors
|
||||
self.post_processors: list[PostProcessorApi] = []
|
||||
|
||||
self.post_processors.append(
|
||||
ReviewDescriptionProcessor(self.config, self.metrics)
|
||||
)
|
||||
if any(c.review.genai.enabled_in_config for c in self.config.cameras.values()):
|
||||
self.post_processors.append(
|
||||
ReviewDescriptionProcessor(self.config, self.metrics, self.genai_client)
|
||||
)
|
||||
|
||||
if self.config.lpr.enabled:
|
||||
self.post_processors.append(
|
||||
@ -244,7 +246,6 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
self.stop_event = stop_event
|
||||
self.tracked_events: dict[str, list[Any]] = {}
|
||||
self.early_request_sent: dict[str, bool] = {}
|
||||
self.genai_client = get_genai_client(config)
|
||||
|
||||
# recordings data
|
||||
self.recordings_available_through: dict[str, float] = {}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
"""Generative AI module for Frigate."""
|
||||
|
||||
import importlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from typing import Any, Optional
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user