MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / _random_data

Method _random_data

tests/test_visualizer.py:16–32  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

14
15class TestVisualizer(unittest.TestCase):
16 def _random_data(self):
17 H, W = 100, 100
18 N = 10
19 img = np.random.rand(H, W, 3) * 255
20 boxxy = np.random.rand(N, 2) * (H // 2)
21 boxes = np.concatenate((boxxy, boxxy + H // 2), axis=1)
22
23 def _rand_poly():
24 return np.random.rand(3, 2).flatten() * H
25
26 polygons = [[_rand_poly() for _ in range(np.random.randint(1, 5))] for _ in range(N)]
27
28 mask = np.zeros_like(img[:, :, 0], dtype=np.bool)
29 mask[:10, 10:20] = 1
30
31 labels = [str(i) for i in range(N)]
32 return img, boxes, labels, polygons, [mask] * N
33
34 @property
35 def metadata(self):

Calls

no outgoing calls

Tested by

no test coverage detected