2

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'])
                  )

3 Answers3

1

Be carreful of the format of your dataset, maybe you passed Pascal_VOC format instead of coco. https://albumentations.ai/docs/getting_started/bounding_boxes_augmentation/

tCot
  • 307
  • 2
  • 7
1

The reason maybe is you use opencv to read image, not PIL.Image. Opencv read image is: HWC.
PIL.Image read image is: WHC. And Albumentations need the input is :WHC.

buggggggg
  • 11
  • 1
0

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.

  • 1
    could you please tell me how you solved the issue? or what exactly do I need to check? Thanks! – iamkk Apr 14 '22 at 09:49