Esempio n. 1
0
 def test_batch_match(self, device, dtype):
     # The batch size of voxelgrids and odms must match.
     with pytest.raises(
             ValueError,
             match="Expected voxelgrids and odms' batch size to be the same, "
             "but got 2 for odms and 3 for voxelgrid."):
         voxelgrids = torch.ones((3, 3, 3, 3), device=device, dtype=dtype)
         odms = torch.ones((2, 6, 3, 3), device=device, dtype=dtype)
         vg.project_odms(odms, voxelgrids)
Esempio n. 2
0
 def test_dimension_match(self, device, dtype):
     # The dimension of voxelgrids and odms must match
     with pytest.raises(
             ValueError,
             match=
             "Expected voxelgrids and odms' dimension size to be the same, "
             "but got 3 for odms and 4 for voxelgrid."):
         voxelgrids = torch.ones((2, 4, 4, 4), device=device, dtype=dtype)
         odms = torch.ones((2, 6, 3, 3), device=device, dtype=dtype)
         vg.project_odms(odms, voxelgrids)
Esempio n. 3
0
    def test_empty_filled_odms(self, device, dtype):
        # If the input is an empty odms, the output should be a filled voxel grid
        odms1 = torch.zeros((6, 3, 3), device=device, dtype=dtype)

        # If the input odms is a filled odms. the output should be an empty voxel grid
        odms2 = torch.ones((6, 3, 3), device=device, dtype=dtype) * 3

        odms = torch.stack((odms1, odms2))
        voxelgrids = vg.project_odms(odms)

        assert torch.equal(
            voxelgrids[0],
            torch.ones((3, 3, 3), device=device, dtype=torch.bool))
        assert torch.equal(
            voxelgrids[1],
            torch.zeros((3, 3, 3), device=device, dtype=torch.bool))
Esempio n. 4
0
    def test_handmade_input_vote4(self, device, dtype):
        # The input is hand-made.
        odms = torch.tensor([[[[2, 0, 0], [2, 0, 0], [1, 1, 0]],
                              [[0, 1, 1], [0, 1, 2], [1, 0, 2]],
                              [[2, 0, 0], [2, 1, 0], [1, 1, 0]],
                              [[0, 1, 1], [0, 1, 1], [1, 0, 2]],
                              [[1, 0, 3], [0, 0, 1], [3, 2, 0]],
                              [[0, 2, 3], [2, 0, 0], [3, 0, 0]]]],
                            device=device,
                            dtype=dtype)

        expected_votes = torch.tensor([[[[1, 1, 0], [1, 1, 1], [0, 1, 1]],
                                        [[1, 1, 0], [1, 1, 1], [0, 1, 1]],
                                        [[1, 1, 0], [1, 1, 1], [0, 1, 1]]]],
                                      device=device,
                                      dtype=torch.bool)

        output_votes = vg.project_odms(odms, votes=4)
        assert torch.equal(output_votes, expected_votes)