Skip to content

save ply from verts and faces #710

@nairouzshehata

Description

@nairouzshehata

❓ Questions on how to use PyTorch3D

meshv is a torch Tensor of num of verts by 3
meshf is torch.long of num of faces by 3
save_obj(filename, meshv, meshf) works perfectly but save_ply(filename, meshv, meshf) produces the below error:

pytorch3d/io/ply_io.py in save_ply(f, verts, faces, verts_normals, ascii, decimal_places, path_manager)
   1157         path_manager = PathManager()
   1158     with _open_file(f, path_manager, "wb") as f:
-> 1159         _save_ply(
   1160             f,
   1161             verts=verts,
in _save_ply(f, verts, faces, verts_normals, verts_colors, ascii, decimal_places)
   1096                 # rows are 13 bytes: a one-byte 3 followed by three four-byte face indices.
   1097                 faces_uints = np.full((len(faces_array), 13), 3, dtype=np.uint8)
-> 1098                 faces_uints[:, 1:] = faces_array.astype(np.uint32).view(np.uint8)
   1099                 if isinstance(f, BytesIO):
   1100                     f.write(faces_uints.tobytes())

ValueError: could not broadcast input array from shape (3000,3) into shape (750,12)

NOTE: Please look at the existing list of Issues tagged with the label 'question](https://github.com/facebookresearch/pytorch3d/issues?q=label%3Aquestion) or ['how-to. Only open a new issue if you cannot find an answer there.

Also note the following:

  1. If you encountered any errors or unexpected issues while using PyTorch3D and need help resolving them,
    please use the "Bugs / Unexpected behaviors" issue template.

  2. We do not answer general machine learning / computer vision questions that are not specific to
    PyTorch3D, such as how a model works or what algorithm/methods can be
    used to achieve X.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions