Replace hardcoded config and directory scan with YAML config and explicit clip list
- config.py constants -> config/config.yaml (user-editable, git-ignored) - Questions and defaults now defined in the YAML, including per-question defaults - ClipSelector no longer scans the data dir; reads a user-provided clips.txt instead - Removed --daily / --time / --skip-existing-day args - video_loader now samples frames evenly across the full clip - pyyaml added as a dependency Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,44 +1,38 @@
|
||||
class Config:
|
||||
DISPLAY_MAX = 480
|
||||
FPS_FALLBACK = 25
|
||||
MAX_FRAMES = 100
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
QUESTIONS = [
|
||||
(
|
||||
"River",
|
||||
[
|
||||
("flow", "Flow Regime", ["Turbulent", "Laminar", "Uncertain"]),
|
||||
("shadows", "Strong Shadows", ["Yes", "No", "Uncertain"]),
|
||||
("artifacts", "Artifacts on River", ["Yes", "No", "Uncertain"]),
|
||||
],
|
||||
),
|
||||
(
|
||||
"Scene",
|
||||
[
|
||||
("lighting", "Lighting", ["Day", "Night", "Uncertain"]),
|
||||
@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 [
|
||||
(
|
||||
"exposure",
|
||||
"Exposure",
|
||||
["Overexposed", "Underexposed", "Both", "Normal", "Uncertain"],
|
||||
),
|
||||
],
|
||||
),
|
||||
(
|
||||
"Weather",
|
||||
[
|
||||
("snowing", "Snowing", ["Yes", "No", "Uncertain"]),
|
||||
("snow_on_ground", "Snow on Ground", ["Yes", "No", "Uncertain"]),
|
||||
],
|
||||
),
|
||||
]
|
||||
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
|
||||
]
|
||||
|
||||
DEFAULTS = {
|
||||
"flow": "Laminar",
|
||||
"shadows": "No",
|
||||
"artifacts": "No",
|
||||
"lighting": "Day",
|
||||
"exposure": "Normal",
|
||||
"snowing": "No",
|
||||
"snow_on_ground": "No",
|
||||
}
|
||||
|
||||
def load_config(path: Path) -> AppConfig:
|
||||
with open(path) as f:
|
||||
data = yaml.safe_load(f)
|
||||
return AppConfig(**data)
|
||||
|
||||
Reference in New Issue
Block a user