layumi / AICIty-reID-2020

:red_car: The 1st Place Submission to AICity Challenge 2020 re-id track (Baidu-UTS submission)
MIT License
449 stars 110 forks source link

mAP calculation #37

Closed vokhidovhusan closed 2 years ago

vokhidovhusan commented 3 years ago

Hello @layumi I didn't quite understand your mAP calculation. Is there any explanation you could share me? Why are you adding olp_precision even though every ap is being summed up And also I didn't get why we should divide by 2 before sum them up (here: ap = ap + d_recall*(old_precision + precision)/2)

def compute_mAP(index, good_index, junk_index):
    ap = 0
    cmc = torch.IntTensor(len(index)).zero_()
    if good_index.size==0:   # if empty
        cmc[0] = -1
        return ap,cmc

    # remove junk_index
    mask = np.in1d(index, junk_index, invert=True)
    index = index[mask]

    # find good_index index
    ngood = len(good_index)
    mask = np.in1d(index, good_index)
    rows_good = np.argwhere(mask==True)
    rows_good = rows_good.flatten()

    cmc[rows_good[0]:] = 1
    for i in range(ngood):
        d_recall = 1.0/ngood
        precision = (i+1)*1.0/(rows_good[i]+1)
        if rows_good[i]!=0:
            old_precision = i*1.0/rows_good[i]
        else:
            old_precision=1.0
        ap = ap + d_recall*(old_precision + precision)/2

    return ap, cmc
layumi commented 3 years ago

Hi It is according to the evaluation code ( cpp) for Oxford Building dataset. https://www.robots.ox.ac.uk/~vgg/data/oxbuildings/compute_ap.cpp