-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-ssd-caffe.sh
151 lines (126 loc) · 4.32 KB
/
install-ssd-caffe.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
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
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
#############################################################################
# INSTALL SINGLESHOT MULTIBOX DETECTOR BASED ON CAFFE ON UBUNTU OR DEBIAN #
#############################################################################
if [ ! -z $1 ] && ([ $1 = '-h' ] || [ $1 = '--help' ]); then
echo '
#*****************************************************************#
# Usage: #
# $ source install-ssd-caffe.sh #
# (Set up for building in current directory) #
# #
# $ WORK=<dir_name> source install-ssd-caffe.sh #
# (Set up for building in another directory <dir_name>) #
#*****************************************************************#'
return 0 2>/dev/null || exit 0
fi
#### Pre-defined color code
Red='\033[0;31m'
Black='\033[0;30m'
Dark_Gray='\033[1;30m'
Red='\033[0;31m'
Light_Red='\033[1;31m'
Green='\033[0;32m'
Light_Green='\033[1;32m'
Brown_Orange='\033[0;33m'
Yellow='\033[1;33m'
Blue='\033[0;34m'
Light_Blue='\033[1;34m'
Purple='\033[0;35m'
Light_Purple='\033[1;35m'
Cyan='\033[0;36m'
Light_Cyan='\033[1;36m'
Light_Gray='\033[0;37m'
White='\033[1;37m'
NC='\033[0m'
##########################
#### Pre-defined functions for printing messages
function RUN {
echo -e "${Yellow}$*${NC}"
$*
return $?
}
function INFO {
echo -e "${Light_Cyan}$*${NC}"
}
function ERROR {
echo -e " ${Red}$*${NC}"
}
function COMMAND {
echo -e " ${Yellow}$*${NC}"
}
################################################
if [ -z $WORK ]; then WORK=$PWD;fi
INFO "Step 1. Install dependencies"
RUN sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
RUN sudo apt-get install --no-install-recommends libboost-all-dev
RUN sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
RUN sudo apt-get install libatlas-base-dev
RUN sudo apt-get install libopenblas-dev
INFO "Step 2. Install Python dependencies"
RUN sudo -H pip install -U pip
RUN sudo apt-get install fort77 gfortran
RUN sudo apt-get install python-dev python-pip python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
INFO ""
INFO ""
INFO "Step 3. Clone Single Shot Detector from repository"
RUN git clone https://github.com/weiliu89/caffe.git
RUN cd $WORK/caffe
RUN git checkout ssd
INFO ""
INFO ""
INFO "Step 4. Configure Caffe for installation (CPU only)"
RUN cd $WORK/caffe
RUN cp ../Makefile.config.cpu_only Makefile.config
#RUN cp Makefile.config.example Makefile.config
#sed -i "s/# CPU_ONLY := 1/CPU_ONLY := 1/" Makefile.config
INFO "Step 5. Install Python Dependencies"
RUN cd $WORK/caffe/python
for req in $(cat requirements.txt); do sudo pip install $req; done
INFO "Step 6. Export Python Path"
export PYTHONPATH=$WORK/caffe/python:$PYTHONPATH
INFO ""
INFO ""
INFO "Step 7. Make and Install"
RUN cd $WORK/caffe
var=$(nproc)
RUN sudo make all -j$var
RUN sudo make pycaffe
RUN sudo make test -j$var
RUN sudo make runtest -j$var
INFO "==================================================================="
INFO "Installation is completed."
INFO "==================================================================="
INFO ""
INFO ""
INFO "Let's test the ssd by running it on webcam."
read
INFO "Download a pre-trained model from the link below"
INFO "https://drive.google.com/uc?id=0BzKzrI_SkD1_WVVTSmQxU0dVRzA&export=download"
INFO ""
INFO "Unzip the 'VGGNet' folder in $WORK/caffe/models"
INFO ""
INFO "Press Enter when done"
INFO ""
INFO ""
read
INFO "Please connect your webcam."
INFO "Press Enter when done."
read
INFO "Preparing example file to run only on CPU"
RUN cd $WORK/caffe/examples/ssd
INFO "Replacing Solver from GPU to CPU"
COMMAND "#sed -i 's/solver_mode = P.Solver.GPU/solver_mode = P.Solver.CPU/' ssd_pascal_webcam.py"
sed -i "s/solver_mode = P.Solver.GPU/solver_mode = P.Solver.CPU/" ssd_pascal_webcam.py
INFO ""
INFO ""
INFO "Please go to Caffe root folder"
COMMAND "#cd $WORK/caffe/"
INFO ""
INFO "You can now run the following command:"
COMMAND "#python examples/ssd/ssd_pascal_webcam.py"
INFO "==================================================================="
INFO "Task completed."
INFO "==================================================================="
INFO ""
INFO ""