(self, idx)
| 380 | return datalist |
| 381 | |
| 382 | def __getitem__(self, idx): |
| 383 | try: |
| 384 | data = copy.deepcopy(self.datalist[idx]) |
| 385 | except Exception as e: |
| 386 | print(f'[{self.__class__.__name__}] Error loading data {idx}') |
| 387 | print(e) |
| 388 | exit(0) |
| 389 | |
| 390 | img_path, img_shape, bbox = \ |
| 391 | data['img_path'], data['img_shape'], data['bbox'] |
| 392 | as_smplx = data['as_smplx'] |
| 393 | gender = data['gender'].copy() |
| 394 | for gender_str, gender_num in { |
| 395 | 'neutral': -1, 'male': 0, 'female': 1}.items(): |
| 396 | gender[gender==gender_str]=gender_num |
| 397 | gender = gender.astype(int) |
| 398 | |
| 399 | img_whole_bbox = np.array([0, 0, img_shape[1], img_shape[0]]) |
| 400 | img = load_img(img_path, order='BGR') |
| 401 | |
| 402 | num_person = len(data['bbox']) |
| 403 | data_name = self.__class__.__name__ |
| 404 | img, img2bb_trans, bb2img_trans, rot, do_flip = \ |
| 405 | augmentation_instance_sample(img, img_whole_bbox, self.data_split,data,data_name) |
| 406 | cropped_img_shape=img.shape[:2] |
| 407 | |
| 408 | num_person = len(data['bbox']) |
| 409 | if self.data_split == 'train': |
| 410 | joint_cam = data['joint_cam'] # num, 137,4 |
| 411 | if joint_cam is not None: |
| 412 | dummy_cord = False |
| 413 | joint_cam[:,:,:3] = \ |
| 414 | joint_cam[:,:,:3] - joint_cam[:, self.joint_set['root_joint_idx'], None, :3] # root-relative |
| 415 | else: |
| 416 | # dummy cord as joint_cam |
| 417 | dummy_cord = True |
| 418 | joint_cam = np.zeros( |
| 419 | (num_person, self.joint_set['joint_num'], 4), |
| 420 | dtype=np.float32) |
| 421 | |
| 422 | joint_img = data['joint_img'] |
| 423 | # do rotation on keypoints |
| 424 | joint_img_aug, joint_cam_wo_ra, joint_cam_ra, joint_trunc = \ |
| 425 | process_db_coord_batch_no_valid( |
| 426 | joint_img, joint_cam, do_flip, img_shape, |
| 427 | self.joint_set['flip_pairs'], img2bb_trans, rot, |
| 428 | self.joint_set['joints_name'], smpl_x.joints_name, |
| 429 | cropped_img_shape) |
| 430 | joint_img_aug[:,:,2:] = joint_img_aug[:,:,2:] * joint_trunc |
| 431 | |
| 432 | # smplx coordinates and parameters |
| 433 | smplx_param = data['smplx_param'] |
| 434 | smplx_pose, smplx_shape, smplx_expr, smplx_pose_valid, \ |
| 435 | smplx_joint_valid, smplx_expr_valid, smplx_shape_valid = \ |
| 436 | process_human_model_output_batch_simplify( |
| 437 | smplx_param, do_flip, rot, as_smplx) |
| 438 | # if cam not provided, we take joint_img as smplx joint 2d, |
| 439 | # which is commonly the case for our processed humandata |
nothing calls this directly
no test coverage detected