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

Function keypoints_from_regression

tools/preprocess/pose2d_utils.py:740–770  ·  view source on GitHub ↗

Get final keypoint predictions from regression vectors and transform them back to the image. Note: - batch_size: N - num_keypoints: K Args: regression_preds (np.ndarray[N, K, 2]): model prediction. center (np.ndarray[N, 2]): Center of the bounding box (x

(regression_preds, center, scale, img_size)

Source from the content-addressed store, hash-verified

738
739
740def keypoints_from_regression(regression_preds, center, scale, img_size):
741 """Get final keypoint predictions from regression vectors and transform
742 them back to the image.
743
744 Note:
745 - batch_size: N
746 - num_keypoints: K
747
748 Args:
749 regression_preds (np.ndarray[N, K, 2]): model prediction.
750 center (np.ndarray[N, 2]): Center of the bounding box (x, y).
751 scale (np.ndarray[N, 2]): Scale of the bounding box
752 wrt height/width.
753 img_size (list(img_width, img_height)): model input image size.
754
755 Returns:
756 tuple:
757
758 - preds (np.ndarray[N, K, 2]): Predicted keypoint location in images.
759 - maxvals (np.ndarray[N, K, 1]): Scores (confidence) of the keypoints.
760 """
761 N, K, _ = regression_preds.shape
762 preds, maxvals = regression_preds, np.ones((N, K, 1), dtype=np.float32)
763
764 preds = preds * img_size
765
766 # Transform back to the image
767 for i in range(N):
768 preds[i] = transform_preds(preds[i], center[i], scale[i], img_size)
769
770 return preds, maxvals
771
772
773def keypoints_from_heatmaps(heatmaps, center, scale, unbiased=False, post_process="default", kernel=11, valid_radius_factor=0.0546875, use_udp=False, target_type="GaussianHeatmap"):

Callers

nothing calls this directly

Calls 1

transform_predsFunction · 0.85

Tested by

no test coverage detected