Spaces:
Running
on
Zero
Running
on
Zero
xiaoyuxi
commited on
Commit
·
e5d8a8b
1
Parent(s):
145825f
backend
Browse files
app.py
CHANGED
|
@@ -496,7 +496,7 @@ def reset_points(original_img: str, sel_pix):
|
|
| 496 |
def launch_viz(grid_size, vo_points, fps, original_image_state):
|
| 497 |
"""Launch visualization with user-specific temp directory"""
|
| 498 |
if original_image_state is None:
|
| 499 |
-
return None, None
|
| 500 |
|
| 501 |
try:
|
| 502 |
if BACKEND_AVAILABLE and backend_client:
|
|
@@ -589,8 +589,8 @@ def launch_viz(grid_size, vo_points, fps, original_image_state):
|
|
| 589 |
else:
|
| 590 |
print("⚠️ No tracking video content received from backend")
|
| 591 |
|
| 592 |
-
# 返回iframe HTML
|
| 593 |
-
return iframe_html, local_video_path
|
| 594 |
else:
|
| 595 |
error_msg = result.get("error", "Unknown error") if isinstance(result, dict) else "Backend processing failed"
|
| 596 |
print(f"❌ Backend processing failed: {error_msg}")
|
|
@@ -663,11 +663,11 @@ def launch_viz(grid_size, vo_points, fps, original_image_state):
|
|
| 663 |
</div>
|
| 664 |
</div>
|
| 665 |
"""
|
| 666 |
-
return error_message, None
|
| 667 |
|
| 668 |
except Exception as e:
|
| 669 |
print(f"Error in launch_viz: {e}")
|
| 670 |
-
return None, None
|
| 671 |
|
| 672 |
def clear_all():
|
| 673 |
"""Clear all buffers and temporary files"""
|
|
@@ -676,6 +676,14 @@ def clear_all():
|
|
| 676 |
gr.update(value=756),
|
| 677 |
gr.update(value=3))
|
| 678 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 679 |
def update_tracker_model(model_name):
|
| 680 |
"""Update tracker model (placeholder function)"""
|
| 681 |
return
|
|
@@ -1091,6 +1099,13 @@ with gr.Blocks(
|
|
| 1091 |
interactive=False,
|
| 1092 |
height=300
|
| 1093 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1094 |
|
| 1095 |
# 3D Visualization - Make it larger and more prominent
|
| 1096 |
with gr.Row():
|
|
@@ -1181,14 +1196,14 @@ with gr.Blocks(
|
|
| 1181 |
)
|
| 1182 |
|
| 1183 |
clear_all_btn.click(
|
| 1184 |
-
fn=
|
| 1185 |
-
outputs=[video_input, interactive_frame, selected_points, grid_size, vo_points, fps]
|
| 1186 |
)
|
| 1187 |
|
| 1188 |
launch_btn.click(
|
| 1189 |
fn=launch_viz,
|
| 1190 |
inputs=[grid_size, vo_points, fps, original_image_state],
|
| 1191 |
-
outputs=[viz_html, tracking_result_video]
|
| 1192 |
)
|
| 1193 |
|
| 1194 |
# Acknowledgment section for TAPIR3D - moved to the end
|
|
|
|
| 496 |
def launch_viz(grid_size, vo_points, fps, original_image_state):
|
| 497 |
"""Launch visualization with user-specific temp directory"""
|
| 498 |
if original_image_state is None:
|
| 499 |
+
return None, None, None
|
| 500 |
|
| 501 |
try:
|
| 502 |
if BACKEND_AVAILABLE and backend_client:
|
|
|
|
| 589 |
else:
|
| 590 |
print("⚠️ No tracking video content received from backend")
|
| 591 |
|
| 592 |
+
# 返回iframe HTML、视频路径和HTML文件路径(用于下载)
|
| 593 |
+
return iframe_html, local_video_path, random_path
|
| 594 |
else:
|
| 595 |
error_msg = result.get("error", "Unknown error") if isinstance(result, dict) else "Backend processing failed"
|
| 596 |
print(f"❌ Backend processing failed: {error_msg}")
|
|
|
|
| 663 |
</div>
|
| 664 |
</div>
|
| 665 |
"""
|
| 666 |
+
return error_message, None, None
|
| 667 |
|
| 668 |
except Exception as e:
|
| 669 |
print(f"Error in launch_viz: {e}")
|
| 670 |
+
return None, None, None
|
| 671 |
|
| 672 |
def clear_all():
|
| 673 |
"""Clear all buffers and temporary files"""
|
|
|
|
| 676 |
gr.update(value=756),
|
| 677 |
gr.update(value=3))
|
| 678 |
|
| 679 |
+
def clear_all_with_download():
|
| 680 |
+
"""Clear all buffers including download component"""
|
| 681 |
+
return (None, None, [],
|
| 682 |
+
gr.update(value=50),
|
| 683 |
+
gr.update(value=756),
|
| 684 |
+
gr.update(value=3),
|
| 685 |
+
None) # HTML download component
|
| 686 |
+
|
| 687 |
def update_tracker_model(model_name):
|
| 688 |
"""Update tracker model (placeholder function)"""
|
| 689 |
return
|
|
|
|
| 1099 |
interactive=False,
|
| 1100 |
height=300
|
| 1101 |
)
|
| 1102 |
+
|
| 1103 |
+
# HTML文件下载组件
|
| 1104 |
+
html_download = gr.File(
|
| 1105 |
+
label="📥 Download 3D Visualization HTML",
|
| 1106 |
+
interactive=False,
|
| 1107 |
+
visible=True
|
| 1108 |
+
)
|
| 1109 |
|
| 1110 |
# 3D Visualization - Make it larger and more prominent
|
| 1111 |
with gr.Row():
|
|
|
|
| 1196 |
)
|
| 1197 |
|
| 1198 |
clear_all_btn.click(
|
| 1199 |
+
fn=clear_all_with_download,
|
| 1200 |
+
outputs=[video_input, interactive_frame, selected_points, grid_size, vo_points, fps, html_download]
|
| 1201 |
)
|
| 1202 |
|
| 1203 |
launch_btn.click(
|
| 1204 |
fn=launch_viz,
|
| 1205 |
inputs=[grid_size, vo_points, fps, original_image_state],
|
| 1206 |
+
outputs=[viz_html, tracking_result_video, html_download]
|
| 1207 |
)
|
| 1208 |
|
| 1209 |
# Acknowledgment section for TAPIR3D - moved to the end
|