Spaces:
Running
Running
| from __future__ import annotations | |
| import random | |
| from pathlib import Path | |
| from typing import Any, Dict | |
| import numpy as np | |
| import torch | |
| import yaml | |
| def set_seed(seed: int) -> None: | |
| random.seed(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |
| torch.cuda.manual_seed_all(seed) | |
| def load_yaml(path: str | Path) -> Dict[str, Any]: | |
| with Path(path).open("r", encoding="utf-8") as f: | |
| return yaml.safe_load(f) | |
| def ensure_dir(path: str | Path) -> Path: | |
| target = Path(path) | |
| target.mkdir(parents=True, exist_ok=True) | |
| return target | |