Download src/utils/model_info.py from ArcaeaOffline/crnn-pytorch: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/ArcaeaOffline/crnn-pytorch/resolve/main/src/utils/model_info.py
- Command line
-
hf download hf://ArcaeaOffline/crnn-pytorch/src/utils/model_info.py
-
curl -L -o model_info.py https://huggingface.co/ArcaeaOffline/crnn-pytorch/resolve/main/src/utils/model_info.py
1.26 kB
| import dataclasses | |
| from datetime import datetime, timezone | |
| class TrainingInfo: | |
| """Training artifacts, stored under the "training" key of model_info.json.""" | |
| image_width: int | |
| image_height: int | |
| labels: list[str] | |
| built_time: datetime | |
| blank_token: str | |
| pad_token: str | |
| def built_timestamp(self) -> int: | |
| return int(self.built_time.astimezone(timezone.utc).timestamp()) | |
| def asdict(self): | |
| return { | |
| "image_width": self.image_width, | |
| "image_height": self.image_height, | |
| "labels": self.labels.copy(), | |
| "built_timestamp": self.built_timestamp, | |
| "blank_token": self.blank_token, | |
| "pad_token": self.pad_token, | |
| } | |
| def from_dict(cls, model_info_dict: dict): | |
| return cls( | |
| image_width=model_info_dict["image_width"], | |
| image_height=model_info_dict["image_height"], | |
| labels=model_info_dict["labels"].copy(), | |
| built_time=datetime.fromtimestamp( | |
| model_info_dict["built_timestamp"], timezone.utc | |
| ), | |
| blank_token=model_info_dict["blank_token"], | |
| pad_token=model_info_dict["pad_token"], | |
| ) | |