forked from Github/frigate
Fixes & Tweaks (#14013)
* Rework to create util for onnx initialization * Fix shm log * Fix onClick exceptoins
This commit is contained in:
@@ -426,6 +426,8 @@ class FrigateApp:
|
||||
logger.info(f"Camera processor started for {name}: {camera_process.pid}")
|
||||
|
||||
def start_camera_capture_processes(self) -> None:
|
||||
shm_frame_count = self.shm_frame_count()
|
||||
|
||||
for name, config in self.config.cameras.items():
|
||||
if not self.config.cameras[name].enabled:
|
||||
logger.info(f"Capture process not started for disabled camera {name}")
|
||||
@@ -434,7 +436,7 @@ class FrigateApp:
|
||||
capture_process = util.Process(
|
||||
target=capture_camera,
|
||||
name=f"camera_capture:{name}",
|
||||
args=(name, config, self.shm_frame_count(), self.camera_metrics[name]),
|
||||
args=(name, config, shm_frame_count, self.camera_metrics[name]),
|
||||
)
|
||||
capture_process.daemon = True
|
||||
self.camera_metrics[name].capture_process = capture_process
|
||||
@@ -521,7 +523,7 @@ class FrigateApp:
|
||||
|
||||
if shm_frame_count < 10:
|
||||
logger.warning(
|
||||
f"The current SHM size of {total_shm}MB is too small, recommend increasing it to at least {round(min_req_shm + cam_total_frame_size)}MB."
|
||||
f"The current SHM size of {total_shm}MB is too small, recommend increasing it to at least {round(min_req_shm + cam_total_frame_size * 10)}MB."
|
||||
)
|
||||
|
||||
return shm_frame_count
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
from pydantic import Field
|
||||
@@ -10,6 +9,7 @@ from frigate.detectors.detector_config import (
|
||||
BaseDetectorConfig,
|
||||
ModelTypeEnum,
|
||||
)
|
||||
from frigate.util.model import get_ort_providers
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -38,37 +38,9 @@ class ONNXDetector(DetectionApi):
|
||||
path = detector_config.model.path
|
||||
logger.info(f"ONNX: loading {detector_config.model.path}")
|
||||
|
||||
providers = (
|
||||
["CPUExecutionProvider"]
|
||||
if detector_config.device == "CPU"
|
||||
else ort.get_available_providers()
|
||||
providers, options = get_ort_providers(
|
||||
detector_config.device == "CPU", detector_config.device
|
||||
)
|
||||
options = []
|
||||
|
||||
for provider in providers:
|
||||
if provider == "TensorrtExecutionProvider":
|
||||
os.makedirs(
|
||||
"/config/model_cache/tensorrt/ort/trt-engines", exist_ok=True
|
||||
)
|
||||
options.append(
|
||||
{
|
||||
"trt_timing_cache_enable": True,
|
||||
"trt_engine_cache_enable": True,
|
||||
"trt_timing_cache_path": "/config/model_cache/tensorrt/ort",
|
||||
"trt_engine_cache_path": "/config/model_cache/tensorrt/ort/trt-engines",
|
||||
}
|
||||
)
|
||||
elif provider == "OpenVINOExecutionProvider":
|
||||
os.makedirs("/config/model_cache/openvino/ort", exist_ok=True)
|
||||
options.append(
|
||||
{
|
||||
"cache_dir": "/config/model_cache/openvino/ort",
|
||||
"device_type": detector_config.device,
|
||||
}
|
||||
)
|
||||
else:
|
||||
options.append({})
|
||||
|
||||
self.model = ort.InferenceSession(
|
||||
path, providers=providers, provider_options=options
|
||||
)
|
||||
|
||||
39
frigate/util/model.py
Normal file
39
frigate/util/model.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Model Utils"""
|
||||
|
||||
import os
|
||||
|
||||
import onnxruntime as ort
|
||||
|
||||
|
||||
def get_ort_providers(
|
||||
force_cpu: bool = False, openvino_device: str = "AUTO"
|
||||
) -> tuple[list[str], list[dict[str, any]]]:
|
||||
if force_cpu:
|
||||
return (["CPUExecutionProvider"], [{}])
|
||||
|
||||
providers = ort.get_available_providers()
|
||||
options = []
|
||||
|
||||
for provider in providers:
|
||||
if provider == "TensorrtExecutionProvider":
|
||||
os.makedirs("/config/model_cache/tensorrt/ort/trt-engines", exist_ok=True)
|
||||
options.append(
|
||||
{
|
||||
"trt_timing_cache_enable": True,
|
||||
"trt_engine_cache_enable": True,
|
||||
"trt_timing_cache_path": "/config/model_cache/tensorrt/ort",
|
||||
"trt_engine_cache_path": "/config/model_cache/tensorrt/ort/trt-engines",
|
||||
}
|
||||
)
|
||||
elif provider == "OpenVINOExecutionProvider":
|
||||
os.makedirs("/config/model_cache/openvino/ort", exist_ok=True)
|
||||
options.append(
|
||||
{
|
||||
"cache_dir": "/config/model_cache/openvino/ort",
|
||||
"device_type": openvino_device,
|
||||
}
|
||||
)
|
||||
else:
|
||||
options.append({})
|
||||
|
||||
return (providers, options)
|
||||
Reference in New Issue
Block a user