MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / _get_max_preds_3d

Function _get_max_preds_3d

tools/preprocess/pose2d_utils.py:408–442  ·  view source on GitHub ↗

Get keypoint predictions from 3D score maps. Note: batch size: N num keypoints: K heatmap depth size: D heatmap height: H heatmap width: W Args: heatmaps (np.ndarray[N, K, D, H, W]): model predicted heatmaps. Returns: tuple: A tu

(heatmaps)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected