From a21bb3710e009a638733a0cfbeb0d3105ff35203 Mon Sep 17 00:00:00 2001 From: Ian Stenbit <3072903+ianstenbit@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:21:46 -0600 Subject: [PATCH] Switch back to tf 2.12 as minimum version (#1934) * Switch back to tf 2.12 as minimum version * Update backend shim * Handle multiplex directly in kpls --- .../preprocessing/base_image_augmentation_layer.py | 9 +++++++-- .../vectorized_base_image_augmentation_layer.py | 9 +++++++-- keras_cv/version_check.py | 2 +- keras_cv/version_check_test.py | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/keras_cv/layers/preprocessing/base_image_augmentation_layer.py b/keras_cv/layers/preprocessing/base_image_augmentation_layer.py index a1102428bc..0535147f77 100644 --- a/keras_cv/layers/preprocessing/base_image_augmentation_layer.py +++ b/keras_cv/layers/preprocessing/base_image_augmentation_layer.py @@ -12,8 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import keras import tensorflow as tf -from keras.src import backend as keras_backend + +if hasattr(keras, "src"): + keras_backend = keras.src.backend +else: + keras_backend = keras.backend from keras_cv import bounding_box from keras_cv.backend import keras @@ -118,7 +123,7 @@ def augment_image(self, image, transformation): ``` Note that since the randomness is also a common functionality, this layer - also includes a keras.backend.RandomGenerator, which can be used to + also includes a keras_backend.RandomGenerator, which can be used to produce the random numbers. The random number generator is stored in the `self._random_generator` attribute. """ diff --git a/keras_cv/layers/preprocessing/vectorized_base_image_augmentation_layer.py b/keras_cv/layers/preprocessing/vectorized_base_image_augmentation_layer.py index 0542a81a3e..024ca6a0fb 100644 --- a/keras_cv/layers/preprocessing/vectorized_base_image_augmentation_layer.py +++ b/keras_cv/layers/preprocessing/vectorized_base_image_augmentation_layer.py @@ -12,8 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import keras import tensorflow as tf -from keras.src import backend as keras_backend + +if hasattr(keras, "src"): + keras_backend = keras.src.backend +else: + keras_backend = keras.backend from keras_cv import bounding_box from keras_cv.backend import keras @@ -97,7 +102,7 @@ def __init__(self): ``` Note that since the randomness is also a common functionality, this layer - also includes a keras.backend.RandomGenerator, which can be used to + also includes a keras_backend.RandomGenerator, which can be used to produce the random numbers. The random number generator is stored in the `self._random_generator` attribute. """ diff --git a/keras_cv/version_check.py b/keras_cv/version_check.py index 44bc131451..5f75db666a 100644 --- a/keras_cv/version_check.py +++ b/keras_cv/version_check.py @@ -18,7 +18,7 @@ import tensorflow as tf from packaging.version import parse -MIN_VERSION = "2.13.0" +MIN_VERSION = "2.12.0" def check_tf_version(): diff --git a/keras_cv/version_check_test.py b/keras_cv/version_check_test.py index 347745a45e..933d2b7014 100644 --- a/keras_cv/version_check_test.py +++ b/keras_cv/version_check_test.py @@ -29,11 +29,11 @@ def cleanup_tf_version(): def test_check_tf_version_error(): - tf.__version__ = "2.12.0" + tf.__version__ = "2.11.0" with pytest.raises( RuntimeError, - match="Tensorflow package version needs to be at least 2.13.0", + match="Tensorflow package version needs to be at least 2.12.0", ): version_check.check_tf_version()