Skip to content

Commit

Permalink
Finally
Browse files Browse the repository at this point in the history
  • Loading branch information
soma2000-lang committed Feb 27, 2023
1 parent b62a339 commit 3abe7d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
4 changes: 1 addition & 3 deletions benchmarks/vectorized_crop_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ def __init__(
self.bounding_box_format = bounding_box_format
self.force_output_dense_images = True

def get_random_transformation(
self, image=None, label=None, bounding_box=None, **kwargs
):
def get_random_transformation(self, **kwargs):
crop_area_factor = self.crop_area_factor()
aspect_ratio = self.aspect_ratio_factor()

Expand Down
4 changes: 1 addition & 3 deletions keras_cv/layers/preprocessing/random_crop_and_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ def __init__(
self.bounding_box_format = bounding_box_format
self.force_output_dense_images = True

def get_random_transformation_batch(
self, batch_size, label=None, bounding_box=None, **kwargs
):
def get_random_transformation_batch(self, batch_size, **kwargs):
crop_area_factor = self.crop_area_factor()
aspect_ratio = self.aspect_ratio_factor()

Expand Down
30 changes: 8 additions & 22 deletions keras_cv/layers/preprocessing/random_crop_and_resize_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ def test_augment_one_hot_segmentation_mask(self):
mask_shape = (1, self.height, self.width, 1)
image = tf.random.uniform(shape=input_image_shape, seed=self.seed)
mask = tf.one_hot(
tf.squeeze(
np.random.randint(2, size=mask_shape) * (classes - 1), axis=-1
),
tf.squeeze(np.random.randint(2, size=mask_shape) * (classes - 1), axis=-1),
classes,
)

Expand Down Expand Up @@ -209,12 +207,8 @@ def test_augment_bounding_box_single(self):
"boxes": tf.convert_to_tensor([[0, 0, 1, 1]], dtype=tf.float32),
"classes": tf.convert_to_tensor([0], dtype=tf.float32),
}
output["bounding_boxes"] = bounding_box.to_dense(
output["bounding_boxes"]
)
self.assertAllClose(
expected_output["boxes"], output["bounding_boxes"]["boxes"]
)
output["bounding_boxes"] = bounding_box.to_dense(output["bounding_boxes"])
self.assertAllClose(expected_output["boxes"], output["bounding_boxes"]["boxes"])
self.assertAllClose(
expected_output["classes"], output["bounding_boxes"]["classes"]
)
Expand Down Expand Up @@ -248,12 +242,8 @@ def test_augment_boxes_batched_input(self):
),
"classes": tf.convert_to_tensor([[0, 0], [0, 0]]),
}
output["bounding_boxes"] = bounding_box.to_dense(
output["bounding_boxes"]
)
self.assertAllClose(
expected_output["boxes"], output["bounding_boxes"]["boxes"]
)
output["bounding_boxes"] = bounding_box.to_dense(output["bounding_boxes"])
self.assertAllClose(expected_output["boxes"], output["bounding_boxes"]["boxes"])
self.assertAllClose(
expected_output["classes"], output["bounding_boxes"]["classes"]
)
Expand Down Expand Up @@ -283,12 +273,8 @@ def test_augment_boxes_ragged(self):
"classes": tf.ragged.constant([[0, 0], [0]]),
}
expected_output = bounding_box.to_dense(expected_output)
output["bounding_boxes"] = bounding_box.to_dense(
output["bounding_boxes"]
)
self.assertAllClose(
expected_output["boxes"], output["bounding_boxes"]["boxes"]
)
output["bounding_boxes"] = bounding_box.to_dense(output["bounding_boxes"])
self.assertAllClose(expected_output["boxes"], output["bounding_boxes"]["boxes"])
self.assertAllClose(
expected_output["classes"], output["bounding_boxes"]["classes"]
)
Expand Down Expand Up @@ -321,4 +307,4 @@ def random_crop_and_resize_on_batched_image_train(self):
input_resized = tf.image.resize(image, self.target_size)
output = layer(image, training=True)

self.assertNotAllClose(output[0], output[1])
self.assertNotAllClose(output[0], output[1])

0 comments on commit 3abe7d9

Please sign in to comment.