|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright 2018 Google LLC. All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# ============================================================================= |
| 17 | + |
| 18 | +# Builds resources for the Iris demo. |
| 19 | +# Note this is not necessary to run the demo, because we already provide hosted |
| 20 | +# pre-built resources. |
| 21 | +# Usage example: do this from the 'iris' directory: |
| 22 | +# ./build-resources.sh |
| 23 | + |
| 24 | +set -e |
| 25 | + |
| 26 | +DEMO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 27 | + |
| 28 | +TRAIN_EPOCHS=100 |
| 29 | +while true; do |
| 30 | + if [[ "$1" == "--epochs" ]]; then |
| 31 | + TRAIN_EPOCHS=$2 |
| 32 | + shift 2 |
| 33 | + elif [[ -z "$1" ]]; then |
| 34 | + break |
| 35 | + else |
| 36 | + echo "ERROR: Unrecognized argument: $1" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | +done |
| 40 | + |
| 41 | +RESOURCES_ROOT="${DEMO_DIR}/dist/resources" |
| 42 | +rm -rf "${RESOURCES_ROOT}" |
| 43 | +mkdir -p "${RESOURCES_ROOT}" |
| 44 | + |
| 45 | +# Run Python script to generate the pretrained model and weights files. |
| 46 | +# Make sure you install the tensorflowjs pip package first. |
| 47 | + |
| 48 | +python "${DEMO_DIR}/python/iris.py" \ |
| 49 | + --epochs "${TRAIN_EPOCHS}" \ |
| 50 | + --artifacts_dir "${RESOURCES_ROOT}" |
| 51 | + |
| 52 | +cd ${DEMO_DIR} |
| 53 | +yarn |
| 54 | +yarn build |
| 55 | + |
| 56 | +echo |
| 57 | +echo "-----------------------------------------------------------" |
| 58 | +echo "Resources written to ${RESOURCES_ROOT}." |
| 59 | +echo "You can now run the demo with 'yarn watch'." |
| 60 | +echo "-----------------------------------------------------------" |
| 61 | +echo |
0 commit comments