fix: rewrite the test split path for yolov5 and yolov7 downloads - #522
Open
roshaninfordham wants to merge 1 commit into
Open
fix: rewrite the test split path for yolov5 and yolov7 downloads#522roshaninfordham wants to merge 1 commit into
roshaninfordham wants to merge 1 commit into
Conversation
__reformat_yaml prefixed train and val with the dataset location for yolov5pytorch and yolov7pytorch but left test untouched, so a downloaded data.yaml carried two absolute paths and one relative one. Guard the new line with a membership check: a version generated without a test split has no `test` key, and the mt-yolov6 branch above would raise KeyError on such a dataset today.
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.
Description
Closes #156.
Version.__reformat_yamlprefixes the split paths in a downloadeddata.yamlwith the dataset location. Foryolov5pytorchandyolov7pytorchit does this fortrainandvalbut nottest:So the file that lands on disk carries two rewritten paths and one untouched one:
The
mt-yolov6branch directly above already rewrites all three.Type of Change
Changes Made
roboflow/core/version.py— rewritetestalongsidetrainandvalfor the yolov5/yolov7 branch.if "test" in content. A version generated without a test split has notestkey at all, and an unguarded assignment would turn a working download into aKeyError.tests/test_version.py— aTestReformatYamlcase class covering yolov7 and yolov5, plus the no-test-split case.Motivation and Context
I want to flag a decision rather than quietly make it.
#334 ("bugfix - downloading yolov8 files incorrectly amends data.yaml") took the position that this rewriting is itself the mistake — that the server's
../train/imagesis already correct and roboflow-python should leave it alone. That reasoning applies just as well to the yolov5/yolov7 branch, and removing the rewrite entirely is a defensible reading of this issue.I did not do that, because it changes behaviour for every existing yolov5/yolov7 user and relitigates a decision that is yours rather than mine. What is not defensible under either reading is the current state, where one of three splits is treated differently from the other two within the same file. This PR makes the branch internally consistent and nothing more.
If you would rather delete the yolov5/yolov7 rewrite altogether, I am happy to send that instead — say the word and I will swap it.
Two other things I noticed and deliberately left alone:
mt-yolov6branch indexescontent["test"]unguarded, so it raisesKeyErroron a dataset with no test split. Same latent bug, different format; out of scope here..lstrip("..")strips a set of characters, not a prefix, so it is equivalent to the.lstrip(".")used two lines above. Harmless for these inputs, but the two branches read as if they differ when they do not.Testing
Against unmodified
main, two of the three new tests fail on exactly the reported symptom:The third (no test split present) passes either way by design — it exists to pin the guard, so that a future change cannot reintroduce a
KeyError.Google Colab (optional)
Not applicable; the change is in local post-download file handling and is covered by unit tests that write and re-read a
data.yamlin a temporary directory, with no API key or network access needed.