Skip to content

Why mesh not good? #36

@qpc001

Description

@qpc001

I am integrating the MILO to my 3DGS using gsplat v1.4.0, but the mesh is not good, too noise, which extract from extract_mesh() func .

        # extract_mesh already imported at module level
        mesh = extract_mesh(
            delaunay_tets=delaunay_tets,
            pivots_sdf=pivots_sdf,
            means=means,
            scales=scales_exp,
            rotations=quats_norm,
            gaussian_idx=delaunay_xyz_idx,
            filter_large_edges=self.config.filter_large_edges,
            collapse_large_edges=self.config.collapse_large_edges,
        )
        
        if mesh is None or mesh.faces is None or mesh.faces.shape[0] == 0:
            # Try without filter_large_edges
            mesh = extract_mesh(
                delaunay_tets=delaunay_tets,
                pivots_sdf=pivots_sdf,
                means=means,
                scales=scales_exp,
                rotations=quats_norm,
                gaussian_idx=delaunay_xyz_idx,
                filter_large_edges=False,
                collapse_large_edges=False,
            )
            
            if mesh is None or mesh.faces is None or mesh.faces.shape[0] == 0:
                raise ValueError("[MILo] Mesh extraction returned empty mesh even without filtering")
        
        # Debug: Check mesh after extraction
        if step == self.config.start_iter or (step > 100 and step < 115):
            print(f"[MILo Debug] step={step} After extract_mesh:")
            print(f"  mesh.verts: nan={mesh.verts.isnan().sum()}, inf={mesh.verts.isinf().sum()}, shape={mesh.verts.shape}")
            if mesh.verts.isnan().any() or mesh.verts.isinf().any():
                print(f"  WARNING: mesh.verts has NaN/Inf! This will cause gradient explosion!")
        
        # --- Save mesh for debugging (every 500 steps) ---
        if step % 500 == 0:
            try:
                import os
                import trimesh
                debug_dir = "/home/user/shared_dir/vggt/dn-splatter/debug"
                os.makedirs(debug_dir, exist_ok=True)
                
                verts_np = mesh.verts.detach().cpu().numpy()
                faces_np = mesh.faces.detach().cpu().numpy()
                
                tri_mesh = trimesh.Trimesh(vertices=verts_np, faces=faces_np)
                mesh_path = os.path.join(debug_dir, f"milo_mesh_step{step:06d}.ply")
                tri_mesh.export(mesh_path)

                n_pivots = pivots.shape[0]
                sdf_positive = (pivots_sdf > 0).sum().item()
                sdf_negative = (pivots_sdf < 0).sum().item()
                sdf_near_zero = (pivots_sdf.abs() < 0.1).sum().item()
                scale_stats = f"[{scales_exp.min().item():.4f}, {scales_exp.max().item():.4f}]"
                
                print(f"[MILo] step={step} Mesh saved: verts={len(verts_np)}, faces={len(faces_np)}")
                print(f"  pivots={n_pivots}, SDF: pos={sdf_positive}, neg={sdf_negative}, near_zero={sdf_near_zero}")
                print(f"  scales range: {scale_stats}")
                print(f"  path: {mesh_path}")
            except Exception as e:
                print(f"[MILo] Failed to save mesh: {e}")

Here is the mesh depth and normal at iteration 17400:

Image Image

Here is the depth and normal from gsplat:

Image Image

Here is the mesh getting from extract_mesh()

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions