All constants are in config
This commit is contained in:
@@ -4,6 +4,22 @@ from pathlib import Path
|
||||
import yaml
|
||||
|
||||
|
||||
@dataclass
|
||||
class FilenameConfig:
|
||||
video_in_zip: str = "left.mp4"
|
||||
video_tmp_suffix: str = ".mp4"
|
||||
zip_extension: str = ".zip"
|
||||
mask: str = "mask.png"
|
||||
metadata: str = "metadata.json"
|
||||
frame: str = "frame.png"
|
||||
overlay: str = "overlay.png"
|
||||
mask_vis: str = "mask_vis.png"
|
||||
gif_original_hires: str = "video_original_hires.gif"
|
||||
gif_original_lowres: str = "video_original_lowres.gif"
|
||||
gif_overlay_hires: str = "video_overlay_hires.gif"
|
||||
gif_overlay_lowres: str = "video_overlay_lowres.gif"
|
||||
|
||||
|
||||
@dataclass
|
||||
class AppConfig:
|
||||
display_max: int = 480
|
||||
@@ -13,6 +29,7 @@ class AppConfig:
|
||||
out_dir: str = "data/annotation_results"
|
||||
clips_file: str = "config/clips.txt"
|
||||
questions: list = field(default_factory=list)
|
||||
filenames: FilenameConfig = field(default_factory=FilenameConfig)
|
||||
|
||||
def get_questions(self):
|
||||
return [
|
||||
@@ -23,7 +40,9 @@ class AppConfig:
|
||||
item["key"],
|
||||
item["label"],
|
||||
[str(o) for o in item["options"]],
|
||||
str(item["default"]) if item.get("default") is not None else None,
|
||||
str(item["default"])
|
||||
if item.get("default") is not None
|
||||
else None,
|
||||
)
|
||||
for item in s["items"]
|
||||
],
|
||||
@@ -35,4 +54,7 @@ class AppConfig:
|
||||
def load_config(path: Path) -> AppConfig:
|
||||
with open(path) as f:
|
||||
data = yaml.safe_load(f)
|
||||
return AppConfig(**data)
|
||||
fn_data = data.pop("filenames", {})
|
||||
cfg = AppConfig(**data)
|
||||
cfg.filenames = FilenameConfig(**fn_data)
|
||||
return cfg
|
||||
|
||||
Reference in New Issue
Block a user