ValueError: x_max is less than or equal to x_min for bbox
I am using albumentations for a set of images and bboxes.
My bounding box is in &quot;yolo&quot; format, i.e., (x_mid, y_mid, width, height), all normalised.
While running albumentations for a set of bounding errors, above error comes (ValueError: x_max is less than or equal to x_min for bbox) when bounding box takes this value : [0.00017655367231635, 0.0002155172413793, 0.0003531073446327, 0.0004310344827586]. Here, x_min, y_min=[0,0].
This error doesn't come for other bounding box - eg: [0.3060659468984962, 0.4418239134174312, 0.2412257095864662, 0.5496854701834863].
This error is solved when I slightly increase all dimensions of ERROR bounding boxes, i.e. :
Increase x_mid, y_mid, x_width and y_width by 0.01 for this ERROR BB [0.00017655367231635, 0.0002155172413793, 0.0003531073446327, 0.0004310344827586].
Resulting ERROR FREE BB: [0.01017655367231635, 0.0102155172413793, 0.0103531073446327, 0.010431034482758601].
Can anybody tell me a way to solve this error without changing dimensions of BB?
I am using below code for albumentations:
import albumentations as A

    A.Compose(
    [
        A.LongestMaxSize(max_size=IMAGE_SIZE),
        A.PadIfNeeded(
            min_height=IMAGE_SIZE, min_width=IMAGE_SIZE, border_mode=cv2.BORDER_CONSTANT
        ),
        A.Normalize(mean=[0, 0, 0], std=[1, 1, 1], max_pixel_value=255,),
        ToTensorV2(),
    ],
    bbox_params=A.BboxParams(format=&quot;yolo&quot;, min_visibility=0.4, label_fields=[]),
)

Detailed error:
---&gt; 62                 augmentations_norm = self.transform_norm(image=image, bboxes=bboxes)
 63                 #print('Aug done')
 64                 image = augmentations_norm[&quot;image&quot;]

/opt/conda/lib/python3.7/site-packages/albumentations/core/composition.py in __call__(self, force_apply, *args, **data)
    178             if dual_start_end is not None and idx == dual_start_end[0]:
    179                 for p in self.processors.values():
--&gt; 180                     p.preprocess(data)
    181 
    182             data = t(force_apply=force_apply, **data)

/opt/conda/lib/python3.7/site-packages/albumentations/core/utils.py in preprocess(self, data)
     60         rows, cols = data[&quot;image&quot;].shape[:2]
     61         for data_name in self.data_fields:
---&gt; 62             data[data_name] = self.check_and_convert(data[data_name], rows, cols, direction=&quot;to&quot;)
     63 
     64     def check_and_convert(self, data, rows, cols, direction=&quot;to&quot;):

/opt/conda/lib/python3.7/site-packages/albumentations/core/utils.py in check_and_convert(self, data, rows, cols, direction)
     68 
     69         if direction == &quot;to&quot;:
---&gt; 70             return self.convert_to_albumentations(data, rows, cols)
     71 
     72         return self.convert_from_albumentations(data, rows, cols)

/opt/conda/lib/python3.7/site-packages/albumentations/augmentations/bbox_utils.py in convert_to_albumentations(self, data, rows, cols)
     49 
     50     def convert_to_albumentations(self, data, rows, cols):
---&gt; 51         return convert_bboxes_to_albumentations(data, self.params.format, rows, cols, check_validity=True)
     52 
     53 

/opt/conda/lib/python3.7/site-packages/albumentations/augmentations/bbox_utils.py in convert_bboxes_to_albumentations(bboxes, source_format, rows, cols, check_validity)
    300 def convert_bboxes_to_albumentations(bboxes, source_format, rows, cols, check_validity=False):
    301     &quot;&quot;&quot;Convert a list bounding boxes from a format specified in `source_format` to the format used by albumentations&quot;&quot;&quot;
--&gt; 302     return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
    303 
    304 

/opt/conda/lib/python3.7/site-packages/albumentations/augmentations/bbox_utils.py in &lt;listcomp&gt;(.0)
    300 def convert_bboxes_to_albumentations(bboxes, source_format, rows, cols, check_validity=False):
    301     &quot;&quot;&quot;Convert a list bounding boxes from a format specified in `source_format` to the format used by albumentations&quot;&quot;&quot;
--&gt; 302     return [convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity) for bbox in bboxes]
    303 
    304 

/opt/conda/lib/python3.7/site-packages/albumentations/augmentations/bbox_utils.py in convert_bbox_to_albumentations(bbox, source_format, rows, cols, check_validity)
    249     bbox = normalize_bbox(bbox, rows, cols)
    250     if check_validity:
--&gt; 251         check_bbox(bbox)
    252     return bbox
    253 

/opt/conda/lib/python3.7/site-packages/albumentations/augmentations/bbox_utils.py in check_bbox(bbox)
    331     x_min, y_min, x_max, y_max = bbox[:4]
    332     if x_max &lt;= x_min:
--&gt; 333         raise ValueError(&quot;x_max is less than or equal to x_min for bbox {bbox}.&quot;.format(bbox=bbox))
    334     if y_max &lt;= y_min:
    335         raise ValueError(&quot;y_max is less than or equal to y_min for bbox {bbox}.&quot;.format(bbox=bbox))

ValueError: x_max is less than or equal to x_min for bbox (0.00390625, 0.00390625, 0.00390625, 0.00390625, 0.0).


Adapted from comments:
When you are using bounding boxes in the albumentations library, you need to ensure that the boxes have a width of more than 0 when looking at your image size. This might not be obvious in the yolo bounding box representation, but you can do a quick check if you do this:
pix_w = int(bb[2]*img_w)
pix_h = int(bb[3]*img_w)
np.testing.assert_equal(np.all([pix_w&gt;0,pix_h&gt;0]), True)

