From 423ceb0d1efa81685d5ffd2bef09fedef74f8954 Mon Sep 17 00:00:00 2001 From: Channingss Date: Fri, 25 Sep 2020 03:46:05 +0000 Subject: [PATCH] update rely of paddle2onnx --- x2paddle/convert.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/x2paddle/convert.py b/x2paddle/convert.py index 09da273..d5c78e7 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) -- GitLab