Add vectorized RandomBrightness, RandomContrast, RandomHue and RandomColorJitter #1406
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #1405
Fixes #1376
Following #1392 but I moved A/B testing into benchmarks suggested by @ianstenbit 's comment at #1392 (comment), also I added XLA Mode
jit_compile=True
for benchmarks suggested by @bhackFor unit tests, only
keras_cv/layers/preprocessing/random_hue_test.py
failed attest_adjust_full_opposite_hue
and could be resolved by relaxing constraintsatol=1e-5, rtol=1e-5
For numerical check (used
image_shape = (1024, 32, 32, 3)
locally):./benchmarks/vectorized_random_brightness.py
passes without any constraint relaxing./benchmarks/vectorized_random_contrast.py
passes withatol=1e-5, rtol=1e-5
at rgb value range./benchmarks/vectorized_random_hue.py
passes withatol=1e-3, rtol=1e-5
at rgb value range./benchmarks/vectorized_random_color_jitter.py
has no numerical check because it is composited by above layersSome notes:
OldRandomBrightness
got similar performance with Graph/XLA Mode, other vectorized layers got significant boostRandomHue
failed to run XLA modeRandomColorJitter
was done after I vectorizing all sub-layersThis is results from benchmarks:
RandomBrightness
RandomContrast
RandomHue (no XLA Mode)
RandomColorJitter
Before submitting
Pull Request section?
to it if that's the case.
Who can review?
@LukeWood @ianstenbit