Showing the changes to python (2 of 2 files). Show all
Unified · Split
| @@ -70,14 +70,15 @@ def act_on_results (action,datapath,respath,filter='d'): · 69 unmodified lines | |||
| 70 | s = re.split(datapath, i ,maxsplit=1)[1] | 70 | s = re.split(datapath, i ,maxsplit=1)[1] |
| 71 | action("%s%s%s"%(respath,'/',s)) | 71 | action("%s%s%s"%(respath,'/',s)) |
| 72 | 72 | ||
| 73 | class task: | 73 | class bench: |
| 74 | 74 | ||
| 75 | def __init__(self,datadir,resdir): | 75 | def __init__(self,datadir,resdir,checkres=False,checkanno=False): |
| 76 | self.datadir = datadir | 76 | self.datadir = datadir |
| 77 | self.resdir = resdir | 77 | self.resdir = resdir |
| 78 | print "Checking data directory", self.datadir | 78 | print "Checking data directory", self.datadir |
| 79 | self.checkdata() | 79 | self.checkdata() |
| 80 | self.checkres() | 80 | if checkanno: self.checkanno() |
| 81 | if checkres: self.checkres() | ||
| 81 | 82 | ||
| 82 | def checkdata(self): | 83 | def checkdata(self): |
| 83 | print "Listing directories in data directory", | 84 | print "Listing directories in data directory", |
| @@ -88,6 +89,8 @@ class task: · 4 unmodified lines | |||
| 88 | self.sndlist = list_snd_files(self.datadir) | 89 | self.sndlist = list_snd_files(self.datadir) |
| 89 | print " (%d elements)" % len(self.sndlist) | 90 | print " (%d elements)" % len(self.sndlist) |
| 90 | #for each in self.sndlist: print each | 91 | #for each in self.sndlist: print each |
| 92 | |||
| 93 | def checkanno(self): | ||
| 91 | print "Listing annotations in data directory", | 94 | print "Listing annotations in data directory", |
| 92 | self.reslist = list_res_files(self.datadir) | 95 | self.reslist = list_res_files(self.datadir) |
| 93 | print " (%d elements)" % len(self.reslist) | 96 | print " (%d elements)" % len(self.reslist) |
| @@ -101,3 +104,9 @@ class task: · 7 unmodified lines | |||
| 101 | def checkres(self): | 104 | def checkres(self): |
| 102 | print "Creating results directory" | 105 | print "Creating results directory" |
| 103 | act_on_results(mkdir,self.datadir,self.resdir,filter='d') | 106 | act_on_results(mkdir,self.datadir,self.resdir,filter='d') |
| 107 | |||
| 108 | def pretty_print(self,values): | ||
| 109 | for i in range(len(values)): | ||
| 110 | print self.formats[i] % values[i], | ||
| 111 | |||
| 112 | |||
| @@ -17,13 +17,8 @@ class onset_parameters: · 16 unmodified lines | |||
| 17 | self.threshold = 0.1 | 17 | self.threshold = 0.1 |
| 18 | self.mode = 'dual' | 18 | self.mode = 'dual' |
| 19 | 19 | ||
| 20 | class taskonset(task): | 20 | class benchonset(bench): |
| 21 | 21 | ||
| 22 | def pretty_print(self,values): | ||
| 23 | for i in range(len(values)): | ||
| 24 | print self.formats[i] % values[i], | ||
| 25 | |||
| 26 | |||
| 27 | def compute_results(self): | 22 | def compute_results(self): |
| 28 | self.P = 100*float(self.expc-self.missed-self.merged)/(self.expc-self.missed-self.merged + self.bad+self.doubled) | 23 | self.P = 100*float(self.expc-self.missed-self.merged)/(self.expc-self.missed-self.merged + self.bad+self.doubled) |
| 29 | self.R = 100*float(self.expc-self.missed-self.merged)/(self.expc-self.missed-self.merged + self.missed+self.merged) | 24 | self.R = 100*float(self.expc-self.missed-self.merged)/(self.expc-self.missed-self.merged + self.missed+self.merged) |
| @@ -157,19 +152,19 @@ thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5] · 127 unmodified lines | |||
| 157 | datapath = "%s%s" % (DATADIR,'/onset/DB/PercussivePhrases/RobertRich') | 152 | datapath = "%s%s" % (DATADIR,'/onset/DB/PercussivePhrases/RobertRich') |
| 158 | respath = '/var/tmp/DB-testings' | 153 | respath = '/var/tmp/DB-testings' |
| 159 | 154 | ||
| 160 | taskonset = taskonset(datapath,respath) | 155 | benchonset = benchonset(datapath,respath,checkres=True,checkanno=True) |
| 161 | 156 | ||
| 162 | taskonset.params = onset_parameters() | 157 | benchonset.params = onset_parameters() |
| 163 | 158 | ||
| 164 | taskonset.titles = [ 'mode', 'thres', 'orig', 'expc', 'missd', 'mergd', | 159 | benchonset.titles = [ 'mode', 'thres', 'orig', 'expc', 'missd', 'mergd', |
| 165 | 'bad', 'doubl', 'corrt', 'GD', 'FP', 'GD-merged', 'FP-pruned', | 160 | 'bad', 'doubl', 'corrt', 'GD', 'FP', 'GD-merged', 'FP-pruned', |
| 166 | 'prec', 'recl', 'dist' ] | 161 | 'prec', 'recl', 'dist' ] |
| 167 | taskonset.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s", | 162 | benchonset.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s", |
| 168 | "| %6s", "| %6s", "| %6s", "| %8s", "| %8s", "| %8s", "| %8s", | 163 | "| %6s", "| %6s", "| %6s", "| %8s", "| %8s", "| %8s", "| %8s", |
| 169 | "| %6s", "| %6s", "| %6s"] | 164 | "| %6s", "| %6s", "| %6s"] |
| 170 | 165 | ||
| 171 | #taskonset.run_bench(modes=modes,thresholds=thresholds) | 166 | #benchonset.run_bench(modes=modes,thresholds=thresholds) |
| 172 | taskonset.auto_learn(modes=modes) | 167 | benchonset.auto_learn(modes=modes) |
| 173 | 168 | ||
| 174 | # gatherdata | 169 | # gatherdata |
| 175 | #act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'') | 170 | #act_on_data(my_print,datapath,respath,suffix='.txt',filter='f -name \'*.wav\'') |