3a90f56a681b0bab6001c0da9afa5d271bc3694b
[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 echo
27
28 # Generating the pool file
29
30 DATA_PATH=./rmk-data
31 POOL_NAME=${DATA_PATH}/rmk.pool
32
33 if [[ -d ${DATA_PATH} ]]; then
34
35     if [[ -f ${POOL_NAME} ]]; then
36
37         echo "The pool file exists."
38
39     else
40
41         echo "Can not find the pool file, checking the data integrity."
42
43         md5sum -c ${DATA_PATH}/list.md5
44
45         if [[ $? != 0 ]]; then
46             echo "The data set is corrupted. You can download it" >&2
47             echo "from ${MAIN_URL}" >&2
48             exit 1
49         fi
50
51         echo "Generating the pool file."
52
53         ./list_to_pool ${DATA_PATH}/full.lst ${DATA_PATH} ${POOL_NAME}.wrk
54
55         if [[ $? == 0 ]]; then
56             mv ${POOL_NAME}.wrk ${POOL_NAME}
57         else
58             \rm ${POOL_NAME}.wrk 2> /dev/null
59             echo "Pool generation failed." >&2
60             exit 1
61         fi
62
63     fi
64
65 else
66
67     echo "Can not find the RateMyKitten images in ${DATA_PATH}. You can" >&2
68     echo "download them from ${MAIN_URL}" >&2
69     exit 1
70
71 fi
72
73 # Running the computation per se
74
75 RESULT_DIR=./results
76
77 if [[ ! -d ${RESULT_DIR} ]]; then
78     mkdir ${RESULT_DIR}
79 fi
80
81 for SEED in {0..9}; do
82
83     for MODE in hb h+b; do
84
85         EXPERIMENT_RESULT_DIR="${RESULT_DIR}/${MODE}-${SEED}"
86
87         mkdir ${EXPERIMENT_RESULT_DIR} 2> /dev/null
88
89         if [[ $? == 0 ]]; then
90
91             OPTS="--random-seed=${SEED} --wanted-true-positive-rate=0.75"
92
93             if [[ $MODE == "h+b" ]]; then
94                 OPTS="${OPTS} --force-head-belly-independence=yes"
95             fi
96
97             if [[ $1 == "light" ]]; then
98                 OPTS="${OPTS} --nb-classifiers-per-level=1 --nb-weak-learners-per-classifier=10"
99                 OPTS="${OPTS} --proportion-for-train=0.1 --proportion-for-validation=0.1 --proportion-for-test=0.1"
100             fi
101
102             ./folding \
103                 --niceness=15 \
104                 --pool-name=${POOL_NAME} \
105                 --nb-levels=2 \
106                 --nb-classifiers-per-level=25 --nb-weak-learners-per-classifier=100 \
107                 --result-path=${EXPERIMENT_RESULT_DIR} \
108                 --detector-name=${EXPERIMENT_RESULT_DIR}/default.det \
109                 ${OPTS} \
110                 open-pool \
111                 train-detector \
112                 compute-thresholds \
113                 write-detector \
114                 sequence-test-detector | tee -a ${EXPERIMENT_RESULT_DIR}/stdout
115
116         else
117
118             echo "${EXPERIMENT_RESULT_DIR} exists, aborting experiment."
119
120         fi
121
122     done
123
124 done