Skip to content

[1/2] Add Image Ops for Data Augmentation #1333

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

Closed
6 of 13 tasks
abhichou4 opened this issue Mar 18, 2020 · 46 comments
Closed
6 of 13 tasks

[1/2] Add Image Ops for Data Augmentation #1333

abhichou4 opened this issue Mar 18, 2020 · 46 comments

Comments

@abhichou4
Copy link
Contributor

abhichou4 commented Mar 18, 2020

Part 2: #1353

As part of #1226, relevant image ops need to be added to tfa.image. List of ops tracked in this issue (tick the op only once the corresponding PR is merged):

  • Blend
  • CutOut
  • Identity
  • Translate X, Y
  • Shear X, Y
  • Solarize Ops
  • Posterize
  • AutoContrast
  • Equalize
  • Invert
  • Color
  • Brightness
  • Sharpness

Reference: https://github.com/tensorflow/tpu/blob/master/models/official/efficientnet/autoaugment.py

@vinayvr11
Copy link

Ok So these unchecked options are remaining. But what is PIL does it stands for Pillow or something else. And i have to implement these in autoaugment.py am i right.

@abhichou4
Copy link
Contributor Author

abhichou4 commented Mar 18, 2020

Ok So these unchecked options are remaining. But what is PIL does it stands for Pillow or something else. And i have to implement these in autoaugment.py am i right.

That's right, but the appropriate namescapes and where to place these operations is something that can be discussed here or on your PR.
/cc @bhack @gabrieldemarmiesse

@vinayvr11
Copy link

Ok so for now i just need to make a script for these operations and after that we decide that where to put them all. So all these operations are have to be integrated in one script or i have to make a different scripts for all of them.
Thank you

@gabrieldemarmiesse
Copy link
Member

Yeah, as long as the public API stays the same and is decided first, it's not critical how you name your files.

@vinayvr11
Copy link

@gabrieldemarmiesse : I have some doubts so we have to use the tensorflow for doing these operations or we are free to use any module.
And all these methods have to be made in different files. Please correct me if i am wrong.

@gabrieldemarmiesse
Copy link
Member

You should always use tensorflow to make those ops (so they can run on tpu/cpu/cuda/ROCm and can be exported in a graph and have gradients and many other things... ) and where you put the ops is not critical (meaning we care more about the pull request being merged than about the name of the file, as it can be changed later without impacting the API). You can group ops together in the same file if you feel this is the right move.

Prefer using python only if possible.

@vinayvr11
Copy link

Ok and what about Tensorflow version shall i need to take care about the version also or i can use any version of Tensorflow.

@gabrieldemarmiesse
Copy link
Member

gabrieldemarmiesse commented Mar 18, 2020

We currently test with tensorflow 2.1.0 and 2.2.0rc0

@vinayvr11
Copy link

ok thank you

@vinayvr11
Copy link

@gabrieldemarmiesse : Do we have a pre defined gaussian filter in tensorflow or any similar to this or i just need to make a filter in order to blur the images.

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

Just to compare to this ops checkbox list with RemixMatch/FixMatch https://github.com/google-research/remixmatch/blob/master/libml/augment.py#L36-L41

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

Here the EfficientDet Autoaugment ops list https://github.com/google/automl/blob/master/efficientdet/aug/autoaugment.py#L43-L153

@vinayvr11
Copy link

@bhack
So do we have to make a new list of these ops or leave them out?

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

@vinayvr11 I think it could be interesting to make a new list expecially for BBox ops in EfficentDet in a new ticket and instead extend the list here for image ops. But you need to double check the overlapped ops for these lists.

@vinayvr11
Copy link

Thank you @bhack i want to know one thing can i use numpy for making some ops.

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

@vinayvr11 I think the same as #1333 (comment)

@vinayvr11
Copy link

ok so do we have any filter operation in tensorflow_addons or i have to add that from scratch.

@gabrieldemarmiesse
Copy link
Member

No idea. You can look in the source code, I don't know all the functions by heart haha

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

@vinayvr11 We had an Averaging filter already integrated. See also #358

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

/cc @parth-p

@vinayvr11
Copy link

Thank you

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

