update samples/test/eval_mAP_on_coco_val/coco_eval.py.

Signed-off-by: jario-jin <jariof@foxmail.com>
This commit is contained in:
jario-jin 2023-08-14 01:53:16 +00:00 committed by Gitee
parent 6d0f83b4d3
commit 5c30296b73
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 15 additions and 15 deletions

View File

@ -3,23 +3,23 @@ from pycocotools.cocoeval import COCOeval
import os
if __name__ == '__main__':
path = os.path.abspath(os.path.join(os.getcwd(),"../../.."))
pred_json = 'pd_coco.json'
anno_json = path + '/val2017/instances_val2017.json'
path = os.path.abspath(os.path.join(os.getcwd(),"../../.."))
pred_json = 'pd_coco.json'
anno_json = path + '/val2017/instances_val2017.json'
# use COCO API to load forecast results and annotations
cocoGt = COCO(anno_json)
cocoDt = cocoGt.loadRes(pred_json)
# use COCO API to load forecast results and annotations
cocoGt = COCO(anno_json)
cocoDt = cocoGt.loadRes(pred_json)
# create COCO eval object
cocoEval = COCOeval(cocoGt, cocoDt,'bbox')
# create COCO eval object
cocoEval = COCOeval(cocoGt, cocoDt,'bbox')
# assessment
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
# assessment
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
# save results
with open('coco_eval.txt', 'w') as f:
f.write(str(cocoEval.stats))
# save results
with open('coco_eval.txt', 'w') as f:
f.write(str(cocoEval.stats))