Spaces:
Running
Running
Download src/display/task_selection.py from vLAR/PhysInOne-Leaderboard: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/spaces/vLAR/PhysInOne-Leaderboard/resolve/main/src/display/task_selection.py
- Command line
-
hf download hf://spaces/vLAR/PhysInOne-Leaderboard/src/display/task_selection.py
-
curl -L -o task_selection.py https://huggingface.co/spaces/vLAR/PhysInOne-Leaderboard/resolve/main/src/display/task_selection.py
2.26 kB
| """Display-only VG labels and temporary selector availability.""" | |
| import json | |
| VG_TASK_LABELS = { | |
| "videoGeneration_static_large": "Video Generation with a Static Camera on the Large Test Set", | |
| "videoGeneration_moving_large": "Video Generation with a Moving Camera on the Large Test Set", | |
| "videoGeneration_static_mini": "Video Generation with a Static Camera on the Mini Test Set", | |
| "videoGeneration_moving_mini": "Video Generation with a Moving Camera on the Mini Test Set", | |
| } | |
| VG_DISABLED_TASKS = frozenset({"videoGeneration_static_large", | |
| "videoGeneration_moving_large"}) | |
| def selectable_tasks(task_names: list[str]) -> list[str]: | |
| return [name for name in task_names if name not in VG_DISABLED_TASKS] | |
| def selected_task(selected: str | None, task_names: list[str]) -> str | None: | |
| available = selectable_tasks(task_names) | |
| return selected if selected in available else next(iter(available), None) | |
| def task_label(task_name: str, fallback: str) -> str: | |
| return VG_TASK_LABELS.get(task_name, fallback) | |
| def vg_selection_js(task_names: list[str], task_name: str | None = None) -> str: | |
| if task_name is not None: | |
| selected = selected_task(task_name, task_names) | |
| updates = [selected, {"__type__": "update", "selected": selected}, | |
| "New Submission · " + VG_TASK_LABELS[selected]] | |
| return f"""async () => {{ | |
| await new Promise(resolve => requestAnimationFrame(resolve)); | |
| const active = document.querySelector('.vg-task-tabs [role="tab"][aria-selected="true"]'); | |
| if (active && active.dataset.tabId !== {json.dumps(selected)}) {{ | |
| return [{{__type__: 'update'}}, {{__type__: 'update'}}, {{__type__: 'update'}}]; | |
| }} | |
| return {json.dumps(updates)}; | |
| }}""" | |
| available = selectable_tasks(task_names) | |
| return f"""selected => {{ | |
| const available = {json.dumps(available)}; | |
| const labels = {json.dumps(VG_TASK_LABELS)}; | |
| const task = available.includes(selected) ? selected : available[0]; | |
| return [{{__type__: 'update', selected: task}}, 'New Submission · ' + labels[task], | |
| task, {{__type__: 'update', selected: task}}]; | |
| }}""" | |