update samples/test/eval_mAP_on_coco_val/coco_eval.py.
Signed-off-by: jario-jin <jariof@foxmail.com>
This commit is contained in:
parent
5b66234c72
commit
7a01223db4
|
@ -3,23 +3,23 @@ from pycocotools.cocoeval import COCOeval
|
||||||
import os
|
import os
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
path = os.path.abspath(os.path.join(os.getcwd(),"../../.."))
|
path = os.path.abspath(os.path.join(os.getcwd(),"../../.."))
|
||||||
pred_json = 'pd_coco.json'
|
pred_json = 'pd_coco.json'
|
||||||
anno_json = path + '/val2017/gt_coco.json'
|
anno_json = path + '/val2017/gt_coco.json'
|
||||||
|
|
||||||
# use COCO API to load forecast results and annotations
|
# use COCO API to load forecast results and annotations
|
||||||
cocoGt = COCO(anno_json)
|
cocoGt = COCO(anno_json)
|
||||||
cocoDt = cocoGt.loadRes(pred_json)
|
cocoDt = cocoGt.loadRes(pred_json)
|
||||||
|
|
||||||
# create COCO eval object
|
# create COCO eval object
|
||||||
cocoEval = COCOeval(cocoGt, cocoDt,'bbox')
|
cocoEval = COCOeval(cocoGt, cocoDt,'bbox')
|
||||||
|
|
||||||
# assessment
|
# assessment
|
||||||
cocoEval.evaluate()
|
cocoEval.evaluate()
|
||||||
cocoEval.accumulate()
|
cocoEval.accumulate()
|
||||||
cocoEval.summarize()
|
cocoEval.summarize()
|
||||||
|
|
||||||
|
|
||||||
# save results
|
# save results
|
||||||
with open('coco_eval.txt', 'w') as f:
|
with open('coco_eval.txt', 'w') as f:
|
||||||
f.write(str(cocoEval.stats))
|
f.write(str(cocoEval.stats))
|
||||||
|
|
Loading…
Reference in New Issue