Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions keras_cv/src/datasets/pascal_voc/segmentation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def test_get_image_ids(self):
train_ids = ["2007_000032", "2007_000039", "2007_000063"]
eval_ids = ["2007_000033"]
train_eval_ids = train_ids + eval_ids
self.assertEquals(
self.assertEqual(
segmentation._get_image_ids(data_dir, "train"), train_ids
)
self.assertEquals(
self.assertEqual(
segmentation._get_image_ids(data_dir, "eval"), eval_ids
)
self.assertEquals(
self.assertEqual(
segmentation._get_image_ids(data_dir, "trainval"), train_eval_ids
)

Expand Down Expand Up @@ -161,7 +161,7 @@ def test_parse_annotation_file(self):
},
],
}
self.assertEquals(metadata, expected_result)
self.assertEqual(metadata, expected_result)

def test_decode_png_mask(self):
local_data_dir = os.path.join(self.tempdir, "pascal_voc_2012/")
Expand All @@ -177,19 +177,19 @@ def test_decode_png_mask(self):
segmentation._maybe_populate_voc_color_mapping()
mask = segmentation._decode_png_mask(mask)

self.assertEquals(mask.shape, (281, 500, 1))
self.assertEquals(
self.assertEqual(mask.shape, (281, 500, 1))
self.assertEqual(
tf.reduce_max(mask), 255
) # The 255 value is for the boundary
self.assertEquals(
self.assertEqual(
tf.reduce_min(mask), 0
) # The 0 value is for the background
# The mask contains two classes, 1 and 15, see the label section in the
# previous test case.
self.assertEquals(
self.assertEqual(
tf.reduce_sum(tf.cast(tf.equal(mask, 1), tf.int32)), 4734
)
self.assertEquals(
self.assertEqual(
tf.reduce_sum(tf.cast(tf.equal(mask, 15), tf.int32)), 866
)

Expand Down Expand Up @@ -245,7 +245,7 @@ def test_parse_single_image(self):
data_dir, "SegmentationObject", "2007_000032.png"
),
}
self.assertEquals(result_dict, expected_result)
self.assertEqual(result_dict, expected_result)

def test_build_metadata(self):
local_data_dir = os.path.join(self.tempdir, "pascal_voc_2012/")
Expand All @@ -257,7 +257,7 @@ def test_build_metadata(self):
image_ids = segmentation._get_image_ids(data_dir, "trainval")
metadata = segmentation._build_metadata(data_dir, image_ids)

self.assertEquals(
self.assertEqual(
metadata["image/filename"],
[
"2007_000032.jpg",
Expand Down Expand Up @@ -296,7 +296,7 @@ def test_build_dataset(self):
dataset = segmentation._build_dataset_from_metadata(metadata)

entry = next(dataset.take(1).as_numpy_iterator())
self.assertEquals(entry["image/filename"], b"2007_000032.jpg")
self.assertEqual(entry["image/filename"], b"2007_000032.jpg")
expected_keys = [
"image",
"image/filename",
Expand All @@ -316,18 +316,18 @@ def test_build_dataset(self):

# Check the mask png content
png = entry["class_segmentation"]
self.assertEquals(png.shape, (281, 500, 1))
self.assertEquals(
self.assertEqual(png.shape, (281, 500, 1))
self.assertEqual(
tf.reduce_max(png), 255
) # The 255 value is for the boundary
self.assertEquals(
self.assertEqual(
tf.reduce_min(png), 0
) # The 0 value is for the background
# The mask contains two classes, 1 and 15, see the label section in the
# previous test case.
self.assertEquals(
self.assertEqual(
tf.reduce_sum(tf.cast(tf.equal(png, 1), tf.int32)), 4734
)
self.assertEquals(
self.assertEqual(
tf.reduce_sum(tf.cast(tf.equal(png, 15), tf.int32)), 866
)
4 changes: 2 additions & 2 deletions keras_cv/src/datasets/waymo/load_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_load_from_directory(self):
# Extract records into a list
dataset = [record for record in dataset]

self.assertEquals(len(dataset), 1)
self.assertEqual(len(dataset), 1)
self.assertNotEqual(dataset[0]["timestamp_micros"], 0)

@pytest.mark.skipif(
Expand All @@ -58,5 +58,5 @@ def test_load_from_files(self):
# Extract records into a list
dataset = [record for record in dataset]

self.assertEquals(len(dataset), 1)
self.assertEqual(len(dataset), 1)
self.assertNotEqual(dataset[0]["timestamp_micros"], 0)
4 changes: 2 additions & 2 deletions keras_cv/src/layers/augmenter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_call(self):
]
)
output = augmenter(images)
self.assertEquals(output.shape, images.shape)
self.assertEqual(output.shape, images.shape)

def test_call_with_labels(self):
images = {
Expand All @@ -43,4 +43,4 @@ def test_call_with_labels(self):
]
)
output = augmenter(images)
self.assertEquals(output["images"].shape, images["images"].shape)
self.assertEqual(output["images"].shape, images["images"].shape)
32 changes: 16 additions & 16 deletions keras_cv/src/layers/feature_pyramid_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_return_type_dict(self):
inputs = {2: c2, 3: c3, 4: c4, 5: c5}
output = layer(inputs)
self.assertTrue(isinstance(output, dict))
self.assertEquals(sorted(output.keys()), [2, 3, 4, 5])
self.assertEqual(sorted(output.keys()), [2, 3, 4, 5])

def test_result_shapes(self):
layer = FeaturePyramid(min_level=2, max_level=5)
Expand All @@ -42,9 +42,9 @@ def test_result_shapes(self):
inputs = {2: c2, 3: c3, 4: c4, 5: c5}
output = layer(inputs)
for level in inputs.keys():
self.assertEquals(output[level].shape[1], inputs[level].shape[1])
self.assertEquals(output[level].shape[2], inputs[level].shape[2])
self.assertEquals(output[level].shape[3], layer.num_channels)
self.assertEqual(output[level].shape[1], inputs[level].shape[1])
self.assertEqual(output[level].shape[2], inputs[level].shape[2])
self.assertEqual(output[level].shape[3], layer.num_channels)

# Test with different resolution and channel size
c2 = np.ones([2, 64, 128, 4])
Expand All @@ -56,9 +56,9 @@ def test_result_shapes(self):
layer = FeaturePyramid(min_level=2, max_level=5)
output = layer(inputs)
for level in inputs.keys():
self.assertEquals(output[level].shape[1], inputs[level].shape[1])
self.assertEquals(output[level].shape[2], inputs[level].shape[2])
self.assertEquals(output[level].shape[3], layer.num_channels)
self.assertEqual(output[level].shape[1], inputs[level].shape[1])
self.assertEqual(output[level].shape[2], inputs[level].shape[2])
self.assertEqual(output[level].shape[3], layer.num_channels)

def test_with_keras_input_tensor(self):
# This mimic the model building with Backbone network
Expand All @@ -71,13 +71,13 @@ def test_with_keras_input_tensor(self):
inputs = {2: c2, 3: c3, 4: c4, 5: c5}
output = layer(inputs)
for level in inputs.keys():
self.assertEquals(output[level].shape[1], inputs[level].shape[1])
self.assertEquals(output[level].shape[2], inputs[level].shape[2])
self.assertEquals(output[level].shape[3], layer.num_channels)
self.assertEqual(output[level].shape[1], inputs[level].shape[1])
self.assertEqual(output[level].shape[2], inputs[level].shape[2])
self.assertEqual(output[level].shape[3], layer.num_channels)

def test_invalid_lateral_layers(self):
lateral_layers = [keras.layers.Conv2D(256, 1)] * 3
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "Expect lateral_layers to be a dict"
):
_ = FeaturePyramid(
Expand All @@ -88,7 +88,7 @@ def test_invalid_lateral_layers(self):
3: keras.layers.Conv2D(256, 1),
4: keras.layers.Conv2D(256, 1),
}
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "with keys as .* [2, 3, 4, 5]"
):
_ = FeaturePyramid(
Expand All @@ -97,7 +97,7 @@ def test_invalid_lateral_layers(self):

def test_invalid_output_layers(self):
output_layers = [keras.layers.Conv2D(256, 3)] * 3
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "Expect output_layers to be a dict"
):
_ = FeaturePyramid(
Expand All @@ -108,7 +108,7 @@ def test_invalid_output_layers(self):
3: keras.layers.Conv2D(256, 3),
4: keras.layers.Conv2D(256, 3),
}
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "with keys as .* [2, 3, 4, 5]"
):
_ = FeaturePyramid(
Expand All @@ -126,13 +126,13 @@ def test_invalid_input_features(self):
# Build required for Keas 3
_ = layer(inputs)
list_input = [c2, c3, c4, c5]
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "expects input features to be a dict"
):
layer(list_input)

dict_input_with_missing_feature = {2: c2, 3: c3, 4: c4}
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "Expect feature keys.*[2, 3, 4, 5]"
):
layer(dict_input_with_missing_feature)
6 changes: 3 additions & 3 deletions keras_cv/src/layers/fusedmbconv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_same_input_output_shapes(self):
layer = FusedMBConvBlock(input_filters=32, output_filters=32)

output = layer(inputs)
self.assertEquals(output.shape, [1, 64, 64, 32])
self.assertEqual(output.shape, [1, 64, 64, 32])
self.assertLen(output, 1)
self.assertTrue(isinstance(output, tf.Tensor))

Expand All @@ -45,7 +45,7 @@ def test_different_input_output_shapes(self):
layer = FusedMBConvBlock(input_filters=32, output_filters=48)

output = layer(inputs)
self.assertEquals(output.shape, [1, 64, 64, 48])
self.assertEqual(output.shape, [1, 64, 64, 48])
self.assertLen(output, 1)
self.assertTrue(isinstance(output, tf.Tensor))

Expand All @@ -56,6 +56,6 @@ def test_squeeze_excitation_ratio(self):
)

output = layer(inputs)
self.assertEquals(output.shape, [1, 64, 64, 48])
self.assertEqual(output.shape, [1, 64, 64, 48])
self.assertLen(output, 1)
self.assertTrue(isinstance(output, tf.Tensor))
6 changes: 3 additions & 3 deletions keras_cv/src/layers/mbconv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_same_input_output_shapes(self):
layer = MBConvBlock(input_filters=32, output_filters=32)

output = layer(inputs)
self.assertEquals(output.shape, [1, 64, 64, 32])
self.assertEqual(output.shape, [1, 64, 64, 32])
self.assertLen(output, 1)
self.assertTrue(isinstance(output, tf.Tensor))

Expand All @@ -45,7 +45,7 @@ def test_different_input_output_shapes(self):
layer = MBConvBlock(input_filters=32, output_filters=48)

output = layer(inputs)
self.assertEquals(output.shape, [1, 64, 64, 48])
self.assertEqual(output.shape, [1, 64, 64, 48])
self.assertLen(output, 1)
self.assertTrue(isinstance(output, tf.Tensor))

Expand All @@ -54,6 +54,6 @@ def test_squeeze_excitation_ratio(self):
layer = MBConvBlock(input_filters=32, output_filters=48, se_ratio=0.25)

output = layer(inputs)
self.assertEquals(output.shape, [1, 64, 64, 48])
self.assertEqual(output.shape, [1, 64, 64, 48])
self.assertLen(output, 1)
self.assertTrue(isinstance(output, tf.Tensor))
6 changes: 3 additions & 3 deletions keras_cv/src/layers/preprocessing/cut_mix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def test_single_image_input(self):
ys = tf.one_hot(tf.constant([1]), 2)
inputs = {"images": xs, "labels": ys}
layer = CutMix()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "CutMix received a single image to `call`"
):
_ = layer(inputs)
Expand All @@ -246,15 +246,15 @@ def test_int_labels(self):
ys = tf.one_hot(tf.constant([1, 0]), 2, dtype=tf.int32)
inputs = {"images": xs, "labels": ys}
layer = CutMix()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "CutMix received labels with type"
):
_ = layer(inputs)

def test_image_input(self):
xs = tf.ones((2, 512, 512, 3))
layer = CutMix()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "CutMix expects inputs in a dictionary with format"
):
_ = layer(xs)
4 changes: 2 additions & 2 deletions keras_cv/src/layers/preprocessing/fourier_mix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_image_input_only(self):
tf.float32,
)
layer = FourierMix()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "expects inputs in a dictionary"
):
_ = layer(xs)
Expand All @@ -157,7 +157,7 @@ def test_single_image_input(self):
ys = tf.one_hot(tf.constant([1]), 2)
inputs = {"images": xs, "labels": ys}
layer = FourierMix()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "FourierMix received a single image to `call`"
):
_ = layer(inputs)
8 changes: 4 additions & 4 deletions keras_cv/src/layers/preprocessing/mix_up_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_image_input_only(self):
tf.float32,
)
layer = MixUp()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "expects inputs in a dictionary"
):
_ = layer(xs)
Expand All @@ -169,7 +169,7 @@ def test_single_image_input(self):
ys = tf.one_hot(tf.constant([1]), 2)
inputs = {"images": xs, "labels": ys}
layer = MixUp()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "MixUp received a single image to `call`"
):
_ = layer(inputs)
Expand All @@ -179,15 +179,15 @@ def test_int_labels(self):
ys = tf.one_hot(tf.constant([1, 0]), 2, dtype=tf.int32)
inputs = {"images": xs, "labels": ys}
layer = MixUp()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "MixUp received labels with type"
):
_ = layer(inputs)

def test_image_input(self):
xs = tf.ones((2, 512, 512, 3))
layer = MixUp()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "MixUp expects inputs in a dictionary with format"
):
_ = layer(xs)
6 changes: 3 additions & 3 deletions keras_cv/src/layers/preprocessing/mosaic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_image_input_only(self):
tf.float32,
)
layer = Mosaic()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "expects inputs in a dictionary"
):
_ = layer(xs)
Expand All @@ -101,15 +101,15 @@ def test_single_image_input(self):
ys = tf.one_hot(tf.constant([1]), 2)
inputs = {"images": xs, "labels": ys}
layer = Mosaic()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "Mosaic received a single image to `call`"
):
_ = layer(inputs)

def test_image_input(self):
xs = tf.ones((2, 512, 512, 3))
layer = Mosaic()
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "Mosaic expects inputs in a dictionary with format"
):
_ = layer(xs)
Loading
Loading