MaxNumBoundingBoxes classkeras.layers.MaxNumBoundingBoxes(max_number, fill_value=-1, **kwargs)
Ensure the maximum number of bounding boxes.
Note: This layer is safe to use inside a tf.data or grain pipeline
(independently of which backend you're using).
Arguments
boxes and labels in
bounding_boxes. Defaults to -1.Example
max_boxes_layer = keras.layers.MaxNumBoundingBoxes(
max_number=10,
fill_value=-1
)
images = np.random.randint(0, 255, (1, 224, 224, 3), dtype="uint8")
bounding_boxes = {
"boxes": np.array([
[[10, 20, 100, 150], [50, 60, 200, 250], [0, 0, 50, 50]],
]),
"labels": np.array([[1, 2, 3]])
}
result = max_boxes_layer({
"images": images,
"bounding_boxes": bounding_boxes
})
Guides and examples using MaxNumBoundingBoxes