Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add four global data augmentations for 3D #1028

Merged
merged 31 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3221849
Add base augmentation layer for 3D preception.
Nov 4, 2022
4e032c1
Fix format.
Nov 4, 2022
30af449
Add copyright.
Nov 4, 2022
f73e2ff
Minor change.
Nov 14, 2022
bd26fef
revert the minor change in the test file.
Nov 14, 2022
3f534d5
1. Add global_z_rotation data augmentation.
Nov 14, 2022
693fab0
Auto format.
Nov 14, 2022
8152d70
1. Standardize POINT_CLOUDS and BOUNDING_BOXES
Nov 15, 2022
55a2ffb
Format.
Nov 15, 2022
6f1379c
Delete base_augmentation_layer_3d.py
lengzq Nov 15, 2022
e9a48e0
Delete base_augmentation_layer_3d_test.py
lengzq Nov 15, 2022
b99e351
Merge branch 'keras-team:master' into master
lengzq Nov 16, 2022
86482f1
Standardize POINT_CLOUDS and BOUNDING_BOXES names.
Nov 16, 2022
1a06fb1
Merge branch 'keras-team:master' into master
lengzq Nov 16, 2022
b556f84
Change GlobalZRotation to GlobalRandomZRotation
Nov 17, 2022
0cd396f
Support rotation along X, Y and Z axes.
Nov 17, 2022
19123b9
format.
Nov 17, 2022
de19450
Change file name from global_rotation to global_random_rotation.
Nov 17, 2022
da6cc6d
Merge branch 'keras-team:master' into master
lengzq Nov 17, 2022
eef63ac
Add four more global data augmentations for 3d.
Nov 17, 2022
2bb0c55
format.
Nov 17, 2022
54439f7
Remove unused import.
Nov 17, 2022
c577abc
Fix a typo in GlobalRandomFlippingY.
Nov 18, 2022
5ff7596
Support scaling x, y, and z.
Nov 21, 2022
1223912
Format.
Nov 21, 2022
eb3bc17
update random scaling.
Nov 21, 2022
39755e0
Modified based on comments.
Nov 21, 2022
4d4f0a6
follow up.
Nov 21, 2022
7a90015
Fix a typo in random_scaling_test.py
Nov 21, 2022
4d8cdef
Update.
Nov 21, 2022
d343dd7
Fix two typos.
Nov 21, 2022
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
Prev Previous commit
Next Next commit
format.
  • Loading branch information
Leng Zhaoqi committed Nov 17, 2022
commit 19123b97ef71e31a3b667bd6d46c55bf27fd963b
11 changes: 9 additions & 2 deletions keras_cv/layers/preprocessing3d/global_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class GlobalRandomRotation(base_augmentation_layer_3d.BaseAugmentationLayer3D):

"""

def __init__(self, max_rotation_angle_x, max_rotation_angle_y, max_rotation_angle_z, **kwargs):
def __init__(
self, max_rotation_angle_x, max_rotation_angle_y, max_rotation_angle_z, **kwargs
):
super().__init__(**kwargs)
if max_rotation_angle_x < 0:
raise ValueError("max_rotation_angle_x must be >=0.")
Expand All @@ -70,7 +72,12 @@ def get_random_transformation(self, **kwargs):
random_rotation_z = self._random_generator.random_uniform(
(), minval=-self._max_rotation_angle_z, maxval=self._max_rotation_angle_z
)
return {"pose": tf.stack([0, 0, 0, random_rotation_z, random_rotation_x, random_rotation_y], axis=0)}
return {
"pose": tf.stack(
[0, 0, 0, random_rotation_z, random_rotation_x, random_rotation_y],
axis=0,
)
}

def augment_point_clouds_bounding_boxes(
self, point_clouds, bounding_boxes, transformation, **kwargs
Expand Down
16 changes: 12 additions & 4 deletions keras_cv/layers/preprocessing3d/global_rotation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,39 @@

class GlobalRandomRotationTest(tf.test.TestCase):
def test_augment_point_clouds_and_bounding_boxes(self):
add_layer = GlobalRandomRotation( max_rotation_angle_x=1.0, max_rotation_angle_y=1.0, max_rotation_angle_z=1.0)
add_layer = GlobalRandomRotation(
max_rotation_angle_x=1.0, max_rotation_angle_y=1.0, max_rotation_angle_z=1.0
)
point_clouds = np.random.random(size=(2, 50, 10)).astype("float32")
bounding_boxes = np.random.random(size=(2, 10, 7)).astype("float32")
inputs = {POINT_CLOUDS: point_clouds, BOUNDING_BOXES: bounding_boxes}
outputs = add_layer(inputs)
self.assertNotAllClose(inputs, outputs)

def test_not_augment_point_clouds_and_bounding_boxes(self):
add_layer = GlobalRandomRotation( max_rotation_angle_x=0.0, max_rotation_angle_y=0.0, max_rotation_angle_z=0.0)
add_layer = GlobalRandomRotation(
max_rotation_angle_x=0.0, max_rotation_angle_y=0.0, max_rotation_angle_z=0.0
)
point_clouds = np.random.random(size=(2, 50, 10)).astype("float32")
bounding_boxes = np.random.random(size=(2, 10, 7)).astype("float32")
inputs = {POINT_CLOUDS: point_clouds, BOUNDING_BOXES: bounding_boxes}
outputs = add_layer(inputs)
self.assertAllClose(inputs, outputs)

def test_augment_batch_point_clouds_and_bounding_boxes(self):
add_layer = GlobalRandomRotation( max_rotation_angle_x=1.0, max_rotation_angle_y=1.0, max_rotation_angle_z=1.0)
add_layer = GlobalRandomRotation(
max_rotation_angle_x=1.0, max_rotation_angle_y=1.0, max_rotation_angle_z=1.0
)
point_clouds = np.random.random(size=(3, 2, 50, 10)).astype("float32")
bounding_boxes = np.random.random(size=(3, 2, 10, 7)).astype("float32")
inputs = {POINT_CLOUDS: point_clouds, BOUNDING_BOXES: bounding_boxes}
outputs = add_layer(inputs)
self.assertNotAllClose(inputs, outputs)

def test_not_augment_batch_point_clouds_and_bounding_boxes(self):
add_layer = GlobalRandomRotation( max_rotation_angle_x=0.0, max_rotation_angle_y=0.0, max_rotation_angle_z=0.0)
add_layer = GlobalRandomRotation(
max_rotation_angle_x=0.0, max_rotation_angle_y=0.0, max_rotation_angle_z=0.0
)
point_clouds = np.random.random(size=(3, 2, 50, 10)).astype("float32")
bounding_boxes = np.random.random(size=(3, 2, 10, 7)).astype("float32")
inputs = {POINT_CLOUDS: point_clouds, BOUNDING_BOXES: bounding_boxes}
Expand Down