Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -208,15 +208,34 @@ def generate_video(image):
|
|
208 |
print("video_done")
|
209 |
return video_data
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
# 定义 Gradio 接口
|
212 |
interface = gr.Interface(
|
213 |
-
fn=lambda img:
|
214 |
inputs=gr.Image(type="pil"),
|
215 |
-
outputs=
|
|
|
|
|
|
|
216 |
title="InspiroV Video Generation",
|
217 |
-
description="Upload an image to generate a video",
|
218 |
theme="soft"
|
219 |
)
|
220 |
|
221 |
# 启动 Gradio 应用
|
222 |
interface.launch()
|
|
|
|
|
|
|
|
208 |
print("video_done")
|
209 |
return video_data
|
210 |
|
211 |
+
import traceback
|
212 |
+
|
213 |
+
def safe_generate_video(image):
|
214 |
+
try:
|
215 |
+
# 尝试生成视频
|
216 |
+
return generate_video(image), None
|
217 |
+
except Exception as e:
|
218 |
+
# 捕获任何异常并返回错误消息
|
219 |
+
error_msg = f"An error occurred: {str(e)}"
|
220 |
+
# 可选:打印堆栈跟踪信息以便于调试
|
221 |
+
print(traceback.format_exc())
|
222 |
+
return None, error_msg
|
223 |
+
|
224 |
# 定义 Gradio 接口
|
225 |
interface = gr.Interface(
|
226 |
+
fn=lambda img: safe_generate_video(img.convert('RGB')), # 确保输入是RGB格式的图片
|
227 |
inputs=gr.Image(type="pil"),
|
228 |
+
outputs=[
|
229 |
+
gr.Video(label="Generated Video"),
|
230 |
+
gr.Textbox(label="Error Messages", placeholder="No errors", lines=5)
|
231 |
+
],
|
232 |
title="InspiroV Video Generation",
|
233 |
+
description="Upload an image to generate a video. Any errors will be displayed below.",
|
234 |
theme="soft"
|
235 |
)
|
236 |
|
237 |
# 启动 Gradio 应用
|
238 |
interface.launch()
|
239 |
+
|
240 |
+
# 启动 Gradio 应用
|
241 |
+
interface.launch()
|