Skip to content

Commit 54a70ba

Browse files
fyangftensorflower-gardener
authored andcommitted
Internal change
PiperOrigin-RevId: 481804149
1 parent cc0b9a7 commit 54a70ba

File tree

8 files changed

+11
-39
lines changed

8 files changed

+11
-39
lines changed

official/projects/basnet/serving/basnet.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
from official.vision.serving import semantic_segmentation
2121

2222

23-
MEAN_RGB = (0.485 * 255, 0.456 * 255, 0.406 * 255)
24-
STDDEV_RGB = (0.229 * 255, 0.224 * 255, 0.225 * 255)
25-
26-
2723
class BASNetModule(semantic_segmentation.SegmentationModule):
2824
"""BASNet Module."""
2925

official/projects/basnet/tasks/basnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
def build_basnet_model(
3434
input_specs: tf.keras.layers.InputSpec,
3535
model_config: exp_cfg.BASNetModel,
36-
l2_regularizer: tf.keras.regularizers.Regularizer = None):
36+
l2_regularizer: Optional[tf.keras.regularizers.Regularizer] = None):
3737
"""Builds BASNet model."""
3838
norm_activation_config = model_config.norm_activation
3939
backbone = basnet_model.BASNetEncoder(

official/vision/dataloaders/classification_input.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
from official.vision.ops import augment
2424
from official.vision.ops import preprocess_ops
2525

26-
MEAN_RGB = (0.485 * 255, 0.456 * 255, 0.406 * 255)
27-
STDDEV_RGB = (0.229 * 255, 0.224 * 255, 0.225 * 255)
28-
2926
DEFAULT_IMAGE_FIELD_KEY = 'image/encoded'
3027
DEFAULT_LABEL_FIELD_KEY = 'image/class/label'
3128

@@ -223,7 +220,7 @@ def _parse_train_image(self, decoded_tensors):
223220

224221
# Normalizes image with mean and std pixel values.
225222
image = preprocess_ops.normalize_image(
226-
image, offset=MEAN_RGB, scale=STDDEV_RGB)
223+
image, offset=preprocess_ops.MEAN_RGB, scale=preprocess_ops.STDDEV_RGB)
227224

228225
# Random erasing after the image has been normalized
229226
if self._random_erasing is not None:
@@ -258,7 +255,7 @@ def _parse_eval_image(self, decoded_tensors):
258255

259256
# Normalizes image with mean and std pixel values.
260257
image = preprocess_ops.normalize_image(
261-
image, offset=MEAN_RGB, scale=STDDEV_RGB)
258+
image, offset=preprocess_ops.MEAN_RGB, scale=preprocess_ops.STDDEV_RGB)
262259

263260
# Convert image to self._dtype.
264261
image = tf.image.convert_image_dtype(image, self._dtype)
@@ -284,6 +281,6 @@ def inference_fn(cls,
284281

285282
# Normalizes image with mean and std pixel values.
286283
image = preprocess_ops.normalize_image(
287-
image, offset=MEAN_RGB, scale=STDDEV_RGB)
284+
image, offset=preprocess_ops.MEAN_RGB, scale=preprocess_ops.STDDEV_RGB)
288285
image.set_shape(input_image_size + [num_channels])
289286
return image

official/vision/examples/starter/example_input.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
from official.vision.dataloaders import parser
2727
from official.vision.ops import preprocess_ops
2828

29-
MEAN_RGB = (0.485 * 255, 0.456 * 255, 0.406 * 255)
30-
STDDEV_RGB = (0.229 * 255, 0.224 * 255, 0.225 * 255)
31-
3229

3330
class Decoder(decoder.Decoder):
3431
"""A tf.Example decoder for classification task."""
@@ -102,7 +99,7 @@ def _parse_data(
10299

103100
# Normalizes image with mean and std pixel values.
104101
image = preprocess_ops.normalize_image(
105-
image, offset=MEAN_RGB, scale=STDDEV_RGB)
102+
image, offset=preprocess_ops.MEAN_RGB, scale=preprocess_ops.STDDEV_RGB)
106103

107104
image = tf.image.convert_image_dtype(image, self._dtype)
108105
return image, label

official/vision/serving/detection.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
from official.vision.serving import export_base
2828

2929

30-
MEAN_RGB = (0.485 * 255, 0.456 * 255, 0.406 * 255)
31-
STDDEV_RGB = (0.229 * 255, 0.224 * 255, 0.225 * 255)
32-
33-
3430
class DetectionModule(export_base.ExportModule):
3531
"""Detection Module."""
3632

@@ -74,9 +70,8 @@ def _build_inputs(self, image):
7470
"""Builds detection model inputs for serving."""
7571
model_params = self.params.task.model
7672
# Normalizes image with mean and std pixel values.
77-
image = preprocess_ops.normalize_image(image,
78-
offset=MEAN_RGB,
79-
scale=STDDEV_RGB)
73+
image = preprocess_ops.normalize_image(
74+
image, offset=preprocess_ops.MEAN_RGB, scale=preprocess_ops.STDDEV_RGB)
8075

8176
image, image_info = preprocess_ops.resize_and_crop_image(
8277
image,

official/vision/serving/image_classification.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
from official.vision.serving import export_base
2222

2323

24-
MEAN_RGB = (0.485 * 255, 0.456 * 255, 0.406 * 255)
25-
STDDEV_RGB = (0.229 * 255, 0.224 * 255, 0.225 * 255)
26-
27-
2824
class ClassificationModule(export_base.ExportModule):
2925
"""classification Module."""
3026

@@ -50,9 +46,8 @@ def _build_inputs(self, image):
5046
image, [self._input_image_size[0], self._input_image_size[1], 3])
5147

5248
# Normalizes image with mean and std pixel values.
53-
image = preprocess_ops.normalize_image(image,
54-
offset=MEAN_RGB,
55-
scale=STDDEV_RGB)
49+
image = preprocess_ops.normalize_image(
50+
image, offset=preprocess_ops.MEAN_RGB, scale=preprocess_ops.STDDEV_RGB)
5651
return image
5752

5853
def serve(self, images):

official/vision/serving/semantic_segmentation.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
from official.vision.serving import export_base
2222

2323

24-
MEAN_RGB = (0.485 * 255, 0.456 * 255, 0.406 * 255)
25-
STDDEV_RGB = (0.229 * 255, 0.224 * 255, 0.225 * 255)
26-
27-
2824
class SegmentationModule(export_base.ExportModule):
2925
"""Segmentation Module."""
3026

@@ -41,9 +37,8 @@ def _build_inputs(self, image):
4137
"""Builds classification model inputs for serving."""
4238

4339
# Normalizes image with mean and std pixel values.
44-
image = preprocess_ops.normalize_image(image,
45-
offset=MEAN_RGB,
46-
scale=STDDEV_RGB)
40+
image = preprocess_ops.normalize_image(
41+
image, offset=preprocess_ops.MEAN_RGB, scale=preprocess_ops.STDDEV_RGB)
4742

4843
if self.params.task.train_data.preserve_aspect_ratio:
4944
image, image_info = preprocess_ops.resize_and_crop_image(

official/vision/serving/video_classification.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
from official.vision.serving import export_base
2222
from official.vision.tasks import video_classification
2323

24-
MEAN_RGB = (0.485 * 255, 0.456 * 255, 0.406 * 255)
25-
STDDEV_RGB = (0.229 * 255, 0.224 * 255, 0.225 * 255)
26-
2724

2825
class VideoClassificationModule(export_base.ExportModule):
2926
"""Video classification Module."""

0 commit comments

Comments
 (0)