Spaces:
Sleeping
Sleeping
testcoder-ui
commited on
Commit
·
486cfb1
1
Parent(s):
0f3d3ab
Fix all errors: add OAuth dependencies, fix event binding, and make LoginButton conditional
Browse files- app.py +14 -12
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -536,7 +536,9 @@ with gr.Blocks(title="Video Model Evaluator") as demo:
|
|
| 536 |
""")
|
| 537 |
|
| 538 |
# 添加 HF 登录按钮(Gradio 6.0 OAuth 支持)
|
| 539 |
-
|
|
|
|
|
|
|
| 540 |
|
| 541 |
with gr.Row():
|
| 542 |
with gr.Column(scale=1):
|
|
@@ -611,11 +613,6 @@ with gr.Blocks(title="Video Model Evaluator") as demo:
|
|
| 611 |
# 生成视频
|
| 612 |
status, results, urls = generate_videos(prompt, image, request)
|
| 613 |
|
| 614 |
-
# 更新状态
|
| 615 |
-
model_results_state.value = results
|
| 616 |
-
video_urls_state.value = urls
|
| 617 |
-
prompt_state.value = prompt
|
| 618 |
-
|
| 619 |
# 构建输出列表
|
| 620 |
outputs = [user_info_text, status]
|
| 621 |
has_results = len(urls) > 0
|
|
@@ -623,11 +620,17 @@ with gr.Blocks(title="Video Model Evaluator") as demo:
|
|
| 623 |
# 为每个模型添加视频和评分组件更新
|
| 624 |
for model_name in MODELS_TO_CALL:
|
| 625 |
video_value = urls.get(model_name, None)
|
|
|
|
| 626 |
outputs.append(video_value if video_value else None)
|
| 627 |
outputs.append(gr.update(visible=has_results))
|
| 628 |
-
outputs.append(gr.update(visible=has_results))
|
| 629 |
|
| 630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
|
| 632 |
return tuple(outputs)
|
| 633 |
|
|
@@ -644,10 +647,9 @@ with gr.Blocks(title="Video Model Evaluator") as demo:
|
|
| 644 |
# 构建输入输出列表
|
| 645 |
generate_outputs = [user_info, status_output]
|
| 646 |
for model_name in MODELS_TO_CALL:
|
| 647 |
-
generate_outputs.append(video_components[model_name])
|
| 648 |
-
generate_outputs.append(
|
| 649 |
-
|
| 650 |
-
generate_outputs.extend([submit_btn, model_results_state, video_urls_state])
|
| 651 |
|
| 652 |
submit_inputs = [model_results_state, video_urls_state, prompt_state]
|
| 653 |
submit_inputs.extend([score_components[model_name] for model_name in MODELS_TO_CALL])
|
|
|
|
| 536 |
""")
|
| 537 |
|
| 538 |
# 添加 HF 登录按钮(Gradio 6.0 OAuth 支持)
|
| 539 |
+
# 只在 Space 环境中显示(本地测试时会失败)
|
| 540 |
+
if os.getenv("SPACE_ID"): # SPACE_ID 只在 HF Space 中存在
|
| 541 |
+
login_btn = gr.LoginButton()
|
| 542 |
|
| 543 |
with gr.Row():
|
| 544 |
with gr.Column(scale=1):
|
|
|
|
| 613 |
# 生成视频
|
| 614 |
status, results, urls = generate_videos(prompt, image, request)
|
| 615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
# 构建输出列表
|
| 617 |
outputs = [user_info_text, status]
|
| 618 |
has_results = len(urls) > 0
|
|
|
|
| 620 |
# 为每个模型添加视频和评分组件更新
|
| 621 |
for model_name in MODELS_TO_CALL:
|
| 622 |
video_value = urls.get(model_name, None)
|
| 623 |
+
# 返回视频URL和可见性更新
|
| 624 |
outputs.append(video_value if video_value else None)
|
| 625 |
outputs.append(gr.update(visible=has_results))
|
|
|
|
| 626 |
|
| 627 |
+
# 添加提交按钮可见性、状态变量
|
| 628 |
+
outputs.extend([
|
| 629 |
+
gr.update(visible=has_results), # submit_btn visibility
|
| 630 |
+
prompt, # prompt_state
|
| 631 |
+
results, # model_results_state
|
| 632 |
+
urls # video_urls_state
|
| 633 |
+
])
|
| 634 |
|
| 635 |
return tuple(outputs)
|
| 636 |
|
|
|
|
| 647 |
# 构建输入输出列表
|
| 648 |
generate_outputs = [user_info, status_output]
|
| 649 |
for model_name in MODELS_TO_CALL:
|
| 650 |
+
generate_outputs.append(video_components[model_name]) # 视频组件
|
| 651 |
+
generate_outputs.append(score_components[model_name]) # 评分滑块可见性
|
| 652 |
+
generate_outputs.extend([submit_btn, prompt_state, model_results_state, video_urls_state])
|
|
|
|
| 653 |
|
| 654 |
submit_inputs = [model_results_state, video_urls_state, prompt_state]
|
| 655 |
submit_inputs.extend([score_components[model_name] for model_name in MODELS_TO_CALL])
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio>=4.0.0
|
| 2 |
pandas>=2.0.0
|
| 3 |
huggingface-hub>=0.20.0
|
| 4 |
requests>=2.31.0
|
|
|
|
| 1 |
+
gradio[oauth]>=4.0.0
|
| 2 |
pandas>=2.0.0
|
| 3 |
huggingface-hub>=0.20.0
|
| 4 |
requests>=2.31.0
|