Yolov5: when I run test.py, a error happened

Created on 14 Oct 2020  ·  7Comments  ·  Source: ultralytics/yolov5

❔Question

` try:  # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
        from pycocotools.coco import COCO
        from pycocotools.cocoeval import COCOeval
        print('-------1------')

        imgIds = [int(Path(x).stem) for x in dataloader.dataset.img_files]
        print('------2-------')
        cocoGt = COCO(glob.glob('../coco/annotations/instances_val*.json')[0])  # initialize COCO ground truth api
        cocoDt = cocoGt.loadRes(f)  # initialize COCO pred api
        cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
        cocoEval.params.imgIds = imgIds  # image IDs to evaluate
        cocoEval.evaluate()
        cocoEval.accumulate()
        cocoEval.summarize()
        map, map50 = cocoEval.stats[:2]  # update results ([email protected]:0.95, [email protected])
    except Exception as e:
        print('ERROR: pycocotools unable to run: %s' % e)`

------------> COCO mAP with pycocotools... saving detections_val2017_yolov5s_results.json... -------1------ ERROR: pycocotools unable to run: invalid literal for int() with base 10: 'fire1-80'

Additional context

question

All 7 comments

It by default takes image_id as image name, and in COCO format image_id can't be string, it should be an integer.

@adityak2920 You're right, my image_names contains other characters, not just Numbers.How to change the code here if I want to do this?

@xinxin342 pycocotools mAP eval is only intended for COCO data, and only runs with --data coco.yaml. You can rename your yaml to anything else to avoid this soft error.

@xinxin342 pycocotools mAP eval is only intended for COCO data, and only runs with --data coco.yaml. You can rename your yaml to anything else to avoid this soft error.

But what if we want to run the metrics for our data? Any workaround for that?

@rubeea you would need an COCO-format JSON annotations file before anything else if you wanted to use the pycocotool package on your data.

@rubeea you would need an COCO-format JSON annotations file before anything else if you wanted to use the pycocotool package on your data.
Yeah got it running. Thanks

@rubeea @xinxin342 PR #1396 (Increase pycocotools robustness ) may help improve this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

we1pingyu picture we1pingyu  ·  3Comments

zzb1967736495 picture zzb1967736495  ·  4Comments

linhaoqi027 picture linhaoqi027  ·  4Comments

xinxin342 picture xinxin342  ·  3Comments

KangHoyong picture KangHoyong  ·  3Comments