Calculate the pose accuracy of PCK for each individual keypoint and the averaged accuracy across all keypoints for coordinates. Note: batch_size: N num_keypoints: K Args: pred (np.ndarray[N, K, 2]): Predicted keypoint location. gt (np.ndarray[N, K, 2]):
(pred, gt, mask, normalize, num_step=20)
| 521 | |
| 522 | |
| 523 | def keypoint_auc(pred, gt, mask, normalize, num_step=20): |
| 524 | """Calculate the pose accuracy of PCK for each individual keypoint and the |
| 525 | averaged accuracy across all keypoints for coordinates. |
| 526 | |
| 527 | Note: |
| 528 | batch_size: N |
| 529 | num_keypoints: K |
| 530 | |
| 531 | Args: |
| 532 | pred (np.ndarray[N, K, 2]): Predicted keypoint location. |
| 533 | gt (np.ndarray[N, K, 2]): Groundtruth keypoint location. |
| 534 | mask (np.ndarray[N, K]): Visibility of the target. False for invisible |
| 535 | joints, and True for visible. Invisible joints will be ignored for |
| 536 | accuracy calculation. |
| 537 | normalize (float): Normalization factor. |
| 538 | |
| 539 | Returns: |
| 540 | float: Area under curve. |
| 541 | """ |
| 542 | nor = np.tile(np.array([[normalize, normalize]]), (pred.shape[0], 1)) |
| 543 | x = [1.0 * i / num_step for i in range(num_step)] |
| 544 | y = [] |
| 545 | for thr in x: |
| 546 | _, avg_acc, _ = keypoint_pck_accuracy(pred, gt, mask, thr, nor) |
| 547 | y.append(avg_acc) |
| 548 | |
| 549 | auc = 0 |
| 550 | for i in range(num_step): |
| 551 | auc += 1.0 / num_step * y[i] |
| 552 | return auc |
no test coverage detected