From c990aed713784f03c9bc7f9e47384dcb5d518a8c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 20 Dec 2019 09:13:59 +0000 Subject: [PATCH] [onnx] fix bug of import onnxruntime --- x2paddle/convert.py | 12 +++++++++++- x2paddle/decoder/onnx_decoder.py | 12 +----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x2paddle/convert.py b/x2paddle/convert.py index a12a00a..2c3e157 100644 --- a/x2paddle/convert.py +++ b/x2paddle/convert.py @@ -193,7 +193,17 @@ def main(): assert args.framework is not None, "--framework is not defined(support tensorflow/caffe/onnx)" assert args.save_dir is not None, "--save_dir is not defined" - + + if args.framework == "onnx": + try: + import onnxruntime as rt + version = rt.__version__ + if version != '1.0.0': + print("onnxruntime==1.0.0 is required") + return + except: + print("onnxruntime is not installed, use \"pip install onnxruntime==1.0.0\".") + try: import paddle v0, v1, v2 = paddle.__version__.split('.') diff --git a/x2paddle/decoder/onnx_decoder.py b/x2paddle/decoder/onnx_decoder.py index e464fe9..0a38500 100644 --- a/x2paddle/decoder/onnx_decoder.py +++ b/x2paddle/decoder/onnx_decoder.py @@ -476,17 +476,7 @@ class ONNXDecoder(object): return 'x2paddle_' + name def check_model_running_state(self, model_path): - try: - import onnxruntime as rt - version = rt.__version__ - if version != '1.0.0': - print("onnxruntime==1.0.0 is required") - return - except: - raise Exception( - "onnxruntime is not installed, use \"pip install onnxruntime==1.0.0\"." - ) - + import onnxruntime as rt model = onnx.load(model_path) model = onnx.shape_inference.infer_shapes(model) if len(model.graph.value_info) < len(model.graph.node) - 1: -- GitLab