keras-team / keras-cv

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

RandAug preprocessing layer #29

Closed LukeWood closed 2 years ago

LukeWood commented 2 years ago

https://keras.io/examples/vision/randaugment/

LukeWood commented 2 years ago

This will require rewriting from numpy to TensorFlow

sebastian-sz commented 2 years ago

This will require rewriting from numpy to TensorFlow

I have been using this implementation. Maybe it can help: https://github.com/tensorflow/models/blob/ded32f0500604928e52e27fd3f678e694e5133b7/official/vision/image_classification/augment.py#L905

LukeWood commented 2 years ago

A batched implementation exists in imgaug:

https://github.com/aleju/imgaug

bhack commented 2 years ago

A batched implementation exists in imgaug:

https://github.com/aleju/imgaug

But it Is not the best solution as it needs to be tf.py_function wrapped as It handles Numpy arrays not Tensor.

LukeWood commented 2 years ago

I'll be contributing this shortly

chjort commented 2 years ago

If it could be to any inspiration, I also have a keras layer implementation of RandAug in my own toolbox: https://github.com/chjort/chambers/tree/master/chambers/augmentations specifically at this line.

It is based on https://github.com/tensorflow/tpu/blob/master/models/official/efficientnet/autoaugment.py, but my implementation includes vectorized/batched implementations of all transforms, although some of the layers make use of tensorflow-addons.

LukeWood commented 2 years ago

Thanks for the links! I’ll let you know if I used them. I’ll likely base mine on tensorflow similarity’s

LukeWood commented 2 years ago

https://github.com/tensorflow/similarity/blob/906d141b75acf00d0e1d37dd0d88c432bbb30f57/tensorflow_similarity/augmenters/img_augments.py