我正在为一组图像和 bbox 使用专辑。
我的边界框是“yolo”格式,即(x_mid,y_mid,width,height),全部标准化。
在为一组边界错误运行标注时,当边界框采用以下值时,会出现上述错误(ValueError:x_max 小于或等于 bbox 的 x_min):[0.00017655367231635, 0.0002155172413793, 0.0003531073446327, 0.0004310344827586]。这里,x_min, y_min=[0,0]。
其他边界框不会出现此错误 - 例如:[0.3060659468984962, 0.4418239134174312, 0.2412257095864662, 0.5496854701834863]。
当我稍微增加 ERROR 边界框的所有尺寸时,此错误得到解决,即:将此错误 BB [0.00017655367231635、0.0002155172413793、0.0003531073446327、0.0058631034482] 的 x_mid、y_mid、x_width 和 y_width 增加 0.01。
产生的无错误 BB:[0.01017655367231635、0.0102155172413793、0.0103531073446327、0.010431034482758601]。
谁能告诉我在不改变 BB 尺寸的情况下解决此错误的方法?
我正在使用以下代码进行标注:
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="yolo", min_visibility=0.4, label_fields=[]),
)
详细错误:
---> 62 augmentations_norm = self.transform_norm(image=image, bboxes=bboxes)
63 #print('Aug done')
64 image = augmentations_norm["image"]
/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():
--> 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["image"].shape[:2]
61 for data_name in self.data_fields:
---> 62 data[data_name] = self.check_and_convert(data[data_name], rows, cols, direction="to")
63
64 def check_and_convert(self, data, rows, cols, direction="to"):
/opt/conda/lib/python3.7/site-packages/albumentations/core/utils.py in check_and_convert(self, data, rows, cols, direction)
68
69 if direction == "to":
---> 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):
---> 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 """Convert a list bounding boxes from a format specified in `source_format` to the format used by albumentations"""
--> 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 <listcomp>(.0)
300 def convert_bboxes_to_albumentations(bboxes, source_format, rows, cols, check_validity=False):
301 """Convert a list bounding boxes from a format specified in `source_format` to the format used by albumentations"""
--> 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:
--> 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 <= x_min:
--> 333 raise ValueError("x_max is less than or equal to x_min for bbox {bbox}.".format(bbox=bbox))
334 if y_max <= y_min:
335 raise ValueError("y_max is less than or equal to y_min for bbox {bbox}.".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).