If a key contains 'keypoints', and f'{key}_mask' is in self.keys(), invalid zeros will be inserted to the right places and f'{key}_mask' will be unlocked. Raises: KeyError: A key contains 'keypoints' has been found but its correspo
(self, humandata)
| 1243 | |
| 1244 | return valid_mask |
| 1245 | def decompress_keypoints(self, humandata) -> None: |
| 1246 | """If a key contains 'keypoints', and f'{key}_mask' is in self.keys(), |
| 1247 | invalid zeros will be inserted to the right places and f'{key}_mask' |
| 1248 | will be unlocked. |
| 1249 | |
| 1250 | Raises: |
| 1251 | KeyError: |
| 1252 | A key contains 'keypoints' has been found |
| 1253 | but its corresponding mask is missing. |
| 1254 | """ |
| 1255 | assert bool(humandata['__keypoints_compressed__']) is True |
| 1256 | key_pairs = [] |
| 1257 | for key in humandata.files: |
| 1258 | if key not in KPS2D_KEYS + KPS3D_KEYS: |
| 1259 | continue |
| 1260 | mask_key = f'{key}_mask' |
| 1261 | if mask_key in humandata.files: |
| 1262 | print(f'Decompress {key}...') |
| 1263 | key_pairs.append([key, mask_key]) |
| 1264 | decompressed_dict = {} |
| 1265 | for kpt_key, mask_key in key_pairs: |
| 1266 | mask_array = np.asarray(humandata[mask_key]) |
| 1267 | compressed_kpt = humandata[kpt_key] |
| 1268 | kpt_array = \ |
| 1269 | self.add_zero_pad(compressed_kpt, mask_array) |
| 1270 | decompressed_dict[kpt_key] = kpt_array |
| 1271 | del humandata |
| 1272 | return decompressed_dict |
| 1273 | |
| 1274 | def add_zero_pad(self, compressed_array: np.ndarray, |
| 1275 | mask_array: np.ndarray) -> np.ndarray: |
no test coverage detected