Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse filesz-up to y-up coordinate system.
app.py
CHANGED
@@ -162,13 +162,12 @@ def image_to_3d(
|
|
162 |
return state, video_path
|
163 |
|
164 |
@spaces.GPU
|
165 |
-
|
166 |
def extract_high_quality_mesh(
|
167 |
state: dict,
|
168 |
req: gr.Request,
|
169 |
) -> Tuple[str, str]:
|
170 |
"""
|
171 |
-
Save raw mesh data directly
|
172 |
"""
|
173 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
174 |
|
@@ -177,13 +176,17 @@ def extract_high_quality_mesh(
|
|
177 |
faces = state['mesh']['faces']
|
178 |
trial_id = state['trial_id']
|
179 |
|
180 |
-
#
|
181 |
-
|
|
|
|
|
|
|
|
|
182 |
glb_path = os.path.join(user_dir, f"{trial_id}_full.glb")
|
183 |
simple_mesh.export(glb_path)
|
184 |
|
185 |
return glb_path, glb_path
|
186 |
-
|
187 |
@spaces.GPU
|
188 |
def extract_reduced_glb(
|
189 |
state: dict,
|
|
|
162 |
return state, video_path
|
163 |
|
164 |
@spaces.GPU
|
|
|
165 |
def extract_high_quality_mesh(
|
166 |
state: dict,
|
167 |
req: gr.Request,
|
168 |
) -> Tuple[str, str]:
|
169 |
"""
|
170 |
+
Save raw mesh data directly with correct orientation.
|
171 |
"""
|
172 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
173 |
|
|
|
176 |
faces = state['mesh']['faces']
|
177 |
trial_id = state['trial_id']
|
178 |
|
179 |
+
# Rotate vertices from z-up to y-up
|
180 |
+
rotation_matrix = np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])
|
181 |
+
rotated_vertices = vertices @ rotation_matrix
|
182 |
+
|
183 |
+
# Create mesh and save
|
184 |
+
simple_mesh = trimesh.Trimesh(vertices=rotated_vertices, faces=faces)
|
185 |
glb_path = os.path.join(user_dir, f"{trial_id}_full.glb")
|
186 |
simple_mesh.export(glb_path)
|
187 |
|
188 |
return glb_path, glb_path
|
189 |
+
|
190 |
@spaces.GPU
|
191 |
def extract_reduced_glb(
|
192 |
state: dict,
|