Spaces:
Running on Zero
Running on Zero
Commit ·
f57d572
1
Parent(s): ea74719
Fix live example loading: use gr.update and factory function for proper state update
Browse files
app.py
CHANGED
|
@@ -149,13 +149,13 @@ def on_example_change(task_name, example_choice):
|
|
| 149 |
MAX_FRAMES = 60 # 1fps × 60s = up to 60 frames
|
| 150 |
|
| 151 |
|
| 152 |
-
def
|
| 153 |
-
"""
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
return
|
| 159 |
|
| 160 |
|
| 161 |
def extract_frames_1fps(video_path: str, max_frames: int = MAX_FRAMES) -> list:
|
|
@@ -431,7 +431,7 @@ with gr.Blocks(
|
|
| 431 |
|
| 432 |
for idx, btn in example_btns:
|
| 433 |
btn.click(
|
| 434 |
-
fn=
|
| 435 |
inputs=[],
|
| 436 |
outputs=[video_input, image_input, infer_question],
|
| 437 |
)
|
|
|
|
| 149 |
MAX_FRAMES = 60 # 1fps × 60s = up to 60 frames
|
| 150 |
|
| 151 |
|
| 152 |
+
def make_load_live_example(example_idx):
|
| 153 |
+
"""Create a loader function for a specific live example index."""
|
| 154 |
+
def _load():
|
| 155 |
+
ex = LIVE_EXAMPLES[example_idx]
|
| 156 |
+
images = [str(ROOT / fp) for fp in ex["frames"] if (ROOT / fp).exists()]
|
| 157 |
+
return gr.update(value=None), gr.update(value=images), gr.update(value=ex["question"])
|
| 158 |
+
return _load
|
| 159 |
|
| 160 |
|
| 161 |
def extract_frames_1fps(video_path: str, max_frames: int = MAX_FRAMES) -> list:
|
|
|
|
| 431 |
|
| 432 |
for idx, btn in example_btns:
|
| 433 |
btn.click(
|
| 434 |
+
fn=make_load_live_example(idx),
|
| 435 |
inputs=[],
|
| 436 |
outputs=[video_input, image_input, infer_question],
|
| 437 |
)
|