forked from Kaggle/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_chainercv.py
More file actions
35 lines (28 loc) · 957 Bytes
/
test_chainercv.py
File metadata and controls
35 lines (28 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from __future__ import division
import math
import numpy
import unittest
from chainercv.utils import tile_images
class TestChainerCV(unittest.TestCase):
def test_tile_images(self):
B = numpy.random.randint(10, 20)
n_col = numpy.random.randint(2, 5)
H = 30
W = 40
fill = 128
pad = 0
imgs = numpy.random.uniform(255, size=(B, 3, H, W))
tile = tile_images(imgs, n_col, pad, fill=fill)
if isinstance(pad, int):
pad_y = pad
pad_x = pad
else:
pad_y, pad_x = pad
n_row = int(math.ceil(B / n_col))
self.assertTrue(n_col >= 1 and n_row >= 1)
start_y_11 = H + pad_y + pad_y // 2
start_x_11 = W + pad_x + pad_x // 2
tile_11 = tile[:,
start_y_11:start_y_11 + H,
start_x_11:start_x_11 + W]
numpy.testing.assert_equal(tile_11, imgs[(n_col - 1) + 2])