-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_network.sh
executable file
·211 lines (181 loc) · 6.18 KB
/
run_network.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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/bash
# Workspace dir
ws=$1
#
# Trials
#
# Fine-tune for 350k iterations
baseline="real"
# Train for 350k iterations
declare -a long_trials=(
"sim_big_camera"
"sim_no_camera")
# Train for 100k iterations
declare -a trials=(
"sim_no_camera_base"
"sim_no_camera_chess"
"sim_no_camera_flat"
"sim_no_camera_gradient"
"sim_no_camera_perlin")
# Fine-tune for 25k iterations
declare -a fine_tune_trials=(
"sim_big_camera"
"sim_no_camera"
"sim_no_camera_base"
"sim_no_camera_chess"
"sim_no_camera_flat"
"sim_no_camera_gradient"
"sim_no_camera_perlin")
#
# Metrics
#
declare -a eval_trials=(
"sim_big_camera"
"sim_no_camera"
"sim_no_camera_base"
"sim_no_camera_chess"
"sim_no_camera_flat"
"sim_no_camera_gradient"
"sim_no_camera_perlin"
)
declare -a eval_fine_tune_trials=(
"real"
"sim_big_camera"
"sim_no_camera"
"sim_no_camera_base"
"sim_no_camera_chess"
"sim_no_camera_flat"
"sim_no_camera_gradient"
"sim_no_camera_perlin"
)
#
# Baseline
#
# Launch eval (on CPU) first and send to background
(export CUDA_VISIBLE_DEVICES=3; \
python models/research/object_detection/eval.py \
--logtostderr \
--eval_dir=${ws}/eval/fine_tune/${baseline}/ \
--pipeline_config_path=${ws}/config/fine_tune_${baseline}.config \
--checkpoint_dir=${ws}/train/fine_tune/${baseline}/ &)
# Launch train and wait for conclusion
python models/research/object_detection/train.py \
--logtostderr \
--train_dir=${ws}/train/fine_tune/${baseline}/ \
--pipeline_config_path=${ws}/config/fine_tune_${baseline}.config \
--num_clones=2 \
--ps_tasks=1
# Kill eval process
sleep 5m
pkill -f eval.py
# Export inference graph
python models/research/object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path ${ws}/config/fine_tune_${baseline}.config \
--trained_checkpoint_prefix ${ws}/train/fine_tune/${baseline}/model.ckpt-350000 \
--output_directory ${ws}/inference_graph/fine_tune/${baseline}
#
# Train for 350k iterations
#
# Train from ImageNet runs
for trial in "${long_trials[@]}"
do
(export CUDA_VISIBLE_DEVICES=3; \
python models/research/object_detection/eval.py \
--logtostderr \
--eval_dir=${ws}/eval/${trial}/ \
--pipeline_config_path=${ws}/config/${trial}.config \
--checkpoint_dir=${ws}/train/${trial}/ &)
python models/research/object_detection/train.py \
--logtostderr \
--train_dir=${ws}/train/${trial}/ \
--pipeline_config_path=${ws}/config/${trial}.config \
--num_clones=2 \
--ps_tasks=1
sleep 5m
pkill -f eval.py
python models/research/object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path ${ws}/config/${trial}.config \
--trained_checkpoint_prefix ${ws}/train/${trial}/model.ckpt-350000 \
--output_directory ${ws}/inference_graph/${trial}
done
#
# Train for 100k iterations
#
for trial in "${trials[@]}"
do
(export CUDA_VISIBLE_DEVICES=3; \
python models/research/object_detection/eval.py \
--logtostderr \
--eval_dir=${ws}/eval/${trial}/ \
--pipeline_config_path=${ws}/config/${trial}.config \
--checkpoint_dir=${ws}/train/${trial}/ &)
python models/research/object_detection/train.py \
--logtostderr \
--train_dir=${ws}/train/${trial}/ \
--pipeline_config_path=${ws}/config/${trial}.config \
--num_clones=2 \
--ps_tasks=1
sleep 5m
pkill -f eval.py
python models/research/object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path ${ws}/config/${trial}.config \
--trained_checkpoint_prefix ${ws}/train/${trial}/model.ckpt-100000 \
--output_directory ${ws}/inference_graph/${trial}
done
#
# Fine-tune for 25k iterations
#
for trial in "${fine_tune_trials[@]}"
do
(export CUDA_VISIBLE_DEVICES=3; \
python models/research/object_detection/eval.py \
--logtostderr \
--eval_dir=${ws}/eval/${trial}/ \
--pipeline_config_path=${ws}/config/fine_tune_${trial}.config \
--checkpoint_dir=${ws}/train/fine_tune/${trial}/ &)
python models/research/object_detection/train.py \
--logtostderr \
--train_dir=${ws}/train/fine_tune/${trial}/ \
--pipeline_config_path=${ws}/config/fine_tune_${trial}.config \
--num_clones=2 \
--ps_tasks=1
sleep 5m
pkill -f eval.py
python models/research/object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path ${ws}/config/fine_tune_${trial}.config \
--trained_checkpoint_prefix ${ws}/train/fine_tune/${trial}/model.ckpt-25000 \
--output_directory ${ws}/inference_graph/fine_tune/${trial}
done
#
# Compute metrics
#
for trial in "${eval_trials[@]}"
do
mkdir -p ${ws}/inference_results/${trial}
python -m object_detection/inference/infer_detections \
--input_tfrecord_paths=${ws}/data/test.record \
--output_tfrecord_path=${ws}/inference_results/${trial}/detections.tfrecord \
--inference_graph=${ws}/inference_graph/${trial}/frozen_inference_graph.pb \
--discard_image_pixels
python -m object_detection/metrics/offline_eval_map_corloc \
--eval_dir=${ws}/inference_results/${trial}/ \
--eval_config_path=${ws}/config/test_eval_config.pbtxt \
--input_config_path=${ws}/test_input_config/${trial}.pbtxt
done
for trial in "${eval_fine_tune_trials[@]}"
do
mkdir -p ${ws}/inference_results/fine_tune/${trial}
python -m object_detection/inference/infer_detections \
--input_tfrecord_paths=${ws}/data/test.record \
--output_tfrecord_path=${ws}/inference_results/fine_tune/${trial}/detections.tfrecord \
--inference_graph=${ws}/inference_graph/fine_tune/${trial}/frozen_inference_graph.pb \
--discard_image_pixels
python -m object_detection/metrics/offline_eval_map_corloc \
--eval_dir=${ws}/inference_results/fine_tune/${trial}/ \
--eval_config_path=${ws}/config/test_eval_config.pbtxt \
--input_config_path=${ws}/test_input_config/fine_tune_${trial}.pbtxt
done