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: Expected x_max for bbox to be in the range [0.0, 1.0], got 1.0025. #922

Closed
atikapane opened this issue Jun 15, 2021 · 5 comments

Comments

@atikapane
Copy link

🐛 Bug

I tried to transform images using RandomResizedCrop with its bounding box (yolo format). But, there are images that when the program tried to transform the bounding box, I got error saying that the bounding box value (after transformation) is not in the range of 0-1. I already checked the original bounding box, and there is nothing wrong with the original bounding box value.

This is my pipeline

transform = A.Compose([
    A.RandomResizedCrop(608, 608),
], bbox_params = A.BboxParams(format='yolo'))

This is the code to place the bounding box to an array and transform it

    bboxes = []
    for dt in data:
        ann = []

        # Split string to float
        c, x, y, w, h = map(float, dt.split(' '))
        ann.append(x)
        ann.append(y)
        ann.append(w)
        ann.append(h)
        ann.append(c)

        bboxes.append(ann)

    transformed = transform(image=img, bboxes=bboxes)

And this is the error

  File "C:\Users\Atika Pane\AppData\Roaming\Python\Python38\site-packages\albumentations\core\composition.py", line 180, in __call__
    p.preprocess(data)
  File "C:\Users\Atika Pane\AppData\Roaming\Python\Python38\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 "C:\Users\Atika Pane\AppData\Roaming\Python\Python38\site-packages\albumentations\core\utils.py", line 70, in check_and_convert
    return self.convert_to_albumentations(data, rows, cols)
  File "C:\Users\Atika Pane\AppData\Roaming\Python\Python38\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 "C:\Users\Atika Pane\AppData\Roaming\Python\Python38\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 "C:\Users\Atika Pane\AppData\Roaming\Python\Python38\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 "C:\Users\Atika Pane\AppData\Roaming\Python\Python38\site-packages\albumentations\augmentations\bbox_utils.py", line 251, in convert_bbox_to_albumentations
    check_bbox(bbox)
  File "C:\Users\Atika Pane\AppData\Roaming\Python\Python38\site-packages\albumentations\augmentations\bbox_utils.py", line 327, in check_bbox
    raise ValueError(
ValueError: Expected x_max for bbox (0.9675, 0.19469026548672566, 1.0025, 0.3274336283185841, 0.0) to be in the range [0.0, 1.0], got 1.0025.
@ternaus
Copy link
Collaborator

ternaus commented Jun 15, 2021

Valid values lie in [0, 1) and not [0, 1]

@atikapane
Copy link
Author

But why is it I got error like this when I'm trying to transform the image?
ValueError: Expected x_max for bbox (0.9675, 0.19469026548672566, 1.0025, 0.3274336283185841, 0.0) to be in the range [0.0, 1.0], got 1.0025.

This is the original bounding box

0 0.537500 0.227876 0.130000 0.323009
0 0.982500 0.263274 0.035000 0.137168
0 0.351250 0.471239 0.112500 0.172566

@ternaus
Copy link
Collaborator

ternaus commented Jun 15, 2021

Am I right that for the second box:

x_min = 0.9825
x_max = 0.9825 + 0.035 = 1.0175 ?

@Dipet
Copy link
Collaborator

Dipet commented Jun 15, 2021

@Dipet
Copy link
Collaborator

Dipet commented Jul 7, 2021

Should be fixed by #924

@Dipet Dipet closed this as completed Jul 7, 2021
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