From 0a1078ca9a98d077a8888ab735ab8508fa50c2ff Mon Sep 17 00:00:00 2001 From: jiangjiajun Date: Fri, 2 Aug 2019 10:02:28 +0800 Subject: [PATCH] check requirements --- x2paddle/convert.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/x2paddle/convert.py b/x2paddle/convert.py index 456333a..e591887 100644 --- a/x2paddle/convert.py +++ b/x2paddle/convert.py @@ -52,6 +52,19 @@ def arg_parser(): def tf2paddle(model_path, save_dir): + # check tensorflow installation and version + try: + import tensorflow as tf + version = tf.__version__ + if version >= '2.0.0' or version < '1.0.0': + print( + "1.0.0<=tensorflow<2.0.0 is required, and v1.14.0 is recommended" + ) + return + except: + print("Tensorflow not installed, use \"pip install tensorflow\"") + return + from x2paddle.decoder.tf_decoder import TFDecoder from x2paddle.op_mapper.tf_op_mapper import TFOpMapper @@ -75,6 +88,16 @@ def main(): parser = arg_parser() args = parser.parse_args() + try: + import paddle.fluid as fluid + import paddle + v0, v1, v2 = paddle.__version__.split('.') + if int(v0) != 1 or int(v1) < 5: + print("paddlepaddle>=1.5.0 is required") + return + except: + print("paddlepaddle not installed, use \"pip install paddlepaddle\"") + assert args.framework is not None, "--from is not defined(tensorflow/caffe)" assert args.save_dir is not None, "--save_dir is not defined" -- GitLab