mirror of
https://github.com/open-mmlab/mmengine.git
synced 2025-06-03 21:54:44 +08:00
[Fix] Fix failed unit tests caused by the new released numpy (#838)
* [Fix] Fix failed unit tests caused by the new released numpy * minor fix
This commit is contained in:
parent
4147e976a6
commit
b44048aeb7
@ -364,21 +364,21 @@ class TestVisualizer(TestCase):
|
||||
visualizer.draw_polygons(torch.tensor([[1, 1], [2, 2], [16, 4]]))
|
||||
|
||||
def test_draw_binary_masks(self):
|
||||
binary_mask = np.random.randint(0, 2, size=(10, 10)).astype(np.bool)
|
||||
binary_mask = np.random.randint(0, 2, size=(10, 10)).astype(bool)
|
||||
visualizer = Visualizer(image=self.image)
|
||||
visualizer.draw_binary_masks(binary_mask)
|
||||
visualizer.draw_binary_masks(torch.from_numpy(binary_mask))
|
||||
# multi binary
|
||||
binary_mask = np.random.randint(0, 2, size=(2, 10, 10)).astype(np.bool)
|
||||
binary_mask = np.random.randint(0, 2, size=(2, 10, 10)).astype(bool)
|
||||
visualizer = Visualizer(image=self.image)
|
||||
visualizer.draw_binary_masks(binary_mask, colors=['r', (0, 255, 0)])
|
||||
# test the error that the size of mask and image are different.
|
||||
with pytest.raises(AssertionError):
|
||||
binary_mask = np.random.randint(0, 2, size=(8, 10)).astype(np.bool)
|
||||
binary_mask = np.random.randint(0, 2, size=(8, 10)).astype(bool)
|
||||
visualizer.draw_binary_masks(binary_mask)
|
||||
|
||||
# test non binary mask error
|
||||
binary_mask = np.random.randint(0, 2, size=(10, 10, 3)).astype(np.bool)
|
||||
binary_mask = np.random.randint(0, 2, size=(10, 10, 3)).astype(bool)
|
||||
with pytest.raises(AssertionError):
|
||||
visualizer.draw_binary_masks(binary_mask)
|
||||
|
||||
@ -495,7 +495,7 @@ class TestVisualizer(TestCase):
|
||||
|
||||
def test_chain_call(self):
|
||||
visualizer = Visualizer(image=self.image)
|
||||
binary_mask = np.random.randint(0, 2, size=(10, 10)).astype(np.bool)
|
||||
binary_mask = np.random.randint(0, 2, size=(10, 10)).astype(bool)
|
||||
visualizer.draw_bboxes(torch.tensor([1, 1, 2, 2])). \
|
||||
draw_texts('test', torch.tensor([5, 5])). \
|
||||
draw_lines(x_datas=torch.tensor([1, 5]),
|
||||
|
Loading…
x
Reference in New Issue
Block a user