From d9f100dca778518e69241d316451714259aa66b4 Mon Sep 17 00:00:00 2001 From: luxuhui Date: Fri, 27 Mar 2020 14:07:35 +0800 Subject: [PATCH] fix some tiny bugs N/A Signed-off-by: Luxuhui --- docs/installation/env_requirement.rst | 10 ++++++---- docs/user_guide/basic_usage_cmake.rst | 2 +- tools/clear_workspace.sh | 2 +- tools/image/image_to_tensor.py | 2 +- tools/image/tensor_to_image.py | 2 +- tools/python/encrypt.py | 4 ++-- tools/python/quantize/quantize_stat.py | 2 +- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/installation/env_requirement.rst b/docs/installation/env_requirement.rst index 5fce3955..cb1c5c0d 100644 --- a/docs/installation/env_requirement.rst +++ b/docs/installation/env_requirement.rst @@ -53,12 +53,13 @@ Optional dependencies - Remark * - Android NDK - `NDK installation guide `__ - - Required by Android build, r15b, r15c, r16b, r17b + - Required by Android build, r15b or higher version for bazel users, r17b or higher version for cmake users. * - Bazel - `bazel installation guide `__ - - 0.13.0 + - 0.13.0 * - ADB - - Linux:``apt-get install android-tools-adb`` Mac:``brew cask install android-platform-tools`` + - | Linux:``apt-get install android-tools-adb`` + | Mac:``brew cask install android-platform-tools`` - Required by Android run, >= 1.0.32 * - TensorFlow - pip install tensorflow==1.8.0 @@ -88,4 +89,5 @@ For python dependencies, - For Android build, `ANDROID_NDK_HOME` must be confifigured by using ``export ANDROID_NDK_HOME=/path/to/ndk`` - It will link ``libc++`` instead of ``gnustl`` if ``NDK version >= r17b`` and ``bazel version >= 0.13.0``, please refer to `NDK cpp-support `__. - For Mac, please install Homebrew at first before installing other dependencies. Set ANDROID_NDK_HOME in ``/etc/bashrc`` and then run ``source /etc/bashrc``. This installation was tested with macOS Mojave(10.14). - + +rs. \ No newline at end of file diff --git a/docs/user_guide/basic_usage_cmake.rst b/docs/user_guide/basic_usage_cmake.rst index 60e60416..79a9a120 100644 --- a/docs/user_guide/basic_usage_cmake.rst +++ b/docs/user_guide/basic_usage_cmake.rst @@ -10,7 +10,7 @@ Before you do anything, clear the workspace used by build and test process. .. code-block:: sh - tools/clear_workspace.sh + tools/clear_workspace.sh [--expunge] Build Engine diff --git a/tools/clear_workspace.sh b/tools/clear_workspace.sh index 9635964b..dce33181 100755 --- a/tools/clear_workspace.sh +++ b/tools/clear_workspace.sh @@ -5,7 +5,7 @@ rm -rf mace/codegen/engine rm -rf mace/codegen/opencl for d in build/*; do - if [[ "$d" != "build/cmake-build" ]]; then + if [[ "$1" == "--expunge" || "$d" != "build/cmake-build" ]]; then echo "remove $d" rm -rf "$d" fi diff --git a/tools/image/image_to_tensor.py b/tools/image/image_to_tensor.py index 8dabe6db..dd47dde7 100644 --- a/tools/image/image_to_tensor.py +++ b/tools/image/image_to_tensor.py @@ -58,7 +58,7 @@ def images_to_tensors(input_files, image_shape, mean_values=None): align_corners=False) with tf.Session() as sess: - for i in xrange(len(input_files)): + for i in range(len(input_files)): with tf.gfile.FastGFile(input_files[i], 'rb') as f: src_image = f.read() dst_image = sess.run(image_data, diff --git a/tools/image/tensor_to_image.py b/tools/image/tensor_to_image.py index b9d9d4e7..95f4ef70 100644 --- a/tools/image/tensor_to_image.py +++ b/tools/image/tensor_to_image.py @@ -51,7 +51,7 @@ def tensors_to_images(input_files, image_shape, add_softmax): writer = tf.write_file(output, image_data, name='output_writer') with tf.Session() as sess: - for i in xrange(len(input_files)): + for i in range(len(input_files)): input_data = np.fromfile(input_files[i], dtype=np.float32) \ .reshape(image_shape) output_file = os.path.join(FLAGS.output_dir, os.path.splitext( diff --git a/tools/python/encrypt.py b/tools/python/encrypt.py index 6a28fe2f..a1397ddb 100644 --- a/tools/python/encrypt.py +++ b/tools/python/encrypt.py @@ -35,8 +35,8 @@ GENERATED_NAME = set() def generate_obfuscated_name(namespace, name): md5 = hashlib.md5() - md5.update(namespace) - md5.update(name) + md5.update(namespace.encode('utf-8')) + md5.update(name.encode('utf-8')) md5_digest = md5.hexdigest() name = md5_digest[:8] diff --git a/tools/python/quantize/quantize_stat.py b/tools/python/quantize/quantize_stat.py index a0f4d46b..66a02fc3 100644 --- a/tools/python/quantize/quantize_stat.py +++ b/tools/python/quantize/quantize_stat.py @@ -67,7 +67,7 @@ class QuantizeStat(object): cur_max_idx = 0 cur_min = tensor_min cur_max = tensor_max - for i in xrange(samples): + for i in range(samples): if tensor_mins[i] + 0.1 > cur_max: break -- GitLab