@@ -0,0 +1,1737 @@
+import numpy as np%0Aimport unittest%0A%0Aimport chainer%0A%0Afrom chainercv.experimental.links.model.fcis.utils.mask_voting %5C%0A    import mask_voting%0Afrom chainercv.utils import assert_is_bbox%0Afrom chainercv.utils import generate_random_bbox%0A%0A%0Aclass TestMaskVoting(unittest.TestCase):%0A%0A    def setUp(self):%0A        n_roi = 5%0A        self.roi_size = 7%0A        self.size = (18, 24)%0A        self.n_class = 6%0A        self.bg_label = 0%0A        self.roi_mask_prob = np.random.uniform(%0A            size=(n_roi, self.roi_size, self.roi_size))%0A        self.roi_prob = np.random.uniform(%0A            size=(n_roi, self.n_class))%0A        self.bbox = generate_random_bbox(n_roi, self.size, 0, 18)%0A%0A    def check_mask_voting(%0A            self, roi_mask_prob, roi_prob, bbox,%0A            roi_size, size, n_class, bg_label):%0A        xp = chainer.cuda.get_array_module(roi_mask_prob)%0A        roi_mask_prob, label, score, bbox = mask_voting(%0A            roi_mask_prob, roi_prob, bbox,%0A            size, n_class, 0.5, 0.3, 0.5, 0.4,%0A            bg_label=bg_label)%0A%0A        n_roi = roi_mask_prob.shape%5B0%5D%0A        self.assertIsInstance(roi_mask_prob, xp.ndarray)%0A        self.assertEqual(roi_mask_prob.shape%5B1:%5D, (roi_size, roi_size))%0A        self.assertTrue(%0A            xp.all(xp.logical_and(roi_mask_prob %3E= 0.0, roi_mask_prob %3C= 1.0)))%0A%0A        self.assertIsInstance(label, xp.ndarray)%0A        self.assertEqual(label.shape, (n_roi, ))%0A%0A        self.assertIsInstance(score, xp.ndarray)%0A        self.assertEqual(score.shape, (n_roi, ))%0A%0A        assert_is_bbox(bbox, size)%0A%0A    def test_mask_voting_cpu(self):%0A        self.check_mask_voting(%0A            self.roi_mask_prob, self.roi_prob, self.bbox,%0A            self.roi_size, self.size, self.n_class, self.bg_label)%0A

add test_mask_voting.py