Skip to content

Commit d91b61a

Browse files
divyashreepathihallimattdangerw
authored andcommitted
update input_image_shape -> image_shape (#1785)
* update input_image_shape -> image_shape * update docstring example * code reformat * update tests
1 parent 76d704f commit d91b61a

16 files changed

+37
-38
lines changed

keras_nlp/src/models/csp_darknet/csp_darknet_backbone.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CSPDarkNetBackbone(Backbone):
3838
Use `"depthwise_block"` for depthwise conv block
3939
`"basic_block"` for basic conv block.
4040
Defaults to "basic_block".
41-
input_image_shape: tuple. The input shape without the batch size.
41+
image_shape: tuple. The input shape without the batch size.
4242
Defaults to `(None, None, 3)`.
4343
4444
Examples:
@@ -67,7 +67,7 @@ def __init__(
6767
stackwise_depth,
6868
include_rescaling,
6969
block_type="basic_block",
70-
input_image_shape=(224, 224, 3),
70+
image_shape=(224, 224, 3),
7171
**kwargs,
7272
):
7373
# === Functional Model ===
@@ -78,7 +78,7 @@ def __init__(
7878
)
7979
base_channels = stackwise_num_filters[0] // 2
8080

81-
image_input = layers.Input(shape=input_image_shape)
81+
image_input = layers.Input(shape=image_shape)
8282
x = image_input
8383
if include_rescaling:
8484
x = layers.Rescaling(scale=1 / 255.0)(x)
@@ -119,7 +119,7 @@ def __init__(
119119
self.stackwise_depth = stackwise_depth
120120
self.include_rescaling = include_rescaling
121121
self.block_type = block_type
122-
self.input_image_shape = input_image_shape
122+
self.image_shape = image_shape
123123

124124
def get_config(self):
125125
config = super().get_config()
@@ -129,7 +129,7 @@ def get_config(self):
129129
"stackwise_depth": self.stackwise_depth,
130130
"include_rescaling": self.include_rescaling,
131131
"block_type": self.block_type,
132-
"input_image_shape": self.input_image_shape,
132+
"image_shape": self.image_shape,
133133
}
134134
)
135135
return config

keras_nlp/src/models/csp_darknet/csp_darknet_backbone_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def setUp(self):
2828
"stackwise_depth": [1, 3, 3, 1],
2929
"include_rescaling": False,
3030
"block_type": "basic_block",
31-
"input_image_shape": (224, 224, 3),
31+
"image_shape": (224, 224, 3),
3232
}
3333
self.input_data = np.ones((2, 224, 224, 3), dtype="float32")
3434

keras_nlp/src/models/csp_darknet/csp_darknet_image_classifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class CSPDarkNetImageClassifier(ImageClassifier):
7878
stackwise_depth=[3, 9, 9, 3],
7979
include_rescaling=False,
8080
block_type="basic_block",
81-
input_image_shape = (224, 224, 3),
81+
image_shape = (224, 224, 3),
8282
)
8383
classifier = keras_nlp.models.CSPDarkNetImageClassifier(
8484
backbone=backbone,

keras_nlp/src/models/csp_darknet/csp_darknet_image_classifier_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setUp(self):
3333
stackwise_depth=[1, 3, 3, 1],
3434
include_rescaling=False,
3535
block_type="basic_block",
36-
input_image_shape=(16, 16, 3),
36+
image_shape=(16, 16, 3),
3737
)
3838
self.init_kwargs = {
3939
"backbone": self.backbone,

keras_nlp/src/models/densenet/densenet_backbone.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DenseNetBackbone(Backbone):
3535
include_rescaling: bool, whether to rescale the inputs. If set
3636
to `True`, inputs will be passed through a `Rescaling(1/255.0)`
3737
layer. Defaults to `True`.
38-
input_image_shape: optional shape tuple, defaults to (224, 224, 3).
38+
image_shape: optional shape tuple, defaults to (224, 224, 3).
3939
compression_ratio: float, compression rate at transition layers,
4040
defaults to 0.5.
4141
growth_rate: int, number of filters added by each dense block,
@@ -62,13 +62,13 @@ def __init__(
6262
self,
6363
stackwise_num_repeats,
6464
include_rescaling=True,
65-
input_image_shape=(224, 224, 3),
65+
image_shape=(224, 224, 3),
6666
compression_ratio=0.5,
6767
growth_rate=32,
6868
**kwargs,
6969
):
7070
# === Functional Model ===
71-
image_input = keras.layers.Input(shape=input_image_shape)
71+
image_input = keras.layers.Input(shape=image_shape)
7272

7373
x = image_input
7474
if include_rescaling:
@@ -116,7 +116,7 @@ def __init__(
116116
self.include_rescaling = include_rescaling
117117
self.compression_ratio = compression_ratio
118118
self.growth_rate = growth_rate
119-
self.input_image_shape = input_image_shape
119+
self.image_shape = image_shape
120120

121121
def get_config(self):
122122
config = super().get_config()
@@ -126,7 +126,7 @@ def get_config(self):
126126
"include_rescaling": self.include_rescaling,
127127
"compression_ratio": self.compression_ratio,
128128
"growth_rate": self.growth_rate,
129-
"input_image_shape": self.input_image_shape,
129+
"image_shape": self.image_shape,
130130
}
131131
)
132132
return config

keras_nlp/src/models/densenet/densenet_backbone_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def setUp(self):
2626
"include_rescaling": True,
2727
"compression_ratio": 0.5,
2828
"growth_rate": 32,
29-
"input_image_shape": (224, 224, 3),
29+
"image_shape": (224, 224, 3),
3030
}
3131
self.input_data = np.ones((2, 224, 224, 3), dtype="float32")
3232

keras_nlp/src/models/densenet/densenet_image_classifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class DenseNetImageClassifier(ImageClassifier):
7676
stackwise_depth=[3, 9, 9, 3],
7777
include_rescaling=False,
7878
block_type="basic_block",
79-
input_image_shape = (224, 224, 3),
79+
image_shape = (224, 224, 3),
8080
)
8181
classifier = keras_nlp.models.DenseNetImageClassifier(
8282
backbone=backbone,

keras_nlp/src/models/densenet/densenet_image_classifier_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def setUp(self):
3131
include_rescaling=True,
3232
compression_ratio=0.5,
3333
growth_rate=32,
34-
input_image_shape=(224, 224, 3),
34+
image_shape=(224, 224, 3),
3535
)
3636
self.init_kwargs = {
3737
"backbone": self.backbone,

keras_nlp/src/models/resnet/resnet_backbone.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ResNetBackbone(FeaturePyramidBackbone):
5454
include_rescaling: boolean. If `True`, rescale the input using
5555
`Rescaling` and `Normalization` layers. If `False`, do nothing.
5656
Defaults to `True`.
57-
input_image_shape: tuple. The input shape without the batch size.
57+
image_shape: tuple. The input shape without the batch size.
5858
Defaults to `(None, None, 3)`.
5959
pooling: `None` or str. Pooling mode for feature extraction. Defaults
6060
to `"avg"`.
@@ -107,7 +107,7 @@ def __init__(
107107
block_type,
108108
use_pre_activation=False,
109109
include_rescaling=True,
110-
input_image_shape=(None, None, 3),
110+
image_shape=(None, None, 3),
111111
pooling="avg",
112112
data_format=None,
113113
dtype=None,
@@ -139,7 +139,7 @@ def __init__(
139139
num_stacks = len(stackwise_num_filters)
140140

141141
# === Functional Model ===
142-
image_input = layers.Input(shape=input_image_shape)
142+
image_input = layers.Input(shape=image_shape)
143143
if include_rescaling:
144144
x = layers.Rescaling(scale=1 / 255.0, dtype=dtype)(image_input)
145145
x = layers.Normalization(
@@ -254,7 +254,7 @@ def __init__(
254254
self.block_type = block_type
255255
self.use_pre_activation = use_pre_activation
256256
self.include_rescaling = include_rescaling
257-
self.input_image_shape = input_image_shape
257+
self.image_shape = image_shape
258258
self.pooling = pooling
259259
self.pyramid_outputs = pyramid_outputs
260260

@@ -268,7 +268,7 @@ def get_config(self):
268268
"block_type": self.block_type,
269269
"use_pre_activation": self.use_pre_activation,
270270
"include_rescaling": self.include_rescaling,
271-
"input_image_shape": self.input_image_shape,
271+
"image_shape": self.image_shape,
272272
"pooling": self.pooling,
273273
}
274274
)

keras_nlp/src/models/resnet/resnet_backbone_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def setUp(self):
2727
"stackwise_num_filters": [64, 64, 64],
2828
"stackwise_num_blocks": [2, 2, 2],
2929
"stackwise_num_strides": [1, 2, 2],
30-
"input_image_shape": (None, None, 3),
30+
"image_shape": (None, None, 3),
3131
"pooling": "avg",
3232
}
3333
self.input_size = 64
@@ -84,7 +84,7 @@ def test_saved_model(self, use_pre_activation, block_type):
8484
{
8585
"block_type": block_type,
8686
"use_pre_activation": use_pre_activation,
87-
"input_image_shape": (None, None, 3),
87+
"image_shape": (None, None, 3),
8888
}
8989
)
9090
self.run_model_saving_test(

0 commit comments

Comments
 (0)