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

Method load

detrsmpl/data/data_structures/human_data.py:234–266  ·  view source on GitHub ↗

Load data from npz_path and update them to self. Args: npz_path (str): Path to a dumped npz file.

(self, npz_path: str)

Source from the content-addressed store, hash-verified

232 return self.__keypoints_compressed__
233
234 def load(self, npz_path: str):
235 """Load data from npz_path and update them to self.
236
237 Args:
238 npz_path (str):
239 Path to a dumped npz file.
240 """
241 supported_keys = self.__class__.SUPPORTED_KEYS
242 with np.load(npz_path, allow_pickle=True) as npz_file:
243 tmp_data_dict = dict(npz_file)
244 for key, value in list(tmp_data_dict.items()):
245 if isinstance(value, np.ndarray) and\
246 len(value.shape) == 0:
247 # value is not an ndarray before dump
248 value = value.item()
249 elif key in supported_keys and\
250 type(value) != supported_keys[key]['type']:
251 value = supported_keys[key]['type'](value)
252 if value is None:
253 tmp_data_dict.pop(key)
254 elif key == '__key_strict__' or \
255 key == '__data_len__' or\
256 key == '__keypoints_compressed__':
257 self.__setattr__(key, value)
258 # pop the attributes to keep dict clean
259 tmp_data_dict.pop(key)
260 elif key == 'bbox_xywh' and value.shape[1] == 4:
261 value = np.hstack([value, np.ones([value.shape[0], 1])])
262 tmp_data_dict[key] = value
263 else:
264 tmp_data_dict[key] = value
265 self.update(tmp_data_dict)
266 self.__set_default_values__()
267
268 def dump(self, npz_path: str, overwrite: bool = True):
269 """Dump keys and items to an npz file.

Callers 15

load_annotationsMethod · 0.95
load_annotationsMethod · 0.45
__init__Method · 0.45
_report_ihmrMethod · 0.45
load_annotationsMethod · 0.45
_report_ihmrMethod · 0.45
load_pascal_occludersFunction · 0.45
__init__Method · 0.45
get_itemMethod · 0.45
get_non_sliced_dataMethod · 0.45
fromfileMethod · 0.45
load_by_pickleMethod · 0.45

Calls 4

__setattr__Method · 0.80
itemsMethod · 0.45
updateMethod · 0.45

Tested by 1

collect_results_cpuFunction · 0.36