网上很多方法都是用openvino自带的mo_onnx.py来转的,但个人下载的2022和2024版都没见到这些文件。所以使用不了
(1)2022版openvino:python需要安装对应版本的openvino库(以2022.3.0为例)
python
pip install openvino==2022.3.0
python
from openvino.runtime import Core
from openvino.offline_transformations import serialize
ie = Core()
onnx_model_path = r"C:\Users\25909\Desktop\openvino_test_model\cls_model.onnx"
model_onnx = ie.read_model(model=onnx_model_path)
# compiled_model_onnx = ie.compile_model(model=model_onnx, device_name="CPU")
serialize(model=model_onnx, xml_path="model/exported_onnx_model.xml", bin_path="model/exported_onnx_model.bin", version="UNSPECIFIED")
(2)2024版openvino: python安装openvino2024的库,和2022的区别在于接口变了.
python
from openvino.runtime import Core
from openvino.runtime import serialize
ie = Core()
onnx_model_path = r"C:\Users\25909\Desktop\openvino_test_model\cls_model.onnx"
model_onnx = ie.read_model(model=onnx_model_path)
# compiled_model_onnx = ie.compile_model(model=model_onnx, device_name="CPU")
serialize(model=model_onnx, xml_path="model/exported_onnx_model.xml", bin_path="model/exported_onnx_model.bin", version="UNSPECIFIED")