(gt: dict[str, np.ndarray], pred: dict[str, np.ndarray])
| 251 | |
| 252 | |
| 253 | def _evaluate(gt: dict[str, np.ndarray], pred: dict[str, np.ndarray]): |
| 254 | for k, v in gt.items(): |
| 255 | print(20 * "-") |
| 256 | print(k) |
| 257 | print("GT") |
| 258 | print(v) |
| 259 | print("PR") |
| 260 | print(pred[k]) |
| 261 | |
| 262 | data = prepare_evaluation_data(gt, pred) |
| 263 | oks = compute_oks(data, oks_bbox_margin=0) |
| 264 | |
| 265 | num_joints = gt[list(gt.keys())[0]].shape[1] |
| 266 | coco_gt = _to_coco_ground_truth(gt, num_joints, bbox_margin=0) |
| 267 | coco_pred = _to_coco_predictions(coco_gt, pred, bbox_margin=0) |
| 268 | coco_oks = eval_coco(coco_gt, coco_pred, num_joints) |
| 269 | print(20 * "-") |
| 270 | print("dlc mAP:") |
| 271 | for k, v in oks.items(): |
| 272 | print(k) |
| 273 | print(v) |
| 274 | print(20 * "-") |
| 275 | print(f"pycocotools mAP: {coco_oks}") |
| 276 | print() |
| 277 | dlc_map = oks["mAP"] / 100 |
| 278 | assert_almost_equal(dlc_map, coco_oks) |
| 279 | |
| 280 | |
| 281 | def _to_coco_ground_truth( |
no test coverage detected