forked from meng-tang/rloss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_pascal_scribble.sh
executable file
·148 lines (126 loc) · 4.12 KB
/
run_pascal_scribble.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
#!/bin/sh
echo $HOSTNAME
## MODIFY PATH for YOUR SETTING
ROOT_DIR=/home/m62tang/rloss
CAFFE_DIR=${ROOT_DIR}/deeplab/
CAFFE_BIN=${CAFFE_DIR}/.build_release/tools/caffe.bin
EXP=pascal_scribble
if [ "${EXP}" = "pascal_scribble" ]; then
NUM_LABELS=21
DATA_ROOT=${ROOT_DIR}/data/pascal_scribble/
else
return
fi
## Specify which model to train
########### voc12 ################
#NET_ID=deeplab_largeFOV
#NET_ID=deeplab_msc_largeFOV
#NET_ID=deeplab_vgg16
NET_ID=resnet-101
## Variables used for weakly or semi-supervisedly training
TRAIN_SET_SUFFIX=
#TRAIN_SET_SUFFIX=_aug
DEV_ID=0
#####
## Create dirs
CONFIG_DIR=${EXP}/config/${NET_ID}
MODEL_DIR=${EXP}/model/${NET_ID}
mkdir -p ${MODEL_DIR}
LOG_DIR=${EXP}/log/${NET_ID}
mkdir -p ${LOG_DIR}
export GLOG_log_dir=${LOG_DIR}
## Run
RUN_TRAIN=1
RUN_TRAINWITHDENSECRFLOSS=1
RUN_TEST=1
DENSECRF_LOSS_WEIGHT=1e-8
## Training #1 (on train_aug)
if [ ${RUN_TRAIN} -eq 1 ]; then
#
LIST_DIR=${EXP}/list
TRAIN_SET=train${TRAIN_SET_SUFFIX}
#
if [ "${NET_ID}" = "deeplab_largeFOV" ]; then
# download from http://liangchiehchen.com/projects/Init%20Models.html
MODEL=${EXP}/model/${NET_ID}/vgg16_20M.caffemodel
elif [ "${NET_ID}" = "deeplab_vgg16" ]; then
# download from http://liangchiehchen.com/projects/DeepLabv2_vgg.html
MODEL=${EXP}/model/${NET_ID}/init.caffemodel
elif [ "${NET_ID}" = "resnet-101" ]; then
# download from http://liangchiehchen.com/projects/DeepLabv2_resnet.html
MODEL=${EXP}/model/${NET_ID}/init.caffemodel
fi
#
echo Training net ${EXP}/${NET_ID}
for pname in train solver; do
sed "$(eval echo $(cat sub.sed))" \
${CONFIG_DIR}/${pname}.prototxt > ${CONFIG_DIR}/${pname}_${TRAIN_SET}.prototxt
done
CMD="${CAFFE_BIN} train \
--solver=${CONFIG_DIR}/solver_${TRAIN_SET}.prototxt \
--weights=${MODEL} \
--gpu=${DEV_ID}"
echo $CMD
echo Running ${CMD} && ${CMD}
echo $CMD
fi
if [ ${RUN_TRAINWITHDENSECRFLOSS} -eq 1 ]; then
#
LIST_DIR=${EXP}/list
TRAIN_SET=train${TRAIN_SET_SUFFIX}
if [ "${NET_ID}" = "deeplab_largeFOV" ]; then
MODEL=${EXP}/model/${NET_ID}/train_iter_9000.caffemodel
elif [ "${NET_ID}" = "deeplab_msc_largeFOV" ]; then
MODEL=${EXP}/model/deeplab_largeFOV/trainwithdensecrfloss_iter_9000.caffemodel
elif [ "${NET_ID}" = "deeplab_vgg16" ]; then
MODEL=${EXP}/model/${NET_ID}/train_iter_20000.caffemodel
elif [ "${NET_ID}" = "resnet-101" ]; then
MODEL=${EXP}/model/${NET_ID}/train_iter_20000.caffemodel
fi
#
echo Training net ${EXP}/${NET_ID}
for pname in trainwithdensecrfloss solverwithdensecrfloss; do
sed "$(eval echo $(cat sub.sed))" \
${CONFIG_DIR}/${pname}.prototxt > ${CONFIG_DIR}/${pname}_${TRAIN_SET}.prototxt
done
CMD="${CAFFE_BIN} train \
--solver=${CONFIG_DIR}/solverwithdensecrfloss_${TRAIN_SET}.prototxt \
--weights=${MODEL} \
--gpu=${DEV_ID}"
echo $CMD
echo Running ${CMD} && ${CMD}
echo $CMD
fi
## Test #1 specification (on val or test)
if [ ${RUN_TEST} -eq 1 ]; then
#
for TEST_SET in val; do
TEST_ITER=`cat ${EXP}/list/${TEST_SET}.txt | wc -l`
# for deeplab_vgg16
#MODEL=${EXP}/model/${NET_ID}/train_iter_20000.caffemodel
#MODEL=${EXP}/model/${NET_ID}/trainwithdensecrfloss_iter_10000.caffemodel
# for deeplab_largeFOV
#MODEL=${EXP}/model/${NET_ID}/train_iter_9000.caffemodel
#MODEL=${EXP}/model/${NET_ID}/trainwithdensecrfloss_iter_9000.caffemodel
# for deeplab_msc_largeFOV
#MODEL=${EXP}/model/${NET_ID}/trainwithdensecrfloss_iter_9000.caffemodel
# for resnet-101
MODEL=${EXP}/model/${NET_ID}/train_iter_20000.caffemodel
echo $MODEL
if [ ! -f ${MODEL} ]; then
return
fi
#
echo Testing net ${EXP}/${NET_ID}
FEATURE_DIR=${EXP}/features/${NET_ID}
sed "$(eval echo $(cat sub.sed))" \
${CONFIG_DIR}/test.prototxt > ${CONFIG_DIR}/test_${TEST_SET}.prototxt
CMD="${CAFFE_BIN} test \
--model=${CONFIG_DIR}/test_${TEST_SET}.prototxt \
--weights=${MODEL} \
--gpu=${DEV_ID} \
--iterations=${TEST_ITER}"
echo Running ${CMD} && ${CMD}
echo $CMD
done
fi