1 #!/bin/bash 2 # Copyright 2017 The TensorFlow Authors. All Rights Reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 # ============================================================================== 16 17 set -ex 18 19 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 20 MODELS_URL="https://storage.googleapis.com/download.tensorflow.org/models/tflite/mobilenet_v1_1.0_224_ios_lite_float_2017_11_08.zip" 21 QUANTIZED_MODELS_URL="https://storage.googleapis.com/download.tensorflow.org/models/tflite/mobilenet_v1_224_android_quant_2017_11_08.zip" 22 DOWNLOADS_DIR=$(mktemp -d) 23 24 cd $SCRIPT_DIR 25 26 download_and_extract() { 27 local usage="Usage: download_and_extract URL DIR" 28 local url="${1:?${usage}}" 29 local dir="${2:?${usage}}" 30 echo "downloading ${url}" >&2 31 mkdir -p "${dir}" 32 tempdir=$(mktemp -d) 33 tempdir2=$(mktemp -d) 34 35 curl -L ${url} > ${tempdir}/zipped.zip 36 unzip ${tempdir}/zipped.zip -d ${tempdir2} 37 38 # If the zip file contains nested directories, extract the files from the 39 # inner directory. 40 if ls ${tempdir2}/*/* 1> /dev/null 2>&1; then 41 # unzip has no strip components, so unzip to a temp dir, and move the 42 # files we want from the tempdir to destination. 43 cp -R ${tempdir2}/*/* ${dir}/ 44 else 45 cp -R ${tempdir2}/* ${dir}/ 46 fi 47 rm -rf ${tempdir2} ${tempdir} 48 } 49 50 download_and_extract "${MODELS_URL}" "${DOWNLOADS_DIR}/models" 51 download_and_extract "${QUANTIZED_MODELS_URL}" "${DOWNLOADS_DIR}/quantized_models" 52 53 file ${DOWNLOADS_DIR}/models 54 55 cp ${DOWNLOADS_DIR}/models/models/* simple/data/ 56 cp ${DOWNLOADS_DIR}/quantized_models/* camera/data/ 57 58