예제 #1
0
 def test_assert_is_point_dataset(self):
     if self.valid:
         assert_is_point_dataset(self.dataset, self.n_point, 20,
                                 self.no_mask)
     else:
         with self.assertRaises(AssertionError):
             assert_is_point_dataset(self.dataset, self.n_point, 20,
                                     self.no_mask)
예제 #2
0
    def test_cub_point_dataset(self):
        assert_is_point_dataset(self.dataset, n_point=15, n_example=10)

        idx = np.random.choice(np.arange(10))
        if self.return_bb:
            if self.return_prob_map:
                bb = self.dataset[idx][-2]
            else:
                bb = self.dataset[idx][-1]
            assert_is_bbox(bb[np.newaxis])
        if self.return_prob_map:
            img = self.dataset[idx][0]
            prob_map = self.dataset[idx][-1]
            self.assertEqual(prob_map.dtype, np.float32)
            self.assertEqual(prob_map.shape, img.shape[1:])
            self.assertTrue(np.min(prob_map) >= 0)
            self.assertTrue(np.max(prob_map) <= 1)
    def test_coco_keypoint_dataset(self):
        human_id = 0
        assert_is_point_dataset(
            self.dataset, len(coco_keypoint_names[human_id]),
            n_example=30)

        for _ in range(10):
            i = np.random.randint(0, len(self.dataset))
            img, point, _, label, bbox = self.dataset[i][:5]
            assert_is_bbox(bbox, img.shape[1:])
            self.assertEqual(len(bbox), len(point))

            self.assertIsInstance(label, np.ndarray)
            self.assertEqual(label.dtype, np.int32)
            self.assertEqual(label.shape, (point.shape[0],))

        if self.return_area:
            for _ in range(10):
                i = np.random.randint(0, len(self.dataset))
                _, point, _, _, _, area = self.dataset[i][:6]
                self.assertIsInstance(area, np.ndarray)
                self.assertEqual(area.dtype, np.float32)
                self.assertEqual(area.shape, (point.shape[0],))

        if self.return_crowded:
            for _ in range(10):
                i = np.random.randint(0, len(self.dataset))
                example = self.dataset[i]
                crowded = example[-1]
                point = example[1]
                self.assertIsInstance(crowded, np.ndarray)
                self.assertEqual(crowded.dtype, np.bool)
                self.assertEqual(crowded.shape, (point.shape[0],))

                if not self.use_crowded:
                    np.testing.assert_equal(crowded, 0)