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)
评论列表
文章目录