As Google is a little bit evolutionary fragmented.. 😜 We have others recent interesting augmentations to be double checked for overlaps in https://github.com/google-research/simclr/blob/master/data_util.py.

There you can find also Tensorflow impl. of Gaussian Blur. /cc @chentingpc

@vinayvr11
Copy link

So shall i stop working on this blur ops because i just made a script for blurring using mean_filter.

@abhichou4
Copy link
Contributor Author

So shall i stop working on this blur ops because i just made a script for blurring using mean_filter.

Use that impl as a reference to add Gaussian Blur.

@vinayvr11
Copy link

sure thanks

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

Can we complete at least the unique ops list in checkbox list for image ops in all these source?
Then we could have another new ticket to list all bbox/crop operations.

@vinayvr11
Copy link

Thank you for that @abhichou4 i made a gaussian blur script for Tensorflow addons can i send the PR of that.

@bhack
Copy link
Contributor

bhack commented Mar 18, 2020

@abhichou4 Can you edit the ticket to expand the list?

RemixMatch/FixMatch:

  • Identity
  • AutoContrast
  • Equalize
  • Rotate
  • Solarize
  • Color
  • Contrast
  • Brightness
  • Sharpness
  • ShearX
  • TranslateX
  • TranslateY
  • Posterize
  • ShearY

Then SimCLR..

@vinayvr11
Copy link

Ok so i need this for color can i just assume this and send a PR or wait for merge.

@vinayvr11
Copy link

@abhichou4 : Can i use the random image like you generated in your test script or the repository test_data image.

@abhichou4
Copy link
Contributor Author

abhichou4 commented Mar 19, 2020

@abhichou4 : Can i use the random image like you generated in your test script or the repository test_data image.

test_data seems like a better option. My only concern is dumping all these images with long names.
/cc @fsx950223

@fsx950223
Copy link
Member

@abhichou4 : Can i use the random image like you generated in your test script or the repository test_data image.

test_data seems like a better option. My only concern is dumping all these images with long names.
/cc @fsx950223

I believe test_data is a better option because it could check the actual result.

@vinayvr11
Copy link

@abhichou4 : Can i use the random image like you generated in your test script or the repository test_data image.

test_data seems like a better option. My only concern is dumping all these images with long names.
/cc @fsx950223

Yes, same here but i only test the operation on one image Yellow_smiley_face.png as this is the smallest one.

@vinayvr11
Copy link

I have added the test file as well please check that.

@vinayvr11
Copy link

@abhichou4 : posterize is also done please check that.

@vinayvr11
Copy link

Could you please merge my commits they have passed all tests.

@bhack
Copy link
Contributor

bhack commented Mar 25, 2020

Just for the note... there are many other interesting augmentations operations that could be inspired by https://github.com/aleju/imgaug (It works also on other datatypes like heatmaps, keypoints etc..).
The problem there it is that often it is hard to achieve good perfomance[1][2][3] and it is why we are trying to solve here with TF ops so that we could rely on the TensorFlow compiler/optimization/scheduling/runtime stacks and it is why Nvidia bootstrapped it is using its own library[4].
[1]aleju/imgaug#79
[2]aleju/imgaug#550
[3]aleju/imgaug#178
[4]https://docs.nvidia.com/deeplearning/sdk/dali-developer-guide/docs/examples/augmentation_gallery.html

@Squadrick Squadrick changed the title Add Image Ops for Data Augmentation [1/2] Add Image Ops for Data Augmentation Mar 25, 2020
@Squadrick
Copy link
Member

@abhichou4 @vinayvr11 @bhack The checklist above should only be ticked once the PR has been merged. I've unselected all the open PRs.

Also, please open a single PR for each image op, even if it's a simple op. It makes it super tough to review when 4/5 ops are combined into a single PR.

@abhichou4 I'm closing #1352 since it's WIP, and implements multiple ops. Create separate issues.

@bhack
Copy link
Contributor

bhack commented Mar 25, 2020

@Squadrick Thanks but I have not the privilege level to tick the checklist 😉

@seanpmorgan
Copy link
Member

Per #1226 (comment) the autoaugment/randaugment features will be a part of https://github.com/keras-team/keras-cv

Apologies for not being able to present this information sooner to the contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants