MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / _get_max_preds

Function _get_max_preds

PATH/core/data/transforms/post_transforms.py:406–438  ·  view source on GitHub ↗

Get keypoint predictions from score maps. Note: batch_size: N num_keypoints: K heatmap height: H heatmap width: W Args: heatmaps (np.ndarray[N, K, H, W]): model predicted heatmaps. Returns: tuple: A tuple containing aggregated results.

(heatmaps)

Source from the content-addressed store, hash-verified

404
405
406def _get_max_preds(heatmaps):
407 """Get keypoint predictions from score maps.
408
409 Note:
410 batch_size: N
411 num_keypoints: K
412 heatmap height: H
413 heatmap width: W
414
415 Args:
416 heatmaps (np.ndarray[N, K, H, W]): model predicted heatmaps.
417
418 Returns:
419 tuple: A tuple containing aggregated results.
420
421 - preds (np.ndarray[N, K, 2]): Predicted keypoint location.
422 - maxvals (np.ndarray[N, K, 1]): Scores (confidence) of the keypoints.
423 """
424 assert isinstance(heatmaps,
425 np.ndarray), ('heatmaps should be numpy.ndarray')
426 assert heatmaps.ndim == 4, 'batch_images should be 4-ndim'
427
428 N, K, _, W = heatmaps.shape
429 heatmaps_reshaped = heatmaps.reshape((N, K, -1))
430 idx = np.argmax(heatmaps_reshaped, 2).reshape((N, K, 1))
431 maxvals = np.amax(heatmaps_reshaped, 2).reshape((N, K, 1))
432
433 preds = np.tile(idx, (1, 1, 2)).astype(np.float32)
434 preds[:, :, 0] = preds[:, :, 0] % W
435 preds[:, :, 1] = preds[:, :, 1] // W
436
437 preds = np.where(np.tile(maxvals, (1, 1, 2)) > 0.0, preds, -1)
438 return preds, maxvals
439
440
441def pose_pck_accuracy(output, target, mask, thr=0.05, normalize=None):

Callers 1

pose_pck_accuracyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected