Skip to content

Commit

Permalink
disable layers using internal base random layer
Browse files Browse the repository at this point in the history
  • Loading branch information
divyashreepathihalli committed Nov 8, 2023
1 parent 3ec653d commit e9da187
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
18 changes: 18 additions & 0 deletions keras_cv/layers/check_keras_version_layer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 The KerasCV Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class CheckKerasVersionLayer(keras.layers.Layer):
"""check keras version and raise an error if the layer is not supported"""

def __init__(self, layers):
raise ValueError "This layer is not supported in keras 3"
13 changes: 11 additions & 2 deletions keras_cv/layers/preprocessing_3d/base_augmentation_layer_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@
# limitations under the License.

import tensorflow as tf
from keras_cv.api_export import keras_cv_export
from keras_cv.backend.config import detect_if_tensorflow_uses_keras_3
from tensorflow import keras

from keras_cv.api_export import keras_cv_export
if detect_if_tensorflow_uses_keras_3():
from keras_cv.layers import check_keras_version_layer

base_layer = check_keras_version_layer
else:
from tensorflow.keras.__internal__.layers import BaseRandomLayer

base_layer = BaseRandomLayer

POINT_CLOUDS = "point_clouds"
BOUNDING_BOXES = "bounding_boxes"
Expand All @@ -29,7 +38,7 @@


@keras_cv_export("keras_cv.layers.BaseAugmentationLayer3D")
class BaseAugmentationLayer3D(keras.__internal__.layers.BaseRandomLayer):
class BaseAugmentationLayer3D(base_layer):
"""Abstract base layer for data augmentation for 3D perception.
This layer contains base functionalities for preprocessing layers which
Expand Down
13 changes: 11 additions & 2 deletions keras_cv/layers/regularization/dropblock_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@
# limitations under the License.

import tensorflow as tf
from tensorflow.keras.__internal__.layers import BaseRandomLayer
from keras_cv.backend.config import detect_if_tensorflow_uses_keras_3

if detect_if_tensorflow_uses_keras_3():
from keras_cv.layers import check_keras_version_layer

base_layer = check_keras_version_layer
else:
from tensorflow.keras.__internal__.layers import BaseRandomLayer

base_layer = BaseRandomLayer

from keras_cv.api_export import keras_cv_export
from keras_cv.utils import conv_utils


@keras_cv_export("keras_cv.layers.DropBlock2D")
class DropBlock2D(BaseRandomLayer):
class DropBlock2D(base_layer):
"""Applies DropBlock regularization to input features.
DropBlock is a form of structured dropout, where units in a contiguous
Expand Down

0 comments on commit e9da187

Please sign in to comment.