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

Error when instanciating a Curves object #21

Closed
patrontheo opened this issue Mar 5, 2024 · 3 comments
Closed

Error when instanciating a Curves object #21

patrontheo opened this issue Mar 5, 2024 · 3 comments

Comments

@patrontheo
Copy link

Describe the bug
I can't instanciate a Curves object.

To Reproduce

from faster_coco_eval import COCO
from faster_coco_eval.extra import Curves

cocoGt = COCO('gt.json')
cocoDt = cocoGt.loadRes('pred.json')

cur = Curves(cocoGt, cocoDt, iou_tresh=0.5, iouType='bbox')

KeyError Traceback (most recent call last)
Cell In[2], line 1
----> 1 cur = Curves(coco_gt, coco_gt, iou_tresh=0.5, iouType='bbox')

File ~/mambaforge/envs/fiftyone/lib/python3.10/site-packages/faster_coco_eval/extra/extra.py:33, in ExtraEval.init(self, cocoGt, cocoDt, iouType, min_score, iou_tresh, recall_count, useCats)
30 assert self.cocoGt is not None, "cocoGt is empty"
32 if (self.cocoGt is not None) and (self.cocoDt is not None):
---> 33 self.evaluate()

File ~/mambaforge/envs/fiftyone/lib/python3.10/site-packages/faster_coco_eval/extra/extra.py:52, in ExtraEval.evaluate(self)
48 cocoEval.params.useCats = int(self.useCats) # Выключение labels
50 self.cocoEval = cocoEval
---> 52 cocoEval.evaluate()
53 cocoEval.accumulate()
55 self.eval = cocoEval.eval

File ~/mambaforge/envs/fiftyone/lib/python3.10/site-packages/faster_coco_eval/core/faster_eval_api.py:54, in COCOeval_faster.evaluate(self)
52 elif p.iouType == "keypoints":
53 computeIoU = self.computeOks
---> 54 self.ious = {
55 (imgId, catId): computeIoU(imgId, catId)
56 for imgId in p.imgIds
57 for catId in catIds
58 } # bottleneck
...
--> 206 inds = np.argsort([-d["score"] for d in dt], kind="mergesort")
207 dt = [dt[i] for i in inds]
208 if len(dt) > p.maxDets[-1]:

KeyError: 'score'

Expected behavior
I expect this command to run without errors.

Additional context
The ground truths and annotation files are the same as in my previous issue (#19).

@MiXaiLL76
Copy link
Owner

MiXaiLL76 commented Mar 6, 2024

I can not reproduce (colab):

> md5sum preds.json
a3e73672a41eeb695daa02cb294b2f12  preds.json
> md5sum gt.json
639c028f1228d12b38dbc556dbab2349  gt.json
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from faster_coco_eval import COCO
>>> from faster_coco_eval.extra import Curves
>>> import faster_coco_eval
>>> faster_coco_eval.__version__
'1.4.3'
>>> cocoGt = COCO('gt.json')
>>> cocoDt = cocoGt.loadRes('preds.json')
>>> cur = Curves(cocoGt, cocoDt, iou_tresh=0.5, iouType='bbox')
>>> cur
<faster_coco_eval.extra.curves.Curves object at 0x7f8684e7bb20>
>>>

Perhaps in your preds not all detections have a score.

inds = np.argsort([-d["score"] for d in dt], kind="mergesort")

Sorts detections by the score parameter. Which should be

@MiXaiLL76
Copy link
Owner

@patrontheo Are there any new examples of the bug? or I close this issue

@patrontheo
Copy link
Author

@MiXaiLL76 I tried again and it works, not sure what triggered the error before, sorry about that. Thanks for your answer :)

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