expand support to grayscale similar to cv2

This commit is contained in:
patel-zeel
2025-01-07 22:16:05 +05:30
parent f4850b870f
commit 2ed66bfffc
+7 -3
View File
@@ -173,9 +173,13 @@ def load_yolo_annotations(
w, h = image.size
resolution_wh = (w, h)
if image.mode != "RGB":
raise ValueError(
f"Images must be 'RGB', but {image_path} is '{image.mode}'."
)
if image.mode == "L":
image = image.convert("RGB")
else:
raise ValueError(
f"Images must be 'RGB' or 'grayscale', \
but {image_path} mode is '{image.mode}'."
)
with_masks = _with_mask(lines=lines)
with_masks = force_masks if force_masks else with_masks