mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-21 00:06:44 +01:00
parent
94fd75e014
commit
f36e7430ae
@ -29,6 +29,8 @@ from frigate.comms.mqtt import MqttClient
|
||||
from frigate.comms.webpush import WebPushClient
|
||||
from frigate.comms.ws import WebSocketClient
|
||||
from frigate.comms.zmq_proxy import ZmqProxy
|
||||
from frigate.config.config import FrigateConfig
|
||||
from frigate.config.logger import LogLevel
|
||||
from frigate.const import (
|
||||
CACHE_DIR,
|
||||
CLIPS_DIR,
|
||||
@ -91,7 +93,7 @@ class FrigateApp:
|
||||
self.ptz_metrics: dict[str, PTZMetrics] = {}
|
||||
self.processes: dict[str, int] = {}
|
||||
self.region_grids: dict[str, list[list[dict[str, int]]]] = {}
|
||||
self.config = config
|
||||
self.config: FrigateConfig = config
|
||||
|
||||
def ensure_dirs(self) -> None:
|
||||
for d in [
|
||||
@ -281,7 +283,7 @@ class FrigateApp:
|
||||
except PermissionError:
|
||||
logger.error("Unable to write to /config to save export state")
|
||||
|
||||
migrate_exports(self.config.ffmpeg, self.config.cameras.keys())
|
||||
migrate_exports(self.config.ffmpeg, list(self.config.cameras.keys()))
|
||||
|
||||
def init_external_event_processor(self) -> None:
|
||||
self.external_event_processor = ExternalEventProcessor(self.config)
|
||||
@ -325,7 +327,9 @@ class FrigateApp:
|
||||
largest_frame = max(
|
||||
[
|
||||
det.model.height * det.model.width * 3
|
||||
for (name, det) in self.config.detectors.items()
|
||||
if det.model is not None
|
||||
else 320
|
||||
for det in self.config.detectors.values()
|
||||
]
|
||||
)
|
||||
shm_in = mp.shared_memory.SharedMemory(
|
||||
@ -392,11 +396,12 @@ class FrigateApp:
|
||||
|
||||
# create or update region grids for each camera
|
||||
for camera in self.config.cameras.values():
|
||||
self.region_grids[camera.name] = get_camera_regions_grid(
|
||||
camera.name,
|
||||
camera.detect,
|
||||
max(self.config.model.width, self.config.model.height),
|
||||
)
|
||||
if camera.name:
|
||||
self.region_grids[camera.name] = get_camera_regions_grid(
|
||||
camera.name,
|
||||
camera.detect,
|
||||
max(self.config.model.width, self.config.model.height),
|
||||
)
|
||||
|
||||
def start_camera_processors(self) -> None:
|
||||
for name, config in self.config.cameras.items():
|
||||
@ -505,10 +510,10 @@ class FrigateApp:
|
||||
min_req_shm += 8
|
||||
|
||||
available_shm = total_shm - min_req_shm
|
||||
cam_total_frame_size = 0
|
||||
cam_total_frame_size = 0.0
|
||||
|
||||
for camera in self.config.cameras.values():
|
||||
if camera.enabled:
|
||||
if camera.enabled and camera.detect.width and camera.detect.height:
|
||||
cam_total_frame_size += round(
|
||||
(camera.detect.width * camera.detect.height * 1.5 + 270480)
|
||||
/ 1048576,
|
||||
@ -567,6 +572,19 @@ class FrigateApp:
|
||||
def start(self) -> None:
|
||||
logger.info(f"Starting Frigate ({VERSION})")
|
||||
|
||||
# setup logging
|
||||
logging.getLogger().setLevel(self.config.logger.default.value.upper())
|
||||
|
||||
log_levels = {
|
||||
"werkzeug": LogLevel.error,
|
||||
"ws4py": LogLevel.error,
|
||||
"httpx": LogLevel.error,
|
||||
**self.config.logger.logs,
|
||||
}
|
||||
|
||||
for log, level in log_levels.items():
|
||||
logging.getLogger(log).setLevel(level.value.upper())
|
||||
|
||||
# Ensure global state.
|
||||
self.ensure_dirs()
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
import logging
|
||||
from enum import Enum
|
||||
|
||||
from pydantic import Field, ValidationInfo, model_validator
|
||||
from typing_extensions import Self
|
||||
from pydantic import Field
|
||||
|
||||
from .base import FrigateBaseModel
|
||||
|
||||
@ -22,17 +20,3 @@ class LoggerConfig(FrigateBaseModel):
|
||||
logs: dict[str, LogLevel] = Field(
|
||||
default_factory=dict, title="Log level for specified processes."
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def post_validation(self, info: ValidationInfo) -> Self:
|
||||
if isinstance(info.context, dict) and info.context.get("install", False):
|
||||
logging.getLogger().setLevel(self.default.value.upper())
|
||||
|
||||
log_levels = {
|
||||
"werkzeug": LogLevel.error,
|
||||
"ws4py": LogLevel.error,
|
||||
**self.logs,
|
||||
}
|
||||
|
||||
for log, level in log_levels.items():
|
||||
logging.getLogger(log).setLevel(level.value.upper())
|
||||
|
@ -318,11 +318,6 @@ def get_intel_gpu_stats() -> dict[str, str]:
|
||||
if video_frame is not None:
|
||||
video[key].append(float(video_frame))
|
||||
|
||||
for key in render.keys():
|
||||
print(
|
||||
f"new way has {key} :: {round(((sum(render[key]) / len(render[key])) + (sum(video[key]) / len(video[key]))) / 2, 2)}% total"
|
||||
)
|
||||
|
||||
results["gpu"] = (
|
||||
f"{round(((sum(render['global']) / len(render['global'])) + (sum(video['global']) / len(video['global']))) / 2, 2)}%"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user