pytorch3d
pytorch3d copied to clipboard
result from `marching_cubes` has identical vertex indices
🐛 Bugs / Unexpected behaviors
The result from marching_cubes on GPU is not correct
Instructions To Reproduce the Issue:
pytorch3D installed from commit c292c71 Previous test result is in https://github.com/facebookresearch/pytorch3d/issues/1641#issuecomment-1913169684
import torch
from pytorch3d.ops.marching_cubes import marching_cubes, marching_cubes_naive
from pytorch3d.io import save_obj
from skimage import measure
from skimage.draw import ellipsoid
# Generate a level set about zero of two identical ellipsoids in 3D
ellip_base = ellipsoid(50, 60, 16, levelset=True)
ellip_base_pt = torch.from_numpy(ellip_base).unsqueeze(0).float() # (N, D, H, W)
### 1) Run on CPU with marching_cubes_naive
verts_cpu_naive, faces_cpu_naive = marching_cubes_naive(ellip_base_pt, 0)
save_obj('marching_cubes_naive.obj', verts_cpu_naive[0], faces_cpu_naive[0])
### 2) Run on CPU with marching_cubes
verts_cpu, faces_cpu = marching_cubes(ellip_base_pt, 0)
save_obj('marching_cubes_cpu.obj', verts_cpu[0], faces_cpu[0])
### 3) Run on CUDA with marching_cubes
verts_cuda, faces_cuda = marching_cubes(ellip_base_pt.cuda(), 0)
save_obj('marching_cubes_cuda.obj', verts_cuda[0], faces_cuda[0])
View from meshlab
1) Run on CPU with marching_cubes_naive
2) Run on CPU with marching_cubes
3) Run on CUDA with marching_cubes
I have the same problem on 0.7.6
; for me 0.7.4
is the last version that works correctly.
I believe this to be fixed by https://github.com/facebookresearch/pytorch3d/commit/7566530669203769783c94024c25a39e1744e4ed, I ran your repro locally and it succeeded. Do let me know if it's still broken for you. Thanks!
I can confirm this is working again on main.