import json
import logging
import faster_coco_eval
from faster_coco_eval import COCO, COCOeval_faster
print(f"{faster_coco_eval.__version__=}")
logging.root.setLevel("INFO")
logging.debug("Запись.")
faster_coco_eval.__version__='1.5.3'
prepared_coco_in_dict = COCO.load_json("../tests/dataset/gt_dataset.json")
prepared_anns = COCO.load_json("../tests/dataset/dt_dataset.json")
iouType = "segm"
useCats = False
cocoGt = COCO(prepared_coco_in_dict)
cocoDt = cocoGt.loadRes(prepared_anns)
cocoEval = COCOeval_faster(cocoGt, cocoDt, iouType, extra_calc=True)
cocoEval.params.maxDets = [len(cocoGt.anns)]
if not useCats:
cocoEval.params.useCats = 0 # Выключение labels
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
cocoEval.stats
array([ 0.78327833, 0.78327833, 0.78327833, -1. , 1. , 0. , 0.88888889, 0. , 0. , -1. , 1. , 0. ])
cocoEval.stats_as_dict
{'AP_all': 0.7832783278327835, 'AP_50': 0.7832783278327836, 'AP_75': 0.7832783278327836, 'AP_small': -1.0, 'AP_medium': 1.0, 'AP_large': 0.0, 'AR_all': 0.888888888888889, 'AR_second': 0.0, 'AR_third': 0.0, 'AR_small': -1.0, 'AR_medium': 1.0, 'AR_large': 0.0, 'AR_50': 0.8888888888888888, 'AR_75': 0.8888888888888888, 'mIoU': 1.0, 'mAUC_50': 0.594074074074074}