keras-team / keras-cv

Industry-strength Computer Vision workflows with Keras
Other
1.01k stars 330 forks source link

RandomColorDegeneration and Equalization are not implemented as vectorized operations #2120

Closed sup3rgiu closed 10 months ago

sup3rgiu commented 12 months ago

Current Behavior:

As Keras_CV==0.6.4, RandomColorDegeneration and Equalization preprocessing layers are not subclasses of VectorizedBaseImageAugmentationLayer, thus resulting in a slow forward pass.

Expected Behavior:

RandomColorDegeneration and Equalization preprocessing layers should be subclasses of VectorizedBaseImageAugmentationLayer (introduced in v. 0.5.0). The implementation of RandomColorDegeneration is quite straightforward, while RandomColorDegeneration has a potential bottleneck represented by tf.histogram_fixed_width. In the following Colab I propose an implementation for both layers.

Colab:

This colab includes a possible vectorized implementation of the given layers, and also a benchmark. https://colab.research.google.com/drive/1t5b4a11ae3HWxUoyL-R50E2z8dkNSQYP?usp=sharing

Version:

0.6.4

divyashreepathihalli commented 10 months ago

@sup3rgiu thank you for filing the issue! If you can open a PR for vectorized implementation of these layers with example outputs showing different augmentations for each image in a batch. that would be great!

sup3rgiu commented 10 months ago

@sup3rgiu thank you for filing the issue! If you can open a PR for vectorized implementation of these layers with example outputs showing different augmentations for each image in a batch. that would be great!

Done https://github.com/keras-team/keras-cv/pull/2214