MCPcopy Index your code
hub / github.com/OpenMotionLab/MotionGPT / XYZDatastruct

Class XYZDatastruct

mGPT/data/transforms/xyz.py:40–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39@dataclass
40class XYZDatastruct(Datastruct):
41 transforms: XYZTransform
42 _joints2jfeats: Joints2Jfeats
43
44 features: Optional[Tensor] = None
45 joints_: Optional[Tensor] = None
46 jfeats_: Optional[Tensor] = None
47
48 def __post_init__(self):
49 self.datakeys = ["features", "joints_", "jfeats_"]
50 # starting point
51 if self.features is not None and self.jfeats_ is None:
52 self.jfeats_ = self.features
53
54 @property
55 def joints(self):
56 # Cached value
57 if self.joints_ is not None:
58 return self.joints_
59
60 # self.jfeats_ should be defined
61 assert self.jfeats_ is not None
62
63 self._joints2jfeats.to(self.jfeats.device)
64 self.joints_ = self._joints2jfeats.inverse(self.jfeats)
65 return self.joints_
66
67 @property
68 def jfeats(self):
69 # Cached value
70 if self.jfeats_ is not None:
71 return self.jfeats_
72
73 # self.joints_ should be defined
74 assert self.joints_ is not None
75
76 self._joints2jfeats.to(self.joints.device)
77 self.jfeats_ = self._joints2jfeats(self.joints)
78 return self.jfeats_
79
80 def __len__(self):
81 return len(self.jfeats)

Callers 1

DatastructMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected