Skip to content

Commit fb05c82

Browse files
Export Model APIs (#2389)
* Fix backbone export under models * Namex for API generation * Use Namex API generator * Namex for API generation * Export API namex * Fix typo and export APIs
1 parent 707132b commit fb05c82

File tree

13 files changed

+55
-6
lines changed

13 files changed

+55
-6
lines changed

keras_cv/models/backbones/csp_darknet/csp_darknet_aliases.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
""" # noqa: E501
5353

5454

55-
@keras_cv_export("keras_cv.losses.CSPDarkNetTinyBackbone")
55+
@keras_cv_export("keras_cv.models.CSPDarkNetTinyBackbone")
5656
class CSPDarkNetTinyBackbone(CSPDarkNetBackbone):
5757
def __new__(
5858
cls,
@@ -87,7 +87,7 @@ def presets_with_weights(cls):
8787
return cls.presets
8888

8989

90-
@keras_cv_export("keras_cv.losses.CSPDarkNetSBackbone")
90+
@keras_cv_export("keras_cv.models.CSPDarkNetSBackbone")
9191
class CSPDarkNetSBackbone(CSPDarkNetBackbone):
9292
def __new__(
9393
cls,
@@ -118,7 +118,7 @@ def presets_with_weights(cls):
118118
return {}
119119

120120

121-
@keras_cv_export("keras_cv.losses.CSPDarkNetMBackbone")
121+
@keras_cv_export("keras_cv.models.CSPDarkNetMBackbone")
122122
class CSPDarkNetMBackbone(CSPDarkNetBackbone):
123123
def __new__(
124124
cls,
@@ -149,7 +149,7 @@ def presets_with_weights(cls):
149149
return {}
150150

151151

152-
@keras_cv_export("keras_cv.losses.CSPDarkNetLBackbone")
152+
@keras_cv_export("keras_cv.models.CSPDarkNetLBackbone")
153153
class CSPDarkNetLBackbone(CSPDarkNetBackbone):
154154
def __new__(
155155
cls,
@@ -184,7 +184,7 @@ def presets_with_weights(cls):
184184
return cls.presets
185185

186186

187-
@keras_cv_export("keras_cv.losses.CSPDarkNetXLBackbone")
187+
@keras_cv_export("keras_cv.models.CSPDarkNetXLBackbone")
188188
class CSPDarkNetXLBackbone(CSPDarkNetBackbone):
189189
def __new__(
190190
cls,

keras_cv/models/backbones/efficientnet_lite/efficientnet_lite_aliases.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from keras_cv.api_export import keras_cv_export
1516
from keras_cv.models.backbones.efficientnet_lite.efficientnet_lite_backbone import ( # noqa: E501
1617
EfficientNetLiteBackbone,
1718
)
@@ -41,6 +42,7 @@
4142
""" # noqa: E501
4243

4344

45+
@keras_cv_export("keras_cv.models.EfficientNetLiteB0Backbone")
4446
class EfficientNetLiteB0Backbone(EfficientNetLiteBackbone):
4547
def __new__(
4648
cls,
@@ -73,6 +75,7 @@ def presets_with_weights(cls):
7375
return {}
7476

7577

78+
@keras_cv_export("keras_cv.models.EfficientNetLiteB1Backbone")
7679
class EfficientNetLiteB1Backbone(EfficientNetLiteBackbone):
7780
def __new__(
7881
cls,
@@ -105,6 +108,7 @@ def presets_with_weights(cls):
105108
return {}
106109

107110

111+
@keras_cv_export("keras_cv.models.EfficientNetLiteB2Backbone")
108112
class EfficientNetLiteB2Backbone(EfficientNetLiteBackbone):
109113
def __new__(
110114
cls,
@@ -137,6 +141,7 @@ def presets_with_weights(cls):
137141
return {}
138142

139143

144+
@keras_cv_export("keras_cv.models.EfficientNetLiteB3Backbone")
140145
class EfficientNetLiteB3Backbone(EfficientNetLiteBackbone):
141146
def __new__(
142147
cls,
@@ -169,6 +174,7 @@ def presets_with_weights(cls):
169174
return {}
170175

171176

177+
@keras_cv_export("keras_cv.models.EfficientNetLiteB4Backbone")
172178
class EfficientNetLiteB4Backbone(EfficientNetLiteBackbone):
173179
def __new__(
174180
cls,

keras_cv/models/backbones/efficientnet_lite/efficientnet_lite_backbone.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import copy
2525
import math
2626

27+
from keras_cv.api_export import keras_cv_export
2728
from keras_cv.backend import keras
2829
from keras_cv.models import utils
2930
from keras_cv.models.backbones.backbone import Backbone
@@ -35,6 +36,7 @@
3536
BN_AXIS = 3
3637

3738

39+
@keras_cv_export("keras_cv.models.EfficientNetLiteBackbone")
3840
@keras.saving.register_keras_serializable(package="keras_cv.models")
3941
class EfficientNetLiteBackbone(Backbone):
4042
"""Instantiates the EfficientNetLite architecture using given scaling

keras_cv/models/backbones/efficientnet_v1/efficientnet_v1_aliases.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from keras_cv.api_export import keras_cv_export
1516
from keras_cv.models.backbones.efficientnet_v1.efficientnet_v1_backbone import (
1617
EfficientNetV1Backbone,
1718
)
@@ -33,6 +34,7 @@
3334
""" # noqa: E501
3435

3536

37+
@keras_cv_export("keras_cv.models.EfficientNetV1B0Backbone")
3638
class EfficientNetV1B0Backbone(EfficientNetV1Backbone):
3739
def __new__(
3840
cls,
@@ -63,6 +65,7 @@ def presets_with_weights(cls):
6365
return {}
6466

6567

68+
@keras_cv_export("keras_cv.models.EfficientNetV1B1Backbone")
6669
class EfficientNetV1B1Backbone(EfficientNetV1Backbone):
6770
def __new__(
6871
cls,
@@ -93,6 +96,7 @@ def presets_with_weights(cls):
9396
return {}
9497

9598

99+
@keras_cv_export("keras_cv.models.EfficientNetV1B2Backbone")
96100
class EfficientNetV1B2Backbone(EfficientNetV1Backbone):
97101
def __new__(
98102
cls,
@@ -123,6 +127,7 @@ def presets_with_weights(cls):
123127
return {}
124128

125129

130+
@keras_cv_export("keras_cv.models.EfficientNetV1B3Backbone")
126131
class EfficientNetV1B3Backbone(EfficientNetV1Backbone):
127132
def __new__(
128133
cls,
@@ -153,6 +158,7 @@ def presets_with_weights(cls):
153158
return {}
154159

155160

161+
@keras_cv_export("keras_cv.models.EfficientNetV1B4Backbone")
156162
class EfficientNetV1B4Backbone(EfficientNetV1Backbone):
157163
def __new__(
158164
cls,
@@ -183,6 +189,7 @@ def presets_with_weights(cls):
183189
return {}
184190

185191

192+
@keras_cv_export("keras_cv.models.EfficientNetV1B5Backbone")
186193
class EfficientNetV1B5Backbone(EfficientNetV1Backbone):
187194
def __new__(
188195
cls,
@@ -213,6 +220,7 @@ def presets_with_weights(cls):
213220
return {}
214221

215222

223+
@keras_cv_export("keras_cv.models.EfficientNetV1B6Backbone")
216224
class EfficientNetV1B6Backbone(EfficientNetV1Backbone):
217225
def __new__(
218226
cls,
@@ -243,6 +251,7 @@ def presets_with_weights(cls):
243251
return {}
244252

245253

254+
@keras_cv_export("keras_cv.models.EfficientNetV1B7Backbone")
246255
class EfficientNetV1B7Backbone(EfficientNetV1Backbone):
247256
def __new__(
248257
cls,

keras_cv/models/backbones/efficientnet_v1/efficientnet_v1_backbone.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import copy
1515
import math
1616

17+
from keras_cv.api_export import keras_cv_export
1718
from keras_cv.backend import keras
1819
from keras_cv.models import utils
1920
from keras_cv.models.backbones.backbone import Backbone
@@ -23,6 +24,7 @@
2324
from keras_cv.utils.python_utils import classproperty
2425

2526

27+
@keras_cv_export("keras_cv.models.EfficientNetV1Backbone")
2628
@keras.saving.register_keras_serializable(package="keras_cv.models")
2729
class EfficientNetV1Backbone(Backbone):
2830
"""Instantiates the EfficientNetV1 architecture.

keras_cv/models/backbones/mix_transformer/mix_transformer_aliases.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import copy
1616

17+
from keras_cv.api_export import keras_cv_export
1718
from keras_cv.models.backbones.mix_transformer.mix_transformer_backbone import (
1819
MiTBackbone,
1920
)
@@ -46,6 +47,7 @@
4647
""" # noqa: E501
4748

4849

50+
@keras_cv_export("keras_cv.models.MiTB0Backbone")
4951
class MiTB0Backbone(MiTBackbone):
5052
def __new__(
5153
cls,
@@ -80,6 +82,7 @@ def presets_with_weights(cls):
8082
return cls.presets
8183

8284

85+
@keras_cv_export("keras_cv.models.MiTB1Backbone")
8386
class MiTB1Backbone(MiTBackbone):
8487
def __new__(
8588
cls,
@@ -109,6 +112,7 @@ def presets_with_weights(cls):
109112
return {}
110113

111114

115+
@keras_cv_export("keras_cv.models.MiTB2Backbone")
112116
class MiTB2Backbone(MiTBackbone):
113117
def __new__(
114118
cls,
@@ -138,6 +142,7 @@ def presets_with_weights(cls):
138142
return {}
139143

140144

145+
@keras_cv_export("keras_cv.models.MiTB3Backbone")
141146
class MiTB3Backbone(MiTBackbone):
142147
def __new__(
143148
cls,
@@ -167,6 +172,7 @@ def presets_with_weights(cls):
167172
return {}
168173

169174

175+
@keras_cv_export("keras_cv.models.MiTB4Backbone")
170176
class MiTB4Backbone(MiTBackbone):
171177
def __new__(
172178
cls,
@@ -196,6 +202,7 @@ def presets_with_weights(cls):
196202
return {}
197203

198204

205+
@keras_cv_export("keras_cv.models.MiTB5Backbone")
199206
class MiTB5Backbone(MiTBackbone):
200207
def __new__(
201208
cls,

keras_cv/models/backbones/vgg16/vgg16_backbone.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414

1515
from keras import layers
1616

17+
from keras_cv.api_export import keras_cv_export
1718
from keras_cv.models import utils
1819
from keras_cv.models.backbones.backbone import Backbone
1920

2021

22+
@keras_cv_export("keras_cv.models.VGG16Backbone")
2123
class VGG16Backbone(Backbone):
2224
"""
2325
Reference:

keras_cv/models/backbones/vit_det/vit_det_aliases.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import copy
1616

17+
from keras_cv.api_export import keras_cv_export
1718
from keras_cv.models.backbones.vit_det.vit_det_backbone import ViTDetBackbone
1819
from keras_cv.models.backbones.vit_det.vit_det_backbone_presets import (
1920
backbone_presets,
@@ -41,6 +42,7 @@
4142
""" # noqa: E501
4243

4344

45+
@keras_cv_export("keras_cv.models.ViTDetBBackbone")
4446
class ViTDetBBackbone(ViTDetBackbone):
4547
def __new__(
4648
cls,
@@ -64,6 +66,7 @@ def presets_with_weights(cls):
6466
return cls.presets
6567

6668

69+
@keras_cv_export("keras_cv.models.ViTDetLBackbone")
6770
class ViTDetLBackbone(ViTDetBackbone):
6871
def __new__(
6972
cls,
@@ -87,6 +90,7 @@ def presets_with_weights(cls):
8790
return cls.presets
8891

8992

93+
@keras_cv_export("keras_cv.models.ViTDetHBackbone")
9094
class ViTDetHBackbone(ViTDetBackbone):
9195
def __new__(
9296
cls,

keras_cv/models/feature_extractor/clip/clip_encoder.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
import numpy as np
1515

16+
from keras_cv.api_export import keras_cv_export
1617
from keras_cv.backend import keras
1718
from keras_cv.backend import ops
1819

@@ -31,6 +32,7 @@ def get_initializer(initializer_range=0.02):
3132
return keras.initializers.TruncatedNormal(stddev=initializer_range)
3233

3334

35+
@keras_cv_export("keras_cv.models.feature_extractor.QuickGELU")
3436
class QuickGELU(keras.layers.Layer):
3537
def __init__(self, **kwargs):
3638
super().__init__(**kwargs)
@@ -39,6 +41,7 @@ def call(self, x):
3941
return x * ops.sigmoid(1.702 * x)
4042

4143

44+
@keras_cv_export("keras_cv.models.feature_extractor.ResidualAttention")
4245
class ResidualAttention(keras.layers.Layer):
4346
def __init__(
4447
self,
@@ -136,6 +139,7 @@ def get_config(self):
136139
return config
137140

138141

142+
@keras_cv_export("keras_cv.models.feature_extractor.CLIPEncoder")
139143
class CLIPEncoder(keras.layers.Layer):
140144
def __init__(self, width, num_layers, heads, **kwargs):
141145
super().__init__(**kwargs)
@@ -185,6 +189,7 @@ def get_config(self):
185189
return config
186190

187191

192+
@keras_cv_export("keras_cv.models.feature_extractor.CLIPAttention")
188193
class CLIPAttention(keras.layers.Layer):
189194
"""
190195
Adapted from https://github.com/huggingface/transformers/blob/main/src/transformers/models/clip/modeling_clip.py # noqa: E501

keras_cv/models/feature_extractor/clip/clip_image_model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from keras_cv.api_export import keras_cv_export
1516
from keras_cv.backend import keras
1617
from keras_cv.backend import ops
1718
from keras_cv.models.feature_extractor.clip.clip_encoder import CLIPEncoder
1819
from keras_cv.models.feature_extractor.clip.clip_encoder import get_initializer
1920

2021

22+
@keras_cv_export("keras_cv.models.feature_extractor.CLIPPatchingAndEmbedding")
2123
class CLIPPatchingAndEmbedding(keras.layers.Layer):
2224
def __init__(
2325
self, width, patch_size, input_resolution, output_dim, **kwargs
@@ -95,6 +97,7 @@ def get_config(self):
9597
return config
9698

9799

100+
@keras_cv_export("keras_cv.models.feature_extractor.CLIPImageEncoder")
98101
class CLIPImageEncoder(keras.Model):
99102
def __init__(
100103
self,

0 commit comments

Comments
 (0)