Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse filesLooking at the MeshExtractResult and what we have in the state, we already have the raw vertices and faces directly from the model output - we don't need to do any additional processing at all.
app.py
CHANGED
@@ -162,35 +162,26 @@ def image_to_3d(
|
|
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 |
-
|
171 |
"""
|
172 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
173 |
-
gs, mesh, trial_id = unpack_state(state)
|
174 |
|
175 |
-
#
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
raw_mesh = postprocessing_utils.to_glb(
|
180 |
-
gs,
|
181 |
-
mesh,
|
182 |
-
simplify=0.0, # No simplification at all
|
183 |
-
fill_holes=True, # Keep holes filled
|
184 |
-
fill_holes_max_size=0.04, # Standard hole filling size
|
185 |
-
verbose=True
|
186 |
-
)
|
187 |
|
188 |
-
#
|
|
|
189 |
glb_path = os.path.join(user_dir, f"{trial_id}_full.glb")
|
190 |
-
|
191 |
|
192 |
-
# Final cleanup
|
193 |
-
torch.cuda.empty_cache()
|
194 |
return glb_path, glb_path
|
195 |
|
196 |
@spaces.GPU
|
|
|
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 without any processing.
|
172 |
"""
|
173 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
|
|
174 |
|
175 |
+
# Get the raw mesh data from state
|
176 |
+
vertices = state['mesh']['vertices'] # Already in numpy format from pack_state
|
177 |
+
faces = state['mesh']['faces']
|
178 |
+
trial_id = state['trial_id']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
+
# Create mesh and save directly
|
181 |
+
simple_mesh = trimesh.Trimesh(vertices=vertices, faces=faces)
|
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
|