提交 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 ...@@ -22,7 +22,7 @@ paddlex --export_inference --model_dir=/path/to/paddle_model --save_dir=./infere
``` ```
cd /root/projects/python 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三个文件** **转换成功后会在save_dir下出现后缀名为.xml、.bin、.mapping三个文件**
转换参数说明如下: 转换参数说明如下:
......
...@@ -29,7 +29,7 @@ from . import det ...@@ -29,7 +29,7 @@ from . import det
from . import seg from . import seg
from . import cls from . import cls
from . import slim from . import slim
from . import convertor from . import converter
from . import tools from . import tools
from . import deploy from . import deploy
......
...@@ -168,7 +168,7 @@ def main(): ...@@ -168,7 +168,7 @@ def main():
logging.error( logging.error(
"paddlex --export_inference --model_dir model_path --save_dir infer_model" "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: if args.data_conversion:
assert args.source is not None, "--source should be defined while converting dataset" 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): ...@@ -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" "Only image classifier models, detection models(YOLOv3) and semantic segmentation models(except FastSCNN) are supported to export to ONNX"
) )
try: try:
import x2paddle import paddle2onnx
if x2paddle.__version__ < '0.7.4':
logging.error("You need to upgrade x2paddle >= 0.7.4")
except: except:
logging.error( 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": if opset_version == 10 and model.__class__.__name__ == "YOLOv3":
logging.warning( 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 p2o.op_mapper.opset9.paddle_custom_layer.multiclass_nms.multiclass_nms = multiclass_nms_for_openvino
from x2paddle.op_mapper.paddle2onnx.paddle_op_mapper import PaddleOpMapper mapper = p2o.PaddleOpMapper()
mapper = PaddleOpMapper()
mapper.convert( mapper.convert(
model.test_prog, model.test_prog,
save_dir, save_dir,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册