Changeset 9cf2833


Ignore:
Timestamp:
May 22, 2005, 1:50:49 PM (19 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:
23a44c1
Parents:
edca23f
Message:

evaluate doubled detection
evaluate doubled detection

Location:
python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/aubio/onsetcompare.py

    redca23f r9cf2833  
    2828from numarray import *
    2929
    30 def onset_roc(la, lb, eps):
    31     """ thanks to nicolas wack for the rewrite"""
    32     """ compute differences between two lists """
    33     """ feature: scalable to huge lists """
    34     n, m = len(la), len(lb)
    35     if m == 0 :
    36         return 0,0,0,n,0
    37     missed, bad = 0, 0
    38     # find missed ones first
    39     for x in la:
     30def onset_roc(ltru, lexp, eps):
     31    """ compute differences between two lists
     32          orig = hits + missed + merged
     33          expc = hits + bad + doubled
     34        returns orig, missed, merged, expc, bad, doubled
     35    """
     36    orig, expc = len(ltru), len(lexp)
     37    # if lexp is empty
     38    if expc == 0 : return orig,orig,0,0,0,0
     39    missed, bad, doubled, merged = 0, 0, 0, 0
     40    # find missed and doubled ones first
     41    for x in ltru:
    4042        correspond = 0
    41         for y in lb:
    42             if abs(x-y) <= eps:
    43                 correspond += 1
    44         if correspond == 0:
    45             missed += 1
    46     # then look for bad ones
    47     for y in lb:
     43        for y in lexp:
     44            if abs(x-y) <= eps:    correspond += 1
     45        if correspond == 0:        missed += 1
     46        elif correspond > 1:       doubled += correspond - 1
     47    # then look for bad and merged ones
     48    for y in lexp:
    4849        correspond = 0
    49         for x in la:
    50             if abs(x-y) <= eps:
    51                correspond += 1
    52         if correspond == 0:
    53             bad += 1
    54     ok    = n - missed
    55     hits  = m - bad
    56     # at this point, we must have ok = hits. if not we had
    57     #   - a case were one onset counted for two labels (ok>hits)
    58     #   - a case were one labels matched two onsets (hits>ok)
    59     # bad hack for now (fails if both above cases have happened):
    60     if ok > hits: bad += ok-hits; ok = hits
    61     if hits > ok: missed += hits-ok; hits = ok
    62     total = n
    63     return ok,bad,missed,total,hits
    64    
    65    
     50        for x in ltru:
     51            if abs(x-y) <= eps:    correspond += 1
     52        if correspond == 0:        bad += 1
     53        elif correspond > 1:       merged += correspond - 1
     54    # check consistancy of the results
     55    assert ( orig - missed - merged == expc - bad - doubled)
     56    return orig, missed, merged, expc, bad, doubled
     57
     58def onset_diffs(ltru, lexp, eps):
     59    """ compute differences between two lists
     60          orig = hits + missed + merged
     61          expc = hits + bad + doubled
     62        returns orig, missed, merged, expc, bad, doubled
     63    """
     64    orig, expc = len(ltru), len(lexp)
     65    # if lexp is empty
     66    l = []
     67    if expc == 0 : return l
     68    # find missed and doubled ones first
     69    for x in ltru:
     70        correspond = 0
     71        for y in lexp:
     72            if abs(x-y) <= eps:    l.append(y-x)
     73    # return list of diffs
     74    return l
     75
    6676def notes_roc (la, lb, eps):
    6777    """ creates a matrix of size len(la)*len(lb) then look for hit and miss
     
    98108   
    99109    return l
    100 
    101 """
    102 def onset_roc (la, lb, eps):
    103     \"\"\" build a matrix of all possible differences between two lists \"\"\"
    104     \"\"\" bug: not scalable to huge lists \"\"\"
    105         n, m        = len(la), len(lb)
    106     if m ==0 :
    107         return 0,0,0,n,0
    108         missed, bad = 0, 0
    109         x           = resize(la[:],(m,n))
    110         y           = transpose(resize(lb[:],(n,m)))
    111         teps        = (abs(x-y) <= eps)
    112         resmis      = add.reduce(teps,axis = 0)
    113         for i in range(n) :
    114         if resmis[i] == 0:
    115             missed += 1
    116     resbad = add.reduce(teps,axis=1)
    117     for i in range(m) :
    118         if resbad[i] == 0:
    119             bad += 1
    120     ok    = n - missed
    121     hits  = m - bad
    122     total = n
    123     return ok,bad,missed,total,hits
    124 """
    125 
  • python/aubioonset

    redca23f r9cf2833  
    3636                          action="store", dest="outplot", default=None,
    3737                          help="be quiet [default=None]")
     38        parser.add_option("-M","--mintol",
     39                          action="store", dest="mintol", default=-70,
     40                          help="mintol [default=0.48]")
    3841        (options, args) = parser.parse_args()
    3942        if not len(args):
     
    5053#onsets = getonsets(filename,threshold,silence,mode=options.mode)
    5154onsets = getonsetscausal(filename,threshold,silence,mode=options.mode)
    52 for i in onsets: print i*512./44100.
     55
     56# print all
     57#for i in onsets: print i*512./44100.
     58# prune doubled
     59last = -10.
     60mintol   = float(options.mintol)
     61for i in onsets:
     62        new = i*512./44100.
     63        if (new - last > mintol): print "%f" % new
     64        last = new
Note: See TracChangeset for help on using the changeset viewer.