MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / eval_coco

Function eval_coco

tests/core/inferenceutils/test_map_computation.py:393–418  ·  view source on GitHub ↗
(
    ground_truth: dict,
    predictions: list[dict],
    num_joints: int,
)

Source from the content-addressed store, hash-verified

391
392
393def eval_coco(
394 ground_truth: dict,
395 predictions: list[dict],
396 num_joints: int,
397) -> float | None:
398 try:
399 from pycocotools.coco import COCO
400 from pycocotools.cocoeval import COCOeval
401
402 coco = COCO()
403 coco.dataset["annotations"] = ground_truth["annotations"]
404 coco.dataset["categories"] = ground_truth["categories"]
405 coco.dataset["images"] = ground_truth["images"]
406 coco.dataset["info"] = {"description": "Generated by DeepLabCut"}
407 coco.createIndex()
408
409 coco_det = coco.loadRes(predictions)
410 coco_eval = COCOeval(coco, coco_det, iouType="keypoints")
411 coco_eval.params.kpt_oks_sigmas = np.array(num_joints * [0.1])
412 coco_eval.evaluate()
413 coco_eval.accumulate()
414 coco_eval.summarize()
415 return float(coco_eval.stats[0])
416
417 except ModuleNotFoundError:
418 print("pycocotools is not installed")

Callers 1

_evaluateFunction · 0.70

Calls 1

evaluateMethod · 0.80

Tested by

no test coverage detected