-
Notifications
You must be signed in to change notification settings - Fork 1
/
tool.sh
373 lines (306 loc) · 10.5 KB
/
tool.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#!/bin/bash
# This example requires bash.
GTKDIALOG=gtkdialog
ROOT_DIR="$HOME/CF_tools"
export TMPDIR=/tmp/gtkdialog/examples/"`basename $0`"
mkdir -p "$TMPDIR"
funcmuiCreate() {
echo '<variable>'$1'</variable>'
if [ $2 = 1 ]; then echo '<label>"'"$3"'"</label>'; fi
echo '<action>echo "'"$1 ($3) action for default signal triggered"'"</action>'
if [ ${1:0:3} = "mnu" ]; then echo '</menu>'; else echo '</menuitem>'; fi
}
echo -n > "$TMPDIR"/inoutfile
funcbtnCreate() {
echo '<button>
<label>"'"$2"'"</label>
<action>echo "'"$3"' '$1'"</action>
<action function="'"$4"'">'$1'</action>
</button>'
}
funcentCreate() {
echo '<variable>'$1'</variable>
<action>echo "'$1' action for default signal triggered"</action>
<action signal="changed">echo "'$1' changed to $'$1'"</action>
<action signal="activate">echo "'$1' Enter key-press detected"</action>
<action signal="primary-icon-press">echo "'$1' primary icon press detected"</action>
<action signal="primary-icon-release">echo "'$1' primary icon release detected"</action>
<action signal="secondary-icon-press">echo "'$1' secondary icon press detected"</action>
<action signal="secondary-icon-release">echo "'$1' secondary icon release detected"</action>
</entry>'
#if [ $2 = 1 ]; then echo '<vseparator></vseparator>'; fi
#if [ $3 = 1 ]; then echo '</hbox><hseparator></hseparator><hbox>'; fi
}
train__log="/dev/pts/2"
test__log="/dev/pts/4"
funcSubmitForm() {
#gpu_id=0
# paste the script here~
if [ $1 == "train_evaluate" ]
then
#funcLog train
gen_dir=$gen_dir__train
model=$model__train
weight_file=$weight_file__train
#LABEL_FILE=$gen_dir__train/$model__train/label_map.txt
#img_size=${img_size__train##*x}
img_size=$img_size__train
#echo '<action>python $ROOT_DIR/CF_$model__train/${model__train}_pascal.py --gen_dir=$gen_dir --image_resize=$img_size__train --model_weights=$weight_file__train --labelmap_file=$LABEL_FILE 2>'"$train__log"'</action>'
#echo '<action>python $ROOT_DIR/CF_$model__train/${model__train}_pascal.py --gen_dir=$gen_dir__train --image_resize=$img_size__train --model_weights=$weight_file__train --labelmap_file=$LABEL_FILE 2>&1</action>'
echo '<action>echo ./run_tool.sh -t $type -u 0 -n $num_classes_train -g $gen_dir__train -m $model__train -s $img_size__train -w $weight_file__train -i 0 2>&1</action>'
echo '<action>./run_tool.sh -t $type -u 0 -n $num_classes_train -g $gen_dir__train -m $model__train -s $img_size__train -w $weight_file__train -i 0 2>&1</action>'
elif [ $1 == "detect" ]
then
#gpu_id=$gpu_id__test
gen_dir=$gen_dir__test
model=$model__test
weight_file=$weight_file__test
#LABEL_FILE=$gen_dir__test/$model__test/label_map.txt
img_size=$img_size__test
#echo '<action>python $ROOT_DIR/CF_$model__test/${model__test}_pascal.py --gen_dir=$gen_dir__test --image_resize=$img_size__test --model_weights=$weight_file__test --labelmap_file=$LABEL_FILE 2>&1</action>'
echo '<action>echo ./run_tool.sh -t detect -u $gpu_id -n $num_classes_test -g $gen_dir__test -m $model__test -s $img_size__test -w $weight_file__test -i $img_file 2>&1</action>'
echo '<action>./run_tool.sh -t detect -u $gpu_id -n $num_classes_test -g $gen_dir__test -m $model__test -s $img_size__test -w $weight_file__test -i $img_file 2>&1</action>'
elif [ $1 == "prepare_data" ]
then
gen_dir=$gen_dir__prepare
model=$model__prepare
weight_file=$weight_file__prepare
#LABEL_FILE=$gen_dir__prepare/$model__prepare/label_map.txt
img_size=$img_size__prepare
echo '<action>echo ./prepare_data.sh -g $gen_dir__prepare -d $dataset_dir__prepare -m $model__prepare 2>&1</action>'
echo '<action>./prepare_data.sh -g $gen_dir__prepare -d $dataset_dir__prepare -m $model__prepare 2>&1</action>'
fi
# Execute commands
#cho '<action>echo ./run_tool_.sh -w $weight_file -g $gen_dir -m $model -t train -s $img_size > '"$train__log"'</action>'
#echo '<action>./run_tool_.sh -w $weight_file -g $gen_dir -m $model -t train -s $img_size > '"$train__log"'</action>'
#echo '<action>echo hello $model</action>'
#echo '<action>python $ROOT_DIR/CF_$model/${model}_pascal.py --gen_dir=$gen_dir --image_resize=$img_size --model_weights=$weight_file --labelmap_file=$LABEL_FILE 2>'"$train__log"'</action>'
#echo 'funcSubmitForm '$1' '$2''
}
funcLog() {
if [ $1 == "train_evaluate" ]
then
WELCOME="Hi! Tutu here"
__tty=$tty
#echo '<input>echo echo \$tty</input>
# <action>echo "log__train=$log__train"</action>'
fi
}
for func in $(declare -F | cut -f3 -d' ')
do
echo $func
export -f $func
done
export -f funcSubmitForm
export MAIN_DIALOG='
<window title="Tool" resizable="true" width-request="400" border-width="0" scrollable="true">
<vbox>
<notebook labels="Train - Evaluate|Detect|Prepare datasets">
<vbox border-width="10" spacing="10">
<hbox>
<text>
<label>Type:</label>
</text>
<comboboxentry active="0">
<variable>type</variable>
<item>train</item>
<item>evaluate</item>
</comboboxentry>
</hbox>
<hbox>
<text>
<label>Model:</label>
</text>
<comboboxentry active="0">
<variable>model__train</variable>
<item>ssd</item>
<item>fssd</item>
<item>yolo</item>
</comboboxentry>
</hbox>
<hbox>
<text>
<label>Num classes:</label>
</text>
<entry activates-default="true">
<default>21</default>
'"`funcentCreate num_classes_train 0 0`"'
</hbox>
<hbox>
<text>
<label>Input size:</label>
</text>
<comboboxentry active="0">
<variable>img_size__train</variable>
<item>300</item>
<item>512</item>
<item>448</item>
</comboboxentry>
</hbox>
<hbox>
<text>
<label>Dataset generation dir:</label>
</text>
<entry fs-action="folder"
fs-title="Select folder"
editable="false"
block-function-signals="true">
<output file>'"$TMPDIR"'/outputfile</output>
'"`funcentCreate gen_dir__train 0 0`"'
'"`funcbtnCreate gen_dir__train Select """Inserting into""" fileselect`"'
</hbox>
<hbox>
<text>
<label>Model weight (.caffemodel)</label>
</text>
<entry fs-action="file"
fs-title="Select a file"
fs-filters="*.caffemodel"
editable="false"
block-function-signals="true">
<output file>'"$TMPDIR"'/outputfile</output>
'"`funcentCreate weight_file__train 0 0`"'
'"`funcbtnCreate weight_file__train Select """Inserting into""" fileselect`"'
</hbox>
<hbox homogeneous="true">
<button>
<label>Execute</label>
'"`funcSubmitForm train_evaluate`"'
</button>
</hbox>
</vbox>
<vbox border-width="10" spacing="10">
<hbox>
<text>
<label>Model:</label>
</text>
<comboboxentry active="0">
<variable>model__test</variable>
<item>ssd</item>
<item>fssd</item>
<item>yolo</item>
</comboboxentry>
</hbox>
<hbox>
<text>
<label>GPU id:</label>
</text>
<entry activates-default="true">
<default>0</default>
'"`funcentCreate gpu_id 0 0`"'
</hbox>
<hbox>
<text>
<label>Num classes:</label>
</text>
<entry activates-default="true">
<default>21</default>
'"`funcentCreate num_classes_test 0 0`"'
</hbox>
<hbox>
<text>
<label>Input size:</label>
</text>
<comboboxentry active="0">
<variable>img_size__test</variable>
<item>300</item>
<item>512</item>
<item>448</item>
</comboboxentry>
</hbox>
<hbox>
<text>
<label>Dataset generation dir name:</label>
</text>
<entry fs-action="folder"
fs-title="Select folder"
editable="false"
block-function-signals="true">
<output file>'"$TMPDIR"'/outputfile</output>
'"`funcentCreate gen_dir__test 0 0`"'
'"`funcbtnCreate gen_dir__test Select """Inserting into""" fileselect`"'
</hbox>
<hbox>
<text>
<label>Model weight (.caffemodel)</label>
</text>
<entry fs-action="file"
fs-title="Select a file"
fs-filters="*.caffemodel"
editable="false"
block-function-signals="true">
<output file>'"$TMPDIR"'/outputfile</output>
'"`funcentCreate weight_file__test 0 0`"'
'"`funcbtnCreate weight_file__test Select """Inserting into""" fileselect`"'
</hbox>
<hbox>
<text>
<label>Test image </label>
</text>
<entry fs-action="file"
fs-title="Select a file"
editable="false"
block-function-signals="true">
<output file>'"$TMPDIR"'/outputfile</output>
'"`funcentCreate img_file 0 0`"'
'"`funcbtnCreate img_file Select """Inserting into""" fileselect`"'
</hbox>
<hbox homogeneous="true">
<button>
<label>Execute</label>
'"`funcSubmitForm detect`"'
</button>
<button cancel></button>
</hbox>
</vbox>
<vbox border-width="10" spacing="10">
<hbox>
<text>
<label>Model:</label>
</text>
<comboboxentry active="0">
<variable>model__prepare</variable>
<item>ssd</item>
<item>fssd</item>
<item>yolo</item>
</comboboxentry>
</hbox>
<hbox height="10" width="1000">
<text>
<label>Dataset directory:</label>
</text>
<entry fs-action="folder"
fs-title="Select folder"
editable="false"
block-function-signals="true">
<output file>'"$TMPDIR"'/outputfile</output>
'"`funcentCreate dataset_dir__prepare 0 0`"'
'"`funcbtnCreate dataset_dir__prepare Select """Inserting into""" fileselect`"'
</hbox>
<hbox>
<text>
<label>Dataset generation dir:</label>
</text>
<entry fs-action="folder"
fs-title="Select folder"
editable="false"
block-function-signals="true">
<output file>'"$TMPDIR"'/outputfile</output>
'"`funcentCreate gen_dir__prepare 0 0`"'
'"`funcbtnCreate gen_dir__prepare Select """Inserting into""" fileselect`"'
</hbox>
<hbox homogeneous="true">
<button>
<label>Execute</label>
'"`funcSubmitForm prepare_data`"'
</button>
</hbox>
</vbox>
</notebook>
</vbox>
</window>
'
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac