Repository navigation
[datasets] Keep relative image folders readable in RecognitionDataset.merge_dataset - #2177
Conversation
….merge_dataset merge_dataset moves the root of the merged dataset to "/" and joins each image path to its former root, but a relative root yields relative paths, which are then read from the filesystem root (e.g. "train/part_a/images/0.png" is read as "/train/part_a/images/0.png"). This breaks the recognition training script as soon as --train_path is a relative folder with several subfolders. The roots are now made absolute before being joined.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2177 +/- ##
=======================================
Coverage 97.62% 97.63%
=======================================
Files 170 170
Lines 10744 10744
=======================================
+ Hits 10489 10490 +1
+ Misses 255 254 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
felixdittrich92
left a comment
There was a problem hiding this comment.
Thanks for the PR @MohammadHijjawi97 👍
Only one small change and we are good to merge.
…e a DataLoader over the merged dataset
|
Thanks for the review, @felixdittrich92! I removed the separate test and extended |
felixdittrich92
left a comment
There was a problem hiding this comment.
Thanks @MohammadHijjawi97 LGTM 👍
RecognitionDataset.merge_datasetmoves the root of the merged dataset to/and joins each image path to its former root. With a relative root (e.g.--train_path data/traininreferences/recognition/train.py, which merges every subfolder), the joined paths stay relative and are then read from the filesystem root, so every sample fails to load.Repro:
Before:
FileNotFoundErrorfor/train/part_a/images/part_a.png(resolved from the filesystem root instead of the working directory)After: both samples load.
Changes:
test_recognition_dataset_merge(relative image folder, two merges, every sample readable); it fails without the fixChecks:
pytest tests/pytorch/test_datasets_pt.py -k recognition_dataset,ruff check,ruff format --check,mypy.Any feedback is welcome 🤗