Skip to content
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

Add AugMix #407

Merged
merged 20 commits into from
Jun 14, 2022
Merged

Add AugMix #407

merged 20 commits into from
Jun 14, 2022

Conversation

quantumalaviya
Copy link
Contributor

closes #40
Moreover, added util functions from keras to support translation and rotation layers.

download

@quantumalaviya
Copy link
Contributor Author

Currently, I have only implemented the main layers used in the implementation ( color, contrast, brightness, sharpness is not implemented)

I have also re-coded Posterization and Solarization as part of this layer because tensor inputs weren't compatible.

Lastly, the layer isn't vectorized. I believe it's better this way for now and we can further vectorized the layer in a follow-up layer (if possible)

@quantumalaviya
Copy link
Contributor Author

Also, this implementation is highly inspired by @szacho's wonderful implementation.

Thanks!

@LukeWood
Copy link
Contributor

LukeWood commented May 2, 2022

Also, this implementation is highly inspired by @szacho's wonderful implementation.

Thanks!

Be sure to include this in references! Thanks!

@LukeWood
Copy link
Contributor

LukeWood commented May 2, 2022

Currently, I have only implemented the main layers used in the implementation ( color, contrast, brightness, sharpness is not implemented)

I have also re-coded Posterization and Solarization as part of this layer because tensor inputs weren't compatible.

Lastly, the layer isn't vectorized. I believe it's better this way for now and we can further vectorized the layer in a follow-up layer (if possible)

Thanks for the PR @quantumalaviya. I will review it as soon as I can.

Copy link
Contributor

@LukeWood LukeWood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some preliminary comments @quantumalaviya!

Great work, this is coming along great. Definitely a substantial effort, and happy to review again once we have the comments above addressed. Thanks!

keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Show resolved Hide resolved
@quantumalaviya
Copy link
Contributor Author

Are we keeping this on hold until #431 is resolved? @LukeWood

@LukeWood
Copy link
Contributor

It's not the worst thing in the world to repeat yourself occasionally in code, but if possible we should use our layers' _augment_image methods with a static provided transformation.

If this isn't possible let me know

1 similar comment
@LukeWood
Copy link
Contributor

It's not the worst thing in the world to repeat yourself occasionally in code, but if possible we should use our layers' _augment_image methods with a static provided transformation.

If this isn't possible let me know

@quantumalaviya
Copy link
Contributor Author

I can't exactly think of a way to reduce the lines of code here. I considered using it for the sample_level calls but I don't think there will be a considerable reduction. To my understanding, this method was more useful in cases where labels and augmentations had to share a common transformation.

If you have something specific in mind, let me know.

@LukeWood
Copy link
Contributor

Sounds good, let me play around with it a bit more! Thanks!

keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Show resolved Hide resolved
@LukeWood
Copy link
Contributor

Thanks for the hard work on this one @quantumalaviya ! it will be a wonderful feature soon!

keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Show resolved Hide resolved
keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
@quantumalaviya
Copy link
Contributor Author

Also fixed sample usages in FMix and MixUp in docstrings

Copy link
Contributor

@LukeWood LukeWood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes, think I believe it will look pretty good.

Copy link
Contributor

@LukeWood LukeWood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful!

Can you re-run the example script with all of the changes to ensure it still works as we expect? Then if so, I believe we are ready to go!

keras_cv/layers/preprocessing/aug_mix.py Outdated Show resolved Hide resolved
@LukeWood
Copy link
Contributor

Thank you @quantumalaviya for the contribution! This is great, and the API looks good.

In the future, we may want to refactor the helper methods to be reused in their corresponding KPLs, but this is an implementation detail not an API change - so this is great

@LukeWood LukeWood merged commit 0a9640e into keras-team:master Jun 14, 2022
pranavjadhav001 pushed a commit to pranavjadhav001/keras-cv that referenced this pull request Jun 26, 2022
* adding augmix

* add augmix with demo

* add augmix test

* add augmix

* Update aug_mix.py

* Update aug_mix.py

* Update aug_mix_demo.py

* updating augmix with changes

* init commit with review comments

* fix linting issues

* removing RandomShear assignment in constructor

* review comments part 2

* review comments part 2 fix

* review comments part 3

* change variable names

* fix lint issues

* edit serialization test

* edit demo to use utils

* Update augmix

Co-authored-by: Luke Wood <lukewoodcs@gmail.com>
ianstenbit pushed a commit to ianstenbit/keras-cv that referenced this pull request Aug 6, 2022
* adding augmix

* add augmix with demo

* add augmix test

* add augmix

* Update aug_mix.py

* Update aug_mix.py

* Update aug_mix_demo.py

* updating augmix with changes

* init commit with review comments

* fix linting issues

* removing RandomShear assignment in constructor

* review comments part 2

* review comments part 2 fix

* review comments part 3

* change variable names

* fix lint issues

* edit serialization test

* edit demo to use utils

* Update augmix

Co-authored-by: Luke Wood <lukewoodcs@gmail.com>
adhadse pushed a commit to adhadse/keras-cv that referenced this pull request Sep 17, 2022
* adding augmix

* add augmix with demo

* add augmix test

* add augmix

* Update aug_mix.py

* Update aug_mix.py

* Update aug_mix_demo.py

* updating augmix with changes

* init commit with review comments

* fix linting issues

* removing RandomShear assignment in constructor

* review comments part 2

* review comments part 2 fix

* review comments part 3

* change variable names

* fix lint issues

* edit serialization test

* edit demo to use utils

* Update augmix

Co-authored-by: Luke Wood <lukewoodcs@gmail.com>
freedomtan pushed a commit to freedomtan/keras-cv that referenced this pull request Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AugMix image augmentation
3 participants