Spaces:
Paused
Paused
Wrap generate in try-except to surface backend errors
Browse files
app.py
CHANGED
|
@@ -136,31 +136,41 @@ def generate(files: Any):
|
|
| 136 |
)
|
| 137 |
return None, None, err_placeholder, status
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
| 141 |
|
| 142 |
-
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
|
| 153 |
-
|
| 154 |
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
|
| 166 |
# ----------------------------------------------------------------------------
|
|
|
|
| 136 |
)
|
| 137 |
return None, None, err_placeholder, status
|
| 138 |
|
| 139 |
+
import traceback
|
| 140 |
+
try:
|
| 141 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 142 |
+
model.to(device)
|
| 143 |
|
| 144 |
+
gaussians = model(result.images)[0]
|
| 145 |
|
| 146 |
+
video_path = tempfile.mktemp(suffix=".mp4")
|
| 147 |
+
ply_path = tempfile.mktemp(suffix=".ply")
|
| 148 |
|
| 149 |
+
viz.turntable(gaussians, video_path, sweep_deg=None)
|
| 150 |
+
gaussians.save_ply(ply_path)
|
| 151 |
|
| 152 |
+
center, radius = viz.scene_center_radius(gaussians)
|
| 153 |
+
cx, cy, cz = center.tolist()
|
| 154 |
|
| 155 |
+
viewer_html = build_viewer_iframe(ply_path, cx=cx, cy=cy, cz=cz, r=radius)
|
| 156 |
|
| 157 |
+
status = (
|
| 158 |
+
f"Loaded {result.image_count} still image(s) and selected "
|
| 159 |
+
f"{result.selected_video_frames} of {result.decoded_video_frames} decoded video frame(s).\n"
|
| 160 |
+
f"Total ZipSplat views: {len(result.images)}."
|
| 161 |
+
)
|
| 162 |
+
if result.warnings:
|
| 163 |
+
status += "\n\nWarnings:\n" + "\n".join(result.warnings)
|
| 164 |
|
| 165 |
+
return video_path, ply_path, viewer_html, status
|
| 166 |
+
except Exception as e:
|
| 167 |
+
err_msg = f"Backend Crash during generation:\n{traceback.format_exc()}"
|
| 168 |
+
err_html = (
|
| 169 |
+
f'<div style="height: 500px; padding: 20px; overflow-y: auto; '
|
| 170 |
+
f'background: #080b12; color: #f87171; border-radius: 12px; font-family: monospace;">'
|
| 171 |
+
f"{err_msg.replace(chr(10), '<br>')}</div>"
|
| 172 |
+
)
|
| 173 |
+
return None, None, err_html, err_msg
|
| 174 |
|
| 175 |
|
| 176 |
# ----------------------------------------------------------------------------
|