Files
clip-annotator/src/river_annotation_tool/config.py

39 lines
991 B
Python
Raw Normal View History

from dataclasses import dataclass, field
from pathlib import Path
2026-05-20 13:26:03 +02:00
import yaml
2026-05-20 13:26:03 +02:00
@dataclass
class AppConfig:
display_max: int = 480
fps_fallback: int = 25
max_frames: int = 100
data_dir: str = "data/clips"
out_dir: str = "data/annotation_results"
clips_file: str = "config/clips.txt"
questions: list = field(default_factory=list)
def get_questions(self):
return [
2026-05-20 13:26:03 +02:00
(
s["section"],
[
(
item["key"],
item["label"],
[str(o) for o in item["options"]],
str(item["default"]) if item.get("default") is not None else None,
)
for item in s["items"]
],
)
for s in self.questions
]
2026-05-20 13:26:03 +02:00
def load_config(path: Path) -> AppConfig:
with open(path) as f:
data = yaml.safe_load(f)
return AppConfig(**data)