Spaces:
Running
on
Zero
Running
on
Zero
xiaoyuxi
commited on
Commit
·
0fa54db
1
Parent(s):
1365486
vggt
Browse files
app.py
CHANGED
|
@@ -104,19 +104,26 @@ def handle_video_upload(video):
|
|
| 104 |
# For gr.Blocks, we use predict method
|
| 105 |
if 0 in backend_api.fns:
|
| 106 |
print("🔧 Using backend Blocks predict method")
|
| 107 |
-
result = backend_api.predict(0, [video, [], 50, 756, 3])
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
else:
|
| 119 |
-
print("Backend
|
| 120 |
# Fallback to local processing
|
| 121 |
pass
|
| 122 |
else:
|
|
@@ -304,25 +311,43 @@ def launch_viz(grid_size, vo_points, fps, original_image_state):
|
|
| 304 |
print(f"🔧 Original image state type: {type(original_image_state)}")
|
| 305 |
print(f"🔧 Original image state preview: {str(original_image_state)[:100]}...")
|
| 306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
# For gr.Blocks, we use predict method
|
| 308 |
if 0 in backend_api.fns:
|
| 309 |
print("🔧 Using backend Blocks predict method")
|
| 310 |
-
#
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
else:
|
| 323 |
-
print("Backend
|
| 324 |
-
|
| 325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
else:
|
| 327 |
print("Backend function 0 not found")
|
| 328 |
# Fallback to error message
|
|
@@ -354,6 +379,7 @@ def launch_viz(grid_size, vo_points, fps, original_image_state):
|
|
| 354 |
<p style='color: #666; font-size: 12px; margin: 0;'>Backend URL: {BACKEND_SPACE_URL}</p>
|
| 355 |
<p style='color: #666; font-size: 12px; margin: 0;'>Backend Type: {type(backend_api) if backend_api else 'None'}</p>
|
| 356 |
<p style='color: #666; font-size: 12px; margin: 0;'>Available Functions: {list(backend_api.fns.keys()) if backend_api and hasattr(backend_api, 'fns') else 'None'}</p>
|
|
|
|
| 357 |
</div>
|
| 358 |
<p style='color: #2d3436; font-weight: bold; margin-top: 15px;'>
|
| 359 |
Current Status: Backend unavailable - Running in limited mode
|
|
|
|
| 104 |
# For gr.Blocks, we use predict method
|
| 105 |
if 0 in backend_api.fns:
|
| 106 |
print("🔧 Using backend Blocks predict method")
|
|
|
|
| 107 |
|
| 108 |
+
# Check if predict is callable
|
| 109 |
+
if callable(backend_api.predict):
|
| 110 |
+
result = backend_api.predict(0, [video, [], 50, 756, 3])
|
| 111 |
+
|
| 112 |
+
print(f"✅ Backend video upload API call successful!")
|
| 113 |
+
print(f"🔧 Result type: {type(result)}")
|
| 114 |
+
|
| 115 |
+
# Parse the result - expect a dict with success status
|
| 116 |
+
if isinstance(result, dict) and result.get("success"):
|
| 117 |
+
# For now, just extract the first frame locally
|
| 118 |
+
display_image = extract_first_frame(video)
|
| 119 |
+
original_image_state = json.dumps({"video_path": video, "frame": "backend_processing"})
|
| 120 |
+
return original_image_state, display_image, [], 50, 756, 3
|
| 121 |
+
else:
|
| 122 |
+
print("Backend processing failed, using local fallback")
|
| 123 |
+
# Fallback to local processing
|
| 124 |
+
pass
|
| 125 |
else:
|
| 126 |
+
print("❌ Backend predict is not callable")
|
| 127 |
# Fallback to local processing
|
| 128 |
pass
|
| 129 |
else:
|
|
|
|
| 311 |
print(f"🔧 Original image state type: {type(original_image_state)}")
|
| 312 |
print(f"🔧 Original image state preview: {str(original_image_state)[:100]}...")
|
| 313 |
|
| 314 |
+
# Debug: Check what predict actually is
|
| 315 |
+
print(f"🔧 Backend API predict type: {type(backend_api.predict)}")
|
| 316 |
+
print(f"🔧 Backend API predict: {backend_api.predict}")
|
| 317 |
+
|
| 318 |
# For gr.Blocks, we use predict method
|
| 319 |
if 0 in backend_api.fns:
|
| 320 |
print("🔧 Using backend Blocks predict method")
|
| 321 |
+
# Check if predict is callable
|
| 322 |
+
if callable(backend_api.predict):
|
| 323 |
+
# For now, we'll use empty points since we're in local mode
|
| 324 |
+
result = backend_api.predict(0, [None, [], grid_size, vo_points, fps])
|
| 325 |
+
|
| 326 |
+
print(f"✅ Backend API call successful!")
|
| 327 |
+
print(f"🔧 Result type: {type(result)}")
|
| 328 |
+
print(f"🔧 Result: {result}")
|
| 329 |
+
|
| 330 |
+
# Parse the result
|
| 331 |
+
if isinstance(result, dict) and result.get("success"):
|
| 332 |
+
viz_html = result.get("viz_html_path", "")
|
| 333 |
+
track_video_path = result.get("track_video_path", "")
|
| 334 |
+
return viz_html, track_video_path
|
| 335 |
+
else:
|
| 336 |
+
print("Backend processing failed, showing error message")
|
| 337 |
+
# Fallback to error message
|
| 338 |
+
pass
|
| 339 |
else:
|
| 340 |
+
print("❌ Backend predict is not callable")
|
| 341 |
+
print(f"🔧 Predict type: {type(backend_api.predict)}")
|
| 342 |
+
# Try alternative approach
|
| 343 |
+
if hasattr(backend_api, 'call_function'):
|
| 344 |
+
print("🔧 Trying call_function method")
|
| 345 |
+
result = backend_api.call_function(0, [None, [], grid_size, vo_points, fps])
|
| 346 |
+
# Handle result...
|
| 347 |
+
else:
|
| 348 |
+
print("❌ No callable method found")
|
| 349 |
+
# Fallback to error message
|
| 350 |
+
pass
|
| 351 |
else:
|
| 352 |
print("Backend function 0 not found")
|
| 353 |
# Fallback to error message
|
|
|
|
| 379 |
<p style='color: #666; font-size: 12px; margin: 0;'>Backend URL: {BACKEND_SPACE_URL}</p>
|
| 380 |
<p style='color: #666; font-size: 12px; margin: 0;'>Backend Type: {type(backend_api) if backend_api else 'None'}</p>
|
| 381 |
<p style='color: #666; font-size: 12px; margin: 0;'>Available Functions: {list(backend_api.fns.keys()) if backend_api and hasattr(backend_api, 'fns') else 'None'}</p>
|
| 382 |
+
<p style='color: #666; font-size: 12px; margin: 0;'>Predict Type: {type(backend_api.predict) if backend_api and hasattr(backend_api, 'predict') else 'None'}</p>
|
| 383 |
</div>
|
| 384 |
<p style='color: #2d3436; font-weight: bold; margin-top: 15px;'>
|
| 385 |
Current Status: Backend unavailable - Running in limited mode
|