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

Expected x_max for bbox (0.4358974358974359, 0.30288461538461536, 1.061965811965812, 0.9663461538461539, 13) to be in the range [0.0, 1.0], got 1.061965811965812. #947

Closed
aliceinland opened this issue Jul 5, 2021 · 3 comments

Comments

@aliceinland
Copy link

🐛 Bug

When trying to perform data augmentation with bounding boxes and mask in yolo format, this is the output the is produced.

To Reproduce

Steps to reproduce the behavior:

File "/workspace/deepfashion_train/dataset.py", line 126, in __getitem__
    transformed = self.trans(image=np.asarray(img), masks=mask_list, bboxes = boxes.detach().tolist(), class_labels = labels.detach().tolist())  #bboxes = bbox_labels)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/core/composition.py", line 180, in __call__
    p.preprocess(data)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/core/utils.py", line 62, in preprocess
    data[data_name] = self.check_and_convert(data[data_name], rows, cols, direction="to")
  File "/opt/conda/lib/python3.8/site-packages/albumentations/core/utils.py", line 70, in check_and_convert
    return self.convert_to_albumentations(data, rows, cols)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 51, in convert_to_albumentations
    return convert_bboxes_to_albumentations(data, self.params.format, rows, cols, check_validity=True)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 302, in convert_bboxes_to_albumentations
    return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 302, in <listcomp>
    return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 251, in convert_bbox_to_albumentations
    check_bbox(bbox)
  File "/opt/conda/lib/python3.8/site-packages/albumentations/augmentations/bbox_utils.py", line 327, in check_bbox
    raise ValueError(
ValueError: Expected x_max for bbox (0.4358974358974359, 0.30288461538461536, 1.061965811965812, 0.9663461538461539, 13) to be in the range [0.0, 1.0], got 1.061965811965812.

The code that generates this error is:

self.trans = A.Compose([
                A.Resize(224, 224),
                        #A.Resize(256, 128),
                        #A.RandomRotate90(),
                A.Flip(),
                A.ColorJitter(brightness= 0.3, contrast= 0.3,saturation=0.1, hue=0.1, p=0.3),
                #A.Transpose(),
                A.GaussNoise(),
                #A.RandomCrop(width=224, height=224),
                A.OneOf([
                    A.MotionBlur(p=.5),
                    A.MedianBlur(blur_limit=3, p=0.5),
                    A.Blur(blur_limit=3, p=0.5),
                ], p=0.5),
                A.ShiftScaleRotate(shift_limit=0.0625, scale_limit=0.2, rotate_limit=45, p=0.5),
                A.OneOf([
                    A.OpticalDistortion(p=0.5),
                    A.GridDistortion(p=.3),
                    A.PiecewiseAffine(p=0.5),
                ], p=0.5),
                A.OneOf([
                    A.CLAHE(clip_limit=2),
                    A.Emboss(),
                    A.RandomBrightnessContrast(),            
                ], p=0.5),
                A.HueSaturationValue(p=0.5),
                    #A.Normalize(mean=(0.486, 0.459, 0.408), std=(0.229, 0.224, 0.225)),
                    ToTensorV2()
                ], bbox_params=A.BboxParams(format='coco', label_fields=['class_labels']))
        else:
            self.trans = A.Compose([
                A.Resize(224, 224),
                ToTensorV2()
            ], bbox_params = A.BboxParams(format='coco', label_fields=['class_labels']))

Expected behavior

Perform some image augmentations technique over the dataset with bounding boxes and masks.

Environment

  • Albumentations version (e.g., 0.1.8): 1.0.0
  • Python version (e.g., 3.7): 3.7
  • OS (e.g., Linux): Linux
  • How you installed albumentations (conda, pip, source): pip
@yisaienkov
Copy link
Contributor

I think it happens because your box extends beyond the right edge of the input image.

@aliceinland
Copy link
Author

Yes, but this happens during the process of data augmentation performed with albumentation.
The same issue was report in issue #922, #903 and other ones linked in issue #922.

@Dipet
Copy link
Collaborator

Dipet commented Jul 7, 2021

Should be fixed by #924

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

No branches or pull requests

3 participants