Changeset 6ae3a77 for python/test/bench/onset/bench-onset
- Timestamp:
- Feb 23, 2006, 3:23:30 AM (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:
- ee7b9da
- Parents:
- a12563ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/test/bench/onset/bench-onset
ra12563ea r6ae3a77 11 11 self.thresholds = thresholds 12 12 self.pretty_titles() 13 d,e,f =[],[],[]13 d,e,f,g = [],[],[],[] 14 14 for mode in modes: 15 15 self.vlist = [] 16 16 self.params.onsetmode = mode 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 17 24 for threshold in self.thresholds: 18 25 self.params.threshold = threshold 19 self.dir_exec() 20 self.dir_eval() 21 self.pretty_print() 22 #print self.v 26 self.dir_eval_print() 23 27 self.vlist.append(self.v) 24 28 self.plotroc(d) 25 29 self.plotfmeas(e) 26 30 self.plotpr(f) 27 #print vlist 31 #self.plothistcat(g) 32 33 34 28 35 #self.plotplotroc(d) 29 36 #self.plotplotfmeas(e) … … 34 41 self.plotplotfmeas(e,outplot=outplot,extension=ext) 35 42 self.plotplotpr(f,outplot=outplot,extension=ext) 36 37 38 def auto_learn(self,modes=['dual'],thresholds=[0.1,1.5]): 39 """ simple dichotomia like algorithm to optimise threshold """ 40 self.modes = modes 41 self.pretty_titles() 42 for mode in self.modes: 43 steps = 11 44 lesst = thresholds[0] 45 topt = thresholds[1] 46 self.params.onsetmode = mode 47 48 self.params.threshold = topt 49 self.dir_exec() 50 self.dir_eval() 51 self.pretty_print() 52 topF = self.F 53 54 self.params.threshold = lesst 55 self.dir_exec() 56 self.dir_eval() 57 self.pretty_print() 58 lessF = self.F 59 60 for i in range(steps): 61 self.params.localmin = True 62 self.params.delay = 1. 63 self.dir_exec() 64 self.dir_eval() 65 self.params.threshold = ( lesst + topt ) * .5 66 self.dir_exec() 67 self.dir_eval() 68 self.pretty_print() 69 if self.F == 100.0 or self.F == topF: 70 print "assuming we converged, stopping" 71 break 72 #elif abs(self.F - topF) < 0.01 : 73 # print "done converging" 74 # break 75 if topF < self.F: 76 #lessF = topF 77 #lesst = topt 78 topF = self.F 79 topt = self.params.threshold 80 elif lessF < self.F: 81 lessF = self.F 82 lesst = self.params.threshold 83 if topt == lesst: 84 lesst /= 2. 85 86 def auto_learn2(self,modes=['dual'],thresholds=[0.00001,1.0]): 87 """ simple dichotomia like algorithm to optimise threshold """ 88 self.modes = modes 89 self.pretty_titles([]) 90 for mode in self.modes: 91 steps = 10 92 step = 0.4 93 self.params.onsetmode = mode 94 self.params.threshold = thresholds[0] 95 cur = 0 96 97 for i in range(steps): 98 self.dir_exec() 99 self.dir_eval() 100 self.pretty_print() 101 new = self.P 102 if self.R == 0.0: 103 #print "Found maximum, highering" 104 step /= 2. 105 self.params.threshold -= step 106 elif new == 100.0: 107 #print "Found maximum, highering" 108 step *= .99 109 self.params.threshold += step 110 elif cur > new: 111 #print "lower" 112 step /= 2. 113 self.params.threshold -= step 114 elif cur < new: 115 #print "higher" 116 step *= .99 117 self.params.threshold += step 118 else: 119 print "Assuming we converged" 120 break 121 cur = new 122 43 #self.plotplothistcat(g,outplot=outplot,extension=ext) 123 44 124 45 if __name__ == "__main__": … … 129 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] 130 51 #modes = [ 'hfc' ] 131 #thresholds = [0. 1, 1.5]52 #thresholds = [0.5] 132 53 133 54 #datapath = "%s%s" % (DATADIR,'/onset/DB/*/')
Note: See TracChangeset
for help on using the changeset viewer.