NVlabs / Deep_Object_Pose

Deep Object Pose Estimation (DOPE) – ROS inference (CoRL 2018)
Other
1.03k stars 287 forks source link

Inconsistency in data augmentation using Albumentations #352

Closed wetoo-cando closed 6 months ago

wetoo-cando commented 7 months ago

I noticed an inconsistency in data augmentation using Albumentations.

When you rotate the (cropped) image, Albumentations seems to fill up corner areas (which are empty due to the rotation) by mirroring pixels in the nearby area. In some situations with an object of interest near the image corner, the object in the image gets overwritten by mirrored pixels. However, the transformed keypoints corr. to the object still remain. This results in a training image with keypoints "apparently in the middle of nowhere".

This cannot be good for training. Has anyone noticed this before? For now I am setting A.Rotate(limit=0) (effectively removing the rotation randomization). A better way of course would be to remove the rotated keypoints if the object gets overwritten.

https://github.com/NVlabs/Deep_Object_Pose/blob/1655459de50cfcbf01f7d24775f834cab400aa25/scripts/train2/utils_dope.py#L258C8-L267C10

# data augmentation
transform = A.Compose(
    [
        A.RandomCrop(width=400, height=400),
        A.Rotate(limit=180),
        A.RandomBrightnessContrast(brightness_limit=0.1,contrast_limit=0.15,p=1),
        A.GaussNoise(p=1),

    ], 
    keypoint_params=A.KeypointParams(format='xy',remove_invisible=False)
)
TontonTremblay commented 7 months ago

This is a good catch, I did not think about the problems it could create. We should update the data pipeline, thank you.

thohemp commented 6 months ago

Hello, instead of removing the rotation augmentation completely, I suggest changing the border mode:

A.Rotate(limit=180, border_mode=cv2.BORDER_CONSTANT)

Instead of mirroring, this will just add a black border and should be less confusing during the training.

wetoo-cando commented 6 months ago

Thanks @thohemp !