File size: 820 Bytes
d7e58f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import torch, os


def keypoint_xyxyzz_to_xyzxyz(keypoints: torch.Tensor):
    """_summary_

    Args:
        keypoints (torch.Tensor): ..., 51
    """
    res = torch.zeros_like(keypoints)
    num_points = keypoints.shape[-1] // 3
    Z = keypoints[..., :2 * num_points]
    V = keypoints[..., 2 * num_points:]
    res[..., 0::3] = Z[..., 0::2]
    res[..., 1::3] = Z[..., 1::2]
    res[..., 2::3] = V[...]
    return res


def keypoint_xyzxyz_to_xyxyzz(keypoints: torch.Tensor):
    """_summary_

    Args:
        keypoints (torch.Tensor): ..., 51
    """
    res = torch.zeros_like(keypoints)
    num_points = keypoints.shape[-1] // 3
    res[..., 0:2 * num_points:2] = keypoints[..., 0::3]
    res[..., 1:2 * num_points:2] = keypoints[..., 1::3]
    res[..., 2 * num_points:] = keypoints[..., 2::3]
    return res