#!/usr/bin/env python # coding: utf-8 # In[1]: 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("Запись.") # In[2]: def load(file): with open(file) as io: _data = json.load(io) return _data # In[3]: prepared_coco_in_dict = load("../tests/dataset/gt_dataset.json") prepared_anns = load("../tests/dataset/dt_dataset.json") # In[4]: iouType = "segm" useCats = False # In[5]: 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() # In[6]: cocoEval.stats # In[7]: cocoEval.stats_as_dict