Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mAP calculation #37

Closed
vokhidovhusan opened this issue Mar 18, 2021 · 1 comment
Closed

mAP calculation #37

vokhidovhusan opened this issue Mar 18, 2021 · 1 comment

Comments

@vokhidovhusan
Copy link

vokhidovhusan commented Mar 18, 2021

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
Copy link
Owner

layumi commented Mar 20, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants