Skip to content

Commit

Permalink
Add API Gen
Browse files Browse the repository at this point in the history
  • Loading branch information
sampathweb committed Apr 27, 2024
1 parent f351683 commit eb89f75
Show file tree
Hide file tree
Showing 35 changed files with 129 additions and 121 deletions.
33 changes: 21 additions & 12 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,16 @@ jobs:
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY}}
JAX_ENABLE_X64: true
run: |
pytest keras_cv/bounding_box \
keras_cv/callbacks \
keras_cv/losses \
keras_cv/layers/object_detection \
keras_cv/layers/preprocessing \
keras_cv/models/backbones \
keras_cv/models/classification \
keras_cv/models/object_detection/retinanet \
keras_cv/models/object_detection/yolo_v8 \
keras_cv/models/object_detection_3d \
keras_cv/models/segmentation \
pytest keras_cv/src/bounding_box \
keras_cv/src/callbacks \
keras_cv/src/losses \
keras_cv/src/layers/object_detection \
keras_cv/src/layers/preprocessing \
keras_cv/src/models/classification \
keras_cv/src/models/object_detection/retinanet \
keras_cv/src/models/object_detection/yolo_v8 \
keras_cv/src/models/object_detection_3d \
keras_cv/src/models/segmentation \
--durations 0
format:
name: Check the code format
Expand All @@ -121,10 +120,20 @@ jobs:
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install tensorflow~=2.14
pip install -r requirements.txt
pip install -e ".[tests]" --progress-bar off --upgrade
pip install keras-nlp-nightly
- name: Lint
run: bash shell/lint.sh
- name: Check for API changes
run: |
bash shell/api_gen.sh
git status
clean=$(git status | grep "nothing to commit")
if [ -z "$clean" ]; then
echo "Please run shell/api_gen.sh to generate API."
exit 1
fi
- name: Clang
uses: DoozyX/clang-format-lint-action@v0.17
with:
Expand Down
52 changes: 26 additions & 26 deletions .kokoro/github/ubuntu/gpu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,32 @@ pip install --no-deps -e "." --progress-bar off
if [ "${RUN_XLARGE:-0}" == "1" ]
then
pytest --cache-clear --check_gpu --run_large --run_extra_large --durations 0 \
keras_cv/bounding_box \
keras_cv/callbacks \
keras_cv/losses \
keras_cv/layers/object_detection \
keras_cv/layers/preprocessing \
keras_cv/models/backbones \
keras_cv/models/classification \
keras_cv/models/object_detection/retinanet \
keras_cv/models/object_detection/yolo_v8 \
keras_cv/models/object_detection_3d \
keras_cv/models/segmentation \
keras_cv/models/feature_extractor/clip \
keras_cv/models/stable_diffusion
keras_cv/src/bounding_box \
keras_cv/src/callbacks \
keras_cv/src/losses \
keras_cv/src/layers/object_detection \
keras_cv/src/layers/preprocessing \
keras_cv/src/models/backbones \
keras_cv/src/models/classification \
keras_cv/src/models/object_detection/retinanet \
keras_cv/src/models/object_detection/yolo_v8 \
keras_cv/src/models/object_detection_3d \
keras_cv/src/models/segmentation \
keras_cv/src/models/feature_extractor/clip \
keras_cv/src/models/stable_diffusion
else
pytest --cache-clear --check_gpu --run_large --durations 0 \
keras_cv/bounding_box \
keras_cv/callbacks \
keras_cv/losses \
keras_cv/layers/object_detection \
keras_cv/layers/preprocessing \
keras_cv/models/backbones \
keras_cv/models/classification \
keras_cv/models/object_detection/retinanet \
keras_cv/models/object_detection/yolo_v8 \
keras_cv/models/object_detection_3d \
keras_cv/models/segmentation \
keras_cv/models/feature_extractor/clip \
keras_cv/models/stable_diffusion
keras_cv/src/bounding_box \
keras_cv/src/callbacks \
keras_cv/src/losses \
keras_cv/src/layers/object_detection \
keras_cv/src/layers/preprocessing \
keras_cv/src/models/backbones \
keras_cv/src/models/classification \
keras_cv/src/models/object_detection/retinanet \
keras_cv/src/models/object_detection/yolo_v8 \
keras_cv/src/models/object_detection_3d \
keras_cv/src/models/segmentation \
keras_cv/src/models/feature_extractor/clip \
keras_cv/src/models/stable_diffusion
fi
3 changes: 1 addition & 2 deletions api_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import os
import re
import shutil

import namex
Expand Down Expand Up @@ -98,7 +97,7 @@ def build():
update_package_init(build_init_fname)
# Add __version__ to keras package
export_version_string(build_api_init_fname)
# Copy back the keras_cv/api and keras_cv/__init__.py from build directory
# Copy back the keras_cv/api and keras_cv/__init__.py from build dir
if os.path.exists(code_api_dir):
shutil.rmtree(code_api_dir)
shutil.copytree(build_api_dir, code_api_dir)
Expand Down
32 changes: 16 additions & 16 deletions keras_cv/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
version_check.check_tf_version()
# isort:on

from keras_cv.src import bounding_box
from keras_cv.src import callbacks
from keras_cv.src import datasets
from keras_cv.src import layers
from keras_cv.src import losses
from keras_cv.src import metrics
from keras_cv.src import models
from keras_cv.src import training
from keras_cv.src import utils
from keras_cv.src import visualization
from keras_cv.src.core import ConstantFactorSampler
from keras_cv.src.core import FactorSampler
from keras_cv.src.core import NormalFactorSampler
from keras_cv.src.core import UniformFactorSampler
from keras_cv.src.version_utils import __version__
from keras_cv.src.version_utils import version
from keras_cv.src import bounding_box # noqa: E402
from keras_cv.src import callbacks # noqa: E402
from keras_cv.src import datasets # noqa: E402
from keras_cv.src import layers # noqa: E402
from keras_cv.src import losses # noqa: E402
from keras_cv.src import metrics # noqa: E402
from keras_cv.src import models # noqa: E402
from keras_cv.src import training # noqa: E402
from keras_cv.src import utils # noqa: E402
from keras_cv.src import visualization # noqa: E402
from keras_cv.src.core import ConstantFactorSampler # noqa: E402
from keras_cv.src.core import FactorSampler # noqa: E402
from keras_cv.src.core import NormalFactorSampler # noqa: E402
from keras_cv.src.core import UniformFactorSampler # noqa: E402
from keras_cv.src.version_utils import __version__ # noqa: E402
from keras_cv.src.version_utils import version # noqa: E402
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ConstantFactorSampler(FactorSampler):
Example:
```python
constant_factor = keras_cv.ConstantFactorSampler(0.5)
constant_factor = keras_cv.src.ConstantFactorSampler(0.5)
random_sharpness = keras_cv.layers.RandomSharpness(factor=constant_factor)
# random_sharpness will now always use a factor of 0.5
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

class ConstantFactorSamplerTest(TestCase):
def test_sample(self):
factor = keras_cv.ConstantFactorSampler(0.3)
factor = keras_cv.src.ConstantFactorSampler(0.3)
self.assertEqual(factor(), 0.3)

def test_config(self):
factor = keras_cv.ConstantFactorSampler(0.3)
factor = keras_cv.src.ConstantFactorSampler(0.3)
config = factor.get_config()
self.assertEqual(config["value"], 0.3)
4 changes: 2 additions & 2 deletions keras_cv/src/layers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
AnchorGenerator,
)
from keras_cv.src.layers.object_detection.box_matcher import BoxMatcher
from keras_cv.src.layers.object_detection.multi_class_non_max_suppression import (
from keras_cv.src.layers.object_detection.multi_class_non_max_suppression import ( # noqa: E501
MultiClassNonMaxSuppression,
)
from keras_cv.src.layers.object_detection.non_max_suppression import (
Expand Down Expand Up @@ -125,7 +125,7 @@
from keras_cv.src.layers.preprocessing_3d.waymo.global_random_scaling import (
GlobalRandomScaling,
)
from keras_cv.src.layers.preprocessing_3d.waymo.global_random_translation import (
from keras_cv.src.layers.preprocessing_3d.waymo.global_random_translation import ( # noqa: E501
GlobalRandomTranslation,
)
from keras_cv.src.layers.preprocessing_3d.waymo.group_points_by_bounding_boxes import ( # noqa: E501
Expand Down
2 changes: 1 addition & 1 deletion keras_cv/src/layers/preprocessing/grid_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class GridMask(BaseImageAugmentationLayer):
size smaller, and higher values make the grid mask large.
Floats should be in the range [0, 1]. 0.5 indicates that grid and
spacing will be of equal size. To always use the same value, pass a
`keras_cv.ConstantFactorSampler()`.
`keras_cv.src.ConstantFactorSampler()`.
Defaults to `(0, 0.5)`.
rotation_factor:
Expand Down
2 changes: 1 addition & 1 deletion keras_cv/src/layers/preprocessing/grid_mask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_in_tf_function(self):

fill_value = 255.0
layer = GridMask(
ratio_factor=keras_cv.ConstantFactorSampler(0.5),
ratio_factor=keras_cv.src.ConstantFactorSampler(0.5),
rotation_factor=0.5,
fill_mode="constant",
fill_value=fill_value,
Expand Down
2 changes: 1 addition & 1 deletion keras_cv/src/layers/preprocessing_3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from keras_cv.src.layers.preprocessing_3d.waymo.global_random_scaling import (
GlobalRandomScaling,
)
from keras_cv.src.layers.preprocessing_3d.waymo.global_random_translation import (
from keras_cv.src.layers.preprocessing_3d.waymo.global_random_translation import ( # noqa: E501
GlobalRandomTranslation,
)
from keras_cv.src.layers.preprocessing_3d.waymo.group_points_by_bounding_boxes import ( # noqa: E501
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from keras_cv.src.layers.preprocessing_3d import base_augmentation_layer_3d
from keras_cv.src.layers.preprocessing_3d.waymo.global_random_translation import (
from keras_cv.src.layers.preprocessing_3d.waymo.global_random_translation import ( # noqa: E501
GlobalRandomTranslation,
)
from keras_cv.src.tests.test_case import TestCase
Expand Down
48 changes: 24 additions & 24 deletions keras_cv/src/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,76 +61,76 @@
from keras_cv.src.models.backbones.efficientnet_lite.efficientnet_lite_backbone import ( # noqa: E501
EfficientNetLiteBackbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B0Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B1Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B2Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B3Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B4Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B5Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B6Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B7Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import (
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import ( # noqa: E501
EfficientNetV2B0Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import (
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import ( # noqa: E501
EfficientNetV2B1Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import (
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import ( # noqa: E501
EfficientNetV2B2Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import (
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import ( # noqa: E501
EfficientNetV2B3Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import (
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import ( # noqa: E501
EfficientNetV2Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import (
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import ( # noqa: E501
EfficientNetV2LBackbone,
)
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import (
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import ( # noqa: E501
EfficientNetV2MBackbone,
)
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import (
from keras_cv.src.models.backbones.efficientnet_v2.efficientnet_v2_aliases import ( # noqa: E501
EfficientNetV2SBackbone,
)
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import (
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import ( # noqa: E501
MiTB0Backbone,
)
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import (
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import ( # noqa: E501
MiTB1Backbone,
)
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import (
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import ( # noqa: E501
MiTB2Backbone,
)
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import (
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import ( # noqa: E501
MiTB3Backbone,
)
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import (
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import ( # noqa: E501
MiTB4Backbone,
)
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import (
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import ( # noqa: E501
MiTB5Backbone,
)
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import (
from keras_cv.src.models.backbones.mix_transformer.mix_transformer_aliases import ( # noqa: E501
MiTBackbone,
)
from keras_cv.src.models.backbones.mobilenet_v3.mobilenet_v3_aliases import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from keras_cv.src.models.backbones.csp_darknet.csp_darknet_backbone import (
CSPDarkNetBackbone,
)
from keras_cv.src.models.backbones.csp_darknet.csp_darknet_backbone_presets import (
from keras_cv.src.models.backbones.csp_darknet.csp_darknet_backbone_presets import ( # noqa: E501
backbone_presets,
)
from keras_cv.src.utils.python_utils import classproperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from keras_cv.src.backend import keras
from keras_cv.src.models import utils
from keras_cv.src.models.backbones.backbone import Backbone
from keras_cv.src.models.backbones.csp_darknet.csp_darknet_backbone_presets import (
from keras_cv.src.models.backbones.csp_darknet.csp_darknet_backbone_presets import ( # noqa: E501
backbone_presets,
)
from keras_cv.src.models.backbones.csp_darknet.csp_darknet_backbone_presets import (
from keras_cv.src.models.backbones.csp_darknet.csp_darknet_backbone_presets import ( # noqa: E501
backbone_presets_with_weights,
)
from keras_cv.src.models.backbones.csp_darknet.csp_darknet_utils import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from keras_cv.src.api_export import keras_cv_export
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_backbone import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_backbone import ( # noqa: E501
EfficientNetV1Backbone,
)
from keras_cv.src.utils.python_utils import classproperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
from absl.testing import parameterized

from keras_cv.src.backend import keras
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B0Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_backbone import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_backbone import ( # noqa: E501
EfficientNetV1Backbone,
)
from keras_cv.src.tests.test_case import TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from absl.testing import parameterized

from keras_cv.src.backend import keras
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_aliases import ( # noqa: E501
EfficientNetV1B0Backbone,
)
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_backbone import (
from keras_cv.src.models.backbones.efficientnet_v1.efficientnet_v1_backbone import ( # noqa: E501
EfficientNetV1Backbone,
)
from keras_cv.src.tests.test_case import TestCase
Expand Down
Loading

0 comments on commit eb89f75

Please sign in to comment.