From cb8bca2788abeee58cda42b93f992f39083be574 Mon Sep 17 00:00:00 2001 From: sampathweb <1437573+sampathweb@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:31:14 -0800 Subject: [PATCH] Fix Keras 2 tests with Seed Gen --- .../preprocessing_3d/base_augmentation_layer_3d_test.py | 3 +++ keras_cv/layers/preprocessing_3d/input_format_test.py | 6 ++++-- .../waymo/frustum_random_dropping_points_test.py | 4 +++- .../waymo/frustum_random_point_feature_noise_test.py | 3 +++ .../waymo/global_random_dropping_points_test.py | 3 +++ .../preprocessing_3d/waymo/global_random_flip_test.py | 3 +++ .../preprocessing_3d/waymo/global_random_rotation_test.py | 3 +++ .../preprocessing_3d/waymo/global_random_scaling_test.py | 3 +++ .../waymo/global_random_translation_test.py | 3 +++ .../waymo/group_points_by_bounding_boxes_test.py | 2 ++ .../layers/preprocessing_3d/waymo/random_copy_paste_test.py | 2 ++ .../layers/preprocessing_3d/waymo/random_drop_box_test.py | 3 +++ .../layers/preprocessing_3d/waymo/swap_background_test.py | 3 +++ 13 files changed, 38 insertions(+), 3 deletions(-) diff --git a/keras_cv/layers/preprocessing_3d/base_augmentation_layer_3d_test.py b/keras_cv/layers/preprocessing_3d/base_augmentation_layer_3d_test.py index 22465dbac3..8c15054521 100644 --- a/keras_cv/layers/preprocessing_3d/base_augmentation_layer_3d_test.py +++ b/keras_cv/layers/preprocessing_3d/base_augmentation_layer_3d_test.py @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. import numpy as np +import pytest import tensorflow as tf +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.tests.test_case import TestCase @@ -68,6 +70,7 @@ def __init__(self, **kwargs): super().__init__(**kwargs) +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class BaseImageAugmentationLayerTest(TestCase): def test_auto_vectorize_disabled(self): vectorize_disabled_layer = VectorizeDisabledLayer() diff --git a/keras_cv/layers/preprocessing_3d/input_format_test.py b/keras_cv/layers/preprocessing_3d/input_format_test.py index 0c349f0d88..9662e14497 100644 --- a/keras_cv/layers/preprocessing_3d/input_format_test.py +++ b/keras_cv/layers/preprocessing_3d/input_format_test.py @@ -12,9 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. import numpy as np +import pytest import tensorflow as tf from absl.testing import parameterized +from keras_cv.backend.config import keras_3 from keras_cv.layers import preprocessing_3d from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.tests.test_case import TestCase @@ -95,10 +97,10 @@ def convert_to_model_format(inputs): } +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class InputFormatTest(TestCase): @parameterized.named_parameters(*TEST_CONFIGURATIONS) - def DISABLED_test_equivalent_results_with_model_format(self, layer): - # TODO: Breaks with Keras 2. + def test_equivalent_results_with_model_format(self, layer): point_clouds = np.random.random(size=(3, 2, 50, 10)).astype("float32") bounding_boxes = np.random.random(size=(3, 2, 10, 9)).astype("float32") inputs = {POINT_CLOUDS: point_clouds, BOUNDING_BOXES: bounding_boxes} diff --git a/keras_cv/layers/preprocessing_3d/waymo/frustum_random_dropping_points_test.py b/keras_cv/layers/preprocessing_3d/waymo/frustum_random_dropping_points_test.py index 57570d155c..7896e19f1a 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/frustum_random_dropping_points_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/frustum_random_dropping_points_test.py @@ -1,9 +1,10 @@ # Copyright 2022 Waymo LLC. # # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 - import numpy as np +import pytest +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.frustum_random_dropping_points import ( # noqa: E501 FrustumRandomDroppingPoints, @@ -14,6 +15,7 @@ BOUNDING_BOXES = base_augmentation_layer_3d.BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class FrustumRandomDroppingPointTest(TestCase): def test_augment_point_clouds_and_bounding_boxes(self): add_layer = FrustumRandomDroppingPoints( diff --git a/keras_cv/layers/preprocessing_3d/waymo/frustum_random_point_feature_noise_test.py b/keras_cv/layers/preprocessing_3d/waymo/frustum_random_point_feature_noise_test.py index 859e98a883..cc4b8c6e05 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/frustum_random_point_feature_noise_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/frustum_random_point_feature_noise_test.py @@ -3,8 +3,10 @@ # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 import numpy as np +import pytest from tensorflow import keras +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.frustum_random_point_feature_noise import ( # noqa: E501 FrustumRandomPointFeatureNoise, @@ -16,6 +18,7 @@ POINTCLOUD_LABEL_INDEX = base_augmentation_layer_3d.POINTCLOUD_LABEL_INDEX +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class FrustumRandomPointFeatureNoiseTest(TestCase): def test_augment_point_clouds_and_bounding_boxes(self): add_layer = FrustumRandomPointFeatureNoise( diff --git a/keras_cv/layers/preprocessing_3d/waymo/global_random_dropping_points_test.py b/keras_cv/layers/preprocessing_3d/waymo/global_random_dropping_points_test.py index bd75870848..779dfa6942 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/global_random_dropping_points_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/global_random_dropping_points_test.py @@ -3,7 +3,9 @@ # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 import numpy as np +import pytest +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.global_random_dropping_points import ( # noqa: E501 GlobalRandomDroppingPoints, @@ -14,6 +16,7 @@ BOUNDING_BOXES = base_augmentation_layer_3d.BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class GlobalDropPointsTest(TestCase): def test_augment_point_clouds_and_bounding_boxes(self): add_layer = GlobalRandomDroppingPoints(drop_rate=0.5) diff --git a/keras_cv/layers/preprocessing_3d/waymo/global_random_flip_test.py b/keras_cv/layers/preprocessing_3d/waymo/global_random_flip_test.py index eb910ec561..91d60eb291 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/global_random_flip_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/global_random_flip_test.py @@ -3,7 +3,9 @@ # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 import numpy as np +import pytest +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.global_random_flip import ( GlobalRandomFlip, @@ -14,6 +16,7 @@ BOUNDING_BOXES = base_augmentation_layer_3d.BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class GlobalRandomFlipTest(TestCase): def test_augment_random_point_clouds_and_bounding_boxes(self): add_layer = GlobalRandomFlip() diff --git a/keras_cv/layers/preprocessing_3d/waymo/global_random_rotation_test.py b/keras_cv/layers/preprocessing_3d/waymo/global_random_rotation_test.py index 93e723d0a4..200eb906d1 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/global_random_rotation_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/global_random_rotation_test.py @@ -3,7 +3,9 @@ # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 import numpy as np +import pytest +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.global_random_rotation import ( GlobalRandomRotation, @@ -14,6 +16,7 @@ BOUNDING_BOXES = base_augmentation_layer_3d.BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class GlobalRandomRotationTest(TestCase): def test_augment_point_clouds_and_bounding_boxes(self): add_layer = GlobalRandomRotation( diff --git a/keras_cv/layers/preprocessing_3d/waymo/global_random_scaling_test.py b/keras_cv/layers/preprocessing_3d/waymo/global_random_scaling_test.py index 42d3f0c5dc..03f79ba333 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/global_random_scaling_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/global_random_scaling_test.py @@ -3,7 +3,9 @@ # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 import numpy as np +import pytest +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.global_random_scaling import ( GlobalRandomScaling, @@ -14,6 +16,7 @@ BOUNDING_BOXES = base_augmentation_layer_3d.BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class GlobalScalingTest(TestCase): def test_augment_point_clouds_and_bounding_boxes(self): add_layer = GlobalRandomScaling( diff --git a/keras_cv/layers/preprocessing_3d/waymo/global_random_translation_test.py b/keras_cv/layers/preprocessing_3d/waymo/global_random_translation_test.py index 209f924ca9..0737992aa0 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/global_random_translation_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/global_random_translation_test.py @@ -3,7 +3,9 @@ # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 import numpy as np +import pytest +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.global_random_translation import ( GlobalRandomTranslation, @@ -14,6 +16,7 @@ BOUNDING_BOXES = base_augmentation_layer_3d.BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class GlobalRandomTranslationTest(TestCase): def test_augment_point_clouds_and_bounding_boxes(self): add_layer = GlobalRandomTranslation( diff --git a/keras_cv/layers/preprocessing_3d/waymo/group_points_by_bounding_boxes_test.py b/keras_cv/layers/preprocessing_3d/waymo/group_points_by_bounding_boxes_test.py index 4a230e175d..c2b2914f68 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/group_points_by_bounding_boxes_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/group_points_by_bounding_boxes_test.py @@ -8,6 +8,7 @@ import pytest import tensorflow as tf +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.group_points_by_bounding_boxes import ( # noqa: E501 GroupPointsByBoundingBoxes, @@ -20,6 +21,7 @@ OBJECT_BOUNDING_BOXES = base_augmentation_layer_3d.OBJECT_BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class GroupPointsByBoundingBoxesTest(TestCase): def test_augment_point_clouds_and_bounding_boxes(self): add_layer = GroupPointsByBoundingBoxes( diff --git a/keras_cv/layers/preprocessing_3d/waymo/random_copy_paste_test.py b/keras_cv/layers/preprocessing_3d/waymo/random_copy_paste_test.py index 6cbec4ceb4..ebd0c9bc1a 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/random_copy_paste_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/random_copy_paste_test.py @@ -7,6 +7,7 @@ import numpy as np import pytest +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.random_copy_paste import ( RandomCopyPaste, @@ -19,6 +20,7 @@ OBJECT_BOUNDING_BOXES = base_augmentation_layer_3d.OBJECT_BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class RandomCopyPasteTest(TestCase): @pytest.mark.skipif( "TEST_CUSTOM_OPS" not in os.environ diff --git a/keras_cv/layers/preprocessing_3d/waymo/random_drop_box_test.py b/keras_cv/layers/preprocessing_3d/waymo/random_drop_box_test.py index d10c61c85e..2fdc59b2bc 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/random_drop_box_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/random_drop_box_test.py @@ -3,8 +3,10 @@ # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 import numpy as np +import pytest from tensorflow import keras +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.random_drop_box import RandomDropBox from keras_cv.tests.test_case import TestCase @@ -15,6 +17,7 @@ ADDITIONAL_BOUNDING_BOXES = base_augmentation_layer_3d.ADDITIONAL_BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class RandomDropBoxTest(TestCase): def test_drop_class1_box_point_clouds_and_bounding_boxes(self): keras.utils.set_random_seed(2) diff --git a/keras_cv/layers/preprocessing_3d/waymo/swap_background_test.py b/keras_cv/layers/preprocessing_3d/waymo/swap_background_test.py index 81f467a8d7..90afe50619 100644 --- a/keras_cv/layers/preprocessing_3d/waymo/swap_background_test.py +++ b/keras_cv/layers/preprocessing_3d/waymo/swap_background_test.py @@ -3,7 +3,9 @@ # Licensed under the terms in https://github.com/keras-team/keras-cv/blob/master/keras_cv/layers/preprocessing_3d/waymo/LICENSE # noqa: E501 import numpy as np +import pytest +from keras_cv.backend.config import keras_3 from keras_cv.layers.preprocessing_3d import base_augmentation_layer_3d from keras_cv.layers.preprocessing_3d.waymo.swap_background import ( SwapBackground, @@ -16,6 +18,7 @@ ADDITIONAL_BOUNDING_BOXES = base_augmentation_layer_3d.ADDITIONAL_BOUNDING_BOXES +@pytest.mark.skipif(keras_3(), reason="Not implemented for Keras 3") class SwapBackgroundTest(TestCase): def test_augment_point_clouds_and_bounding_boxes(self): add_layer = SwapBackground()