Spaces:
Running
Running
File size: 2,256 Bytes
9140232 5ed049c 9140232 3bcd059 9140232 238ed9e aa2d072 9140232 f84d907 9140232 5ed049c f84d907 5ed049c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """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}}];
}}"""
|