提交 bec97d23 编写于 作者: C Channingss

export onnx change x2paddle to paddle2onnx

上级 a903d2bf
......@@ -22,7 +22,7 @@ paddlex --export_inference --model_dir=/path/to/paddle_model --save_dir=./infere
```
cd /root/projects/python
python convertor.py --model_dir /path/to/inference_model --save_dir /path/to/openvino_model --fixed_input_shape [w,h]
python converter.py --model_dir /path/to/inference_model --save_dir /path/to/openvino_model --fixed_input_shape [w,h]
```
**转换成功后会在save_dir下出现后缀名为.xml、.bin、.mapping三个文件**
转换参数说明如下:
......
......@@ -29,7 +29,7 @@ from . import det
from . import seg
from . import cls
from . import slim
from . import convertor
from . import converter
from . import tools
from . import deploy
......
......@@ -168,7 +168,7 @@ def main():
logging.error(
"paddlex --export_inference --model_dir model_path --save_dir infer_model"
)
pdx.convertor.export_onnx_model(model, args.save_dir, args.onnx_opset)
pdx.converter.export_onnx_model(model, args.save_dir, args.onnx_opset)
if args.data_conversion:
assert args.source is not None, "--source should be defined while converting dataset"
......
......@@ -37,19 +37,17 @@ def export_onnx_model(model, save_dir, opset_version=10):
"Only image classifier models, detection models(YOLOv3) and semantic segmentation models(except FastSCNN) are supported to export to ONNX"
)
try:
import x2paddle
if x2paddle.__version__ < '0.7.4':
logging.error("You need to upgrade x2paddle >= 0.7.4")
import paddle2onnx
except:
logging.error(
"You need to install x2paddle first, pip install x2paddle>=0.7.4")
"You need to install paddle2onnx first, pip install paddle2onnx")
import paddle2onnx as p2o
if opset_version == 10 and model.__class__.__name__ == "YOLOv3":
logging.warning(
"Export for openVINO by default, the output of multiclass_nms exported to onnx will contains background. If you need onnx completely consistent with paddle, please use X2Paddle to export"
"Export for openVINO by default, the output of multiclass_nms exported to onnx will contains background. If you need onnx completely consistent with paddle, please use paddle2onnx to export"
)
x2paddle.op_mapper.paddle2onnx.opset10.paddle_custom_layer.multiclass_nms.multiclass_nms = multiclass_nms_for_openvino
from x2paddle.op_mapper.paddle2onnx.paddle_op_mapper import PaddleOpMapper
mapper = PaddleOpMapper()
p2o.op_mapper.opset9.paddle_custom_layer.multiclass_nms.multiclass_nms = multiclass_nms_for_openvino
mapper = p2o.PaddleOpMapper()
mapper.convert(
model.test_prog,
save_dir,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册