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

Vectorize RandomBrightness, RandomContrast, RandomHue and RandomColorJitter #1405

Closed
james77777778 opened this issue Feb 16, 2023 · 2 comments · Fixed by #1406
Closed

Vectorize RandomBrightness, RandomContrast, RandomHue and RandomColorJitter #1405

james77777778 opened this issue Feb 16, 2023 · 2 comments · Fixed by #1406

Comments

@james77777778
Copy link
Contributor

Short Description

As #1392 was merged, I'm willing to contribute for vectorized RandomBrightness, RandomContrast, RandomHue and finally to complete vectorized RandomColorJitter.

RandomColorJitter is widely adopted, so the improvement from vectorization should benefit the community.

Other Information

There is an unsolved conversation at #1392 (comment)
and my questions are:

  1. Should we move A/B testings from unit tests into ./benchmarks/random_*.py?
  2. ./benchmarks/ might be flooded by these scripts. Should we create a new folder for these?

For 1., take ./benchmarks/vectorized_random_saturation.py as example:

# add old implementation
class OldRandomSaturation(BaseImageAugmentationLayer):
    ...

# add tests
class RandomSaturationTest(tf.test.TestCase):
    def test_correctness_with_tf_adjust_saturation_normalized_range(self):
        ...
        self.assertAllClose(old_output, output, atol=1e-5, rtol=1e-5)

    def test_correctness_with_tf_adjust_saturation_rgb_range(self):
        ...
        self.assertAllClose(old_output, output, atol=1e-3, rtol=1e-5)


if __name__ == "__main__":
    # run benchmarks (get some figures for improvement)
    ...
    # run unit tests
    tf.test.main()

For 2., I think something like ./benchmarks/vectorization_strategy/vectorized_*.py can be a better layout?

@IMvision12
Copy link
Contributor

hey @james77777778 Just saw your last PR and that was wonderful work on vectorizing random saturation, are there any more augmentations that need to be vectorized, I would like to contribute.

Thanks

@james77777778
Copy link
Contributor Author

Hi @IMvision12
Thanks!

Currently, I'm not targeting any other preprocessing layer. Just want to complete RandomColorJitter in my own interest :)
As #1382 (comment) said, any vectorization should be contribution-welcome.

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