-
Notifications
You must be signed in to change notification settings - Fork 8
/
README
213 lines (192 loc) · 10.5 KB
/
README
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
Example of use:
===============
python v1like_extract_fromcsv.py -i ./test_imageset config/v1like_a.py ./test_imageset/train5test5_split01.csv .v1like_a --nprocessors=$(cat /proc/cpuinfo | grep processor | wc -l)
Steps to reproduce the results from our PLoS 2008 paper:
========================================================
"Why is Real-World Visual Object Recognition Hard?"
By Nicolas Pinto, David D. Cox and James J. DiCarlo (2008)
Published in PLoS Comput Biol 4(1): e27.
doi:10.1371/journal.pcbi.0040027
http://www.ploscompbiol.org/article/info:doi/10.1371/journal.pcbi.0040027
Instructions:
-------------
# -- set up
export PJT=$HOME/plos08_reprod
export NPROCS=$(cat /proc/cpuinfo | grep processor | wc -l)
mkdir -p $PJT/{src,data}
cd $PJT/src
git clone https://github.com/npinto/v1like.git
git clone https://github.com/npinto/sclas.git
export V1LIKE=$PJT/src/v1like
export SCLAS=$PJT/src/sclas
# -- don't forget to install shogun
# see e.g.: https://github.com/npinto/np-toolbox/blob/master/install_scripts/install_shogun0.9.3_Ubuntu9.10.bash
# ----------------------------
# -- #Caltech101: get image set
cd $PJT/data
wget http://www.vision.caltech.edu/Image_Datasets/#Caltech101/101_ObjectCategories.tar.gz
tar xzvf 101_ObjectCategories.tar.gz
# -- #Caltech101: create splits
export ntrain=15 ntest=15
for i in `seq -w 1 10`; do
python $SCLAS/create_traintest_split.py --rseed=$i --ntrain=$ntrain --ntest=$ntest $PJT/data/101_ObjectCategories/{,train${ntrain}test${ntest}_split_${i}.csv};
done;
# -- #Caltech101: generate v1like features
for conf in v1like_a{,_plus}; do
for i in `seq -w 1 10`; do
python $V1LIKE/v1like_extract_fromcsv.py --nprocessors=$NPROCS -i $PJT/data/101_ObjectCategories/ $V1LIKE/config/$conf.py $PJT/data/101_ObjectCategories/train${ntrain}test${ntest}_split_${i}.csv $conf.mat;
done;
done;
# -- #Caltech101: generate kernels
for conf in v1like_a{,_plus}; do
for csv in $PJT/data/101_ObjectCategories/train${ntrain}test${ntest}_split_??.csv; do
python $SCLAS/kernel_generate_fromcsv.py -i $(dirname $csv) $csv $conf.mat $csv.kernel.$conf.mat;
done;
done;
# -- #Caltech101: run SVMs
for conf in v1like_a{,_plus}; do
for csv in $PJT/data/101_ObjectCategories/train${ntrain}test${ntest}_split_??.csv; do
python $SCLAS/svm_ova_fromfilenames.py $csv.kernel.$conf.mat -o $csv.svm_ova_results.$conf.mat;
done;
done;
# -- #Caltech101: average classification results (crudely ;-)
for conf in v1like_a{,_plus}; do
echo $conf;
for i in `seq -w 1 10`; do
python $SCLAS/print_mat.py $PJT/data/101_ObjectCategories/train${ntrain}test${ntest}_split_${i}.csv.svm_ova_results.$conf.mat accuracy;
done | awk '{sum+=$2} END {print sum/NR}';
done;
# v1like_a
# 58.0392
# v1like_a_plus
# 61.4183
# ----------------------------------------
# -- Controlled Invariance: get image sets
cd $PJT/data
wget http://s3.amazonaws.com/PLoS08_ControlSets/PLoS08_ControlSet_Cars_Planes_v01.tar.gz http://s3.amazonaws.com/PLoS08_ControlSets/PLoS08_ControlSet_Cars_Planes_v01.tar.gz.md5
md5sum -c PLoS08_ControlSet_Cars_Planes_v01.tar.gz.md5
tar xzvf PLoS08_ControlSet_Cars_Planes_v01.tar.gz
# -- Controlled Invariance: create splits
export ntrain=100 ntest=30
for dir in $(ls -d $PJT/data/PLoS08_ControlSet_Cars_Planes_v01/*/); do
for i in `seq -w 1 10`; do
python $SCLAS/create_traintest_split.py --rseed=$i --ntrain=$ntrain --ntest=$ntest $dir/{,train${ntrain}test${ntest}_split_${i}.csv};
done;
done;
# -- Controlled Invariance: generate v1like features
for conf in v1like_a{,_plus}; do
for dir in $(ls -d $PJT/data/PLoS08_ControlSet_Cars_Planes_v01/*/); do
for i in `seq -w 1 10`; do
python $V1LIKE/v1like_extract_fromcsv.py --nprocessors=$NPROCS -i $dir/ $V1LIKE/config/$conf.py $dir/train${ntrain}test${ntest}_split_${i}.csv $conf.mat;
done;
done;
done;
# -- Controlled Invariance: generate kernels
for conf in v1like_a{,_plus}; do
for dir in $(ls -d $PJT/data/PLoS08_ControlSet_Cars_Planes_v01/*/); do
for csv in $dir/train${ntrain}test${ntest}_split_??.csv; do
python $SCLAS/kernel_generate_fromcsv.py -i $(dirname $csv) $csv $conf.mat $csv.kernel.$conf.mat;
done;
done;
done;
# -- Controlled Invariance: run SVMs
for conf in v1like_a{,_plus}; do
for dir in $(ls -d $PJT/data/PLoS08_ControlSet_Cars_Planes_v01/*/); do
for csv in $dir/train${ntrain}test${ntest}_split_??.csv; do
python $SCLAS/svm_ova_fromfilenames.py $csv.kernel.$conf.mat -o $csv.svm_ova_results.$conf.mat;
done;
done;
done;
# -- Controlled Invariance: average classification results (crudely ;-)
for conf in v1like_a{,_plus}; do
for dir in $(ls -d $PJT/data/PLoS08_ControlSet_Cars_Planes_v01/*/); do
echo $conf $dir;
for i in `seq -w 1 10`; do
python $SCLAS/print_mat.py $dir/train${ntrain}test${ntest}_split_${i}.csv.svm_ova_results.$conf.mat accuracy;
done | awk '{sum+=$2} END {print sum/NR}';
done;
done;
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation00_NaturalBg_n130_200x200_GS/
#97.1667
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation00_NoiseBg_n130_200x200_GS/
#100
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation00_PhaseScrambledBg_n130_200x200_GS/
#99.8333
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation01_NaturalBg_n130_200x200_GS/
#87.3333
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation01_NoiseBg_n130_200x200_GS/
#97.8333
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation01_PhaseScrambledBg_n130_200x200_GS/
#92.5
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation02_NaturalBg_n130_200x200_GS/
#68.3333
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation02_NoiseBg_n130_200x200_GS/
#84
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation02_PhaseScrambledBg_n130_200x200_GS/
#81.3333
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation03_NaturalBg_n130_200x200_GS/
#65.5
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation03_NoiseBg_n130_200x200_GS/
#74.1667
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation03_PhaseScrambledBg_n130_200x200_GS/
#65.6667
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation04_NaturalBg_n130_200x200_GS/
#54.8333
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation04_NoiseBg_n130_200x200_GS/
#68
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation04_PhaseScrambledBg_n130_200x200_GS/
#62.5
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation05_NaturalBg_n130_200x200_GS/
#51.3333
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation05_NoiseBg_n130_200x200_GS/
#61.8333
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation05_PhaseScrambledBg_n130_200x200_GS/
#57.5
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation06_NaturalBg_n130_200x200_GS/
#45.5
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation06_NoiseBg_n130_200x200_GS/
#55
#v1like_a plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation06_PhaseScrambledBg_n130_200x200_GS/
#50.6667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation00_NaturalBg_n130_200x200_GS/
#97.3333
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation00_NoiseBg_n130_200x200_GS/
#100
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation00_PhaseScrambledBg_n130_200x200_GS/
#99.6667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation01_NaturalBg_n130_200x200_GS/
#86
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation01_NoiseBg_n130_200x200_GS/
#98.3333
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation01_PhaseScrambledBg_n130_200x200_GS/
#92.3333
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation02_NaturalBg_n130_200x200_GS/
#67.1667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation02_NoiseBg_n130_200x200_GS/
#88.6667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation02_PhaseScrambledBg_n130_200x200_GS/
#80.6667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation03_NaturalBg_n130_200x200_GS/
#63.8333
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation03_NoiseBg_n130_200x200_GS/
#78.5
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation03_PhaseScrambledBg_n130_200x200_GS/
#69.1667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation04_NaturalBg_n130_200x200_GS/
#51.5
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation04_NoiseBg_n130_200x200_GS/
#70.6667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation04_PhaseScrambledBg_n130_200x200_GS/
#64.5
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation05_NaturalBg_n130_200x200_GS/
#51.1667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation05_NoiseBg_n130_200x200_GS/
#64.8333
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation05_PhaseScrambledBg_n130_200x200_GS/
#58.1667
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation06_NaturalBg_n130_200x200_GS/
#47
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation06_NoiseBg_n130_200x200_GS/
#57.5
#v1like_a_plus plos08_reprod/data/PLoS08_ControlSet_Cars_Planes_v01/ControlSet_Cars_Planes_Variation06_PhaseScrambledBg_n130_200x200_GS/
#55.3333