(self, train_sample_interval=1, test_sample_interval=1)
| 1167 | |
| 1168 | |
| 1169 | def load_data(self, train_sample_interval=1, test_sample_interval=1): |
| 1170 | |
| 1171 | content = np.load(self.annot_path, allow_pickle=True) |
| 1172 | num_examples = len(content['image_path']) |
| 1173 | |
| 1174 | if 'meta' in content: |
| 1175 | meta = content['meta'].item() |
| 1176 | print('meta keys:', meta.keys()) |
| 1177 | else: |
| 1178 | meta = None |
| 1179 | print('No meta info provided! Please give height and width manually') |
| 1180 | |
| 1181 | print(f'Start loading humandata {self.annot_path} into memory...\nDataset includes: {content.files}'); tic = time.time() |
| 1182 | image_path = content['image_path'] |
| 1183 | |
| 1184 | if meta is not None and 'height' in meta: |
| 1185 | height = np.array(meta['height']) |
| 1186 | width = np.array(meta['width']) |
| 1187 | image_shape = np.stack([height, width], axis=-1) |
| 1188 | else: |
| 1189 | image_shape = None |
| 1190 | |
| 1191 | if self.__class__.__name__ == 'HI4D': |
| 1192 | image_shape = None |
| 1193 | |
| 1194 | # add focal and principal point |
| 1195 | if meta is not None and 'focal_length' in meta: |
| 1196 | focal_length = np.array(meta['focal_length'], dtype=np.float32) |
| 1197 | elif 'focal' in self.cam_param: |
| 1198 | focal_length = np.array(self.cam_param['focal'], dtype=np.float32)[np.newaxis].repeat(num_examples, axis=0) |
| 1199 | else: |
| 1200 | focal_length = None |
| 1201 | if meta is not None and 'principal_point' in meta: |
| 1202 | principal_point = np.array(meta['principal_point'], dtype=np.float32) |
| 1203 | elif 'princpt' in self.cam_param: |
| 1204 | principal_point = np.array(self.cam_param['princpt'], dtype=np.float32)[np.newaxis].repeat(num_examples, axis=0) |
| 1205 | else: |
| 1206 | principal_point = None |
| 1207 | |
| 1208 | bbox_xywh = content['bbox_xywh'] |
| 1209 | |
| 1210 | if 'smplx' in content: |
| 1211 | smplx = content['smplx'].item() |
| 1212 | as_smplx = 'smplx' |
| 1213 | elif 'smpl' in content: |
| 1214 | smplx = content['smpl'].item() |
| 1215 | as_smplx = 'smpl' |
| 1216 | elif 'smplh' in content: |
| 1217 | smplx = content['smplh'].item() |
| 1218 | as_smplx = 'smplh' |
| 1219 | |
| 1220 | # TODO: temp solution, should be more general. But SHAPY is very special |
| 1221 | elif self.__class__.__name__ == 'SHAPY': |
| 1222 | smplx = {} |
| 1223 | |
| 1224 | else: |
| 1225 | raise KeyError('No SMPL for SMPLX available, please check keys:\n' |
| 1226 | f'{content.files}') |
nothing calls this directly
no test coverage detected