Conversation
build_dataset used the file name up to the first dot as the sample name, so files like IMG_0001_jpg.rf.<hash>.jpg (Roboflow exports) all got the same key and overwrote each other. Use os.path.splitext instead. Refs JdeRobot#642
Same first-dot split as the YOLO loader, same fix. Refs JdeRobot#642
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #642
What
yolo.build_dataset()andcoco.build_coco_dataset()now build the sample name withos.path.splitext(os.path.basename(...))[0]instead ofbasename.split(".")[0].Why
Cutting at the first dot gives every Roboflow-exported copy of an image (
IMG_0001_jpg.rf.<hash>.jpg) the same key. Each copy then overwrote the previous row in the dataset dict and was silently left out of evaluation.splitextonly strips the extension, so:img1.jpg→img1(same as before, nothing changes for plain names)IMG_0001_jpg.rf.3f9a1c7e2b.jpg→IMG_0001_jpg.rf.3f9a1c7e2b(unique now)How I tested it
test_build_dataset_keeps_samples_with_dots_in_nameintests/datasets/test_yolo.py. It reuses the existing mocked helper and also checks that a plain name still maps toimg1.tests/datasets/test_coco.pywith a small COCO file written totmp_path, covering four images, three of them with Roboflow-style names.masterand pass with this change.poetry install+poetry run pytest, as in CI: 83 passed, 1 skipped.black --checkis clean on all four files.I used AI assistance while working on this (tracing the loaders and drafting the tests). I've gone through every line and ran all of the above myself.
Note: because sample names now keep their extra dots, predictions that were already saved for such files under the old (truncated) sample name won't be matched after this change and would need to be regenerated.