mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-20 11:48:40 -06:00
Fixes & Tweaks (#14013)
* Rework to create util for onnx initialization * Fix shm log * Fix onClick exceptoins
This commit is contained in:
parent
c0bd3b362c
commit
05fe7f8a48
@ -426,6 +426,8 @@ class FrigateApp:
|
|||||||
logger.info(f"Camera processor started for {name}: {camera_process.pid}")
|
logger.info(f"Camera processor started for {name}: {camera_process.pid}")
|
||||||
|
|
||||||
def start_camera_capture_processes(self) -> None:
|
def start_camera_capture_processes(self) -> None:
|
||||||
|
shm_frame_count = self.shm_frame_count()
|
||||||
|
|
||||||
for name, config in self.config.cameras.items():
|
for name, config in self.config.cameras.items():
|
||||||
if not self.config.cameras[name].enabled:
|
if not self.config.cameras[name].enabled:
|
||||||
logger.info(f"Capture process not started for disabled camera {name}")
|
logger.info(f"Capture process not started for disabled camera {name}")
|
||||||
@ -434,7 +436,7 @@ class FrigateApp:
|
|||||||
capture_process = util.Process(
|
capture_process = util.Process(
|
||||||
target=capture_camera,
|
target=capture_camera,
|
||||||
name=f"camera_capture:{name}",
|
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
|
capture_process.daemon = True
|
||||||
self.camera_metrics[name].capture_process = capture_process
|
self.camera_metrics[name].capture_process = capture_process
|
||||||
@ -521,7 +523,7 @@ class FrigateApp:
|
|||||||
|
|
||||||
if shm_frame_count < 10:
|
if shm_frame_count < 10:
|
||||||
logger.warning(
|
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
|
return shm_frame_count
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
@ -10,6 +9,7 @@ from frigate.detectors.detector_config import (
|
|||||||
BaseDetectorConfig,
|
BaseDetectorConfig,
|
||||||
ModelTypeEnum,
|
ModelTypeEnum,
|
||||||
)
|
)
|
||||||
|
from frigate.util.model import get_ort_providers
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -38,37 +38,9 @@ class ONNXDetector(DetectionApi):
|
|||||||
path = detector_config.model.path
|
path = detector_config.model.path
|
||||||
logger.info(f"ONNX: loading {detector_config.model.path}")
|
logger.info(f"ONNX: loading {detector_config.model.path}")
|
||||||
|
|
||||||
providers = (
|
providers, options = get_ort_providers(
|
||||||
["CPUExecutionProvider"]
|
detector_config.device == "CPU", detector_config.device
|
||||||
if detector_config.device == "CPU"
|
|
||||||
else 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": detector_config.device,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
options.append({})
|
|
||||||
|
|
||||||
self.model = ort.InferenceSession(
|
self.model = ort.InferenceSession(
|
||||||
path, providers=providers, provider_options=options
|
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)
|
@ -154,6 +154,7 @@ export default function HlsVideoPlayer({
|
|||||||
const [mobileCtrlTimeout, setMobileCtrlTimeout] = useState<NodeJS.Timeout>();
|
const [mobileCtrlTimeout, setMobileCtrlTimeout] = useState<NodeJS.Timeout>();
|
||||||
const [controls, setControls] = useState(isMobile);
|
const [controls, setControls] = useState(isMobile);
|
||||||
const [controlsOpen, setControlsOpen] = useState(false);
|
const [controlsOpen, setControlsOpen] = useState(false);
|
||||||
|
const [zoomScale, setZoomScale] = useState(1.0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isDesktop) {
|
if (!isDesktop) {
|
||||||
@ -185,7 +186,11 @@ export default function HlsVideoPlayer({
|
|||||||
}, [videoRef, controlsOpen]);
|
}, [videoRef, controlsOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransformWrapper minScale={1.0} wheel={{ smoothStep: 0.005 }}>
|
<TransformWrapper
|
||||||
|
minScale={1.0}
|
||||||
|
wheel={{ smoothStep: 0.005 }}
|
||||||
|
onZoom={(zoom) => setZoomScale(zoom.state.scale)}
|
||||||
|
>
|
||||||
{frigateControls && (
|
{frigateControls && (
|
||||||
<VideoControls
|
<VideoControls
|
||||||
className={cn(
|
className={cn(
|
||||||
@ -267,7 +272,13 @@ export default function HlsVideoPlayer({
|
|||||||
controls={!frigateControls}
|
controls={!frigateControls}
|
||||||
playsInline
|
playsInline
|
||||||
muted={muted}
|
muted={muted}
|
||||||
onClick={() => onPlayPause(!isPlaying)}
|
onClick={
|
||||||
|
isDesktop
|
||||||
|
? () => {
|
||||||
|
if (zoomScale == 1.0) onPlayPause(!isPlaying);
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
onVolumeChange={() =>
|
onVolumeChange={() =>
|
||||||
setVolume(videoRef.current?.volume ?? 1.0, true)
|
setVolume(videoRef.current?.volume ?? 1.0, true)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user