diff --git a/x2paddle/convert.py b/x2paddle/convert.py index a12a00a11a1af4fff2093f25fb25731971de3353..2c3e157c94490ccc2a05d2a621166fb040cd2ac6 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 e464fe90c81746fee50cb1c835a03c203edbfa41..0a385003eb63d45ce43a3b6fd36f12f2f240cdd7 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: