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

Method __getitem__

detrsmpl/data/data_structures/human_data.py:442–466  ·  view source on GitHub ↗

Get value defined by HumanData. This function will be called by self[key]. In keypoints_compressed mode, if the key contains 'keypoints', an array with zero-padding at absent keypoint will be returned. Call self.get_raw_value(k) to get value without padding. Args:

(self, key: _KT)

Source from the content-addressed store, hash-verified

440 return ret_dict
441
442 def __getitem__(self, key: _KT) -> _VT:
443 """Get value defined by HumanData. This function will be called by
444 self[key]. In keypoints_compressed mode, if the key contains
445 'keypoints', an array with zero-padding at absent keypoint will be
446 returned. Call self.get_raw_value(k) to get value without padding.
447
448 Args:
449 key (_KT):
450 Key in HumanData.
451
452 Returns:
453 _VT:
454 Value to the key.
455 """
456 value = super().__getitem__(key)
457 if self.__keypoints_compressed__:
458 mask_key = f'{key}_mask'
459 if key in self and \
460 isinstance(value, np.ndarray) and \
461 'keypoints' in key and \
462 mask_key in self:
463 mask_array = np.asarray(super().__getitem__(mask_key))
464 value = \
465 self.__class__.__add_zero_pad__(value, mask_array)
466 return value
467
468 def get_raw_value(self, key: _KT) -> _VT:
469 """Get raw value from the dict. It acts the same as

Callers 2

get_raw_valueMethod · 0.45
__setitem__Method · 0.45

Calls 1

__add_zero_pad__Method · 0.80

Tested by

no test coverage detected