Spaces:
Sleeping
Sleeping
Wenjiawang0312
commited on
Commit
·
fe8d016
1
Parent(s):
e7f2fa1
store
Browse files- __pycache__/app.cpython-311.pyc +0 -0
- app.py +4 -4
- test_update.py +18 -0
__pycache__/app.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
|
|
|
app.py
CHANGED
|
@@ -238,12 +238,12 @@ def create_video_survey_app():
|
|
| 238 |
for i in range(4):
|
| 239 |
method_name = f"Method {chr(65+i)}"
|
| 240 |
if method_name in videos:
|
| 241 |
-
video_updates.append(videos[method_name])
|
| 242 |
else:
|
| 243 |
-
video_updates.append(None)
|
| 244 |
|
| 245 |
# 重置评分
|
| 246 |
-
rating_updates = [3
|
| 247 |
|
| 248 |
question_markdown = f"**场景 {question_idx + 1} / {len(question_folders)}**: `{scene_name}`"
|
| 249 |
|
|
@@ -283,7 +283,7 @@ def create_video_survey_app():
|
|
| 283 |
method_mapping,
|
| 284 |
f"**✅ 所有场景已完成!/ All scenes completed!**",
|
| 285 |
save_msg + "\n🎉 感谢参与!/ Thank you for participating!"
|
| 286 |
-
] + [None] * 4 + [3] * 12
|
| 287 |
|
| 288 |
return update_question(new_idx)
|
| 289 |
|
|
|
|
| 238 |
for i in range(4):
|
| 239 |
method_name = f"Method {chr(65+i)}"
|
| 240 |
if method_name in videos:
|
| 241 |
+
video_updates.append(gr.update(value=videos[method_name]))
|
| 242 |
else:
|
| 243 |
+
video_updates.append(gr.update(value=None))
|
| 244 |
|
| 245 |
# 重置评分
|
| 246 |
+
rating_updates = [gr.update(value=3) for _ in range(12)] # 4个视频 x 3个评分,每个默认值为3
|
| 247 |
|
| 248 |
question_markdown = f"**场景 {question_idx + 1} / {len(question_folders)}**: `{scene_name}`"
|
| 249 |
|
|
|
|
| 283 |
method_mapping,
|
| 284 |
f"**✅ 所有场景已完成!/ All scenes completed!**",
|
| 285 |
save_msg + "\n🎉 感谢参与!/ Thank you for participating!"
|
| 286 |
+
] + [gr.update(value=None)] * 4 + [gr.update(value=3)] * 12
|
| 287 |
|
| 288 |
return update_question(new_idx)
|
| 289 |
|
test_update.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# 测试 gr.update() 是否正确工作
|
| 4 |
+
with gr.Blocks() as demo:
|
| 5 |
+
gr.Markdown("# 测试视频和滑块更新")
|
| 6 |
+
|
| 7 |
+
video = gr.Video(label="测试视频")
|
| 8 |
+
slider = gr.Slider(minimum=1, maximum=5, step=1, value=3, label="测试滑块")
|
| 9 |
+
btn = gr.Button("更新")
|
| 10 |
+
|
| 11 |
+
def update_components():
|
| 12 |
+
# 测试返回 gr.update()
|
| 13 |
+
return gr.update(value="/root/.cache/huggingface/hub/datasets--WenjiaWang--videoforuser/snapshots/c273a82a04bb7b0320474ca0904b41b0582f3db4/0O_YyxcC-kA_scene-35_2/gen3c.mp4"), gr.update(value=5)
|
| 14 |
+
|
| 15 |
+
btn.click(update_components, outputs=[video, slider])
|
| 16 |
+
|
| 17 |
+
print("测试应用启动...")
|
| 18 |
+
demo.launch(server_name="0.0.0.0", server_port=7862, share=False)
|