-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathod.py
35 lines (24 loc) · 913 Bytes
/
od.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import argparse
from pycocotools.cocoeval import COCOeval
from pycocotools.coco import COCO
import time
import os
ROOT_DIR = './'
def evaluate_coco(file_name):
# load results in COCO evaluation tool
coco_true = COCO(os.path.join(ROOT_DIR, 'GROUND_TRUTH_COCO_JSON.json'))
coco_pred = coco_true.loadRes(file_name)
coco_eval = COCOeval(coco_true, coco_pred, 'bbox')
coco_eval.evaluate()
coco_eval.accumulate()
coco_eval.summarize()
print(list(coco_eval.stats[:3]) + list(coco_eval.stats[6:8]))
return list(coco_eval.stats[:3]) + list(coco_eval.stats[6:8])
def get_args():
parser = argparse.ArgumentParser(
'Evaluation script for the Object Detection task.')
parser.add_argument('--file_name', type=str, help='Path to the predictions file.')
return parser.parse_args()
if __name__ == '__main__':
opt = get_args()
evaluate_coco(opt.file_name)