keras-team / keras-cv

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

Porting KerasAug into KerasCV #1939

Open james77777778 opened 1 year ago

james77777778 commented 1 year ago

Hi KerasCV team,

I have worked on my own project KerasAug for a while to provide the powerful, performant and bug-free preprocessing/augmentation layers.

As I have noticed that keras-core is planning to refactor the preprocessing layers by incorporating TFDataLayer , it presents a opportunity to port some of the layers from KerasAug into KerasCV.

You can visit benchmarks to see the improvement by KerasAug

Moreover, KerasAug addresses a lot of existing issues within KerasCV:

Will this project benefit the community? I'm willing to contribute!

jbischof commented 1 year ago

@james77777778 thanks for the offer. Can you explain the source of the speedups?

james77777778 commented 1 year ago

@james77777778 thanks for the offer. Can you explain the source of the speedups?

@jbischof Sure! I pick some layers for clarification:

Layer Why Speedup
RandomCropAndResize utilizes tf.image.crop_and_resize with vectorized design +1150%
Resize utilizes tf.image.resize with vectorized design +1017%
RandomColorJitter instead of dircetly using 4 preprocessing layers, implements the logic in one place to reduce the overhead +237%
RandomGaussianBlur utilizes tf.vectorized_map instead of tf.map_fn +1055%
GridMask computes random_transform in vectorized manner +368%

Additionally:

If these improvements are in the plan of KerasCV, I can send the PR (maybe one fix/improvement one small PR?).

jbischof commented 1 year ago

Sounds great @james77777778! I would suggest starting with one or two layers with big improvements so that we can debug any issues early in the process.