Skip to content

Commit e98ea7f

Browse files
authoredMar 30, 2018
Move Python scripts for building examples into tfjs-examples (tensorflow#38)
* WIP * Add mnist-transfer-cnn and update build files * Update build scripts * bugfixes * yarn.lock updates * Remove http-server in favor of yarn watch; fix licenses * Serve local pretrained model with http-server * Let user choose local vs. remote pretrained model.
1 parent d320351 commit e98ea7f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2819
-266
lines changed
 

‎deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright 2018 Google Inc. All Rights Reserved.
2+
# Copyright 2018 Google LLC. All Rights Reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

‎iris/build-resources.sh

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

Comments
 (0)
Please sign in to comment.