Check whether the temporal length of val matches other values. Args: key (Any): Key in HumanData. val (Any): Value to the key. Returns: bool: If temporal dim is defined and temporal length doesn't m
(self, key: Any, val: Any)
| 915 | self.__data_len__ = value |
| 916 | |
| 917 | def __check_value_len__(self, key: Any, val: Any) -> bool: |
| 918 | """Check whether the temporal length of val matches other values. |
| 919 | |
| 920 | Args: |
| 921 | key (Any): |
| 922 | Key in HumanData. |
| 923 | val (Any): |
| 924 | Value to the key. |
| 925 | |
| 926 | Returns: |
| 927 | bool: |
| 928 | If temporal dim is defined and temporal length doesn't match, |
| 929 | return False. |
| 930 | Else return True. |
| 931 | """ |
| 932 | ret_bool = True |
| 933 | supported_keys = self.__class__.SUPPORTED_KEYS |
| 934 | # check definition |
| 935 | if key in supported_keys: |
| 936 | # check temporal length |
| 937 | if 'dim' in supported_keys[key] and \ |
| 938 | supported_keys[key]['dim'] is not None: |
| 939 | val_slice_dim = supported_keys[key]['dim'] |
| 940 | if supported_keys[key]['type'] == dict: |
| 941 | slice_key = supported_keys[key]['slice_key'] |
| 942 | val_data_len = val[slice_key].shape[val_slice_dim] |
| 943 | else: |
| 944 | val_data_len = val.shape[val_slice_dim] |
| 945 | if self.data_len < 0: |
| 946 | # no data_len yet, assign a new one |
| 947 | self.data_len = val_data_len |
| 948 | else: |
| 949 | # check if val_data_len matches recorded data_len |
| 950 | if self.data_len != val_data_len: |
| 951 | ret_bool = False |
| 952 | if not ret_bool: |
| 953 | err_msg = 'Temporal check Failed:\n' |
| 954 | err_msg += f'key={str(key)}\n' |
| 955 | err_msg += f'val\'s data_len={val_data_len}\n' |
| 956 | err_msg += f'expected data_len={self.data_len}\n' |
| 957 | print_log(msg=err_msg, |
| 958 | logger=self.__class__.logger, |
| 959 | level=logging.ERROR) |
| 960 | return ret_bool |
| 961 | |
| 962 | def generate_mask_from_confidence(self, keys=None) -> None: |
| 963 | """Generate mask from keypoints' confidence. Keypoints that have zero |