Skip to content

Commit aab9557

Browse files
Krzysztof Chalupkafacebook-github-bot
Krzysztof Chalupka
authored andcommitted
Submesh 0/n: Default to empty Meshes
Summary: The default behavior of Meshes (with verts=None, faces=None) throws an exception: ``` meshes = Meshes() > ValueError: Verts and Faces must be either a list or a tensor with shape (batch_size, N, 3) where N is either the maximum number of verts or faces respectively. ``` Instead, let's default to an empty mesh, following e.g. PyTorch: ``` empty_tensor = torch.FloatTensor() > torch.tensor([]) ``` this change is backwards-compatible (you can still init with verts=[], faces=[]). Reviewed By: bottler, nikhilaravi Differential Revision: D35443453 fbshipit-source-id: d638a8fef49a089bf0da6dd2201727b94ceb21ec
1 parent 67fff95 commit aab9557

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

pytorch3d/structures/meshes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ class Meshes:
214214

215215
def __init__(
216216
self,
217-
verts=None,
218-
faces=None,
217+
verts,
218+
faces,
219219
textures=None,
220220
*,
221221
verts_normals=None,

tests/test_meshes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ def test_simple_random_meshes(self):
265265
self.assertTrue(mesh_to_edges_packed_first_idx[0] == 0)
266266

267267
def test_allempty(self):
268-
verts_list = []
269-
faces_list = []
270-
mesh = Meshes(verts=verts_list, faces=faces_list)
268+
mesh = Meshes(verts=[], faces=[])
271269
self.assertEqual(len(mesh), 0)
272270
self.assertEqual(mesh.verts_padded().shape[0], 0)
273271
self.assertEqual(mesh.faces_padded().shape[0], 0)

0 commit comments

Comments
 (0)