Dump keys and items to a pickle file. It's a secondary dump method, when a HumanData instance is too large to be dumped by self.dump() Args: pkl_path (str): Path to a dumped pickle file. overwrite (bool, optional): Whether to o
(self, pkl_path: str, overwrite: bool = True)
| 1083 | self.__keypoints_compressed__ = False |
| 1084 | |
| 1085 | def dump_by_pickle(self, pkl_path: str, overwrite: bool = True) -> None: |
| 1086 | """Dump keys and items to a pickle file. It's a secondary dump method, |
| 1087 | when a HumanData instance is too large to be dumped by self.dump() |
| 1088 | |
| 1089 | Args: |
| 1090 | pkl_path (str): |
| 1091 | Path to a dumped pickle file. |
| 1092 | overwrite (bool, optional): |
| 1093 | Whether to overwrite if there is already a file. |
| 1094 | Defaults to True. |
| 1095 | |
| 1096 | Raises: |
| 1097 | ValueError: |
| 1098 | npz_path does not end with '.pkl'. |
| 1099 | FileExistsError: |
| 1100 | When overwrite is False and file exists. |
| 1101 | """ |
| 1102 | if not check_path_suffix(pkl_path, ['.pkl']): |
| 1103 | raise ValueError('Not an pkl file.') |
| 1104 | if not overwrite: |
| 1105 | if check_path_existence(pkl_path, 'file') == Existence.FileExist: |
| 1106 | raise FileExistsError |
| 1107 | dict_to_dump = { |
| 1108 | '__key_strict__': self.__key_strict__, |
| 1109 | '__data_len__': self.__data_len__, |
| 1110 | '__keypoints_compressed__': self.__keypoints_compressed__, |
| 1111 | } |
| 1112 | dict_to_dump.update(self) |
| 1113 | with open(pkl_path, 'wb') as f_writeb: |
| 1114 | pickle.dump(dict_to_dump, |
| 1115 | f_writeb, |
| 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. |
nothing calls this directly
no test coverage detected