-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_workspace_efficientdet_server.sh
More file actions
142 lines (102 loc) · 4.58 KB
/
generate_workspace_efficientdet_server.sh
File metadata and controls
142 lines (102 loc) · 4.58 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
#1. Create a folder for your datasets. Usually, multiple users use one folder for all datasets to be able to share them. Later on, in the
#training and inference scripts, you will need the path to the dataset.
#2. Create the EML tools folder structure, e.g. ```eml-tools```. The structure can be found here: https://github.com/embedded-machine-learning/eml-tools#interface-folder-structure
ROOTFOLDER=`pwd`
#In your root directory, create the structure. Sample code
mkdir -p eml_projects
mkdir -p venv
#3. Clone the EML tools repository into your workspace
EMLTOOLSFOLDER=./eml-tools
if [ ! -d "$EMLTOOLSFOLDER" ] ; then
git clone https://github.com/embedded-machine-learning/eml-tools.git "$EMLTOOLSFOLDER"
else
echo $EMLTOOLSFOLDER already exists
fi
# Project setup
#4. Clone the AutoML repository
AUTOMLFOLDER=./automl
if [ ! -d "$AUTOMLFOLDER" ] ; then
git clone https://github.com/google/automl.git "$AUTOMLFOLDER"
else
echo $AUTOMLFOLDER already exists
fi
#5. Create a virtual environment for TF2ODA in your venv folder. The venv folder is put outside of the project folder to
#avoid copying lots of small files when you copy the project folder. Conda would also be a good alternative.
# From root
cd $ROOTFOLDER
cd ./venv
EFFDETENV=effdet_py36
if [ ! -d "$EFFDETENV" ] ; then
virtualenv -p python3.8 $EFFDETENV
source ./$EFFDETENV/bin/activate
# Install necessary libraries
python -m pip install --upgrade pip
pip install --upgrade setuptools cython wheel
# Install EML libraries
pip install lxml xmltodict tdqm beautifulsoup4 pycocotools numpy tdqm pandas matplotlib pillow
# Install TF2ODA specifics
#pip install tensorflow==2.4.1
cd $ROOTFOLDER
pip install -r ./$AUTOMLFOLDER/efficientdet/requirements.txt
pip install onnx-simplifier networkx defusedxml progress requests tf2onnx
# Update from 1.19 to 1.21, else there is an error
pip install --upgrade numpy
cd $ROOTFOLDER/automl/efficientdet
export PYTHONPATH=$PYTHONPATH:`pwd`
echo New python path $PYTHONPATH
cd $ROOTFOLDER
echo # Test installation
# If all tests are OK or skipped, then the installation was successful
#python object_detection/builders/model_builder_tf2_test.py
echo Test if Tensorflow works with CUDA on the machine. For TF2.4.1, you have to use CUDA 11.0
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
echo Installation complete
else
echo $EFFDETENV already exists
fi
cd $ROOTFOLDER
source ./venv/$EFFDETENV/bin/activate
# Create TF2ODA environment that is used for the evaluation and inference measurements
TF2ODAENV=tf24_py36
if [ ! -d "$TF2ODAENV" ] ; then
virtualenv -p python3.8 $TF2ODAENV
source ./$TF2ODAENV/bin/activate
# Install necessary libraries
python -m pip install --upgrade pip
pip install --upgrade setuptools cython wheel
# Install EML libraries
pip install lxml xmltodict tdqm beautifulsoup4 pycocotools numpy tdqm pandas matplotlib pillow
cd $ROOTFOLDER
echo # Install protobuf
PROTOC_ZIP=protoc-3.14.0-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$PROTOC_ZIP
unzip -o $PROTOC_ZIP -d protobuf
rm -f $PROTOC_ZIP
echo # Clone tensorflow repository
git clone https://github.com/tensorflow/models.git
cd models/research/
cp object_detection/packages/tf2/setup.py .
python -m pip install .
# Update from 1.19 to 1.21, else there is an error
pip install --upgrade numpy
echo # Add object detection and slim to python path
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
echo # Prepare TF2 Proto Files
../../protobuf/bin/protoc object_detection/protos/*.proto --python_out=.
echo # Test installation
# If all tests are OK or skipped, then the installation was successful
python object_detection/builders/model_builder_tf2_test.py
# Install TF2ODA specifics
#pip install tensorflow==2.4.1
echo #Test if Tensorflow works with CUDA on the machine. For TF2.4.1, you have to use CUDA 11.0
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
echo "Important information: If there are any library errors, you have to install the correct versions manually. TFODAPI does install the latest version of "
echo "tensorflow. However, in this script Tensorflow 2.4.1 is desired. Then, you have to uninstall the newer versions and replace with current versions."
echo # Installation complete
else
echo $TF2ODAENV already exists
fi
cd $ROOTFOLDER
source ./venv/$EFFDETENV/bin/activate
echo Created environment for AutoML EfficientDet Training and inference