image_test.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:luminoth 作者: tryolabs 项目源码 文件源码
def testRandomPatchLargerThanImage(self):
        """Tests random_patch normalizes the minimum sizes.
        """
        im_shape = (600, 800, 3)
        total_boxes = 5
        config = EasyDict({
            'min_height': 900,
            'min_width': 900
        })
        label = 3
        image, bboxes = self._get_image_with_boxes(im_shape, total_boxes)
        # Add a label to each bbox.
        bboxes_w_label = tf.concat(
            [
                bboxes,
                tf.fill((bboxes.shape[0], 1), label)
            ],
            axis=1
        )
        ret_image, ret_bboxes = self._random_patch(
            image, config, bboxes_w_label
        )
        # Assertions
        self.assertLessEqual(ret_bboxes.shape[0], total_boxes)
        self.assertGreater(ret_bboxes.shape[0], 0)
        self.assertTrue(np.all(ret_bboxes >= 0))
        self.assertTrue(np.all(
            ret_bboxes[:, 0] <= ret_image.shape[1]
        ))
        self.assertTrue(np.all(
            ret_bboxes[:, 1] <= ret_image.shape[0]
        ))
        self.assertTrue(np.all(
            ret_bboxes[:, 2] <= ret_image.shape[1]
        ))
        self.assertTrue(np.all(
            ret_bboxes[:, 3] <= ret_image.shape[0]
        ))
        self.assertTrue(np.all(ret_image.shape <= im_shape))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号