question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Yolo boxes format overflowing image and thowing an exception

See original GitHub issue

🐛 Bug

I have some bounding boxes in yolo format that are off the image.

To Reproduce

  1. Have boxes outside image in yolo format and try to augment

\lib\site-packages\albumentations\augmentations\bbox_utils.py", line 330, in check_bbox “to be in the range [0.0, 1.0], got {value}.”.format(bbox=bbox, name=name, value=value) ValueError: Expected x_max for bbox (0.9967206790123457, 0.5379050925925926, 1.0001929012345678, 0.5529513888888888, 0) to be in the range [0.0, 1.0], got 1.0001929012345678.

Expected behavior

I would prefer it to clip the boxes, or at least give me the option to do so.

Environment

  • Albumentations version (e.g., 0.1.8): 0.5.2
  • Python version (e.g., 3.7): 3.6
  • OS (e.g., Linux): Windows
  • How you installed albumentations (conda, pip, source): pip
  • Any other relevant information:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Trud09commented, Mar 8, 2021

The image might be proprietary, but here is one box causing the issue:

Yolo Format: [0.99662423, 0.7520255 , 0.00675154, 0.01446759]

My albumentations conversion: [0.99324846, 0.7447917, 1.0, 0.7592593]

Exception for this box: Exception has occurred: ValueError Expected x_max for bbox (0.9934413580246914, 0.7450810185185185, 1.0001929012345678, 0.7592592592592593, 0) to be in the range [0.0, 1.0], got 1.0001929012345678.

My conversion code:

def yolo_to_norm_voc(bboxes):
    x_mean, y_mean, w, h = bboxes[:, 0], bboxes[:, 1], bboxes[:, 2], bboxes[:, 3]

    x_min = x_mean - (w/2)
    y_min = y_mean - (h/2)

    x_min, x_max, y_min, y_max = x_min, x_min + w, y_min, y_min + h
    return np.stack([x_min, y_min, x_max, y_max], 1)
0reactions
Dipetcommented, Jul 7, 2021

Should be fixed by #924

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: Expected x_max for bbox to be in the range [0.0 ...
Bug I tried to transform images using RandomResizedCrop with its bounding box (yolo format). But, there are images that when the program ...
Read more >
Yolo V5 issue "Exception: Dataset not found." on local machine
I have a train, test and valid files that contain all the image and labels files. I have tested the files on googlecolap...
Read more >
Import pre-annotated data into Label Studio
Import predicted labels, predictions, pre-annotations, or pre-labels into Label Studio for your data labeling, machine learning, and data science projects.
Read more >
Detect and Track Objects with ML Kit on Android - Firebase
When you pass ML Kit images, ML Kit returns, for each image, a list of up to five detected objects and their position...
Read more >
'function' object has no attribute 'drop'
'function' Object Has No Attribute 'drop'Passing a string of a filename will save the screenshot to a file as well as return it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found