Load data from pkl_path and update them to self. When a HumanData Instance was dumped by self.dump_by_pickle(), use this to load. Args: npz_path (str): Path to a dumped npz file.
(self, pkl_path: str)
| 1116 | protocol=pickle.HIGHEST_PROTOCOL) |
| 1117 | |
| 1118 | def load_by_pickle(self, pkl_path: str) -> None: |
| 1119 | """Load data from pkl_path and update them to self. |
| 1120 | |
| 1121 | When a HumanData Instance was dumped by |
| 1122 | self.dump_by_pickle(), use this to load. |
| 1123 | Args: |
| 1124 | npz_path (str): |
| 1125 | Path to a dumped npz file. |
| 1126 | """ |
| 1127 | with open(pkl_path, 'rb') as f_readb: |
| 1128 | tmp_data_dict = pickle.load(f_readb) |
| 1129 | for key, value in list(tmp_data_dict.items()): |
| 1130 | if value is None: |
| 1131 | tmp_data_dict.pop(key) |
| 1132 | elif key == '__key_strict__' or \ |
| 1133 | key == '__data_len__' or\ |
| 1134 | key == '__keypoints_compressed__': |
| 1135 | self.__setattr__(key, value) |
| 1136 | # pop the attributes to keep dict clean |
| 1137 | tmp_data_dict.pop(key) |
| 1138 | elif key == 'bbox_xywh' and value.shape[1] == 4: |
| 1139 | value = np.hstack([value, np.ones([value.shape[0], 1])]) |
| 1140 | tmp_data_dict[key] = value |
| 1141 | else: |
| 1142 | tmp_data_dict[key] = value |
| 1143 | self.update(tmp_data_dict) |
| 1144 | self.__set_default_values__() |
| 1145 | |
| 1146 | def __set_default_values__(self) -> None: |
| 1147 | """For older versions of HumanData, call this method to apply missing |
nothing calls this directly
no test coverage detected