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 new point cloud augmentation - Random Translation #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

phuccuongngo99
Copy link

@phuccuongngo99 phuccuongngo99 commented Oct 22, 2021

What

The current repo doesn't support Random Translation augmentation methods.

This PR adds Random Translation methods here:

class Random_Translate(object):
def __init__(
self,
translate_range_x=(-0.1, 0.1),
translate_range_y=(-0.1, 0.1),
p=0.5
):
#Translate ranges from [-1, 1]
#With 1 being the full length of BEV in x/y direction
self.x_range = translate_range_x
self.y_range = translate_range_y
self.p = p
def __call__(self, lidar, labels):
if np.random.random() <= self.p:
factor_x = np.random.uniform(self.x_range[0], self.x_range[1])
factor_y = np.random.uniform(self.y_range[0], self.y_range[1])
factor_x *= (cnf.boundary["maxX"] - cnf.boundary["minX"])
factor_y *= (cnf.boundary["maxY"] - cnf.boundary["minY"])
lidar[:, 0] += factor_x
lidar[:, 1] += factor_y
labels[:, 0] += factor_x
labels[:, 1] += factor_y
return lidar, labels

Why

It's reasonable since self-driving car requires a fixed view (the car has to be centered bottom of the image)

However, other applications of 3D point clouds object detection may have different settings such as industrial factories and warehouses like what I tried to do. We may need to augment using translation to increase the diversity of our limited dataset.

Testing

We will make changes to train_lidar_transforms here:

def create_train_dataloader(configs):
"""Create dataloader for training"""
train_lidar_transforms = OneOf([
Random_Rotation(limit_angle=20., p=1.0),
Random_Scaling(scaling_range=(0.95, 1.05), p=1.0)
], p=0.66)

After changing, run

cd src/data_process
python kitti_dataloader.py --show-train-data --output-width 608

1) No Augmentation

image

2) Random_Rotate (Existing augmentation)

train_lidar_transforms = OneOf([
    Random_Rotation(limit_angle=30., p=1.0),
], p=1.0)

image

3) Random_Scaling (Existing augmentation)

train_lidar_transforms = OneOf([
    Random_Scaling(scaling_range=(0.50, 1.50), p=1.0),
], p=1.0)

You can see that's it's zoomed out
image

4) Random_Translate (Added in this PR)

train_lidar_transforms = OneOf([
    Random_Translate(translate_range_x=(-0.5, 0.5),
                    translate_range_y=(-0.5, 0.5),
                    p=1.0)
], p=1.0)

You can see the image is translated, the view shifts upwards, no longer starting from the car
image

@phuccuongngo99 phuccuongngo99 marked this pull request as ready for review October 23, 2021 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant