Skip to content

Commit

Permalink
Fix Keras 2 tests with Seed Gen
Browse files Browse the repository at this point in the history
  • Loading branch information
sampathweb committed Nov 16, 2023
1 parent c40e9a2 commit cb8bca2
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions keras_cv/layers/preprocessing_3d/input_format_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down

0 comments on commit cb8bca2

Please sign in to comment.