-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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_min for bbox (-0.02666666666666667, 0.3022222222222222, 0.10666666666666667, 0.48444444444444446, tensor(1)) to be in the range [0.0, 1.0], got -0.02666666666666667. #679
Comments
What is the shape of the image? |
This unfortunately is regularly happening for me as well. Here's my env along with a reproducible script. It seems to me that all of these errors seem to deal with numerical errors when doing geometric operations on totally legit bounding boxes right at the image boundary. CC: @BeckerFelix Environment
import numpy as np
import albumentations as A
np.random.seed(123)
HEIGHT, WIDTH = 720, 1280
def random_bbox():
x1 = np.random.randint(low=0, high=WIDTH)
y1 = np.random.randint(low=0, high=HEIGHT)
x2 = np.random.randint(low=x1 + 1, high=WIDTH + 1)
y2 = np.random.randint(low=y1 + 1, high=HEIGHT + 1)
bbox_albu = A.convert_bbox_to_albumentations([x1, y1, x2, y2], source_format='pascal_voc', rows=HEIGHT, cols=WIDTH)
bbox_yolo = A.convert_bbox_from_albumentations(bbox_albu, target_format='yolo', rows=HEIGHT, cols=WIDTH, check_validity=True)
# NOTE: at this point the bounding box has been checked to be valid.
return bbox_yolo
transform = A.Compose(
[A.HorizontalFlip(), A.RandomBrightnessContrast()],
bbox_params=A.BboxParams(format='yolo', label_fields=["class_labels"])
)
img = np.zeros((HEIGHT, WIDTH, 3), dtype=np.uint8)
for i in range(1000):
bboxes = [random_bbox()]
try:
transform(image=img, bboxes=bboxes, class_labels=[1])
except:
print(f"[{i}] Invalid transformation of box: {str(bboxes[0])}")
>>> [327] Invalid transformation of box: (0.755859375, 0.5944444444444444, 0.48671875, 0.3611111111111111)
>>> [363] Invalid transformation of box: (0.373046875, 0.9409722222222222, 0.68828125, 0.11527777777777778)
>>> [683] Invalid transformation of box: (0.465625, 0.9881944444444445, 0.5765625, 0.020833333333333332) |
Problem with floating point arithmetic.
I think cliping using conversion to int for x_min and x_max will fix this error. |
Thank you @Dipet , that was really fast. I wanted to ask if I could be of any help after a long weekend but I see it's already implemented and approved. Awesome work! |
Should be fixed by #924 |
This problem is still present in version
I am using the following augmentations for an object detection problem:
|
🐛 Bug
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Environment
conda
,pip
, source): pipAdditional context
I'm getting ValueError:
Expected x_min for bbox (-0.02666666666666667, 0.3022222222222222, 0.10666666666666667, 0.48444444444444446, tensor(1)) to be in the range [0.0, 1.0], got -0.02666666666666667.
message
my original box is
new_boxes->[[442. 79. 972. 564.]]
its x_min, y_min, x_max, y_max format
then it only give this error message when
The text was updated successfully, but these errors were encountered: