From 0fe42f0a0c562f52de7f984bdedc20eeef24e688 Mon Sep 17 00:00:00 2001 From: Suryaprakash Shanmugam Date: Mon, 25 Oct 2021 15:48:36 +0530 Subject: [PATCH] Refactor code & Bug fixes --- build_ovtf.py | 12 +++++++----- examples/TF_1_x/object_detection_sample.py | 2 ++ examples/object_detection_sample.py | 2 ++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/build_ovtf.py b/build_ovtf.py index 80213da3a..f88534520 100644 --- a/build_ovtf.py +++ b/build_ovtf.py @@ -200,6 +200,9 @@ def main(): ) if arguments.use_openvino_from_location != '': + if not os.path.isdir(arguments.use_openvino_from_location): + raise AssertionError("Path doesn't exist {0}".format( + arguments.use_openvino_from_location)) ver_file = arguments.use_openvino_from_location + \ '/deployment_tools/inference_engine/version.txt' if not os.path.exists(ver_file): @@ -264,12 +267,13 @@ def main(): artifacts_location = os.path.abspath(arguments.artifacts_dir) artifacts_location = os.path.abspath(artifacts_location) - print("ARTIFACTS location: " + artifacts_location) #If artifacts doesn't exist create if not os.path.isdir(artifacts_location): os.mkdir(artifacts_location) + print("ARTIFACTS location: " + artifacts_location) + #install virtualenv install_virtual_env(venv_dir) @@ -283,8 +287,6 @@ def main(): if (arguments.target_arch): target_arch = arguments.target_arch - print("Target Arch: %s" % target_arch) - # The cxx_abi flag is translated to _GLIBCXX_USE_CXX11_ABI # For gcc older than 5.3, this flag is set to 0 and for newer ones, # this is set to 1 @@ -339,7 +341,6 @@ def main(): os.chdir(cwd) else: if not arguments.build_tf_from_source: - print("Using TensorFlow version", tf_version) print("Install TensorFlow") if arguments.cxx11_abi_version == "0": @@ -384,7 +385,6 @@ def main(): tf_src_dir = os.path.join(artifacts_location, "tensorflow") print("TF_SRC_DIR: ", tf_src_dir) # Download TF source for enabling TF python tests - pwd_now = os.getcwd() if not os.path.exists(artifacts_location): raise AssertionError( "Path doesn't exist {0}".format(artifacts_location)) @@ -393,6 +393,8 @@ def main(): download_repo("tensorflow", "https://github.com/tensorflow/tensorflow.git", tf_version) + print("Using TensorFlow version", tf_version) + pwd_now = os.getcwd() if not os.path.exists(pwd_now): raise AssertionError("Path doesn't exist {0}".format(pwd_now)) os.chdir(pwd_now) diff --git a/examples/TF_1_x/object_detection_sample.py b/examples/TF_1_x/object_detection_sample.py index 2b430bcb3..9d598d347 100644 --- a/examples/TF_1_x/object_detection_sample.py +++ b/examples/TF_1_x/object_detection_sample.py @@ -297,6 +297,8 @@ def load_labels(label_file): elif input_mode == 'image': images = [input_file] elif input_mode == 'directory': + if not os.path.isdir(input_file): + raise AssertionError("Path doesn't exist {0}".format(input_file)) images = [os.path.join(input_file, i) for i in os.listdir(input_file)] result_dir = os.path.join(input_file, '../detections') if not os.path.exists(result_dir): diff --git a/examples/object_detection_sample.py b/examples/object_detection_sample.py index 518f5b28e..22e451e8f 100644 --- a/examples/object_detection_sample.py +++ b/examples/object_detection_sample.py @@ -210,6 +210,8 @@ def load_labels(label_file): elif input_mode == 'image': images = [input_file] elif input_mode == 'directory': + if not os.path.isdir(input_file): + raise AssertionError("Path doesn't exist {0}".format(input_file)) images = [os.path.join(input_file, i) for i in os.listdir(input_file)] result_dir = os.path.join(input_file, '../detections') if not os.path.exists(result_dir):