You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
YOLO loader only handles one image extension: other images are dropped or fail in read_annotation #700
YOLODataset only works with one image extension (im_ext, default "jpg"), but YOLO datasets often mix .jpg, .jpeg and .png.
Folder mode (val: images/val): build_dataset builds the image name as label.replace(".txt", f".{im_ext}"), so images with any other extension are skipped without a warning.
List mode (val: val.txt): images are taken from the list, so a .png is loaded, but read_annotation rebuilds the image path with im_ext and raises FileNotFoundError.
To reproduce
# images/val/a.jpg, b.png, c.jpeg, each with labels/val/<name>.txtds=YOLODataset("data.yaml", root) # val: images/valprint(list(ds.dataset.index)) # ['a'] (b and c dropped)# val.txt listing images/val/a.jpg and images/val/b.pngds2=YOLODataset("data2.yaml", root) # val: val.txtds2.read_annotation(os.path.join(root, ds2.dataset.loc["b", "annotation"]))
# FileNotFoundError: ...images/val/b.jpg
Expected
All labelled images are loaded whatever their extension, and read_annotation uses the image path already stored in the dataset (or the image size from the caller) instead of rebuilding it.
Possible fix
In folder mode, look for the image with any common extension (jpg, jpeg, png, bmp, ...), like Ultralytics does. In read_annotation, look up the stored image path instead of rebuilding it from the label path. This is related to #667 (that one is about "images"/"labels" in parent folder names), so the two fixes could share the same path lookup. Happy to open a PR.
Activity