@attr.slow def test_call_cpu(self): self.check_call() @attr.gpu @attr.slow def test_call_gpu(self): self.link.to_gpu() self.check_call() @testing.parameterize(*testing.product({ 'model': [ResNet50, ResNet101, ResNet152], 'n_class': [None, 500, 1000], 'pretrained_model': ['imagenet'], 'mean': [None, np.random.uniform((3, 1, 1)).astype(np.float32)], 'arch': ['he', 'fb'], })) class TestResNetPretrained(unittest.TestCase): @attr.slow def test_pretrained(self): kwargs = { 'n_class': self.n_class, 'pretrained_model': self.pretrained_model, 'mean': self.mean, 'arch': self.arch, } if self.pretrained_model == 'imagenet': valid = self.n_class in {None, 1000}
self.assertEqual(features.dtype, np.float32) @attr.slow def test_call_cpu(self): self.check_call() @attr.gpu @attr.slow def test_call_gpu(self): self.link.to_gpu() self.check_call() @testing.parameterize(*testing.product({ 'model': [SEResNeXt50, SEResNeXt101], 'n_class': [None, 500, 1000], 'pretrained_model': ['imagenet'], 'mean': [None, np.random.uniform((3, 1, 1)).astype(np.float32)], })) class TestSEResNeXtPretrained(unittest.TestCase): @attr.slow def test_pretrained(self): kwargs = { 'n_class': self.n_class, 'pretrained_model': self.pretrained_model, 'mean': self.mean, } if self.pretrained_model == 'imagenet': valid = self.n_class in {None, 1000}
@attr.slow def test_call_cpu(self): self.check_call() @attr.gpu @attr.slow def test_call_gpu(self): self.link.to_gpu() self.check_call() @testing.parameterize(*testing.product({ 'model': [MobileNetV2], 'n_class': [None, 500, 1001], 'pretrained_model': ['imagenet'], 'mean': [None, np.random.uniform((3, 1, 1)).astype(np.float32)], 'arch': ['tf'], })) class TestMobileNetPretrained(unittest.TestCase): @attr.slow def test_pretrained(self): kwargs = { 'n_class': self.n_class, 'pretrained_model': self.pretrained_model, 'mean': self.mean, 'arch': self.arch, } if self.pretrained_model == 'imagenet': valid = self.n_class in {None, 1001}
from __future__ import division import math import numpy as np import unittest from chainercv.utils import testing from chainercv.utils import tile_images @testing.parameterize(*testing.product({ 'fill': [128, (104, 117, 123), np.random.uniform(255, size=(3, 1, 1))], 'pad': [0, 1, 2, 3, (3, 5), (5, 2)] })) class TestTileImages(unittest.TestCase): def test_tile_images(self): B = np.random.randint(10, 20) n_col = np.random.randint(2, 5) H = 30 W = 40 imgs = np.random.uniform(255, size=(B, 3, H, W)) tile = tile_images(imgs, n_col, self.pad, fill=self.fill) if isinstance(self.pad, int): pad_y = self.pad pad_x = self.pad else: pad_y, pad_x = self.pad n_row = int(math.ceil(B / n_col)) self.assertTrue(n_col >= 1 and n_row >= 1)