Spaces:
Running
on
Zero
Running
on
Zero
yanranxiaoxi
commited on
Commit
•
f33836c
1
Parent(s):
7d68b4d
feat: add video show
Browse files
app.py
CHANGED
@@ -236,7 +236,7 @@ def step_2_generate_obj(image):
|
|
236 |
|
237 |
def step_3_generate_video(image):
|
238 |
_, video_path = generate_mesh(image, export_video=True)
|
239 |
-
return video_path
|
240 |
|
241 |
# 从 assets 文件夹中设置示例文件,并限制最多读取 10 个文件
|
242 |
example_folder = "assets"
|
@@ -274,23 +274,24 @@ with gr.Blocks() as demo:
|
|
274 |
|
275 |
with gr.Row():
|
276 |
with gr.Column():
|
|
|
277 |
video_file_output = gr.File(label="下载视频")
|
278 |
with gr.Column():
|
279 |
-
|
280 |
|
281 |
|
282 |
# 清除输出
|
283 |
def clear_model_viewer():
|
284 |
"""在加载新模型前重置 Gradio。"""
|
285 |
update_output = gr.update(value=None)
|
286 |
-
return update_output
|
287 |
|
288 |
# 首先清除输出的数据
|
289 |
-
img_input.change(clear_model_viewer, inputs=None, outputs=model_output)
|
290 |
|
291 |
# 然后生成模型和视频
|
292 |
generate_mesh_button.click(step_2_generate_obj, inputs=img_input, outputs=[obj_file_output, model_output])
|
293 |
-
generate_video_button.click(step_3_generate_video, inputs=img_input, outputs=video_file_output)
|
294 |
|
295 |
demo.launch(
|
296 |
auth=(os.environ.get('AUTH_USERNAME'), os.environ.get('AUTH_PASSWORD'))
|
|
|
236 |
|
237 |
def step_3_generate_video(image):
|
238 |
_, video_path = generate_mesh(image, export_video=True)
|
239 |
+
return video_path, video_path
|
240 |
|
241 |
# 从 assets 文件夹中设置示例文件,并限制最多读取 10 个文件
|
242 |
example_folder = "assets"
|
|
|
274 |
|
275 |
with gr.Row():
|
276 |
with gr.Column():
|
277 |
+
obj_file_output = gr.File(label="下载 .obj 文件")
|
278 |
video_file_output = gr.File(label="下载视频")
|
279 |
with gr.Column():
|
280 |
+
video_output = gr.Video(label="360° 视频")
|
281 |
|
282 |
|
283 |
# 清除输出
|
284 |
def clear_model_viewer():
|
285 |
"""在加载新模型前重置 Gradio。"""
|
286 |
update_output = gr.update(value=None)
|
287 |
+
return update_output, update_output
|
288 |
|
289 |
# 首先清除输出的数据
|
290 |
+
img_input.change(clear_model_viewer, inputs=None, outputs=[model_output, video_output])
|
291 |
|
292 |
# 然后生成模型和视频
|
293 |
generate_mesh_button.click(step_2_generate_obj, inputs=img_input, outputs=[obj_file_output, model_output])
|
294 |
+
generate_video_button.click(step_3_generate_video, inputs=img_input, outputs=[video_file_output, video_output])
|
295 |
|
296 |
demo.launch(
|
297 |
auth=(os.environ.get('AUTH_USERNAME'), os.environ.get('AUTH_PASSWORD'))
|