-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_workspace_tf2oda_server.sh
More file actions
100 lines (74 loc) · 3.57 KB
/
generate_workspace_tf2oda_server.sh
File metadata and controls
100 lines (74 loc) · 3.57 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
#!/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
#4. Create the task spooler script to be able to use the correct task spooler on the device. In our case, just copy
#./init_ts.sh
# Project setup
#1. Go to your project folder and clone the YoloV5 repository. Then rename it for your project.
#cd eml_projects/
#YOLOFOLDER=./yolov3-oxford-pets
#if [ ! -d "$YOLOFOLDER" ] ; then
# git clone https://github.com/ultralytics/yolov3.git $YOLOFOLDER
#else
# echo $YOLOFOLDER already exists
#fi
#2. Create a virtual environment for yolov5 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
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
# 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])))"
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 .
# Upgrade numpy to 2.21 from 2.19, else there will be an error https://stackoverflow.com/questions/66060487/valueerror-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-exp
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
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/$TF2ODAENV/bin/activate
echo Created TF2ODA environment
echo create template project folder