diff --git a/x2paddle/convert.py b/x2paddle/convert.py index 09da2731d93a4b357bc019d3caeb71ff852c0625..d5c78e761ce1aa88e67a4405074fccb28ad1d727 100644 --- a/x2paddle/convert.py +++ b/x2paddle/convert.py @@ -239,12 +239,16 @@ def pytorch2paddle(model_path, save_dir, input_shapes): def paddle2onnx(model_path, save_dir, opset_version=10): import paddle.fluid as fluid try: - import paddle2onnx as p2o + import paddle2onnx except: print( "[ERROR] paddle2onnx not installed, use \"pip install paddle2onnx\"") - p2o.convert( - model_path, + + import paddle2onnx as p2o + model = p2o.PaddleDecoder(model_path, '__model__', '__params__') + mapper = p2o.PaddleOpMapper() + mapper.convert( + model.program, save_dir, scope=fluid.global_scope(), opset_version=opset_version)