MCPcopy Create free account
hub / github.com/MotrixLab/ADHMR / load_data

Method load_data

HMR-Scorer/data/humandata.py:138–452  ·  view source on GitHub ↗
(self, train_sample_interval=1, test_sample_interval=1)

Source from the content-addressed store, hash-verified

136 )
137
138 def load_data(self, train_sample_interval=1, test_sample_interval=1):
139
140 content = np.load(self.annot_path, allow_pickle=True)
141 num_examples = len(content['image_path'])
142
143 if 'meta' in content:
144 meta = content['meta'].item()
145 print('meta keys:', meta.keys())
146 else:
147 meta = None
148 print('No meta info provided! Please give height and width manually')
149
150 print(f'Start loading humandata {self.annot_path} into memory...\nDataset includes: {content.files}'); tic = time.time()
151 image_path = content['image_path']
152
153 if meta is not None and 'height' in meta:
154 height = np.array(meta['height'])
155 width = np.array(meta['width'])
156 image_shape = np.stack([height, width], axis=-1)
157 else:
158 image_shape = None
159
160 if self.__class__.__name__ == 'HI4D':
161 image_shape = None
162
163 # add focal and principal point
164 # import ipdb;ipdb.set_trace()
165 if meta is not None and 'focal_length' in meta:
166 focal_length = np.array(meta['focal_length'], dtype=np.float32)
167 elif 'focal' in self.cam_param:
168 focal_length = np.array(self.cam_param['focal'], dtype=np.float32)[np.newaxis].repeat(num_examples, axis=0)
169 else:
170 focal_length = None
171 if meta is not None and 'principal_point' in meta:
172 principal_point = np.array(meta['principal_point'], dtype=np.float32)
173 elif 'princpt' in self.cam_param:
174 principal_point = np.array(self.cam_param['princpt'], dtype=np.float32)[np.newaxis].repeat(num_examples, axis=0)
175 else:
176 principal_point = None
177
178 bbox_xywh = content['bbox_xywh']
179
180 if 'smplx' in content:
181 smplx = content['smplx'].item()
182 as_smplx = 'smplx'
183 elif 'smpl' in content:
184 smplx = content['smpl'].item()
185 as_smplx = 'smpl'
186 elif 'smplh' in content:
187 smplx = content['smplh'].item()
188 as_smplx = 'smplh'
189
190 # TODO: temp solution, should be more general. But SHAPY is very special
191 elif self.__class__.__name__ == 'SHAPY':
192 smplx = {}
193
194 else:
195 raise KeyError('No SMPL for SMPLX available, please check keys:\n'

Callers

nothing calls this directly

Calls 6

decompress_keypointsMethod · 0.95
process_bboxFunction · 0.90
printFunction · 0.85
loadMethod · 0.45
keysMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected