-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sh
executable file
·83 lines (69 loc) · 1.55 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
flatbuffers_repo="https://github.com/google/flatbuffers.git"
flatbuffers_dir="flatbuffers"
schema_url="https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/lite/schema/schema.fbs"
schema="schema.fbs"
virtualenv="venv"
setup_venv () {
# setup virtual environment and install needed python packages
pip3 install virtualenv
if ! [ -d $virtualenv ]; then
echo "setting up virtual environment ..."
python3 -m virtualenv $virtualenv
fi
echo "installing packages"
. $virtualenv/bin/activate
pip3 install $flatbuffers_dir/python/
pip3 install tensorflow
pip3 install keras
pip3 install numpy
pip3 install pillow
}
setup_flatbuffers () {
# download and build the flatbuffer code
if [ -d $flatbuffers_dir ]; then
echo "flatbuffers already installed."
else
git clone $flatbuffers_repo
fi
cd $flatbuffers_dir
cmake -G "Unix Makefiles"
make -j4
cd ..
# build schema file
if ! [ -e $schema ]; then
echo "downloading scheme"
wget $schema_url -O $schema
fi
if ! [ -d tflite ]; then
echo "building tflite schema"
./$flatbuffers_dir/flatc -p $schema
fi
}
print_usage () {
echo "Usage: $0 [all|flatbuffers|venv]"
echo ""
echo "Options:"
echo " -h, --help print this message"
}
if [ "$1" = "all" ]; then
setup_flatbuffers
setup_venv
else
case "$1" in
-h|--help)
print_usage
exit 0
;;
flatbuffers)
setup_flatbuffers
;;
venv)
setup_venv
;;
*)
print_usage
exit 0
;;
esac
fi