diff --git a/pytorch3d/io/ply_io.py b/pytorch3d/io/ply_io.py index 77cd8fbc..5ec7f662 100644 --- a/pytorch3d/io/ply_io.py +++ b/pytorch3d/io/ply_io.py @@ -1043,7 +1043,7 @@ def _load_ply(f, *, path_manager: PathManager) -> _PlyData: faces = torch.LongTensor(np.vstack(face_arrays).astype(np.int64)) else: face_list = [] - for face_item in face: + for (face_item,) in face: if face_item.ndim != 1: raise ValueError("Bad face data.") if face_item.shape[0] < 3: diff --git a/tests/test_io_ply.py b/tests/test_io_ply.py index 8297765e..98394a34 100644 --- a/tests/test_io_ply.py +++ b/tests/test_io_ply.py @@ -195,6 +195,15 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase): ): io.load_mesh(f3.name) + def test_heterogenous_verts_per_face(self): + # The cube but where one face is pentagon not square. + text = CUBE_PLY_LINES.copy() + text[-1] = "5 3 7 4 0 1" + stream = StringIO("\n".join(text)) + verts, faces = load_ply(stream) + self.assertEqual(verts.shape, (8, 3)) + self.assertEqual(faces.shape, (13, 3)) + def test_save_too_many_colors(self): verts = torch.tensor( [[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0]], dtype=torch.float32