import numpy as np
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.6'
prepared_coco_in_dict = COCO.load_json("../tests/lvis_dataset/lvis_val_100.json")
prepared_anns = COCO.load_json("../tests/lvis_dataset/lvis_results_100.json")
iouType = "bbox"
from lvis import LVISEval
lvis_eval = LVISEval("../tests/lvis_dataset/lvis_val_100.json", "../tests/lvis_dataset/lvis_results_100.json", iouType)
INFO:lvis.lvis:Loading annotations. INFO:lvis.lvis:Creating index. INFO:lvis.lvis:Index created. INFO:lvis.results:Loading and preparing results. INFO:lvis.results:Creating index. INFO:lvis.results:Index created.
%%time
lvis_eval.evaluate()
INFO:lvis.eval:Running per image evaluation. INFO:lvis.eval:Evaluate annotation type *bbox* INFO:lvis.eval:COCOeval_opt._prepare() finished... INFO:lvis.eval:DONE (t=0.01s).
CPU times: user 766 ms, sys: 32 ms, total: 798 ms Wall time: 794 ms
%%time
lvis_eval.accumulate()
INFO:lvis.eval:Accumulating evaluation results.
CPU times: user 111 ms, sys: 2.12 ms, total: 114 ms Wall time: 113 ms
%%time
lvis_eval.summarize()
CPU times: user 22.5 ms, sys: 21.4 ms, total: 43.8 ms Wall time: 42.8 ms
lvis_eval.print_results()
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.368 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.626 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.384 Average Precision (AP) @[ IoU=0.50:0.95 | area= s | maxDets=300 catIds=all] = 0.301 Average Precision (AP) @[ IoU=0.50:0.95 | area= m | maxDets=300 catIds=all] = 0.438 Average Precision (AP) @[ IoU=0.50:0.95 | area= l | maxDets=300 catIds=all] = 0.447 Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= r] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= c] = 0.274 Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= f] = 0.388 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.430 Average Recall (AR) @[ IoU=0.50:0.95 | area= s | maxDets=300 catIds=all] = 0.345 Average Recall (AR) @[ IoU=0.50:0.95 | area= m | maxDets=300 catIds=all] = 0.488 Average Recall (AR) @[ IoU=0.50:0.95 | area= l | maxDets=300 catIds=all] = 0.515
cocoGt = COCO(prepared_coco_in_dict)
cocoDt = cocoGt.loadRes(prepared_anns)
cocoEval = COCOeval_faster(cocoGt, cocoDt, iouType, lvis_style=True, print_function=print)
cocoEval.params.maxDets = [300]
%%time
cocoEval.evaluate()
Evaluate annotation type *bbox* COCOeval_opt._prepare() finished... DONE (t=0.01s). COCOeval_opt.evaluate() finished... DONE (t=0.63s). CPU times: user 581 ms, sys: 53.2 ms, total: 634 ms Wall time: 631 ms
%%time
cocoEval.accumulate()
Accumulating evaluation results... COCOeval_opt.accumulate() finished... DONE (t=0.00s). CPU times: user 42 µs, sys: 20 µs, total: 62 µs Wall time: 59.6 µs
%%time
cocoEval.summarize()
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.368 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.626 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.384 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=300 catIds=all] = 0.301 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=300 catIds=all] = 0.438 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=300 catIds=all] = 0.447 Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= r] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= c] = 0.274 Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds= f] = 0.388 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 catIds=all] = 0.430 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=300 catIds=all] = 0.345 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=300 catIds=all] = 0.488 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=300 catIds=all] = 0.515 Average Recall (AR) @[ IoU=0.50 | area= all | maxDets=300 catIds=all] = 0.720 Average Recall (AR) @[ IoU=0.75 | area= all | maxDets=300 catIds=all] = 0.445 CPU times: user 31.7 ms, sys: 8.7 ms, total: 40.4 ms Wall time: 39.5 ms