facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.85k stars 1.32k forks source link

when i use pytorch3d to visual a voxel error. #1793

Closed xiaoc57 closed 3 months ago

xiaoc57 commented 6 months ago

❓ Questions on how to use PyTorch3D

i use the code below to visual my voxel from shapenet. the shapenet model is d8e2e2a923b372731cf97e154cc62f43. i look this model in meshlab which is correct. Why does this happen?

def render_vox(voxels_src, src_path = "submissions/source_vox.gif", num_views = 100):

    R, T = look_at_view_transform(dist=5, elev=0, azim=np.linspace(-180, 180, num_views, endpoint=False))
    many_cameras = FoVPerspectiveCameras(R=R, T=T, device=voxels_src.device)
    renderer = get_mesh_renderer(device=voxels_src.device)

    cube_src = cubify(voxels_src, 0.5, align="center")
    vertex_src = cube_src.verts_list()[0]
    texture_src = TexturesVertex(vertex_src.unsqueeze(0))
    cube_src.textures = texture_src

    my_images = renderer(cube_src.extend(num_views), cameras=many_cameras)
    my_images = my_images[:, ..., :3].cpu().detach().numpy()
    my_images = (my_images * 255).astype(np.uint8)
    img_list = [i for i in my_images]
    imageio.mimsave(src_path, img_list, fps=15)

4025157198 this figure is used imageio FUG(AV6ZSINBA9MNDVUU9~X this figure is used meshlab to watch.

bottler commented 6 months ago

The problem is the gap/break in the chair, right? If so, can you look at voxel_src and see what the values are in the gap? What is the exact code which produces voxel_src? Does changing the threshold from 0.5, e.g. to a lower number, help? Can you try running marching cubes instead?