I want to apply data augmentations from PyTorch’s Albumentations to images with bounding boxes.
When I apply the HorizontalFlip Transformation, I receive this error ValueError: Expected x_max for bbox (0.6505353259854019, 0.517013871576637, 1.1234809015877545, 0.6447916687466204, 3) to be in the range [0.0, 1.0], got 1.1234809015877545.
I use the following code
A.Compose([ A.HorizontalFlip(p=1), ToTensorV2(p=1.0)], p=1.0, bbox_params=A.BboxParams(format='coco',min_area=0, min_visibility=0,label_fields=['labels']) )
When I apply the Cutout transformation, I do not have any error regarding the bounding boxes
A.Compose([ A.Cutout(num_holes=10, max_h_size=32, max_w_size=32, fill_value=0, p=0.5), ToTensorV2(p=1.0)], p=1.0, bbox_params=A.BboxParams(format='coco',min_area=0, min_visibility=0,label_fields=['labels']) )
Advertisement
Answer
The bounding box exceeded the image since after the transformation it ends up being larger than the image size. Check carefully the dimensions of the bounding box.