-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcoco_instance_evaluation.py
43 lines (36 loc) · 1.24 KB
/
coco_instance_evaluation.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
36
37
38
39
40
41
42
43
"""
Evaluation for COCO val2017:
python ./tools/coco_instance_evaluation.py \
--gt-json-file COCO_GT_JSON \
--dt-json-file COCO_DT_JSON \
--iou-type boundary
"""
import argparse
import os
import numpy as np
from boundary_iou.coco_instance_api.coco import COCO
from boundary_iou.coco_instance_api.cocoeval import COCOeval
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--gt-json-file", default="")
parser.add_argument("--dt-json-file", default="")
parser.add_argument("--iou-type", default="segm")
parser.add_argument("--dilation-ratio", default="0.020", type=float)
parser.add_argument("--lvis", action='store_true')
args = parser.parse_args()
print(args)
annFile = args.gt_json_file
resFile = args.dt_json_file
dilation_ratio = args.dilation_ratio
if args.iou_type == "boundary":
get_boundary = True
else:
get_boundary = False
cocoGt = COCO(annFile, get_boundary=get_boundary, dilation_ratio=dilation_ratio)
cocoDt = cocoGt.loadRes(resFile)
cocoEval = COCOeval(cocoGt, cocoDt, iouType=args.iou_type, dilation_ratio=dilation_ratio)
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
if __name__ == '__main__':
main()