Download training/config.py from DancingNow/swag-train-bundle: direct link, hf CLI and curl.
- Browser
- Download file 792 Bytes
-
https://huggingface.co/DancingNow/swag-train-bundle/resolve/main/training/config.py
- Command line
-
hf download hf://DancingNow/swag-train-bundle/training/config.py
-
curl -L -o config.py https://huggingface.co/DancingNow/swag-train-bundle/resolve/main/training/config.py
792 Bytes
| from __future__ import annotations | |
| from pathlib import Path | |
| from typing import Any | |
| import yaml | |
| SECTIONS = ("data", "model", "diffusion", "training", "output") | |
| def load_config(path: Path) -> dict[str, Any]: | |
| with path.open("r", encoding="utf-8") as handle: | |
| config = yaml.safe_load(handle) | |
| if not isinstance(config, dict): | |
| raise ValueError(f"Config must contain a mapping: {path}") | |
| missing = [section for section in SECTIONS if not isinstance(config.get(section), dict)] | |
| if missing: | |
| raise ValueError(f"Missing config sections: {', '.join(missing)}") | |
| return config | |
| def resolve_path(project_root: Path, value: str) -> Path: | |
| path = Path(value).expanduser() | |
| return path.resolve() if path.is_absolute() else (project_root / path).resolve() | |