import json
import logging
import faster_coco_eval
from faster_coco_eval import COCO
from faster_coco_eval.extra import Curves
from faster_coco_eval.extra import PreviewResults
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")
threshold_iou = 0.5
iouType = "segm"
cocoGt = COCO(prepared_coco_in_dict)
cocoDt = cocoGt.loadRes(prepared_anns)
cur = Curves(cocoGt, cocoDt, iou_tresh=threshold_iou, iouType=iouType)
cur.plot_pre_rec()
cur.plot_f1_confidence()
cocoGt = COCO(prepared_coco_in_dict)
cocoDt = cocoGt.loadRes(prepared_anns)
results = PreviewResults(
cocoGt, cocoDt, iou_tresh=threshold_iou, iouType=iouType, useCats=False
)
results.display_matrix()
results = PreviewResults(
cocoGt, cocoDt, iou_tresh=threshold_iou, iouType=iouType, useCats=True
)
results.display_tp_fp_fn(data_folder="../tests/dataset/", image_ids=[1, 2, 3])