import json
import logging
import faster_coco_eval
from faster_coco_eval import COCO, COCOeval_faster
from faster_coco_eval.extra import Curves
print(f"{faster_coco_eval.__version__=}")
logging.root.setLevel("INFO")
logging.debug("Запись.")
faster_coco_eval.__version__='1.5.4'
prepared_coco_in_dict = COCO.load_json("../tests/kp_dataset/gt_dataset.json")
prepared_anns = COCO.load_json("../tests/kp_dataset/dt_dataset.json")
iouType = "keypoints"
cocoGt = COCO(prepared_coco_in_dict)
cocoDt = cocoGt.loadRes(prepared_anns)
cocoEval = COCOeval_faster(
cocoGt, cocoDt, iouType, extra_calc=True, kpt_oks_sigmas=[0.025] * 4
)
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
cocoEval.stats_as_dict
{'AP_all': 0.9763163924878505, 'AP_50': 0.9801980198019802, 'AP_75': 0.9801980198019802, 'AP_medium': -1.0, 'AP_large': 0.9763163924878505, 'AR_all': 0.982608695652174, 'AR_second': 0.9855072463768116, 'AR_third': 0.9855072463768116, 'AR_medium': -1.0, 'AR_large': 0.982608695652174, 'mIoU': 0.9743220702458776, 'mAUC_50': 0.98}
cur = Curves(cocoGt, cocoDt, iouType=iouType, kpt_oks_sigmas=[0.025] * 4)
cur.plot_ced_metric()
cur.plot_f1_confidence()