Download model/boltzgen/task/predict/loading_utils.py from OneScience-Group/BoltzGen: direct link, hf CLI and curl.
- Browser
- Download file 996 Bytes
-
https://huggingface.co/OneScience-Group/BoltzGen/resolve/main/model/boltzgen/task/predict/loading_utils.py
- Command line
-
hf download hf://OneScience-Group/BoltzGen/model/boltzgen/task/predict/loading_utils.py
-
curl -L -o loading_utils.py https://huggingface.co/OneScience-Group/BoltzGen/resolve/main/model/boltzgen/task/predict/loading_utils.py
996 Bytes
| from pathlib import Path | |
| from boltzgen.data.data import Record, Structure | |
| def load_record(record_id: str, record_dir: Path) -> Record: | |
| """Load the given record. | |
| Parameters | |
| ---------- | |
| record_id : str | |
| The record id to load. | |
| record_dir : Path | |
| The path to the record directory. | |
| Returns | |
| ------- | |
| Record | |
| The loaded record. | |
| """ | |
| return Record.load(record_dir / f"{record_id}.json") | |
| def load_structure(record: Record, struct_dir: Path) -> Structure: | |
| """Load the given input data. | |
| Parameters | |
| ---------- | |
| record : str | |
| The record to load. | |
| target_dir : Path | |
| The path to the data directory. | |
| Returns | |
| ------- | |
| Input | |
| The loaded input. | |
| """ | |
| if (struct_dir / f"{record.id}.npz").exists(): | |
| structure_path = struct_dir / f"{record.id}.npz" | |
| else: | |
| structure_path = struct_dir / f"{record.id}" / f"{record.id}_model_0.npz" | |
| return Structure.load(structure_path) | |