Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -216,6 +216,31 @@ def step4_track(session_id):
|
|
| 216 |
# New: run all steps sequentially
|
| 217 |
@spaces.GPU()
|
| 218 |
def generate_results_and_mesh(image, session_id):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
# Step 1
|
| 220 |
status1, crop_img, _, _ = preprocess_image(image_array)
|
| 221 |
if "❌" in status1:
|
|
|
|
| 216 |
# New: run all steps sequentially
|
| 217 |
@spaces.GPU()
|
| 218 |
def generate_results_and_mesh(image, session_id):
|
| 219 |
+
|
| 220 |
+
"""
|
| 221 |
+
Process an input image through a 3D reconstruction pipeline and return the intermediate outputs and mesh file.
|
| 222 |
+
|
| 223 |
+
This function runs a multi‐step workflow to go from a raw input image to a reconstructed 3D mesh:
|
| 224 |
+
1. **Preprocessing**: crops and masks the image for object isolation.
|
| 225 |
+
2. **Normals Estimation**: computes surface normal maps.
|
| 226 |
+
3. **UV Mapping**: generates UV coordinate maps for texturing.
|
| 227 |
+
4. **Tracking**: performs final alignment/tracking to prepare for mesh export.
|
| 228 |
+
5. **Mesh Discovery**: locates the resulting `.ply` file in the tracking output directory.
|
| 229 |
+
|
| 230 |
+
Args:
|
| 231 |
+
image (PIL.Image.Image or ndarray): Input image to reconstruct.
|
| 232 |
+
session_id (str): Unique identifier for this session’s output directories.
|
| 233 |
+
|
| 234 |
+
Returns:
|
| 235 |
+
tuple:
|
| 236 |
+
- final_status (str): Newline‐separated status messages from each pipeline step.
|
| 237 |
+
- crop_img (Image or None): Cropped and preprocessed image.
|
| 238 |
+
- normals_img (Image or None): Estimated surface normals visualization.
|
| 239 |
+
- uv_img (Image or None): UV‐map visualization.
|
| 240 |
+
- track_img (Image or None): Tracking/registration result.
|
| 241 |
+
- mesh_file (str or None): Path to the generated 3D mesh (`.ply`), if found.
|
| 242 |
+
"""
|
| 243 |
+
|
| 244 |
# Step 1
|
| 245 |
status1, crop_img, _, _ = preprocess_image(image_array)
|
| 246 |
if "❌" in status1:
|