video_cascade_svm_pad_algorithm.py 6.95 KB
Newer Older
1
2
#!/usr/bin/env python

3
from bob.pad.base.algorithm import SVMCascadePCA
4
5
6
7
8
9
10
11
12
13
14

#=======================================================================================
# Define instances here:

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.2}
N = 2
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

15
algorithm_n2_gamma_02 = SVMCascadePCA(
16
17
18
19
20
21
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
22
23
24
25
26
27
28
29

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.1}
N = 2
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

30
algorithm_n2_gamma_01 = SVMCascadePCA(
31
32
33
34
35
36
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
37
38
39
40
41
42
43
44

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.05}
N = 2
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

45
algorithm_n2_gamma_005 = SVMCascadePCA(
46
47
48
49
50
51
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
52
53
54
55
56
57
58
59

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.01}
N = 2
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

60
algorithm_n2_gamma_001 = SVMCascadePCA(
61
62
63
64
65
66
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
67
68
69
70
71
72
73
74
75
76

#=======================================================================================

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.1}
N = 10
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

77
algorithm_n10_gamma_01 = SVMCascadePCA(
78
79
80
81
82
83
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
84
85
86
87
88
89
90
91

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.05}
N = 10
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

92
algorithm_n10_gamma_005 = SVMCascadePCA(
93
94
95
96
97
98
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
99
100
101
102
103
104
105
106

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.01}
N = 10
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

107
algorithm_n10_gamma_001 = SVMCascadePCA(
108
109
110
111
112
113
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
114
115
116
117
118
119
120
121

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.005}
N = 10
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

122
algorithm_n10_gamma_0005 = SVMCascadePCA(
123
124
125
126
127
128
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
129
130
131
132
133
134
135
136
137
138

#=======================================================================================

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.5}
N = 20
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

139
algorithm_n20_gamma_05 = SVMCascadePCA(
140
141
142
143
144
145
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
146
147
148
149
150
151
152
153

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.2}
N = 20
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

154
algorithm_n20_gamma_02 = SVMCascadePCA(
155
156
157
158
159
160
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
161
162
163
164
165
166
167
168

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.1}
N = 20
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

169
algorithm_n20_gamma_01 = SVMCascadePCA(
170
171
172
173
174
175
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
176
177
178
179
180
181
182
183

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.05}
N = 20
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

184
algorithm_n20_gamma_005 = SVMCascadePCA(
185
186
187
188
189
190
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
191
192
193
194
195
196
197
198

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.01}
N = 20
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

199
algorithm_n20_gamma_001 = SVMCascadePCA(
200
201
202
203
204
205
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
206
207
208
209
210
211
212
213

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.005}
N = 20
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

214
algorithm_n20_gamma_0005 = SVMCascadePCA(
215
216
217
218
219
220
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
221
222
223
224
225
226
227
228

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.001}
N = 20
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

229
algorithm_n20_gamma_0001 = SVMCascadePCA(
230
231
232
233
234
235
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
236
237
238
239
240
241
242
243
244
245

#=======================================================================================

MACHINE_TYPE = 'ONE_CLASS'
KERNEL_TYPE = 'RBF'
SVM_KWARGS = {'nu': 0.001, 'gamma': 0.1}
N = 2
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = False

246
algorithm_n2_gamma_01_video_level = SVMCascadePCA(
247
248
249
250
251
252
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=SVM_KWARGS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
253

254
255
256
257
258
259
260
261
262
263
264
#=======================================================================================

# Test the cascade of two-class SVMs.

MACHINE_TYPE = 'C_SVC'
KERNEL_TYPE = 'RBF'
TRAINER_GRID_SEARCH_PARAMS = {'cost': 1, 'gamma': 0.01}
N = 2
POS_SCORES_SLOPE = 0.01
FRAME_LEVEL_SCORES_FLAG = True

265
algorithm_n2_two_class_svm_c1_gamma_001 = SVMCascadePCA(
266
267
268
269
270
271
    machine_type=MACHINE_TYPE,
    kernel_type=KERNEL_TYPE,
    svm_kwargs=TRAINER_GRID_SEARCH_PARAMS,
    N=N,
    pos_scores_slope=POS_SCORES_SLOPE,
    frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)