#!/bin/bash
+set -e
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+command_exists() {
+ command -v "$@" > /dev/null 2>&1
+}
+
+usage()
+{
+ echo "Usage: tf2nnpkg --info <path/to/info> --graphdef <path/to/pb> -o <path/to/nnpkg/directory>"
+ exit 0
+}
+
# Parse command-line arguments
#
-# --info <path/to/info> --graphdef <path/to/pb> -o <path/to/nnpkg/directory>
while [ "$#" -ne 0 ]; do
CUR="$1"
case $CUR in
+ '--help')
+ usage
+ ;;
'--info')
export INFO_FILE="$2"
shift 2
esac
done
-set -e
-
-# TODO CHECK ARGUMENTS
-# TODO CHECK "flatc"
+if [ -z ${GRAPHDEF_FILE} ] || [ ! -e ${GRAPHDEF_FILE} ]; then
+ echo "pb is not found. Please check --graphdef is correct."
+ exit 2
+fi
-echo "ROOT is '${ROOT}'"
+if [ -z ${INFO_FILE} ] || [ ! -e ${INFO_FILE} ]; then
+ echo "info is not found. Please check --info is correct."
+ exit 2
+fi
FILE_BASE=$(basename ${GRAPHDEF_FILE})
MODEL_NAME="${FILE_BASE%.*}"
export tflite_schema="${ROOT}/res/tflite_schema.fbs"
export circle_schema="${ROOT}/res/circle_schema.fbs"
+if ! command_exists $flatc; then
+ echo "Please make sure flatc is in path"
+ exit 2
+fi
+
TMPDIR=$(mktemp -d)
trap "{ rm -rf $TMPDIR; }" EXIT