From: Paul Brossier Date: Fri, 17 Feb 2006 13:14:34 +0000 (+0000) Subject: remove gettruth from onset, add rocloc evaluation mode X-Git-Tag: 0.4.0-beta1~1305 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=4045ba4b18c20abf9aa3cda54416e1b0d8b6cd96;p=aubio.git remove gettruth from onset, add rocloc evaluation mode remove gettruth from onset, add rocloc evaluation mode --- diff --git a/python/aubio/tasks.py b/python/aubio/tasks.py index c67b20ca..49fd5b7e 100644 --- a/python/aubio/tasks.py +++ b/python/aubio/tasks.py @@ -377,40 +377,34 @@ class taskonset(task): now = 0 return now, val - def gettruth(self): - from os.path import isfile - ftru = '.'.join(self.input.split('.')[:-1]) - ftru = '.'.join((ftru,'txt')) - if isfile(ftru): return ftru - else: return - def eval(self,lres): + def eval(self,inputdata,ftru,mode='roc',vmode=''): from txtfile import read_datafile - from onsetcompare import onset_roc - amode = 'roc' - vmode = 'verbose' - vmode = '' - ftru = self.gettruth() - if not ftru: - print "ERR: no truth file found" - return + from onsetcompare import onset_roc, onset_diffs, onset_rocloc ltru = read_datafile(ftru,depth=0) - for i in range(len(lres)): lres[i] = lres[i][0]*self.params.step + lres = [] + for i in range(len(inputdata)): lres.append(inputdata[i][0]*self.params.step) if vmode=='verbose': - print "Running with mode %s" % self.params.mode, + print "Running with mode %s" % self.params.onsetmode, print " and threshold %f" % self.params.threshold, - print " on file", input + print " on file", self.input #print ltru; print lres - if amode == 'localisation': + if mode == 'local': l = onset_diffs(ltru,lres,self.params.tol) mean = 0 for i in l: mean += i - if len(l): print "%.3f" % (mean/len(l)) - else: print "?0" - elif amode == 'roc': + if len(l): mean = "%.3f" % (mean/len(l)) + else: mean = "?0" + return l, mean + elif mode == 'roc': self.orig, self.missed, self.merged, \ self.expc, self.bad, self.doubled = \ onset_roc(ltru,lres,self.params.tol) + elif mode == 'rocloc': + self.orig, self.missed, self.merged, \ + self.expc, self.bad, self.doubled, \ + self.l, self.mean = \ + onset_rocloc(ltru,lres,self.params.tol) def plot(self,onsets,ofunc): import Gnuplot, Gnuplot.funcutils