def __init__(self, n_fg_class):
     extractor = DummyExtractor()
     super(DummyFasterRCNN, self).__init__(
         extractor=extractor,
         rpn=RPN(extractor.scales),
         head=Head(n_fg_class + 1, extractor.scales),
     )
Example #2
0
    def _check_rpn_loss(self, xp):
        locs = [
            chainer.Variable(_random_array(xp, (2, 32 * 32 * 3, 4))),
            chainer.Variable(_random_array(xp, (2, 16 * 16 * 3, 4))),
            chainer.Variable(_random_array(xp, (2, 8 * 8 * 3, 4))),
        ]
        confs = [
            chainer.Variable(_random_array(xp, (2, 32 * 32 * 3))),
            chainer.Variable(_random_array(xp, (2, 16 * 16 * 3))),
            chainer.Variable(_random_array(xp, (2, 8 * 8 * 3))),
        ]
        anchors = RPN(scales=(1 / 2, 1 / 4, 1 / 8)) \
            .anchors(((32, 32), (16, 16), (8, 8)))
        bboxes = [
            xp.array(((2, 4, 6, 7), (1, 12, 3, 30)), dtype=np.float32),
            xp.array(((10, 2, 12, 12), ), dtype=np.float32),
        ]

        loc_loss, conf_loss = rpn_loss(locs, confs, anchors,
                                       ((480, 640), (320, 320)), bboxes)

        self.assertIsInstance(loc_loss, chainer.Variable)
        self.assertIsInstance(loc_loss.array, xp.ndarray)
        self.assertEqual(loc_loss.shape, ())

        self.assertIsInstance(conf_loss, chainer.Variable)
        self.assertIsInstance(conf_loss.array, xp.ndarray)
        self.assertEqual(conf_loss.shape, ())
 def __init__(self, n_fg_class, return_values, min_size, max_size):
     extractor = DummyExtractor()
     super(DummyFasterRCNN, self).__init__(
         extractor=extractor,
         rpn=RPN(extractor.scales),
         bbox_head=BboxHead(n_fg_class + 1, extractor.scales),
         mask_head=MaskHead(n_fg_class + 1, extractor.scales),
         return_values=return_values,
         min_size=min_size, max_size=max_size,
     )
Example #4
0
 def setUp(self):
     self.link = RPN(scales=(1 / 2, 1 / 4, 1 / 8))