Spaces:
Running
Running
Commit
·
1064203
1
Parent(s):
0236769
修复HuggingFace Space启动错误:调整代码结构确保变量在定义后引用
Browse files
app.py
CHANGED
@@ -1028,22 +1028,6 @@ if IN_HF_SPACE and 'spaces' in globals():
|
|
1028 |
# 调用普通的process函数实现,以避免重复代码
|
1029 |
return process(input_image, prompt, n_prompt, seed, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache)
|
1030 |
|
1031 |
-
# 仅在环境中设置,不在这里覆盖process函数
|
1032 |
-
process_gpu = process_with_gpu
|
1033 |
-
|
1034 |
-
|
1035 |
-
# 处理函数
|
1036 |
-
ips = [input_image, prompt, n_prompt, seed, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache]
|
1037 |
-
|
1038 |
-
# 开始和结束按钮事件
|
1039 |
-
if IN_HF_SPACE and 'spaces' in globals() and GPU_AVAILABLE and not cpu_fallback_mode:
|
1040 |
-
# 使用带GPU装饰器的处理函数
|
1041 |
-
start_button.click(fn=process_gpu, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button])
|
1042 |
-
else:
|
1043 |
-
# 使用普通处理函数
|
1044 |
-
start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button])
|
1045 |
-
|
1046 |
-
end_button.click(fn=end_process)
|
1047 |
|
1048 |
quick_prompts = [
|
1049 |
'The girl dances gracefully, with clear movements, full of charm.',
|
@@ -1536,4 +1520,17 @@ with block:
|
|
1536 |
# 错误信息区域 - 确保使用HTML组件以支持我们的自定义错误消息格式
|
1537 |
error_message = gr.HTML('', elem_id='error-message', visible=True)
|
1538 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1539 |
block.launch()
|
|
|
1028 |
# 调用普通的process函数实现,以避免重复代码
|
1029 |
return process(input_image, prompt, n_prompt, seed, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache)
|
1030 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1031 |
|
1032 |
quick_prompts = [
|
1033 |
'The girl dances gracefully, with clear movements, full of charm.',
|
|
|
1520 |
# 错误信息区域 - 确保使用HTML组件以支持我们的自定义错误消息格式
|
1521 |
error_message = gr.HTML('', elem_id='error-message', visible=True)
|
1522 |
|
1523 |
+
# 在此处定义处理函数需要的输入参数列表,确保UI元素已定义
|
1524 |
+
ips = [input_image, prompt, n_prompt, seed, total_second_length, latent_window_size, steps, cfg, gs, rs, gpu_memory_preservation, use_teacache]
|
1525 |
+
|
1526 |
+
# 开始和结束按钮事件
|
1527 |
+
if IN_HF_SPACE and 'spaces' in globals() and GPU_AVAILABLE and not cpu_fallback_mode:
|
1528 |
+
# 使用带GPU装饰器的处理函数
|
1529 |
+
start_button.click(fn=process_with_gpu, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button])
|
1530 |
+
else:
|
1531 |
+
# 使用普通处理函数
|
1532 |
+
start_button.click(fn=process, inputs=ips, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button, end_button])
|
1533 |
+
|
1534 |
+
end_button.click(fn=end_process)
|
1535 |
+
|
1536 |
block.launch()
|