automatic commit
[folded-ctf.git] / run.sh
1 #!/bin/bash
2
3 #########################################################################
4 # This program is free software: you can redistribute it and/or modify  #
5 # it under the terms of the version 3 of the GNU General Public License #
6 # as published by the Free Software Foundation.                         #
7 #                                                                       #
8 # This program is distributed in the hope that it will be useful, but   #
9 # WITHOUT ANY WARRANTY; without even the implied warranty of            #
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      #
11 # General Public License for more details.                              #
12 #                                                                       #
13 # You should have received a copy of the GNU General Public License     #
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.  #
15 #                                                                       #
16 # Written by Francois Fleuret, (C) IDIAP                                #
17 # Contact <francois.fleuret@idiap.ch> for comments & bug reports        #
18 #########################################################################
19
20 MAIN_URL="http://www.idiap.ch/folded-ctf"
21
22 # Compiling
23
24 make -j -k
25
26 if [[ $? != 0 ]]; then
27     echo "Compilation failed." >&2
28     exit 1
29 fi
30
31 echo
32
33 # Generating the pool file
34
35 DATA_PATH=./rmk-data
36 POOL_NAME=${DATA_PATH}/rmk.pool
37
38 if [[ -d ${DATA_PATH} ]]; then
39
40     if [[ -f ${POOL_NAME} ]]; then
41
42         echo "The pool file exists."
43
44     else
45
46         echo "Can not find the pool file, checking the data integrity."
47
48         md5sum -c ${DATA_PATH}/list.md5
49
50         if [[ $? != 0 ]]; then
51             echo "The data set is corrupted. You can download it" >&2
52             echo "from ${MAIN_URL}" >&2
53             exit 1
54         fi
55
56         echo "Generating the pool file."
57
58         ./list_to_pool ${DATA_PATH}/full.lst ${DATA_PATH} ${POOL_NAME}.wrk
59
60         if [[ $? == 0 ]]; then
61             mv ${POOL_NAME}.wrk ${POOL_NAME}
62         else
63             \rm ${POOL_NAME}.wrk 2> /dev/null
64             echo "Pool generation failed." >&2
65             exit 1
66         fi
67
68     fi
69
70 else
71
72     echo "Can not find the RateMyKitten images in ${DATA_PATH}. You can" >&2
73     echo "download them from ${MAIN_URL}" >&2
74     exit 1
75
76 fi
77
78 # Running the computation per se
79
80 RESULT_DIR=./results
81
82 if [[ ! -d ${RESULT_DIR} ]]; then
83     mkdir ${RESULT_DIR}
84 fi
85
86 for SEED in {0..9}; do
87
88     for MODE in hb h+b; do
89
90         EXPERIMENT_RESULT_DIR="${RESULT_DIR}/${MODE}-${SEED}"
91
92         mkdir ${EXPERIMENT_RESULT_DIR} 2> /dev/null
93
94         if [[ $? == 0 ]]; then
95
96             OPTS="--random-seed=${SEED} --wanted-true-positive-rate=0.75"
97
98             if [[ $MODE == "h+b" ]]; then
99                 OPTS="${OPTS} --force-head-belly-independence=yes"
100             fi
101
102             if [[ $1 == "light" ]]; then
103                 OPTS="${OPTS} --nb-classifiers-per-level=1 --nb-weak-learners-per-classifier=10"
104                 OPTS="${OPTS} --proportion-for-train=0.1 --proportion-for-validation=0.1 --proportion-for-test=0.1"
105             fi
106
107             ./folding \
108                 --niceness=15 \
109                 --pool-name=${POOL_NAME} \
110                 --nb-levels=2 \
111                 --nb-classifiers-per-level=25 --nb-weak-learners-per-classifier=100 \
112                 --result-path=${EXPERIMENT_RESULT_DIR} \
113                 --detector-name=${EXPERIMENT_RESULT_DIR}/default.det \
114                 ${OPTS} \
115                 open-pool \
116                 train-detector \
117                 compute-thresholds \
118                 write-detector \
119                 sequence-test-detector | tee -a ${EXPERIMENT_RESULT_DIR}/stdout
120
121         else
122
123             echo "${EXPERIMENT_RESULT_DIR} exists, aborting experiment."
124
125         fi
126
127     done
128
129 done