MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __getitem__

Method __getitem__

datasets/UBody_MM.py:585–1029  ·  view source on GitHub ↗
(self, idx)

Source from the content-addressed store, hash-verified

583
584 return datalist
585 def __getitem__(self, idx):
586 try:
587 data = copy.deepcopy(self.datalist[idx])
588 except Exception as e:
589 print(f'[{self.__class__.__name__}] Error loading data {idx}')
590 print(e)
591 exit(0)
592
593 img_path, img_shape, bbox = data['img_path'], data['img_shape'], data[
594 'bbox']
595 as_smplx = data['as_smplx']
596 if 'gender' in data:
597 gender = data['gender'].copy()
598 for gender_str, gender_num in {
599 'neutral': -1, 'male': 0, 'female': 1}.items():
600 gender[gender==gender_str]=gender_num
601 gender = gender.astype(int)
602 else:
603 gender = np.array([-1]*len(bbox))
604 img_whole_bbox = np.array([0, 0, img_shape[1], img_shape[0]])
605 img = load_img(img_path, order='BGR')
606 num_person = len(data['bbox'])
607 data_name = self.__class__.__name__
608 img, img2bb_trans, bb2img_trans, rot, do_flip = \
609 augmentation_instance_sample(img, img_whole_bbox, self.data_split,data,data_name)
610 cropped_img_shape=img.shape[:2]
611 num_person = len(data['bbox'])
612
613 if self.data_split == 'train':
614 # h36m gt
615 if 'joint_cam' in data:
616 joint_cam = data['joint_cam']
617 else:
618 joint_cam = None
619
620 if joint_cam is not None:
621 dummy_cord = False
622 joint_cam[:,:,:3] = joint_cam[:,:,:3] - joint_cam[:, self.
623 joint_set['root_joint_idx'],
624 None, :3] # root-relative
625 else:
626 # dummy cord as joint_cam
627 dummy_cord = True
628 joint_cam = np.zeros(
629 (num_person, self.joint_set['joint_num'], 4),
630 dtype=np.float32)
631
632 joint_img = data['joint_img']
633
634 # do rotation on keypoints
635 joint_img_aug, joint_cam_wo_ra, joint_cam_ra, joint_trunc = \
636 process_db_coord_batch_no_valid(
637 joint_img, joint_cam, do_flip, img_shape,
638 self.joint_set['flip_pairs'], img2bb_trans, rot,
639 self.joint_set['joints_name'], smpl_x.joints_name,
640 cropped_img_shape)
641 joint_img_aug[:,:,2:] = joint_img_aug[:,:,2:] * joint_trunc
642

Callers

nothing calls this directly

Calls 9

load_imgFunction · 0.90
deepcopyMethod · 0.80
copyMethod · 0.80
printFunction · 0.50
itemsMethod · 0.45

Tested by

no test coverage detected