2024-05-27 23:49:35 +03:00
|
|
|
import openvino as ov
|
|
|
|
|
from openvino.tools import mo
|
2024-09-06 18:09:38 +03:00
|
|
|
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.'
|
2024-05-27 23:49:35 +03:00
|
|
|
|
|
|
|
|
ov_model = mo.convert_model(
|
|
|
|
|
"/models/ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb",
|
|
|
|
|
compress_to_fp16=True,
|
2024-09-06 18:09:38 +03:00
|
|
|
transformations_config=configs[0],
|
2024-05-27 23:49:35 +03:00
|
|
|
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")
|