Skip to content

Load YOLO images whose extension differs from im_ext - #701

Open
soujasK wants to merge 1 commit into
JdeRobot:masterfrom
soujasK:fix/700-yolo-image-extensions
Open

soujasK wants to merge 1 commit into
JdeRobot:masterfrom
soujasK:fix/700-yolo-image-extensions

Conversation

@soujasK

@soujasK soujasK commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #700

YOLODataset built the image name from the label file with im_ext,so in folder splits images with another extension (.png,.jpeg,.JPG...) were skipped without a warning.read_annotation rebuilt the image path the same way,so a .png listed in a .txt split failed with FileNotFoundError.

A small helper (_find_image_fname) now tries the same name with other common image extensions (jpg,jpeg,png,bmp,tif,tiff,webp,lower and upper case) when the expected file does not exist.It is used in folder splits and in read_annotation.When the expected file exists nothing changes.

This touches yolo.py like #668 and #697,but different lines,so it merges cleanly with both.

Tests:

  • added tests/datasets/test_yolo_image_extensions.py with real files in tmp_path:a folder split with .jpg,.png,.jpeg and .JPG images,and read_annotation for a .png in a folder split and in a .txt split.All 3 fail on master and pass here.
  • tests/datasets/test_yolo.py still passes (5 passed in total on Windows,Python 3.11).

Used an AI assistant to help with this.

build_dataset built the image name from the label with im_ext, so in
folder splits images with another extension (.png, .jpeg, .JPG, ...)
were skipped without a warning. read_annotation rebuilt the image path
the same way, so a .png listed in a .txt split failed with
FileNotFoundError.

Both now fall back to the same name with other common image extensions
when the expected file does not exist.

Fixes JdeRobot#700

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YOLO loader only handles one image extension: other images are dropped or fail in read_annotation

1 participant