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 17set -ex 18 19SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 20FLOAT_MODEL_URL="http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224.tgz" 21QUANTIZED_MODEL_URL="http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz" 22DOWNLOADS_DIR=$(mktemp -d) 23 24cd "$SCRIPT_DIR" 25 26download_and_extract() { 27 local url="$1" 28 local dir="$2" 29 echo "downloading ${url}" >&2 30 mkdir -p "${dir}" 31 tempdir=$(mktemp -d) 32 33 curl -L ${url} > ${tempdir}/archive.tgz 34 cd ${dir} 35 tar zxvf ${tempdir}/archive.tgz 36 rm -rf ${tempdir} 37} 38 39download_and_extract "${FLOAT_MODEL_URL}" "${DOWNLOADS_DIR}/float_model" 40download_and_extract "${QUANTIZED_MODEL_URL}" "${DOWNLOADS_DIR}/quantized_model" 41 42cd "$SCRIPT_DIR" 43cp "${DOWNLOADS_DIR}/float_model/mobilenet_v1_1.0_224.tflite" "simple/data/mobilenet_v1_1.0_224.tflite" 44cp "${DOWNLOADS_DIR}/float_model/mobilenet_v1_1.0_224.tflite" "camera/data/mobilenet_v1_1.0_224.tflite" 45cp "${DOWNLOADS_DIR}/quantized_model/mobilenet_v1_1.0_224_quant.tflite" \ 46 'camera/data/mobilenet_quant_v1_224.tflite' 47echo "Done" 48