mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-01 11:20:32 +03:00
adapt analytics to free-form model scenes, split notice counts, and peewee 4
This commit is contained in:
@@ -7,7 +7,7 @@ from frigate.analytics.context import ReportContext
|
||||
from frigate.analytics.schema import DetectionModel, DetectionSection, ModelSource
|
||||
from frigate.config.config import DEFAULT_MODEL
|
||||
from frigate.const import MODEL_CACHE_DIR
|
||||
from frigate.detectors.detector_config import SceneEnum
|
||||
from frigate.detectors.detector_config import DEFAULT_SCENE
|
||||
from frigate.detectors.detector_types import DetectorTypeEnum
|
||||
from frigate.detectors.device import runner_names
|
||||
|
||||
@@ -38,7 +38,7 @@ def collect(ctx: ReportContext) -> DetectionSection:
|
||||
|
||||
# FrigateApp.start_detectors names the processes in this same order
|
||||
names = iter(runner_names([spec for _, specs in model_specs for spec in specs]))
|
||||
models: dict[SceneEnum, DetectionModel] = {}
|
||||
models: list[DetectionModel] = []
|
||||
|
||||
for model, specs in model_specs:
|
||||
speeds: list[float] = []
|
||||
@@ -49,13 +49,16 @@ def collect(ctx: ReportContext) -> DetectionSection:
|
||||
if isinstance(speed, int | float) and speed > 0:
|
||||
speeds.append(float(speed))
|
||||
|
||||
models[model.scene] = DetectionModel(
|
||||
detector=DetectorTypeEnum(specs[0].detector),
|
||||
devices=len(specs),
|
||||
model_type=model.model_type,
|
||||
input=f"{model.width}x{model.height}",
|
||||
source=model_source(model.path),
|
||||
inference_ms=rate(sum(speeds) / len(speeds)) if speeds else None,
|
||||
models.append(
|
||||
DetectionModel(
|
||||
default=model.scene == DEFAULT_SCENE,
|
||||
detector=DetectorTypeEnum(specs[0].detector),
|
||||
devices=len(specs),
|
||||
model_type=model.model_type,
|
||||
input=f"{model.width}x{model.height}",
|
||||
source=model_source(model.path),
|
||||
inference_ms=rate(sum(speeds) / len(speeds)) if speeds else None,
|
||||
)
|
||||
)
|
||||
|
||||
return DetectionSection(
|
||||
|
||||
@@ -32,11 +32,14 @@ def notice_deltas(notice_stats: list[dict[str, Any]]) -> dict[Any, NoticeCounts]
|
||||
continue
|
||||
|
||||
occurrences = max(row["occurrences"] - row["reported_occurrences"], 0)
|
||||
dismissals = max(row["dismissals"] - row["reported_dismissals"], 0)
|
||||
acknowledgements = max(
|
||||
row["acknowledgements"] - row["reported_acknowledgements"], 0
|
||||
)
|
||||
mutes = max(row["mutes"] - row["reported_mutes"], 0)
|
||||
|
||||
if occurrences or dismissals:
|
||||
if occurrences or acknowledgements or mutes:
|
||||
deltas[NoticeKindKey(row["kind"])] = NoticeCounts(
|
||||
occurrences=occurrences, dismissals=dismissals
|
||||
occurrences=occurrences, acknowledgements=acknowledgements, mutes=mutes
|
||||
)
|
||||
|
||||
return deltas
|
||||
|
||||
@@ -13,7 +13,7 @@ from frigate.config.camera.birdseye import BirdseyeModeEnum
|
||||
from frigate.config.camera.camera import CameraTypeEnum
|
||||
from frigate.config.camera.genai import GenAIProviderEnum, GenAIRoleEnum
|
||||
from frigate.config.classification import ModelSizeEnum
|
||||
from frigate.detectors.detector_config import ModelTypeEnum, SceneEnum
|
||||
from frigate.detectors.detector_config import ModelTypeEnum
|
||||
from frigate.detectors.detector_types import DetectorTypeEnum
|
||||
from frigate.ffmpeg_presets import PRESETS_HW_ACCEL_DECODE, PRESETS_INPUT
|
||||
from frigate.notices.types import NOTICE_KINDS
|
||||
@@ -53,6 +53,7 @@ class GpuVendor(StrEnum):
|
||||
nvidia = "nvidia"
|
||||
rockchip = "rockchip"
|
||||
rpi = "rpi"
|
||||
apple_silicon = "apple-silicon"
|
||||
other = "other"
|
||||
|
||||
|
||||
@@ -63,6 +64,7 @@ class DecodeFamily(StrEnum):
|
||||
intel_qsv = "intel-qsv"
|
||||
jetson = "jetson"
|
||||
rpi = "rpi"
|
||||
apple_silicon = "apple-silicon"
|
||||
other = "other"
|
||||
|
||||
|
||||
@@ -73,12 +75,14 @@ class HardwareKey(StrEnum):
|
||||
openvino_npu = "openvino:NPU"
|
||||
onnx_amd = "onnx:amd"
|
||||
onnx_nvidia = "onnx:nvidia"
|
||||
onnx_lighter = "onnx:lighter"
|
||||
tensorrt = "tensorrt"
|
||||
hailo = "hailo"
|
||||
memryx = "memryx"
|
||||
deepx = "deepx"
|
||||
rknn = "rknn"
|
||||
axengine = "axengine"
|
||||
axelera = "axelera"
|
||||
synaptics = "synaptics"
|
||||
cpu = "cpu"
|
||||
other = "other"
|
||||
@@ -228,6 +232,7 @@ class HardwareSection(AnalyticsModel):
|
||||
|
||||
|
||||
class DetectionModel(AnalyticsModel):
|
||||
default: bool = metric("Whether the model serves cameras that set no scene")
|
||||
detector: DetectorTypeEnum = metric("Detector type the model runs on")
|
||||
devices: int = count("Devices the model runs on")
|
||||
model_type: ModelTypeEnum = metric("Model architecture")
|
||||
@@ -240,7 +245,7 @@ class DetectionModel(AnalyticsModel):
|
||||
|
||||
|
||||
class DetectionSection(AnalyticsModel):
|
||||
models: dict[SceneEnum, DetectionModel] = metric("Detection models keyed by scene")
|
||||
models: list[DetectionModel] = metric("Detection models")
|
||||
detection_fps: float = metric("Detections per second across cameras", ge=0)
|
||||
skipped_fps: float = metric("Frames per second skipped across cameras", ge=0)
|
||||
|
||||
@@ -369,7 +374,8 @@ class FeaturesSection(AnalyticsModel):
|
||||
|
||||
class NoticeCounts(AnalyticsModel):
|
||||
occurrences: int = count("Occurrences since the last accepted report")
|
||||
dismissals: int = count("Dismissals since the last accepted report")
|
||||
acknowledgements: int = count("Acknowledgements since the last accepted report")
|
||||
mutes: int = count("Mutes since the last accepted report")
|
||||
|
||||
|
||||
class HealthSection(AnalyticsModel):
|
||||
|
||||
Reference in New Issue
Block a user