DeyvidKochanov-TomTom / kprnet

MIT License
65 stars 12 forks source link

How to do rotation or noise data augmentation? #12

Closed huixiancheng closed 3 years ago

huixiancheng commented 3 years ago

Hi,sir. Coulld you give me some advice? I use data augmentation like this,they will raise errors of out index

            if np.random.rand() > 0.5:
                MAX_PERCENT_REMOVE = 0.08
                n_points = points_xyz.shape[0]
                n_delete = int(random.random() * n_points * MAX_PERCENT_REMOVE)
                indices_del = np.random.randint(0, n_points, n_delete)
                points_refl = np.delete(points_refl, indices_del, axis=0)
                points_xyz = np.delete(points_xyz, indices_del, axis=0)
                labels = np.delete(labels, indices_del, axis=0)
            if np.random.rand() > 0.5:
                # rotate the point cloud
                euler_angle = np.random.normal(0.0, 40, 1)[0]  # 40
                r = np.array(R.from_euler('zyx', [[euler_angle, 0, 0]], degrees=True).as_matrix())
                r_t = r.transpose()
                points_xyz = points_xyz.dot(r_t)
                points_xyz = np.squeeze(points_xyz)
            if np.random.rand() > 0.5:
                points_xyz[:, 1] = -points_xyz[:, 1]    # 不能只反转y 与后面的翻转冲突 等于没变
            if np.random.rand() > 0.5:
                # shit the point cloud cloud
                shift_x = np.random.uniform(-5, 5)
                shift_y = np.random.uniform(-3, 3)
                shift_z = np.random.uniform(-1, 0)
                points_xyz[:, 0] = points_xyz[:, 0] + shift_x
                points_xyz[:, 1] = points_xyz[:, 1] + shift_y
                points_xyz[:, 2] = points_xyz[:, 2] + shift_z
            # else: #np.random.rand() > 0.5:
            #     points_xyz = jitter_point_range(points_xyz)
        (depth_image, refl_image, py, px, proj_xyz, proj_label) = do_range_projection(points_xyz, points_refl, labels)

QQ截图20210412213738 Could this be solve or just cann't do such ways in Unfold Projection?

Moreover, Could you give me some advices on how to train the two hard sem.seg classes: Motorcyclist and Other-ground.In my experiment, They are completely close to 0

DeyvidKochanov-TomTom commented 3 years ago

Hi,

you could add them one by one and see which ones break the projection?

The first one seems okay. The random rotation probably doesn't work with the unfolding projection. The third one probably breaks the projection and is also already done after the projection here. The random shifts potentially also break the projection maybe small random shifts for each point can be applied. See issue #8 for an explanation of how the unfolding works. Basically anything that changes the order of the azimuth angles of the points will break the projection so doing a lot augmentation is hard.

For the rare classes I don't know, some papers weight them and use different loss functions maybe that helps... although we do have the OHEM. 3D methods also seem in general more data efficient because they don't have to deal with scale changes and its easier to augment.

huixiancheng commented 3 years ago

thank you sir!