mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-08 06:25:27 +03:00
use openvino on cpu as default model
- faster than tflite on cpu - add to default generated config
This commit is contained in:
parent
27017d35f4
commit
25c24ab5e8
@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -80,17 +81,40 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
yaml = YAML()
|
yaml = YAML()
|
||||||
|
|
||||||
|
DEFAULT_DETECTORS = {
|
||||||
|
"ov": {
|
||||||
|
"type": "openvino",
|
||||||
|
"device": "CPU",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DEFAULT_MODEL = {
|
||||||
|
"width": 300,
|
||||||
|
"height": 300,
|
||||||
|
"input_tensor": "nhwc",
|
||||||
|
"input_pixel_format": "bgr",
|
||||||
|
"path": "/openvino-model/ssdlite_mobilenet_v2.xml",
|
||||||
|
"labelmap_path": "/openvino-model/coco_91cl_bkgr.txt",
|
||||||
|
}
|
||||||
|
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
|
||||||
|
|
||||||
|
|
||||||
|
def _render_default_yaml(data: dict) -> str:
|
||||||
|
buf = io.StringIO()
|
||||||
|
_yaml_writer = YAML()
|
||||||
|
_yaml_writer.indent(mapping=2, sequence=4, offset=2)
|
||||||
|
_yaml_writer.dump(data, buf)
|
||||||
|
return buf.getvalue()
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_CONFIG = f"""
|
DEFAULT_CONFIG = f"""
|
||||||
mqtt:
|
mqtt:
|
||||||
enabled: False
|
enabled: False
|
||||||
|
|
||||||
|
{_render_default_yaml({"detectors": DEFAULT_DETECTORS, "model": DEFAULT_MODEL})}
|
||||||
cameras: {{}} # No cameras defined, UI wizard should be used
|
cameras: {{}} # No cameras defined, UI wizard should be used
|
||||||
version: {CURRENT_CONFIG_VERSION}
|
version: {CURRENT_CONFIG_VERSION}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
|
|
||||||
DEFAULT_DETECT_DIMENSIONS = {"width": 1280, "height": 720}
|
|
||||||
|
|
||||||
# stream info handler
|
# stream info handler
|
||||||
stream_info_retriever = StreamInfoRetriever()
|
stream_info_retriever = StreamInfoRetriever()
|
||||||
|
|
||||||
@ -679,6 +703,9 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
model_config["path"] = "/cpu_model.tflite"
|
model_config["path"] = "/cpu_model.tflite"
|
||||||
elif detector_config.type == "edgetpu":
|
elif detector_config.type == "edgetpu":
|
||||||
model_config["path"] = "/edgetpu_model.tflite"
|
model_config["path"] = "/edgetpu_model.tflite"
|
||||||
|
elif detector_config.type == "openvino":
|
||||||
|
for default_key, default_value in DEFAULT_MODEL.items():
|
||||||
|
model_config.setdefault(default_key, default_value)
|
||||||
|
|
||||||
model = ModelConfig.model_validate(model_config)
|
model = ModelConfig.model_validate(model_config)
|
||||||
model.check_and_load_plus_model(self.plus_api, detector_config.type)
|
model.check_and_load_plus_model(self.plus_api, detector_config.type)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user