Changeset 4045ba4 for python


Ignore:
Timestamp:
Feb 17, 2006, 2:14:34 PM (18 years ago)
Author:
Paul Brossier <piem@altern.org>
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:
0cd995a
Parents:
8b0595e
Message:

remove gettruth from onset, add rocloc evaluation mode
remove gettruth from onset, add rocloc evaluation mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/tasks.py

    r8b0595e r4045ba4  
    378378                        return now, val
    379379
    380         def gettruth(self):
    381                 from os.path import isfile
    382                 ftru = '.'.join(self.input.split('.')[:-1])
    383                 ftru = '.'.join((ftru,'txt'))
    384                 if isfile(ftru): return ftru
    385                 else:            return
    386 
    387         def eval(self,lres):
     380
     381        def eval(self,inputdata,ftru,mode='roc',vmode=''):
    388382                from txtfile import read_datafile
    389                 from onsetcompare import onset_roc
    390                 amode = 'roc'
    391                 vmode = 'verbose'
    392                 vmode = ''
    393                 ftru = self.gettruth()
    394                 if not ftru:
    395                         print "ERR: no truth file found"
    396                         return
     383                from onsetcompare import onset_roc, onset_diffs, onset_rocloc
    397384                ltru = read_datafile(ftru,depth=0)
    398                 for i in range(len(lres)): lres[i] = lres[i][0]*self.params.step
     385                lres = []
     386                for i in range(len(inputdata)): lres.append(inputdata[i][0]*self.params.step)
    399387                if vmode=='verbose':
    400                         print "Running with mode %s" % self.params.mode,
     388                        print "Running with mode %s" % self.params.onsetmode,
    401389                        print " and threshold %f" % self.params.threshold,
    402                         print " on file", input
     390                        print " on file", self.input
    403391                #print ltru; print lres
    404                 if amode == 'localisation':
     392                if mode == 'local':
    405393                        l = onset_diffs(ltru,lres,self.params.tol)
    406394                        mean = 0
    407395                        for i in l: mean += i
    408                         if len(l): print "%.3f" % (mean/len(l))
    409                         else: print "?0"
    410                 elif amode == 'roc':
     396                        if len(l): mean = "%.3f" % (mean/len(l))
     397                        else: mean = "?0"
     398                        return l, mean
     399                elif mode == 'roc':
    411400                        self.orig, self.missed, self.merged, \
    412401                                self.expc, self.bad, self.doubled = \
    413402                                onset_roc(ltru,lres,self.params.tol)
     403                elif mode == 'rocloc':
     404                        self.orig, self.missed, self.merged, \
     405                                self.expc, self.bad, self.doubled, \
     406                                self.l, self.mean = \
     407                                onset_rocloc(ltru,lres,self.params.tol)
    414408
    415409        def plot(self,onsets,ofunc):
Note: See TracChangeset for help on using the changeset viewer.