-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vectorize Random Shear. #1518
Comments
Hi @sebastian-sz There is a workaround for def augment_bounding_boxes(
self, bounding_boxes, transformations, images, **kwargs
):
...
bounding_boxes = bounding_box.to_dense(bounding_boxes) # <-- to transform Side effect: it will fulfill dummy boxes to meet the max number of the boxes in the batch VectorizedBaseImageAugmentationLayer will automatically turn it back at Line 317 keras-cv/keras_cv/layers/preprocessing/vectorized_base_image_augmentation_layer.py Lines 310 to 318 in cd12204
P.S. keras-cv/keras_cv/layers/preprocessing/base_image_augmentation_layer.py Lines 450 to 461 in cd12204
I'm not sure if we are encouraged to augment bounding_boxes in Kindly ping @LukeWood @ianstenbit |
Awesome! Go ahead and introduce this @sebastian-sz |
Regarding this, we can always just use a |
@james77777778 thank you for the suggestion - it works with Ragged! @LukeWood there seems to be a different issue on master branch with the non-vectorized implementation. These are some of the outputs that I'm getting from The boxes look quite off in some of those examples - are we sure that the current algorithm to augment bounding boxes is correct? |
Looks like it was just a bug in the demo: https://github.com/keras-team/keras-cv/pull/1534/files |
Short Description
Random Shear can be vectorized, similar to other layers. It seems the performance benefit is quite large for layers that use
ImageProjectiveTransformV3
(similar to: #1480).EDIT: the below graphs were generated with slight error that favoured Vectorized implementation. These are updated graphs, without the error.
Vectorized implementation is faster than the original:
Known Issues
augment_bounding_boxes
is quite challenging. I did vectorize the existing code, but it doesn't work if the bounding box is atf.RaggedTensor
as it's impossible totf.transpose
ragged tensors (transposing bounding boxes is necessary for matmul).This breaks the
examples/layers/preprocessing/bounding_box/random_shear_demo.py
No XLA for
ImageProjetiveTransformV3
.Let me know what you think!
The text was updated successfully, but these errors were encountered: