| 127 | |
| 128 | |
| 129 | class HumanData(dict): |
| 130 | logger = None |
| 131 | SUPPORTED_KEYS = _HumanData_SUPPORTED_KEYS |
| 132 | WARNED_KEYS = [] |
| 133 | |
| 134 | def __new__(cls: _HumanData, *args: Any, **kwargs: Any) -> _HumanData: |
| 135 | """New an instance of HumanData. |
| 136 | |
| 137 | Args: |
| 138 | cls (HumanData): HumanData class. |
| 139 | |
| 140 | Returns: |
| 141 | HumanData: An instance of HumanData. |
| 142 | """ |
| 143 | ret_human_data = super().__new__(cls, args, kwargs) |
| 144 | setattr(ret_human_data, '__data_len__', -1) |
| 145 | setattr(ret_human_data, '__key_strict__', False) |
| 146 | setattr(ret_human_data, '__keypoints_compressed__', False) |
| 147 | return ret_human_data |
| 148 | |
| 149 | @classmethod |
| 150 | def set_logger(cls, logger: Union[logging.Logger, str, None] = None): |
| 151 | """Set logger of HumanData class. |
| 152 | |
| 153 | Args: |
| 154 | logger (logging.Logger | str | None, optional): |
| 155 | The way to print summary. |
| 156 | See `mmcv.utils.print_log()` for details. |
| 157 | Defaults to None. |
| 158 | """ |
| 159 | cls.logger = logger |
| 160 | |
| 161 | @classmethod |
| 162 | def fromfile(cls, npz_path: str) -> _HumanData: |
| 163 | """Construct a HumanData instance from an npz file. |
| 164 | |
| 165 | Args: |
| 166 | npz_path (str): |
| 167 | Path to a dumped npz file. |
| 168 | |
| 169 | Returns: |
| 170 | HumanData: |
| 171 | A HumanData instance load from file. |
| 172 | """ |
| 173 | ret_human_data = cls() |
| 174 | ret_human_data.load(npz_path) |
| 175 | return ret_human_data |
| 176 | |
| 177 | @classmethod |
| 178 | def new(cls, |
| 179 | source_dict: dict = None, |
| 180 | key_strict: bool = False) -> _HumanData: |
| 181 | """Construct a HumanData instance from a dict. |
| 182 | |
| 183 | Args: |
| 184 | source_dict (dict, optional): |
| 185 | A dict with items in HumanData fashion. |
| 186 | Defaults to None. |