MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / eval_coco

Function eval_coco

tests/core/metrics/test_metrics_map_computation.py:374–399  ·  view source on GitHub ↗
(
    ground_truth: dict,
    predictions: list[dict],
    num_joints: int,
)

Source from the content-addressed store, hash-verified

372
373
374def eval_coco(
375 ground_truth: dict,
376 predictions: list[dict],
377 num_joints: int,
378) -> float | None:
379 try:
380 from pycocotools.coco import COCO
381 from pycocotools.cocoeval import COCOeval
382
383 coco = COCO()
384 coco.dataset["annotations"] = ground_truth["annotations"]
385 coco.dataset["categories"] = ground_truth["categories"]
386 coco.dataset["images"] = ground_truth["images"]
387 coco.dataset["info"] = {"description": "Generated by DeepLabCut"}
388 coco.createIndex()
389
390 coco_det = coco.loadRes(predictions)
391 coco_eval = COCOeval(coco, coco_det, iouType="keypoints")
392 coco_eval.params.kpt_oks_sigmas = np.array(num_joints * [0.1])
393 coco_eval.evaluate()
394 coco_eval.accumulate()
395 coco_eval.summarize()
396 return float(coco_eval.stats[0])
397
398 except ModuleNotFoundError:
399 print("pycocotools is not installed")

Callers 1

_evaluateFunction · 0.70

Calls 1

evaluateMethod · 0.80

Tested by

no test coverage detected