From 07e13740fd181fc3ddec7d9a594d8a08666645f6 Mon Sep 17 00:00:00 2001 From: Qianli Scott Zhu Date: Fri, 22 Apr 2022 10:34:55 -0700 Subject: [PATCH] Cherrypick ImageAugmetation related change to R2.9 (#16454) * Enable the keras dtensor API in OSS. PiperOrigin-RevId: 438858608 * Switching learning/brain dependency to OSS compatible test_util This is one test file failing, due to the monkey patching happens in the dtensor.init(), and I will need to dig more about the root cause (probably due to patching tf.Variable with DVariable, and cause logic difference for instance type checking.) PiperOrigin-RevId: 439676157 * Update the docstring for keras.dtensor components. 1. Add docstring for LayoutMap. 2. Hide certain methods for keras.dtensor.optimizers. PiperOrigin-RevId: 442651549 * add no-op label augmentation to RandomContrast PiperOrigin-RevId: 439938098 * Add augment_label to RandomBrightness PiperOrigin-RevId: 443122383 * Create augment_label method: ``` def augment_label(self, label, transformation=None): return label ``` on remaining image augmentation layers PiperOrigin-RevId: 443446864 * Revert "Create augment_label method:" This reverts commit 1694cb4ea0ca084c49a178afe45bbee4379a2cc4. Co-authored-by: Luke Wood --- keras/layers/preprocessing/image_preprocessing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/keras/layers/preprocessing/image_preprocessing.py b/keras/layers/preprocessing/image_preprocessing.py index bcdd27924fd..eeed5bd77aa 100644 --- a/keras/layers/preprocessing/image_preprocessing.py +++ b/keras/layers/preprocessing/image_preprocessing.py @@ -1527,6 +1527,9 @@ def __init__(self, factor, value_range=(0, 255), seed=None, **kwargs): def augment_image(self, image, transformation=None): return self._brightness_adjust(image, transformation['rgb_delta']) + def augment_label(self, label, transformation=None): + return label + def get_random_transformation(self, image=None, label=None,