Closed wshinigamic closed 7 months ago
I encountered the same problem. And it seems like that the problem exists only for CPU version of marching cubes as running the same example on CUDA produces correct vertices.
@Vezzp That's weird. We've had (and fixed) various problems with the cuda marching cubes recently. But the CPU code has been working the whole time as far as we knew. Can you provide an example? And maybe can you run an example from our tests?
I test with v0.7.5
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(10, 60, 16, levelset=True)
ellip_base_pt = torch.from_numpy(ellip_base).unsqueeze(0).float() # (N, D, H, W)
### 1) Run on CPU naive
### Slower than 4) Run by skimage
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 the code from CUDA
### --> Weird result
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 the code from CUDA --> Error: RuntimeError: expected scalar type Int but found Long
### https://github.com/facebookresearch/pytorch3d/issues/1679
# verts_cuda, faces_cuda = marching_cubes(ellip_base_pt.cuda(), 0)
### 4) Run by skimage
### --> Can't save the face with pytorch3D
verts_skimage, faces_skimage, normals_skimage, values_skimage = measure.marching_cubes(ellip_base, 0)
save_obj('marching_cubes_skimage.obj', torch.from_numpy(verts_skimage.copy()), torch.from_numpy(normals_skimage.copy()))
1) Run on CPU naive
2) Run on CPU with the code from CUDA
4) Run by skimage
🐛 Bugs / Unexpected behaviors
All vertices returned by pytorch3d.ops.marching_cubes.marching_cubes() have coordinates -1.
Instructions To Reproduce the Issue:
Code:
Output: