Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -298,10 +298,10 @@ def generate_video_pro(image,desc):
|
|
298 |
|
299 |
import traceback
|
300 |
|
301 |
-
def safe_generate_video(
|
302 |
try:
|
303 |
-
#
|
304 |
-
return
|
305 |
except Exception as e:
|
306 |
# 捕获任何异常并返回错误消息
|
307 |
error_msg = f"An error occurred: {str(e)}"
|
@@ -309,7 +309,7 @@ def safe_generate_video(image):
|
|
309 |
print(traceback.format_exc())
|
310 |
return None, error_msg
|
311 |
|
312 |
-
|
313 |
with gr.Blocks() as demo:
|
314 |
gr.Markdown("Upload an image and provide a description to generate a video.")
|
315 |
|
@@ -322,7 +322,7 @@ with gr.Blocks() as demo:
|
|
322 |
video_output = gr.Video(label="Generated Video")
|
323 |
error_output = gr.Textbox(label="Error Messages", placeholder="No errors", lines=5)
|
324 |
submit_button.click(
|
325 |
-
lambda img, desc: safe_generate_video(
|
326 |
inputs=[image_input, description_input],
|
327 |
outputs=[video_output, error_output]
|
328 |
)
|
@@ -336,9 +336,9 @@ with gr.Blocks() as demo:
|
|
336 |
video_output_pro = gr.Video(label="Generated Video")
|
337 |
error_output_pro = gr.Textbox(label="Error Messages", placeholder="No errors", lines=5)
|
338 |
submit_button_pro.click(
|
339 |
-
lambda img, desc: safe_generate_video(
|
340 |
inputs=[image_input_pro, description_input_pro],
|
341 |
outputs=[video_output_pro, error_output_pro]
|
342 |
)
|
343 |
-
|
344 |
demo.launch()
|
|
|
|
298 |
|
299 |
import traceback
|
300 |
|
301 |
+
def safe_generate_video(func, *args):
|
302 |
try:
|
303 |
+
# 尝试生成视频,调用传入的函数
|
304 |
+
return func(*args), None
|
305 |
except Exception as e:
|
306 |
# 捕获任何异常并返回错误消息
|
307 |
error_msg = f"An error occurred: {str(e)}"
|
|
|
309 |
print(traceback.format_exc())
|
310 |
return None, error_msg
|
311 |
|
312 |
+
|
313 |
with gr.Blocks() as demo:
|
314 |
gr.Markdown("Upload an image and provide a description to generate a video.")
|
315 |
|
|
|
322 |
video_output = gr.Video(label="Generated Video")
|
323 |
error_output = gr.Textbox(label="Error Messages", placeholder="No errors", lines=5)
|
324 |
submit_button.click(
|
325 |
+
lambda img, desc: safe_generate_video(generate_video_basic, img, desc),
|
326 |
inputs=[image_input, description_input],
|
327 |
outputs=[video_output, error_output]
|
328 |
)
|
|
|
336 |
video_output_pro = gr.Video(label="Generated Video")
|
337 |
error_output_pro = gr.Textbox(label="Error Messages", placeholder="No errors", lines=5)
|
338 |
submit_button_pro.click(
|
339 |
+
lambda img, desc: safe_generate_video(generate_video_pro, img, desc),
|
340 |
inputs=[image_input_pro, description_input_pro],
|
341 |
outputs=[video_output_pro, error_output_pro]
|
342 |
)
|
|
|
343 |
demo.launch()
|
344 |
+
|