YOLO loader only handles one image extension: other images are dropped or fail in read_annotation
Maintainers usually reply within 6 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- computer-vision, machine-learning
Research direction
Read YOLODataset.build_dataset and YOLODataset.read_annotation, which the issue identifies as the affected entry points. Reproduce with a folder containing labelled .jpg, .png, and .jpeg images and with a list that includes a non-default extension. Done when folder mode loads every labelled image and list mode reads annotations without rebuilding an incorrect image path.
Written by the indexing model from the issue text.
Description
Description
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_datasetbuilds the image name aslabel.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.pngis loaded, butread_annotationrebuilds the image path withim_extand raisesFileNotFoundError.
To reproduce
# images/val/a.jpg, b.png, c.jpeg, each with labels/val/<name>.txt
ds = YOLODataset("data.yaml", root) # val: images/val
print(list(ds.dataset.index)) # ['a'] (b and c dropped)
# val.txt listing images/val/a.jpg and images/val/b.png
ds2 = YOLODataset("data2.yaml", root) # val: val.txt
ds2.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.
- Dominant language
- Python
- Stars
- 117
- Forks
- 121
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JdeRobot/PerceptionMetrics
-
COCO loader drops images that have the same file name in different subfoldersPossibly taken @Vivaan-Atharva claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JdeRobot/PerceptionMetrics#702 ·
Maintainers usually reply within 6 days
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
JdeRobot/PerceptionMetrics#698 ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JdeRobot/PerceptionMetrics#693 ·
Maintainers usually reply within 6 days
-
COCO-style mAP@[0.5:0.95] doesn't match pycocotools (uses 11-point interpolation)May be free again @clarkf19 claimed this 16 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JdeRobot/PerceptionMetrics#685 · 3 comments ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
JdeRobot/PerceptionMetrics#684 · 1 comment ·
Maintainers usually reply within 6 days
All issues in JdeRobot/PerceptionMetrics
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TigreGotico/orthography2ipa#2950 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Unstructured-IO/unstructured#4876 ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openfoodfacts/openfoodfacts-python#579 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
fairagro/m4.2_sql_to_arc#388 ·
Maintainers usually reply within 1 day