frigate/docker/main/build_ov_model.py
Amit Gurdasani d360c4f808 Use ffmpeg from deb-multimedia.org for trixie (and generally update container to use trixie base image).
This change migrates the frigate container build to use Debian trixie as the base image.
This permits us to use newer upstream packages (and, for example, stop needing to use a custom ffmpeg
build). The main hitch was the need for Python 3.9 for Pycoral from the Google apt repository, for
Coral Edge TPU support. Fortunately, the open source community has stepped up, and there are now
TFLite and Pycoral wheels available for Python 3.10-3.12 as well.
2024-09-06 16:21:23 +01:00

20 lines
818 B
Python

import openvino as ov
from openvino.tools import mo
from pathlib import Path
from site import getsitepackages
def transformations_config_location(path: Path):
return path / 'openvino' / 'tools' / 'mo' / 'front' / 'tf' / 'ssd_v2_support.json'
configs = [transformations_config_location(Path(path)) for path in getsitepackages()]
assert len(configs) > 0, 'Expected at least one transformations config to exist but none existed.'
ov_model = mo.convert_model(
"/models/ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb",
compress_to_fp16=True,
transformations_config=configs[0],
tensorflow_object_detection_api_pipeline_config="/models/ssdlite_mobilenet_v2_coco_2018_05_09/pipeline.config",
reverse_input_channels=True,
)
ov.save_model(ov_model, "/models/ssdlite_mobilenet_v2.xml")