-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
feat(layers): Migrate RandomChoice and RandomApply layers from keras-cv to keras #20752
base: master
Are you sure you want to change the base?
feat(layers): Migrate RandomChoice and RandomApply layers from keras-cv to keras #20752
Conversation
- Added RandomChoice and RandomApply layers to keras.layers.preprocessing.image_preprocessing. - Implemented necessary transform methods (transform_images, transform_labels, transform_bounding_boxes, transform_segmentation_masks) to comply with BaseImagePreprocessingLayer. - Updated tests to ensure compatibility with keras and fix failing test cases. - Added support for batchwise processing, auto-vectorization, and random seed control.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20752 +/- ##
==========================================
+ Coverage 81.94% 82.01% +0.06%
==========================================
Files 553 557 +4
Lines 51536 51972 +436
Branches 7978 8034 +56
==========================================
+ Hits 42231 42623 +392
- Misses 7363 7393 +30
- Partials 1942 1956 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
…andomApply and RandomChoice layers - Updated layers to handle JAX backend-specific behavior and avoid tracer leaks. - Updated tests to use backend-agnostic Keras operations. - Skipped JAX-specific tests with TODO to investigate further. - Removed Tensorflow-specific dependencies for better backend compatibility.
keras/src/layers/preprocessing/image_preprocessing/random_apply_test.py
Outdated
Show resolved
Hide resolved
- Add handling for layers with get_random_transformation method in both RandomApply and RandomChoice preprocessing layers - Fix seed handling in RandomChoice to ensure consistent behavior across backends - Remove JAX-specific test skipmarks after addressing tracer errors
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
- Simplified docstrings. - Removed copyright headers from files. - Refactored RandomApply and RandomChoice. - Streamlined transformation logic and improved overall code organization. - Eliminated redundant backend-specific code paths.
@fchollet, would love your thoughts on these changes whenever you get a chance, thanks! Also please do look into the comment I've left unresolved regarding whether it should inherit from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
@innat do you want to review?
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
keras/src/layers/preprocessing/image_preprocessing/random_apply.py
Outdated
Show resolved
Hide resolved
Sure, I'll review it. Thanks for tagging me. |
keras/src/layers/preprocessing/image_preprocessing/random_choice.py
Outdated
Show resolved
Hide resolved
- removed unused auto_vectorize parameter from both layers - shortened docstring headers to fit on one line - added backticks around boolean keywords (True, False) in docstrings - fixed incorrect transform methods (bounding_boxes, labels, segmentation_masks) to return inputs unchanged - removed unnecessary transformation methods from RandomChoice for consistency with original implementation
RandomChoice
andRandomApply
layers tokeras.layers.preprocessing.image_preprocessing
transform_images
,transform_labels
,transform_bounding_boxes
,transform_segmentation_masks
) to comply withBaseImagePreprocessingLayer