-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathMakefile
200 lines (185 loc) · 9.7 KB
/
Makefile
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
cur_dir := "$(shell pwd)"
wider_name := WIDERfacedet
fddb_name := FDDBfacedet
combine_name := WIDER_FDDB_facedet
data_dir := /home/dmitrii/Work/Datasets
wider_dir := $(data_dir)/$(wider_name)
fddb_dir := $(data_dir)/$(fddb_name)
lmdb_pyscript := /opt/movidius/ssd-caffe/scripts/create_annoset.py
caffe_exec := /opt/movidius/ssd-caffe/build/tools/caffe
wider_train_id := 0B6eKvaijfFUDQUUwd21EckhUbWs
wider_val_id := 0B6eKvaijfFUDd3dIRmpvSk8tLUk
# Models PROFILING and COMPILING
profile_initial:
cd models/ssd_voc_profile; \
mvNCProfile ../ssd_voc/deploy.prototxt -w ../ssd_voc/MobileNetSSD_deploy.caffemodel -s 12; \
cd ../..
compile_initial:
cd models/ssd_voc_profile; \
mvNCCompile ../ssd_voc/deploy.prototxt -w ../ssd_voc/MobileNetSSD_deploy.caffemodel -s 12; \
cd ../..
profile_face_full:
mkdir -p models/tmp && \
python3 models/ssd_voc/merge_bn.py models/ssd_face/ssd_face_deploy_bn.prototxt models/ssd_face/best_bn_full.caffemodel \
models/ssd_face/ssd_face_deploy.prototxt models/tmp/test.caffemodel && \
cd models/tmp; \
mvNCProfile ../ssd_face/ssd_face_deploy.prototxt -w ./test.caffemodel -s 12; \
cd ../..
profile_short_init:
mkdir -p models/tmp && \
python3 models/ssd_voc/merge_bn.py models/ssd_face_pruned/face_deploy_bn.prototxt models/ssd_face_pruned/short_init.caffemodel \
models/ssd_face_pruned/face_deploy.prototxt models/tmp/test.caffemodel && \
cd models/tmp; \
mvNCProfile ../ssd_face_pruned/face_deploy.prototxt -w ./test.caffemodel -s 12; \
cd ../..
# Load, convert and merge DATASETS
# load
wider_load:
mkdir -p -v $(wider_dir) && cd $(wider_dir) && \
wget --quiet --save-cookies cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$(wider_train_id)" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p' > confirm.txt && \
wget --load-cookies cookies.txt "https://docs.google.com/uc?export=download&confirm=`cat confirm.txt`&id=$(wider_train_id)" -O WIDER_train.zip && \
wget --quiet --save-cookies cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$(wider_val_id)" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p' > confirm.txt && \
wget --load-cookies cookies.txt "https://docs.google.com/uc?export=download&confirm=`cat confirm.txt`&id=$(wider_val_id)" -O WIDER_val.zip && \
wget http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/support/bbx_annotation/wider_face_split.zip -O wider_face_split.zip && \
rm -rf cookies.txt && rm -rf confirm.txt
fddb_load:
mkdir -p -v $(fddb_dir) && cd $(fddb_dir) && \
wget http://tamaraberg.com/faceDataset/originalPics.tar.gz -O originalPics.tar.gz && \
wget http://vis-www.cs.umass.edu/fddb/FDDB-folds.tgz -O FDDB-folds.tgz
datasets:
cd $(wider_dir) && unzip -u WIDER_train && unzip -u WIDER_val && unzip -u wider_face_split && \
cd $(fddb_dir) && tar -xvzf originalPics.tar.gz && tar -xvzf FDDB-folds.tgz
# WIDER
wider_xml:
cd $(wider_dir) && \
cd WIDER_train && \
mkdir -p -v xml && \
cd ../WIDER_val && \
mkdir -p -v xml && \
cd $(cur_dir) && \
python3 ./scripts/make_wider_xml.py $(wider_dir)/ WIDER_train/xml/ WIDER_val/xml/
wider_lmdb: wider_xml
python3 $(lmdb_pyscript) --anno-type=detection --label-map-file=$(wider_dir)/labelmap.prototxt \
--min-dim=0 --max-dim=0 --resize-width=0 --resize-height=0 --check-label --encode-type=jpg --encoded \
--redo \
$(wider_dir) $(wider_dir)/trainval.txt $(wider_dir)/WIDER_train/lmdb/wider_train_lmdb \
./data; \
python3 $(lmdb_pyscript) --anno-type=detection --label-map-file=$(wider_dir)/labelmap.prototxt \
--min-dim=0 --max-dim=0 --resize-width=0 --resize-height=0 --check-label --encode-type=jpg --encoded \
--redo \
$(wider_dir) $(wider_dir)/test.txt $(wider_dir)/WIDER_val/lmdb/wider_test_lmdb \
./data \
# FDDB
fddb_xml:
cd $(fddb_dir) && \
mkdir -p -v xml && \
cd xml && \
mkdir -p -v trainval && \
mkdir -p -v test && \
cd $(cur_dir) && \
python3 ./scripts/make_fddb_xml.py $(fddb_dir)/ xml/trainval/ xml/test/
fddb_lmdb: fddb_xml
python3 $(lmdb_pyscript) --anno-type=detection --label-map-file=$(fddb_dir)/labelmap.prototxt \
--min-dim=0 --max-dim=0 --resize-width=0 --resize-height=0 --check-label --encode-type=jpg --encoded \
--redo \
$(fddb_dir) $(fddb_dir)/trainval.txt $(fddb_dir)/lmdb/fddb_train_lmdb \
./data; \
python3 $(lmdb_pyscript) --anno-type=detection --label-map-file=$(fddb_dir)/labelmap.prototxt \
--min-dim=0 --max-dim=0 --resize-width=0 --resize-height=0 --check-label --encode-type=jpg --encoded \
--redo \
$(fddb_dir) $(fddb_dir)/test.txt $(fddb_dir)/lmdb/fddb_test_lmdb \
./data \
# both
merge_datasets:
cd $(data_dir) && \
mkdir -p -v $(combine_name) && \
cd $(cur_dir) && \
python3 ./scripts/merge_wider_fddb.py $(data_dir)/ $(wider_name)/ $(fddb_name)/ $(combine_name)/
lmdb: wider_xml fddb_xml merge_datasets
python3 $(lmdb_pyscript) --anno-type=detection --label-map-file=$(data_dir)/$(combine_name)/labelmap.prototxt \
--min-dim=0 --max-dim=0 --resize-width=0 --resize-height=0 --check-label --encode-type=jpg --encoded \
--redo \
$(data_dir) $(data_dir)/$(combine_name)/trainval.txt \
$(data_dir)/$(combine_name)/lmdb/wider_fddb_train_lmdb \
./data; \
python3 $(lmdb_pyscript) --anno-type=detection --label-map-file=$(data_dir)/$(combine_name)/labelmap.prototxt \
--min-dim=0 --max-dim=0 --resize-width=0 --resize-height=0 --check-label --encode-type=jpg --encoded \
--redo \
$(data_dir) $(data_dir)/$(combine_name)/test.txt \
$(data_dir)/$(combine_name)/lmdb/wider_fddb_test_lmdb \
./data \
# GENERATE MODELS
gen_templates:
python3 ./models/ssd_voc/gen.py --stage=train --lmdb=$(cur_dir)/data/wider_fddb_train_lmdb/ \
--label-map=$(cur_dir)/models/labelmap.prototxt --class-num=2 \
> models/ssd_face/ssd_face_train.prototxt; \
python3 ./models/ssd_voc/gen.py --stage=test --lmdb=$(cur_dir)/data/wider_fddb_test_lmdb/ \
--label-map=$(cur_dir)/models/labelmap.prototxt --class-num=2 \
> models/ssd_face/ssd_face_test.prototxt; \
python3 ./models/ssd_voc/gen.py --stage=deploy --class-num=2 \
> models/ssd_face/ssd_face_deploy.prototxt; \
python3 ./models/ssd_voc/gen.py --stage=deploy_bn --class-num=2 \
> models/ssd_face/ssd_face_deploy_bn.prototxt
check_templates:
python3 ./scripts/check_proto.py
face_model_full: gen_templates
python3 ./scripts/make_face_model_full.py
face_model_pruned:
python3 ./scripts/make_face_model_pruned.py
face_model_short:
python3 ./scripts/make_face_model_short.py
# TRAIN, TEST
train_full:
$(caffe_exec) train -solver train_files/solver_train_full.prototxt -weights models/ssd_face/face_init_full.caffemodel 2>&1 | \
tee `cat train_files/solver_train_full.prototxt | grep snapshot_prefix | grep -o \".* | tr -d \"`_log.txt
resume_full:
$(caffe_exec) train -solver train_files/solver_train_full.prototxt -snapshot `cat train_files/snapshot.txt` 2>&1 | \
tee -a `cat train_files/solver_train_full.prototxt | grep snapshot_prefix | grep -o \".* | tr -d \"`_log.txt
test_full:
mkdir -p models/tmp && mkdir -p images/output && \
python3 models/ssd_voc/merge_bn.py models/ssd_face/ssd_face_train.prototxt `cat train_files/weights.txt` \
models/ssd_face/ssd_face_deploy.prototxt models/tmp/test.caffemodel && \
python3 scripts/test_on_examples.py models/ssd_face/ssd_face_deploy.prototxt && \
cat train_files/weights.txt && echo "\n\nmAP:" && \
$(caffe_exec) train -solver train_files/solver_test_full.prototxt -weights `cat train_files/weights.txt` 2>&1 | \
grep -o "Test net output .* = [0-9]*\.[0-9]*"
test_best_full:
mkdir -p models/tmp && mkdir -p images/output && \
python3 models/ssd_voc/merge_bn.py models/ssd_face/ssd_face_train.prototxt models/ssd_face/best_bn_full.caffemodel \
models/ssd_face/ssd_face_deploy.prototxt models/tmp/test.caffemodel && \
python3 scripts/test_on_examples.py models/ssd_face/ssd_face_deploy.prototxt && \
echo "models/ssd_face/best_bn_full.caffemodel \n\nmAP:" && \
$(caffe_exec) train -solver train_files/solver_test_full.prototxt -weights models/ssd_face/best_bn_full.caffemodel 2>&1 | \
grep -o "Test net output .* = [0-9]*\.[0-9]*"
test_short_init:
mkdir -p models/tmp && mkdir -p images/output && \
python3 models/ssd_voc/merge_bn.py models/ssd_face_pruned/face_train.prototxt models/ssd_face_pruned/short_init.caffemodel \
models/ssd_face_pruned/face_deploy.prototxt models/tmp/test.caffemodel && \
python3 scripts/test_on_examples.py models/ssd_face_pruned/face_deploy.prototxt && \
echo "models/ssd_face_pruned/short_init.caffemodel \n\nmAP:" && \
$(caffe_exec) train -solver train_files/solver_test.prototxt -weights models/ssd_face_pruned/short_init.caffemodel 2>&1 | \
grep -o "Test net output .* = [0-9]*\.[0-9]*"
# DEPLOY models
deploy_full:
mkdir -p models/deploy && \
python3 models/ssd_voc/merge_bn.py models/ssd_face/ssd_face_deploy_bn.prototxt models/ssd_face/best_bn_full.caffemodel \
models/ssd_face/ssd_face_deploy.prototxt models/deploy/ssd-face.caffemodel && \
cp -u -v models/ssd_face/ssd_face_deploy.prototxt models/deploy/ssd-face.prototxt
compile_full: deploy_full
cd models/deploy && mvNCCompile ssd-face.prototxt -w ssd-face.caffemodel -s 12 -o ssd-face.graph && cd ../..
deploy_short:
mkdir -p models/deploy && \
python3 models/ssd_voc/merge_bn.py models/ssd_face_pruned/face_deploy_bn.prototxt models/ssd_face_pruned/short_init.caffemodel \
models/ssd_face_pruned/face_deploy.prototxt models/deploy/ssd-face-longrange.caffemodel && \
cp -u -v models/ssd_face_pruned/face_deploy.prototxt models/deploy/ssd-face-longrange.prototxt
compile_short: deploy_short
cd models/deploy && \
mvNCCompile ssd-face-longrange.prototxt -w ssd-face-longrange.caffemodel -s 12 -o ssd-face-longrange.graph \
&& cd ../..
# PLOT log data and test results
plot_loss:
python3 scripts/plot_loss.py
plot_map:
python3 scripts/plot_map.py train_files/solver_test.prototxt
plot_map_full:
python3 scripts/plot_map.py train_files/solver_test_full.prototxt