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