Here is my code. However, the result is not 1.
def eval_map(ann_json):
with open(ann_json, "r") as f:
data = json.load(f)
for aa in data["annotations"]:
aa["score"] = 0.8
with open("try_pre.json", 'w') as output_json_file:
json.dump(data["annotations"], output_json_file)
coco_gt = COCO(ann_json)
coco_dt = coco_gt.loadRes("try_pre.json")
coco_eval = COCOeval(coco_gt, coco_dt, 'segm')
coco_eval.evaluate()
coco_eval.accumulate()
coco_eval.summarize()
Here is my code. However, the result is not 1. def eval_map(ann_json):
################## ann_json: {"categories": [{"id": 1, "name": "binary", "supercategory": "binary"}], "images": [{ "id": 0, "file_name": "test.png", "width": 300, "height": 300}], "annotations": [ {"image_id": 0, "bbox": [100,100,200,200], "category_id": 1, "iscrowd": 0, "area": 10000.0, "id": 0, "segmentation": [[100,100,200,100,200,200,100,200]]}, {"image_id": 0, "bbox": [10,10,30,30], "category_id": 1, "iscrowd": 0, "area": 400.0, "id": 1, "segmentation": [[10,10,30,10,30,30,30,10]]} ]}
try_pre.json: [ {"image_id": 0, "bbox": [100, 100, 200, 200], "category_id": 1, "iscrowd": 0, "area": 10000.0, "id": 0, "segmentation": [[100, 100, 200, 100, 200, 200, 100, 200]], "score": 0.8}, {"image_id": 0, "bbox": [10, 10, 30, 30], "category_id": 1, "iscrowd": 0, "area": 400.0, "id": 1, "segmentation": [[10, 10, 30, 10, 30, 30, 30, 10]], "score": 0.8} ]
THE RESULT: Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=1000 ] = 0.000 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=1000 ] = 0.000 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=1000 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=1000 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=1000 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=1000 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = -1.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.000