mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 20:02:49 +08:00
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
This commit is contained in:
parent
67fff956a2
commit
aab95575a6
@ -214,8 +214,8 @@ class Meshes:
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
verts=None,
|
verts,
|
||||||
faces=None,
|
faces,
|
||||||
textures=None,
|
textures=None,
|
||||||
*,
|
*,
|
||||||
verts_normals=None,
|
verts_normals=None,
|
||||||
|
@ -265,9 +265,7 @@ class TestMeshes(TestCaseMixin, unittest.TestCase):
|
|||||||
self.assertTrue(mesh_to_edges_packed_first_idx[0] == 0)
|
self.assertTrue(mesh_to_edges_packed_first_idx[0] == 0)
|
||||||
|
|
||||||
def test_allempty(self):
|
def test_allempty(self):
|
||||||
verts_list = []
|
mesh = Meshes(verts=[], faces=[])
|
||||||
faces_list = []
|
|
||||||
mesh = Meshes(verts=verts_list, faces=faces_list)
|
|
||||||
self.assertEqual(len(mesh), 0)
|
self.assertEqual(len(mesh), 0)
|
||||||
self.assertEqual(mesh.verts_padded().shape[0], 0)
|
self.assertEqual(mesh.verts_padded().shape[0], 0)
|
||||||
self.assertEqual(mesh.faces_padded().shape[0], 0)
|
self.assertEqual(mesh.faces_padded().shape[0], 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user