[4cc9fe5] | 1 | #! /usr/bin/python |
---|
| 2 | |
---|
[4f4a8a4] | 3 | from aubio.tasks import * |
---|
[75139a9] | 4 | |
---|
[83c6734] | 5 | from benchonset import mmean, stdev, benchonset |
---|
[e968939] | 6 | |
---|
[83c6734] | 7 | class mybenchonset(benchonset): |
---|
[75139a9] | 8 | |
---|
| 9 | def run_bench(self,modes=['dual'],thresholds=[0.5]): |
---|
[83c6734] | 10 | from os.path import dirname,basename |
---|
[75139a9] | 11 | self.thresholds = thresholds |
---|
[e968939] | 12 | self.pretty_titles() |
---|
[6ae3a77] | 13 | d,e,f,g = [],[],[],[] |
---|
[83c6734] | 14 | for mode in modes: |
---|
| 15 | self.vlist = [] |
---|
[4f4a8a4] | 16 | self.params.onsetmode = mode |
---|
[6ae3a77] | 17 | #self.params.localmin = True |
---|
| 18 | self.params.delay = 2. |
---|
| 19 | self.params.bufsize = 1024 |
---|
| 20 | self.params.hopsize = 256 |
---|
| 21 | self.params.step = float(self.params.hopsize)/float(self.params.samplerate) |
---|
| 22 | #self.params.mintol = 8. |
---|
| 23 | |
---|
[75139a9] | 24 | for threshold in self.thresholds: |
---|
| 25 | self.params.threshold = threshold |
---|
[6ae3a77] | 26 | self.dir_eval_print() |
---|
[83c6734] | 27 | self.vlist.append(self.v) |
---|
| 28 | self.plotroc(d) |
---|
| 29 | self.plotfmeas(e) |
---|
| 30 | self.plotpr(f) |
---|
[6ae3a77] | 31 | #self.plothistcat(g) |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | |
---|
[83c6734] | 35 | #self.plotplotroc(d) |
---|
| 36 | #self.plotplotfmeas(e) |
---|
| 37 | #self.plotplotpr(f) |
---|
| 38 | outplot = basename(self.datadir) |
---|
| 39 | for ext in ("png","svg","ps"): |
---|
| 40 | self.plotplotroc(d,outplot=outplot,extension=ext) |
---|
| 41 | self.plotplotfmeas(e,outplot=outplot,extension=ext) |
---|
| 42 | self.plotplotpr(f,outplot=outplot,extension=ext) |
---|
[6ae3a77] | 43 | #self.plotplothistcat(g,outplot=outplot,extension=ext) |
---|
[75139a9] | 44 | |
---|
[4f4a8a4] | 45 | if __name__ == "__main__": |
---|
| 46 | import sys |
---|
| 47 | if len(sys.argv) > 1: datapath = sys.argv[1] |
---|
| 48 | else: print "ERR: a path is required"; sys.exit(1) |
---|
[83c6734] | 49 | modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] |
---|
[e968939] | 50 | thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2] |
---|
[83c6734] | 51 | #modes = [ 'hfc' ] |
---|
[6ae3a77] | 52 | #thresholds = [0.5] |
---|
[4f4a8a4] | 53 | |
---|
| 54 | #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') |
---|
| 55 | respath = '/var/tmp/DB-testings' |
---|
| 56 | |
---|
[83c6734] | 57 | benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) |
---|
[4f4a8a4] | 58 | benchonset.params = taskparams() |
---|
| 59 | benchonset.task = taskonset |
---|
[e968939] | 60 | benchonset.valuesdict = {} |
---|
[4f4a8a4] | 61 | |
---|
| 62 | try: |
---|
[e968939] | 63 | #benchonset.auto_learn2(modes=modes) |
---|
| 64 | benchonset.run_bench(modes=modes,thresholds=thresholds) |
---|
[4f4a8a4] | 65 | except KeyboardInterrupt: |
---|
| 66 | sys.exit(1) |
---|