diff options
author | 이성재/On-Device Lab(SR)/Principal Engineer/삼성전자 <sj925.lee@samsung.com> | 2019-09-05 04:24:29 -0700 |
---|---|---|
committer | 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com> | 2019-09-05 20:24:29 +0900 |
commit | 87470e1bb9f3d14b42725f81de1b7a5320d96fbd (patch) | |
tree | cdb1a3292f91765493c5050a1c02e0c639054e3c /tools | |
parent | 81d9bd85a90573e1527589c96fbdf99b872545ed (diff) | |
download | nnfw-87470e1bb9f3d14b42725f81de1b7a5320d96fbd.tar.gz nnfw-87470e1bb9f3d14b42725f81de1b7a5320d96fbd.tar.bz2 nnfw-87470e1bb9f3d14b42725f81de1b7a5320d96fbd.zip |
Update `tflite_convert.sh` script (#6869)
- Change to use the 'tensorflow' module installed on the system by
default.
Signed-off-by: Sung-Jae Lee <sj925.lee@samsung.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/tflkit/tflite_convert.sh | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/tools/tflkit/tflite_convert.sh b/tools/tflkit/tflite_convert.sh index 3fe143206..f5b94ede0 100755 --- a/tools/tflkit/tflite_convert.sh +++ b/tools/tflkit/tflite_convert.sh @@ -3,15 +3,12 @@ usage() { echo "usage : $0" - echo " --info=Information file" - echo " --tensorflow_path=TensorFlow path (Use externals/tensorflow by default)" - echo " --tensorflow_version=TensorFlow version (Must be entered)" + echo " --info=<infroamtion file>" + echo " [ --tensorflow_path=<path> --tensorflow_version=<version> ] (If omitted, the module installed in system will be used by default.)" } SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -TF_DIR="${SCRIPT_PATH}/../../externals/tensorflow" - for i in "$@" do case $i in @@ -41,15 +38,16 @@ if [ -z "$INFO" ]; then usage exit 1 fi -if [ -z "$TF_DIR" ]; then - echo "tensorflow_path is unset or set to the empty string" - usage - exit 1 -fi + if [ -z "$TF_VERSION" ]; then - echo "tensorflow_version is unset or set to the empty string" - usage - exit 1 + if [ -z "$TF_DIR" ]; then + TF_VERSION=$(python -c 'import tensorflow as tf; print(tf.__version__)') + echo "TensorFlow version detected : $TF_VERSION" + else + echo "tensorflow_version is unset or set to the empty string" + usage + exit 1 + fi fi if [ ! -x "$(command -v bazel)" ]; then @@ -87,8 +85,13 @@ fi CUR_DIR=$(pwd) { - echo "Enter $TF_DIR" - pushd $TF_DIR > /dev/null + if [ -e "$TF_DIR" ]; then + echo "Enter $TF_DIR" + pushd $TF_DIR > /dev/null + TFLITE_CONVERT="bazel run tensorflow/lite/python:tflite_convert -- " + else + TFLITE_CONVERT="python -m tensorflow.lite.python.tflite_convert " + fi NAME_LIST=() INPUT_SHAPE_LIST=() @@ -111,7 +114,7 @@ CUR_DIR=$(pwd) for (( i=0; i < ${#NAME_LIST[@]}; ++i )); do if [ "${TF_VERSION%%.*}" = "2" ]; then - bazel run tensorflow/lite/python:tflite_convert -- \ + $TFLITE_CONVERT \ --output_file="${NAME_LIST[$i]}" \ --graph_def_file="$GRAPHDEF_PATH" \ --input_arrays="$INPUT" \ @@ -119,7 +122,7 @@ CUR_DIR=$(pwd) --output_arrays="$OUTPUT" \ --allow_custom_ops=true else - bazel run tensorflow/lite/python:tflite_convert -- \ + $TFLITE_CONVERT \ --output_file="${NAME_LIST[$i]}" \ --graph_def_file="$GRAPHDEF_PATH" \ --input_arrays="$INPUT" \ @@ -128,7 +131,10 @@ CUR_DIR=$(pwd) --allow_custom_ops fi done - popd + + if [ -e "$TF_DIR" ]; then + popd + fi for (( i=0; i < ${#NAME_LIST[@]}; ++i )); do echo "OUTPUT FILE : ${NAME_LIST[$i]}" |