Spaces:
Running
Running
Download src/tasks/physiq_display.py from vLAR/PhysInOne-Leaderboard: direct link, hf CLI and curl.
- Browser
- Download file 3.71 kB
-
https://huggingface.co/spaces/vLAR/PhysInOne-Leaderboard/resolve/main/src/tasks/physiq_display.py
- Command line
-
hf download hf://spaces/vLAR/PhysInOne-Leaderboard/src/tasks/physiq_display.py
-
curl -L -o physiq_display.py https://huggingface.co/spaces/vLAR/PhysInOne-Leaderboard/resolve/main/src/tasks/physiq_display.py
3.71 kB
| """Optional display contract matching the Worker's recorded PhysIQ components.""" | |
| from src.display.metric_bar_config import higher_metric_bar_profile | |
| PHYSIQ_LABELS = { | |
| "PhysIQ/Spatial-IoU": "SP IoU", | |
| "PhysIQ/SpatioTemporal-IoU": "ST IoU", | |
| "PhysIQ/Weighted-Spatial-Iou": "WS IoU", | |
| } | |
| # Future prediction records normalized Worker keys, unlike the other tasks. | |
| # Share this mapping between task registration and the train/novel tables. | |
| FUTURE_PHYSIQ_LABELS = { | |
| "physiq_spatial_iou": "SP IoU", | |
| "physiq_spatiotemporal_iou": "ST IoU", | |
| "physiq_weighted_spatial_iou": "WS IoU", | |
| } | |
| PHYSIQ_TOOLTIPS = { | |
| "SP IoU": "PhysIQ Spatial IoU: overlap of motion regions across time", | |
| "ST IoU": "PhysIQ Spatiotemporal IoU: mean of per-frame motion-mask IoUs", | |
| "WS IoU": "PhysIQ Weighted Spatial IoU: overlap of temporal motion occupancy", | |
| } | |
| PHYSIQ_TOOLTIPS.update({ | |
| f"{prefix} {label}": f"{title} — {description}" | |
| for prefix, title in (("NOVEL", "Novel View Synthesis"), ("RESIM", "Resimulation")) | |
| for label, description in list(PHYSIQ_TOOLTIPS.items()) | |
| }) | |
| PHYSIQ_TOOLTIPS.update({ | |
| f"{label} ({view} view)": f"{view.title()} view: {description}" | |
| for view in ("training", "novel") | |
| for label, description in [(label, PHYSIQ_TOOLTIPS[label]) for label in PHYSIQ_LABELS.values()] | |
| }) | |
| def register_physiq_display(task) -> None: | |
| if task.name.startswith("videoGeneration_") or task.name == "motionTransfer": | |
| labels = PHYSIQ_LABELS | |
| elif task.name == "propertyEstimation": | |
| labels = {f"{prefix}_{key}": f"{title} {label}" | |
| for prefix, title in (("novel", "NOVEL"), ("reinit", "RESIM")) | |
| for key, label in PHYSIQ_LABELS.items()} | |
| elif task.name == "task_future_prediction": | |
| labels = {f"{key}_{split}": f"{label} ({title} view)" | |
| for split, title in (("train", "training"), ("novel", "novel")) | |
| for key, label in PHYSIQ_LABELS.items()} | |
| elif task.name == "futurePrediction": | |
| labels = {f"{key}_{split}": f"{label} ({title} view)" | |
| for split, title in (("train", "training"), ("novel", "novel")) | |
| for key, label in FUTURE_PHYSIQ_LABELS.items()} | |
| else: | |
| return | |
| task.leaderboard_columns.extend(key for key in labels if key not in task.leaderboard_columns) | |
| task.column_display_names = {**getattr(task, "column_display_names", {}), **labels} | |
| task.metric_directions = {key: True for key in labels} | |
| task.metric_ranges = {**getattr(task, "metric_ranges", {}), **{key: (0.0, 1.0) for key in labels}} | |
| task.optional_metric_columns = tuple(labels) | |
| def metric_ranges_for_task(task) -> dict: | |
| return {task.column_display_names.get(key, key): bounds | |
| for key, bounds in getattr(task, "metric_ranges", {}).items()} | |
| def metric_bar_modes_for_task(task) -> dict: | |
| modes = {} | |
| for key in dict.fromkeys([task.primary_metric, *task.leaderboard_columns]): | |
| if key in getattr(task, "excel_summary_specs", {}) or key == "overall_error": | |
| continue | |
| tokens = key.lower().split("_") | |
| if "lpips" in tokens: | |
| modes[task.column_display_names.get(key, key)] = "minimum_ratio" | |
| elif key in getattr(task, "metric_ranges", {}) or any(metric in tokens for metric in ("pmf", "psnr", "ssim")): | |
| modes[task.column_display_names.get(key, key)] = "reference_span" | |
| return modes | |
| def metric_bar_profiles_for_task(task) -> dict: | |
| return {task.column_display_names.get(key, key): profile | |
| for key in dict.fromkeys([task.primary_metric, *task.leaderboard_columns]) | |
| if (profile := higher_metric_bar_profile(task, key)) is not None} | |