-
Notifications
You must be signed in to change notification settings - Fork 51
/
config_updates.py
251 lines (226 loc) · 11.3 KB
/
config_updates.py
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
from sacred.config_helpers import DynamicIngredient, CMD
def add_configs(ex):
'''
This functions add generic configuration for the experiments, such as mix-up, architectures, etc...
@param ex: Ba3l Experiment
@return:
'''
@ex.named_config
def nomixup():
'Don\'t apply mix-up (spectrogram level).'
use_mixup = False
mixup_alpha = 0.3
@ex.named_config
def mixup():
' Apply mix-up (spectrogram level).'
use_mixup = True
mixup_alpha = 0.3
@ex.named_config
def mini_train():
'limit training/validation to 5 batches for debbuging.'
trainer = dict(limit_train_batches=5, limit_val_batches=5)
@ex.named_config
def passt():
'use PaSST model'
models = {
"net": DynamicIngredient("models.passt.model_ing")
}
@ex.named_config
def passt_s_20sec():
'use PaSST model pretrained on Audioset (with SWA) ap=476; time encodings for up to 20 seconds'
# python ex_audioset.py evaluate_only with passt_s_ap476
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_f128_20sec_p16_s10_ap474", fstride=10,
tstride=10, input_tdim=2000)
}
basedataset = dict(clip_length=20)
@ex.named_config
def passt_s_30sec():
'use PaSST model pretrained on Audioset (with SWA) ap=476; time encodings for up to 30 seconds'
# python ex_audioset.py evaluate_only with passt_s_ap476
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_f128_30sec_p16_s10_ap473", fstride=10,
tstride=10, input_tdim=3000)
}
basedataset = dict(clip_length=20)
@ex.named_config
def passt_s_ap476():
'use PaSST model pretrained on Audioset (with SWA) ap=476'
# python ex_audioset.py evaluate_only with passt_s_ap476
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_swa_p16_128_ap476", fstride=10,
tstride=10)
}
@ex.named_config
def passt_s_ap4763():
'use PaSST model pretrained on Audioset (with SWA) ap=4763'
# test with: python ex_audioset.py evaluate_only with passt_s_ap4763
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_swa_p16_128_ap4763", fstride=10,
tstride=10)
}
@ex.named_config
def passt_s_ap472():
'use PaSST model pretrained on Audioset (no SWA) ap=472'
# test with: python ex_audioset.py evaluate_only with passt_s_ap472
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_p16_128_ap472", fstride=10,
tstride=10)
}
@ex.named_config
def passt_s_p16_s16_128_ap468():
'use PaSST model pretrained on Audioset (no SWA) ap=468 NO overlap'
# test with: python ex_audioset.py evaluate_only with passt_s_p16_s16_128_ap468
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_p16_s16_128_ap468", fstride=16,
tstride=16)
}
@ex.named_config
def passt_s_swa_p16_s16_128_ap473():
'use PaSST model pretrained on Audioset (SWA) ap=473 NO overlap'
# test with: python ex_audioset.py evaluate_only with passt_s_swa_p16_s16_128_ap473
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_swa_p16_s16_128_ap473", fstride=16,
tstride=16)
}
@ex.named_config
def passt_s_swa_p16_s14_128_ap471():
'use PaSST model pretrained on Audioset stride=14 (SWA) ap=471 '
# test with: python ex_audioset.py evaluate_only with passt_s_swa_p16_s14_128_ap471
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_swa_p16_s14_128_ap471", fstride=14,
tstride=14)
}
@ex.named_config
def passt_s_p16_s14_128_ap469():
'use PaSST model pretrained on Audioset stride=14 (No SWA) ap=469 '
# test with: python ex_audioset.py evaluate_only with passt_s_p16_s14_128_ap469
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_p16_s14_128_ap469", fstride=14,
tstride=14)
}
@ex.named_config
def passt_s_swa_p16_s12_128_ap473():
'use PaSST model pretrained on Audioset stride=12 (SWA) ap=473 '
# test with: python ex_audioset.py evaluate_only with passt_s_swa_p16_s12_128_ap473
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_swa_p16_s12_128_ap473", fstride=12,
tstride=12)
}
@ex.named_config
def passt_s_p16_s12_128_ap470():
'use PaSST model pretrained on Audioset stride=12 (No SWA) ap=4670 '
# test with: python ex_audioset.py evaluate_only with passt_s_p16_s12_128_ap470
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="passt_s_p16_s12_128_ap470", fstride=12,
tstride=12)
}
@ex.named_config
def ensemble_s10():
'use ensemble of PaSST models pretrained on Audioset with S10 mAP=.4864'
# test with: python ex_audioset.py evaluate_only with trainer.precision=16 ensemble_s10
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="ensemble_s10", fstride=None,
tstride=None, instance_cmd="get_ensemble_model",
# don't call get_model but rather get_ensemble_model
arch_list=[
("passt_s_swa_p16_128_ap476", 10, 10),
("passt_s_swa_p16_128_ap4761", 10, 10),
("passt_s_p16_128_ap472", 10, 10),
]
)
}
@ex.named_config
def ensemble_many():
'use ensemble of PaSST models pretrained on Audioset with different strides mAP=.4956'
# test with: python ex_audioset.py evaluate_only with trainer.precision=16 ensemble_many
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="ensemble_many", fstride=None,
tstride=None, instance_cmd="get_ensemble_model",
# don't call get_model but rather get_ensemble_model
arch_list=[
("passt_s_swa_p16_128_ap476", 10, 10),
("passt_s_swa_p16_128_ap4761", 10, 10),
("passt_s_p16_128_ap472", 10, 10),
("passt_s_p16_s12_128_ap470", 12, 12),
("passt_s_swa_p16_s12_128_ap473", 12, 12),
("passt_s_p16_s14_128_ap469", 14, 14),
("passt_s_swa_p16_s14_128_ap471", 14, 14),
("passt_s_swa_p16_s16_128_ap473", 16, 16),
("passt_s_p16_s16_128_ap468", 16, 16),
]
)
}
@ex.named_config
def ensemble_4():
'use ensemble of PaSST models pretrained on Audioset with different strides mAP=.4926'
# test with: python ex_audioset.py evaluate_only with trainer.precision=16 ensemble_many
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="ensemble_many", fstride=None,
tstride=None, instance_cmd="get_ensemble_model",
# don't call get_model but rather get_ensemble_model
arch_list=[
("passt_s_swa_p16_128_ap476", 10, 10),
("passt_s_swa_p16_s12_128_ap473", 12, 12),
("passt_s_swa_p16_s14_128_ap471", 14, 14),
("passt_s_swa_p16_s16_128_ap473", 16, 16),
]
)
}
@ex.named_config
def ensemble_5():
'use ensemble of PaSST models pretrained on Audioset with different strides mAP=.49459'
# test with: python ex_audioset.py evaluate_only with trainer.precision=16 ensemble_many
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="ensemble_many", fstride=None,
tstride=None, instance_cmd="get_ensemble_model",
# don't call get_model but rather get_ensemble_model
arch_list=[
("passt_s_swa_p16_128_ap476", 10, 10),
("passt_s_swa_p16_128_ap4761", 10, 10),
("passt_s_swa_p16_s12_128_ap473", 12, 12),
("passt_s_swa_p16_s14_128_ap471", 14, 14),
("passt_s_swa_p16_s16_128_ap473", 16, 16),
]
)
}
@ex.named_config
def ensemble_s16_14():
'use ensemble of two PaSST models pretrained on Audioset with stride 16 and 14 mAP=.48579'
# test with: python ex_audioset.py evaluate_only with trainer.precision=16 ensemble_s16_14
models = {
"net": DynamicIngredient("models.passt.model_ing", arch="ensemble_s16", fstride=None,
tstride=None, instance_cmd="get_ensemble_model",
# don't call get_model but rather get_ensemble_model
arch_list=[
("passt_s_swa_p16_s14_128_ap471", 14, 14),
("passt_s_swa_p16_s16_128_ap473", 16, 16),
]
)
}
@ex.named_config
def dynamic_roll():
# dynamically roll the spectrograms/waveforms
# updates the dataset config
basedataset = dict(roll=True, roll_conf=dict(axis=1, shift_range=10000)
)
# extra commands
@ex.command
def test_loaders_train_speed():
# test how fast data is being loaded from the data loaders.
itr = ex.datasets.training.get_iter()
import time
start = time.time()
print("hello")
for i, b in enumerate(itr):
if i % 20 == 0:
print(f"{i}/{len(itr)}", end="\r")
end = time.time()
print("totoal time:", end - start)
start = time.time()
print("retry:")
for i, b in enumerate(itr):
if i % 20 == 0:
print(f"{i}/{len(itr)}", end="\r")
end = time.time()
print("totoal time:", end - start)