File size: 771 Bytes
3998c19 a25598f 3998c19 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """Read evaluation metadata without importing the training/model registry."""
import json
from pathlib import Path
def read_mode_config(pretrained_checkpoint):
from omegaconf import OmegaConf
checkpoint = Path(pretrained_checkpoint)
if not checkpoint.is_file():
raise FileNotFoundError(checkpoint)
if checkpoint.suffix != ".pt":
raise ValueError("Expected a .pt checkpoint.")
run = checkpoint.parents[1]
config_path = run / "config.full.yaml"
if not config_path.exists():
config_path = run / "config.yaml"
config = OmegaConf.to_container(OmegaConf.load(config_path), resolve=True)
with (run / "dataset_statistics.json").open() as stream:
statistics = json.load(stream)
return config, statistics
|