test_generator.py 文件源码

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

项目:keras-retinanet 作者: fizyr 项目源码 文件源码
def test_complete(self):
        input_annotations_group = [
            np.array([
                [  0,   0, 50, 50, 0],  # one object of class 0
                [150, 150, 50, 50, 1],  # one object of class 1 with an invalid box
            ], dtype=keras.backend.floatx()),
        ]

        input_image = np.zeros((500, 500, 3), dtype=np.uint8)

        expected_annotations_group = [
            np.array([
                [0, 0, 10, 10],
            ]),
        ]

        simple_generator = SimpleGenerator(input_annotations_group, image=input_image, num_classes=2)
        # expect a UserWarning
        with pytest.warns(UserWarning):
            _, [_, labels_batch] = simple_generator.next()

        # test that only object with class 0 is present in labels_batch
        labels = np.unique(np.argmax(labels_batch == 1, axis=2))
        assert(len(labels) == 1 and labels[0] == 0), 'Expected only class 0 to be present, but got classes {}'.format(labels)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号