Spaces:
Running on Zero
Running on Zero
xiaoyuxi commited on
Commit ·
66adae5
1
Parent(s): 852c062
backend
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import base64
|
|
| 7 |
import requests
|
| 8 |
import time
|
| 9 |
from typing import List, Tuple
|
|
|
|
| 10 |
|
| 11 |
# Backend Space URL - replace with your actual backend space URL
|
| 12 |
BACKEND_SPACE_URL = "Yuxihenry/SpatialTrackerV2_Backend" # Replace with actual backend space URL
|
|
@@ -218,7 +219,7 @@ def handle_video_upload(video):
|
|
| 218 |
# Call the unified API with upload_video function type
|
| 219 |
result = backend_client.predict(
|
| 220 |
"upload_video", # function_type
|
| 221 |
-
video, # video file
|
| 222 |
"", # original_image_state (not used for upload)
|
| 223 |
[], # selected_points (not used for upload)
|
| 224 |
"positive_point", # point_type (not used for upload)
|
|
@@ -864,7 +865,7 @@ with gr.Blocks(
|
|
| 864 |
gr.Markdown("""
|
| 865 |
# 🎯 SpatialTracker V2 - Frontend Interface
|
| 866 |
|
| 867 |
-
Welcome to SpatialTracker V2! This interface allows you to track
|
| 868 |
|
| 869 |
**Instructions:**
|
| 870 |
1. Upload a video file or select from examples below
|
|
@@ -958,8 +959,8 @@ with gr.Blocks(
|
|
| 958 |
["examples/pillow.mp4"],
|
| 959 |
["examples/hockey.mp4"],
|
| 960 |
["examples/drifting.mp4"],
|
| 961 |
-
["examples/ball.mp4"],
|
| 962 |
["examples/ken_block_0.mp4"],
|
|
|
|
| 963 |
["examples/ego_kc1.mp4"],
|
| 964 |
["examples/vertical_place.mp4"],
|
| 965 |
["examples/ego_teaser.mp4"],
|
|
@@ -1008,13 +1009,37 @@ with gr.Blocks(
|
|
| 1008 |
interactive=False,
|
| 1009 |
height=300
|
| 1010 |
)
|
| 1011 |
-
|
| 1012 |
-
|
|
|
|
|
|
|
| 1013 |
with gr.Group():
|
| 1014 |
-
gr.Markdown("### 🌐 3D Visualization")
|
|
|
|
| 1015 |
viz_html = gr.HTML(
|
| 1016 |
label="3D Trajectory Visualization",
|
| 1017 |
-
value="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1018 |
)
|
| 1019 |
|
| 1020 |
# Advanced settings section - changed to open=True
|
|
@@ -1084,6 +1109,45 @@ with gr.Blocks(
|
|
| 1084 |
outputs=[viz_html, tracking_result_video]
|
| 1085 |
)
|
| 1086 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1087 |
# Launch the interface
|
| 1088 |
if __name__ == "__main__":
|
| 1089 |
print("🌟 Launching SpatialTracker V2 Frontend...")
|
|
|
|
| 7 |
import requests
|
| 8 |
import time
|
| 9 |
from typing import List, Tuple
|
| 10 |
+
from gradio_client.utils import handle_file
|
| 11 |
|
| 12 |
# Backend Space URL - replace with your actual backend space URL
|
| 13 |
BACKEND_SPACE_URL = "Yuxihenry/SpatialTrackerV2_Backend" # Replace with actual backend space URL
|
|
|
|
| 219 |
# Call the unified API with upload_video function type
|
| 220 |
result = backend_client.predict(
|
| 221 |
"upload_video", # function_type
|
| 222 |
+
handle_file(video), # video file
|
| 223 |
"", # original_image_state (not used for upload)
|
| 224 |
[], # selected_points (not used for upload)
|
| 225 |
"positive_point", # point_type (not used for upload)
|
|
|
|
| 865 |
gr.Markdown("""
|
| 866 |
# 🎯 SpatialTracker V2 - Frontend Interface
|
| 867 |
|
| 868 |
+
Welcome to SpatialTracker V2! This interface allows you to track any pixels in 3D using our model.
|
| 869 |
|
| 870 |
**Instructions:**
|
| 871 |
1. Upload a video file or select from examples below
|
|
|
|
| 959 |
["examples/pillow.mp4"],
|
| 960 |
["examples/hockey.mp4"],
|
| 961 |
["examples/drifting.mp4"],
|
|
|
|
| 962 |
["examples/ken_block_0.mp4"],
|
| 963 |
+
["examples/ball.mp4"],
|
| 964 |
["examples/ego_kc1.mp4"],
|
| 965 |
["examples/vertical_place.mp4"],
|
| 966 |
["examples/ego_teaser.mp4"],
|
|
|
|
| 1009 |
interactive=False,
|
| 1010 |
height=300
|
| 1011 |
)
|
| 1012 |
+
|
| 1013 |
+
# 3D Visualization - Make it larger and more prominent
|
| 1014 |
+
with gr.Row():
|
| 1015 |
+
with gr.Column():
|
| 1016 |
with gr.Group():
|
| 1017 |
+
gr.Markdown("### 🌐 3D Trajectory Visualization")
|
| 1018 |
+
gr.Markdown("Interactive 3D visualization of 3D point tracking and camera motion:")
|
| 1019 |
viz_html = gr.HTML(
|
| 1020 |
label="3D Trajectory Visualization",
|
| 1021 |
+
value="""
|
| 1022 |
+
<div style='border: 3px solid #667eea; border-radius: 15px; padding: 40px;
|
| 1023 |
+
background: linear-gradient(135deg, #f8f9ff 0%, #e6f3ff 100%);
|
| 1024 |
+
text-align: center; min-height: 600px; display: flex;
|
| 1025 |
+
flex-direction: column; justify-content: center; align-items: center;
|
| 1026 |
+
box-shadow: 0 8px 32px rgba(102, 126, 234, 0.2);'>
|
| 1027 |
+
<div style='font-size: 48px; margin-bottom: 20px;'>🌐</div>
|
| 1028 |
+
<h2 style='color: #667eea; margin-bottom: 15px; font-size: 28px; font-weight: 600;'>
|
| 1029 |
+
3D Trajectory Visualization
|
| 1030 |
+
</h2>
|
| 1031 |
+
<p style='color: #666; font-size: 16px; line-height: 1.6; max-width: 500px; margin-bottom: 25px;'>
|
| 1032 |
+
Perceive the world with Pixel-wise 3D Motions!
|
| 1033 |
+
</p>
|
| 1034 |
+
<div style='background: rgba(102, 126, 234, 0.1); border-radius: 25px;
|
| 1035 |
+
padding: 12px 24px; border: 2px solid rgba(102, 126, 234, 0.2);'>
|
| 1036 |
+
<span style='color: #667eea; font-weight: 600; font-size: 14px;'>
|
| 1037 |
+
⚡ Powered by SpatialTracker V2
|
| 1038 |
+
</span>
|
| 1039 |
+
</div>
|
| 1040 |
+
</div>
|
| 1041 |
+
""",
|
| 1042 |
+
elem_id="viz_container"
|
| 1043 |
)
|
| 1044 |
|
| 1045 |
# Advanced settings section - changed to open=True
|
|
|
|
| 1109 |
outputs=[viz_html, tracking_result_video]
|
| 1110 |
)
|
| 1111 |
|
| 1112 |
+
# Acknowledgment section for TAPIR3D - moved to the end
|
| 1113 |
+
gr.HTML("""
|
| 1114 |
+
<div style='background: linear-gradient(135deg, #fff8e1 0%, #fffbf0 100%);
|
| 1115 |
+
border-radius: 8px;
|
| 1116 |
+
padding: 12px;
|
| 1117 |
+
margin: 15px 0;
|
| 1118 |
+
box-shadow: 0 1px 4px rgba(255, 193, 7, 0.1);
|
| 1119 |
+
border: 1px solid rgba(255, 193, 7, 0.2);'>
|
| 1120 |
+
<div style='text-align: center; color: #5d4037;'>
|
| 1121 |
+
<h5 style='margin: 0 0 6px 0; font-size: 14px; color: #5d4037;'>
|
| 1122 |
+
🙏 Acknowledgments
|
| 1123 |
+
</h5>
|
| 1124 |
+
<p style='margin: 0; font-size: 12px; opacity: 0.9; color: #5d4037; line-height: 1.3;'>
|
| 1125 |
+
Our 3D visualizer is adapted from <strong>TAPIP3D</strong>. We thank the authors for their excellent work!
|
| 1126 |
+
</p>
|
| 1127 |
+
<div style='margin-top: 6px;'>
|
| 1128 |
+
<a href="https://github.com/zbw001/TAPIP3D"
|
| 1129 |
+
target="_blank"
|
| 1130 |
+
style='display: inline-flex;
|
| 1131 |
+
align-items: center;
|
| 1132 |
+
gap: 3px;
|
| 1133 |
+
background: rgba(255, 193, 7, 0.15);
|
| 1134 |
+
color: #5d4037;
|
| 1135 |
+
padding: 3px 10px;
|
| 1136 |
+
border-radius: 12px;
|
| 1137 |
+
text-decoration: none;
|
| 1138 |
+
font-weight: 500;
|
| 1139 |
+
font-size: 11px;
|
| 1140 |
+
border: 1px solid rgba(255, 193, 7, 0.3);
|
| 1141 |
+
transition: all 0.3s ease;'
|
| 1142 |
+
onmouseover="this.style.background='rgba(255, 193, 7, 0.2)'"
|
| 1143 |
+
onmouseout="this.style.background='rgba(255, 193, 7, 0.15)'">
|
| 1144 |
+
📚 TAPIP3D Repository
|
| 1145 |
+
</a>
|
| 1146 |
+
</div>
|
| 1147 |
+
</div>
|
| 1148 |
+
</div>
|
| 1149 |
+
""")
|
| 1150 |
+
|
| 1151 |
# Launch the interface
|
| 1152 |
if __name__ == "__main__":
|
| 1153 |
print("🌟 Launching SpatialTracker V2 Frontend...")
|