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

ValueError(f"Expected {name} for bbox {bbox} to be in the range [0.0, 1.0], got {value}.") #1431

Closed
alejopaullier96 opened this issue Mar 29, 2023 · 3 comments

Comments

@alejopaullier96
Copy link

🐛 Bug

I am getting the following bug which was already addressed here but apparently the bug still persists in albumentations version 1.3.0:

ValueError(f"Expected {name} for bbox {bbox} to be in the range [0.0, 1.0], got {value}.")
ValueError: Expected y_max for bbox (0.14792899408284024, 0.9671641791044776, 0.28205128205128205, 1.0029850746268656, tensor(2)) to be in the range [0.0, 1.0], got 1.0029850746268656.

I am using the following augmentations for an object detection problem:

def get_train_transforms():
    return A.Compose(
        [
            A.Resize(height=config.RESOLUTION, width=config.RESOLUTION, p=1),
            A.Normalize(p=1),
            ToTensorV2(p=1.0),
        ], 
        p=1.0, 
        bbox_params=A.BboxParams(
            format='pascal_voc',
            min_area=0, 
            min_visibility=0,
            label_fields=['labels']
        )
    )

def get_valid_transforms():
    return A.Compose(
        [
            A.Resize(height=config.RESOLUTION, width=config.RESOLUTION, p=1.0),
            A.Normalize(p=1),
            ToTensorV2(p=1.0),
        ], 
        p=1.0, 
        bbox_params=A.BboxParams(
            format='pascal_voc',
            min_area=0, 
            min_visibility=0,
            label_fields=['labels']
        )
    )

Expected behavior

Bounding boxes should not be larger than image dimensions after transformations.

Environment

  • Albumentations version: 1.3.0
  • Python version (e.g., 3.7): 3.7.12
  • OS (e.g., Linux): Linux-5.15.89+-x86_64-with-debian-bullseye-sid
  • How you installed albumentations (conda, pip, source): pip
  • Any other relevant information: Run with GPU on a Kaggle environment (2023-03-29)

Additional context

GPU info: Cuda: Tesla P100-PCIE-16GB

@alejopaullier96
Copy link
Author

After much debugging the problem was due to negative values in bounding boxes data for their x and y coordinates as well as heights and widths of bounding boxes.

@AriyaRasekh
Copy link

AriyaRasekh commented Aug 15, 2023

The bug is defiantly there, I'm assuming some numbers after decimal point somehow is messing up the calculation in the backed, you can try limiting the numbers (your bbox label values) after decimal point to 6 or 10 and try again.

Library has critical bugs for sure. You might have to find a new library for augmentation if the issue persists for you

@ternaus
Copy link
Collaborator

ternaus commented Sep 18, 2024

@alejopaullier96 @AriyaRasekh

The issue could be resolved if one passes clip=True to BboxParams

@ternaus ternaus closed this as completed Sep 18, 2024
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