def __init__(self, n_fg_class): super(DummySSD, self).__init__(extractor=DummyExtractor(), multibox=Multibox(n_class=n_fg_class + 1, aspect_ratios=((2, ), (2, 3), (2, ))), steps=(0.1, 0.25, 1), sizes=(0.1, 0.25, 1, 1.2), mean=np.array((0, 1, 2)).reshape((-1, 1, 1)))
def setUp(self): self.link = Multibox(self.n_class, self.aspect_ratios) xs = list() n_bbox = 0 for ar in self.aspect_ratios: C, H, W = np.random.randint(1, 10, size=3) xs.append( np.random.uniform(size=(self.batchsize, C, H, W)).astype(np.float32)) n_bbox += H * W * (len(ar) + 1) * 2 self.xs = xs self.n_bbox = n_bbox
def __init__(self, n_fg_class=None, pretrained_extractor='auto', pretrained_model=None): super(SSD224, self).__init__( extractor=ResNet101Extractor(pretrained_extractor), multibox=Multibox( n_class=n_fg_class + 1, aspect_ratios=((2, 3), (2, 3), (2, 3), (2, 3))), steps=(4, 8, 16, 32), sizes=(15, 30, 60, 120, 244), mean=_imagenet_mean) if pretrained_model: _load_npz(pretrained_model, self)
def __init__(self, n_fg_class=None, pretrained_model=None): param, path = utils.prepare_pretrained_model( {'n_fg_class': n_fg_class}, pretrained_model, self._models) super(M2Det300, self).__init__( extractor=VGG16MLFPN300(), multibox=Multibox( n_class=param['n_fg_class'] + 1, aspect_ratios=((2,), (2, 3), (2, 3), (2, 3), (2,), (2,))), steps=(8, 16, 32, 64, 100, 300), sizes=(30, 60, 111, 162, 213, 264, 315), mean=_imagenet_mean) if path: chainer.serializers.load_npz(path, self, strict=False)
def __init__(self, n_fg_class=None, pretrained_model=None): param, path = utils.prepare_pretrained_model( {'n_fg_class': n_fg_class}, pretrained_model, self._models) super(M2Det512, self).__init__( extractor=VGG16MLFPN512(), multibox=Multibox( n_class=param['n_fg_class'] + 1, aspect_ratios=((2,), (2, 3), (2, 3), (2, 3), (2,), (2,))), steps=(8, 16, 32, 64, 128, 256), sizes=(30.72, 76.8, 168.96, 261.12, 353.28, 445.44, 537.6), mean=_imagenet_mean) if path: chainer.serializers.load_npz(path, self, strict=False)
def __init__(self, n_fg_class=None, pretrained_model=None): param, path = utils.prepare_pretrained_model( {'n_fg_class': n_fg_class}, pretrained_model, self._models) super(M2Det320, self).__init__( extractor=VGG16MLFPN320(), multibox=Multibox( n_class=param['n_fg_class'] + 1, aspect_ratios=((2,), (2, 3), (2, 3), (2, 3), (2,), (2,))), steps=(8, 16, 32, 64, 107, 320), sizes=(25.6, 48, 105.6, 163.2, 220.8, 278.4, 336), mean=_imagenet_mean) if path: chainer.serializers.load_npz(path, self, strict=False)
def __init__(self, n_fg_class=None, pretrained_model=None): param, path = utils.prepare_pretrained_model( {'n_fg_class': n_fg_class}, pretrained_model, self._models) super(SSD512, self).__init__( extractor=VGG16Extractor512(), multibox=Multibox(n_class=param['n_fg_class'] + 1, aspect_ratios=((2, ), (2, 3), (2, 3), (2, 3), (2, 3), (2, ), (2, ))), steps=(8, 16, 32, 64, 128, 256, 512), sizes=(35.84, 76.8, 153.6, 230.4, 307.2, 384.0, 460.8, 537.6), mean=_imagenet_mean) if path: chainer.serializers.load_npz(path, self, strict=False)
def __init__(self, n_fg_class=None, pretrained_model=None): n_fg_class, path = _check_pretrained_model( n_fg_class, pretrained_model, self._models) super(SSD300, self).__init__( extractor=VGG16Extractor300(), multibox=Multibox( n_class=n_fg_class + 1, aspect_ratios=((2,), (2, 3), (2, 3), (2, 3), (2,), (2,))), steps=[s / 300 for s in (8, 16, 32, 64, 100, 300)], sizes=[s / 300 for s in (30, 60, 111, 162, 213, 264, 315)], mean=_imagenet_mean) if path: chainer.serializers.load_npz(path, self)
def __init__(self, n_fg_class=None, pretrained_model=None): n_fg_class, path = _check_pretrained_model(n_fg_class, pretrained_model, self._models) super(SSD512, self).__init__( extractor=VGG16Extractor512(), multibox=Multibox(n_class=n_fg_class + 1, aspect_ratios=((2, ), (2, 3), (2, 3), (2, 3), (2, 3), (2, ), (2, ))), steps=(8, 16, 32, 64, 128, 256, 512), sizes=(35.84, 76.8, 153.6, 230.4, 307.2, 384.0, 460.8, 537.6), mean=_imagenet_mean) if path: _load_npz(path, self)
def __init__(self, n_fg_class=None, pretrained_model=None, init_scale=0.0001): # うまくいったらpretrained model配布しますね # n_fg_class, path = _check_pretrained_model( # n_fg_class, pretrained_model, self._models) print('initializing with scale={}'.format(init_scale)) initializer = initializers.Normal(init_scale) super(FPNSSD, self).__init__( extractor=FeaturePyramidNetwork(initialW=initializer), multibox=Multibox(n_class=n_fg_class + 1, aspect_ratios=((2, ), (2, 3), (2, 3), (2, 3), (2, ), (2, )), initialW=initializer), steps=(8, 16, 32, 64, 100, 300), sizes=(30, 60, 111, 162, 213, 264, 315), mean=_imagenet_mean)