Changeset 83c6734 for python/test/bench
- Timestamp:
- Feb 20, 2006, 12:37:53 PM (19 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- a7880d9
- Parents:
- 79c04d8
- Location:
- python/test/bench/onset
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/test/bench/onset/Makefile.am
r79c04d8 r83c6734 3 3 export LD_LIBRARY_PATH=$(BASEDIR)/src/.libs:$(BASEDIR)/ext/.libs 4 4 5 SOURCE = \ 6 /archives/samples/DB/PercussivePhrases/CM18/Samba_Audio \ 5 DETAILSOURCE = \ 7 6 /var/tmp/Onset-Mirex2005/poly_pitched \ 8 7 /var/tmp/Onset-Mirex2005/solo_bars_and_bells \ 9 /var/tmp/Onset-Mirex2005/solo_brass \10 8 /var/tmp/Onset-Mirex2005/solo_drums \ 11 9 /var/tmp/Onset-Mirex2005/solo_plucked_strings \ … … 13 11 /var/tmp/Onset-Mirex2005/solo_sustained_strings \ 14 12 /var/tmp/Onset-Mirex2005/solo_winds \ 15 /var/tmp/Onset-Mirex2005/complex \ 16 /var/tmp/Onset-Mirex2005 13 /var/tmp/Onset-Mirex2005/complex 17 14 18 test-aubiocut: $(patsubst %, %.aubiocut, $(SOURCE)) 15 SOURCE = /var/tmp/Onset-Mirex2005 16 17 TESTSOURCE = \ 18 /var/tmp/Onset-Mirex2005/solo_bars_and_bells \ 19 /var/tmp/Onset-Mirex2005/solo_winds \ 20 /archives/samples/DB/PercussivePhrases/CM18/Samba_Audio 21 22 test-aubiocut: $(patsubst %, %.aubiocut, $(TESTSOURCE)) 23 test-aubiodelay: $(patsubst %, %.aubiodelay, $(TESTSOURCE)) 24 test-aubiowindow: $(patsubst %, %.aubiowindow, $(TESTSOURCE)) 25 26 final-aubiocut: $(patsubst %, %.aubiocut, $(DETAILSOURCE) $(SOURCE)) 27 final-aubiodelay: $(patsubst %, %.aubiodelay, $(SOURCE)) 28 final-aubiowindow: $(patsubst %, %.aubiowindow, $(SOURCE)) 19 29 20 30 %.aubiocut: % 21 31 rm -f `basename $<`.aubiocut 22 32 ./bench-onset $< | tee `basename $<`.aubiocut 23 diff `basename $<`.aubiocut.ref `basename $<`.aubiocut 33 -diff `basename $<`.aubiocut.ref `basename $<`.aubiocut 34 35 %.aubiodelay: % 36 rm -f `basename $@` 37 ./bench-delay $< | tee `basename $@` 38 -diff `basename $@`.ref `basename $@` 39 40 %.aubiowindow: % 41 rm -f `basename $@` 42 ./bench-window $< | tee `basename $@` 43 -diff `basename $@`.ref `basename $@` -
python/test/bench/onset/bench-onset
r79c04d8 r83c6734 1 1 #! /usr/bin/python 2 2 3 from aubio.bench.node import *4 3 from aubio.tasks import * 5 4 5 from benchonset import mmean, stdev, benchonset 6 6 7 8 9 def mmean(l): 10 return sum(l)/float(len(l)) 11 12 def stdev(l): 13 smean = 0 14 lmean = mmean(l) 15 for i in l: 16 smean += (i-lmean)**2 17 smean *= 1. / len(l) 18 return smean**.5 19 20 class benchonset(bench): 21 22 """ list of values to store per file """ 23 valuenames = ['orig','missed','Tm','expc','bad','Td'] 24 """ list of lists to store per file """ 25 valuelists = ['l','labs'] 26 """ list of values to print per dir """ 27 printnames = [ 'mode', 'thres', 'dist', 'prec', 'recl', 28 'Ttrue', 'Tfp', 'Tfn', 'Tm', 'Td', 29 'aTtrue', 'aTfp', 'aTfn', 'aTm', 'aTd', 30 'mean', 'smean', 'amean', 'samean'] 31 32 """ per dir """ 33 formats = {'mode': "%12s" , 'thres': "%5.4s", 34 'dist': "%5.4s", 'prec': "%5.4s", 'recl': "%5.4s", 35 'Ttrue': "%5.4s", 'Tfp': "%5.4s", 'Tfn': "%5.4s", 36 'Tm': "%5.4s", 'Td': "%5.4s", 37 'aTtrue':"%5.4s", 'aTfp': "%5.4s", 'aTfn': "%5.4s", 38 'aTm': "%5.4s", 'aTd': "%5.4s", 39 'mean': "%5.40s", 'smean': "%5.40s", 40 'amean': "%5.40s", 'samean': "%5.40s"} 41 42 def dir_eval(self): 43 """ evaluate statistical data over the directory """ 44 totaltrue = sum(self.v['expc'])-sum(self.v['bad'])-sum(self.v['Td']) 45 totalfp = sum(self.v['bad'])+sum(self.v['Td']) 46 totalfn = sum(self.v['missed'])+sum(self.v['Tm']) 47 self.P = 100*float(totaltrue)/max(totaltrue + totalfp,1) 48 self.R = 100*float(totaltrue)/max(totaltrue + totalfn,1) 49 if self.R < 0: self.R = 0 50 self.F = 2.* self.P*self.R / max(float(self.P+self.R),1) 51 N = float(len(self.reslist)) 52 self.v['mode'] = self.params.onsetmode 53 self.v['thres'] = self.params.threshold 54 self.v['thres'] = "%2.3f" % self.params.threshold 55 self.v['dist'] = "%2.3f" % self.F 56 self.v['prec'] = "%2.3f" % self.P 57 self.v['recl'] = "%2.3f" % self.R 58 self.v['Ttrue'] = totaltrue 59 self.v['Tfp'] = totalfp 60 self.v['Tfn'] = totalfn 61 self.v['aTtrue'] = totaltrue/N 62 self.v['aTfp'] = totalfp/N 63 self.v['aTfn'] = totalfn/N 64 self.v['aTm'] = sum(self.v['Tm'])/N 65 self.v['aTd'] = sum(self.v['Td'])/N 66 self.v['Tm'] = sum(self.v['Tm']) 67 self.v['Td'] = sum(self.v['Td']) 68 self.v['mean'] = mmean(self.v['l']) 69 self.v['smean'] = stdev(self.v['l']) 70 self.v['amean'] = mmean(self.v['labs']) 71 self.v['samean'] = stdev(self.v['labs']) 7 class mybenchonset(benchonset): 72 8 73 9 def run_bench(self,modes=['dual'],thresholds=[0.5]): 74 self.modes = modes10 from os.path import dirname,basename 75 11 self.thresholds = thresholds 76 12 self.pretty_titles() 77 for mode in self.modes: 13 d,e,f = [],[],[] 14 for mode in modes: 15 self.vlist = [] 78 16 self.params.onsetmode = mode 79 17 for threshold in self.thresholds: … … 83 21 self.pretty_print() 84 22 #print self.v 23 self.vlist.append(self.v) 24 self.plotroc(d) 25 self.plotfmeas(e) 26 self.plotpr(f) 27 #print vlist 28 #self.plotplotroc(d) 29 #self.plotplotfmeas(e) 30 #self.plotplotpr(f) 31 outplot = basename(self.datadir) 32 for ext in ("png","svg","ps"): 33 self.plotplotroc(d,outplot=outplot,extension=ext) 34 self.plotplotfmeas(e,outplot=outplot,extension=ext) 35 self.plotplotpr(f,outplot=outplot,extension=ext) 36 85 37 86 38 def auto_learn(self,modes=['dual'],thresholds=[0.1,1.5]): … … 107 59 108 60 for i in range(steps): 61 self.params.localmin = True 62 self.params.delay = 1. 63 self.dir_exec() 64 self.dir_eval() 109 65 self.params.threshold = ( lesst + topt ) * .5 110 66 self.dir_exec() … … 170 126 if len(sys.argv) > 1: datapath = sys.argv[1] 171 127 else: print "ERR: a path is required"; sys.exit(1) 172 modes = ['complex', 'energy', 'phase', 'specdiff', 'kl', 'mkl', 'dual'] 173 #modes = [ 'mkl' ] 128 modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] 174 129 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] 175 #thresholds = [1.5] 130 #modes = [ 'hfc' ] 131 #thresholds = [0.1, 1.5] 176 132 177 133 #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') 178 134 respath = '/var/tmp/DB-testings' 179 135 180 benchonset = benchonset(datapath,respath,checkres=True,checkanno=True)136 benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) 181 137 benchonset.params = taskparams() 182 138 benchonset.task = taskonset
Note: See TracChangeset
for help on using the changeset viewer.