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

How can I find the Average Precision and Average Recall from the eval.py file? #352

Closed
AtriSaxena opened this issue May 21, 2019 · 10 comments

Comments

@AtriSaxena
Copy link

AtriSaxena commented May 21, 2019

I want to find the Average Recall and Precision values. I have tried, printing these value Code link
rec = tp / float(npos) prec = tp / np.maximum(tp + fp, np.finfo(np.float64).eps)

But it is printing long list of values which i am not able to get.

@jiawen7777
Copy link

I meet the same problem, have you solved it? Thank you very much

@AtriSaxena
Copy link
Author

I have solved but it was long time ago. I don't remember but tell me more about the problem you are getting? I have used custom data in VOC format.
Can you show me error you are getting?

@wallcuber
Copy link

wallcuber commented Apr 19, 2020

I have the same question. The rec and prec is so long. How did you deal with this?
image

I have solved but it was long time ago. I don't remember but tell me more about the problem you are getting? I have used custom data in VOC format.
Can you show me error you are getting?

@wallcuber
Copy link

I have solved but it was long time ago. I don't remember but tell me more about the problem you are getting? I have used custom data in VOC format.
Can you show me error you are getting?

Does rec[-1] and prec[-1] are the final average Recall and Precision ?

@AtriSaxena
Copy link
Author

AtriSaxena commented Apr 26, 2020

After this Link I have added this code.

rec += [rec] prec += [prec]

And also define rec = [] and prec = []

Than you can print
print('Average Recall = {:.4f}'.format(np.mean(rec))) print('Average Precision = {:.4f}'.format(np.mean(prec)))

        filename = get_voc_results_file_template(set_type, cls)

        rec, prec, ap = voc_eval(
           filename, annopath, imgsetpath.format(set_type), cls, cachedir,
           ovthresh=0.5, use_07_metric=use_07_metric)
        aps += [ap]
        rec += [rec]
        prec += [prec]
        print('AP for {} = {:.4f}'.format(cls, ap))
        with open(os.path.join(output_dir, cls + '_pr.pkl'), 'wb') as f:
            pickle.dump({'rec': rec, 'prec': prec, 'ap': ap}, f)
    print('Mean AP = {:.4f}'.format(np.mean(aps)))
    print('Average Recall = {:.4f}'.format(np.mean(rec)))
    print('Average Precision = {:.4f}'.format(np.mean(prec)))```

The whole loop will be something like this. 
If you are using Custom dataset than you need more changes. 
If this solves tells me.

@jiawen7777
Copy link

jiawen7777 commented Apr 27, 2020 via email

@jiawen7777
Copy link

I think I might miss your reply before
I just saw the reply this morning, Sorry

@AtriSaxena
Copy link
Author

Yeah, I replied last night. I was little busy. Great, it helped you.

AtriSaxena added a commit to AtriSaxena/ssd.pytorch that referenced this issue Apr 27, 2020
As many people looking to find the Average Recall and Precision like in issue amdegroot#352 It's better we should add this in evaluation code.
@zyx961022
Copy link

ValueError: non-broadcastable output operand with shape (11725,) doesn't match the broadcast shape (1,11725)
image

Why do I report this error and how to solve it? please help me, thank you!

@decoli
Copy link

decoli commented Jul 15, 2020

ValueError: non-broadcastable output operand with shape (11725,) doesn't match the broadcast shape (1,11725)
image

Why do I report this error and how to solve it? please help me, thank you!

Have you solved the problem? I encountered the same problem as you.
Then I referred aps += [ap] and @AtriSaxena 's comment, I added these codes:

...
recs = []
precs = []
...
        ...
        recs += [rec]
        precs += [prec]
        ...
    ...
    print('Average Recall = {:.4f}'.format(np.mean(recs)))
    print('Average Precision = {:.4f}'.format(np.mean(precs)))
    ...

This will work, but I’m not sure if it’s right. What do you think?

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

5 participants