Add trainer to yolov8 validator when calling w/o recipe #1599
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.
This PR fixes a bug in our current yolov8 training flow.
The bug reveals itself when
sparseml.ultralytics.train
utility is invoked without arecipe
This happens due to ultralytics codebase, in which a trainer is not passed to the validator on this line: https://github.com/ultralytics/ultralytics/blob/6c65934b555e64bf26edd699865754b5ff651d0c/ultralytics/yolo/engine/trainer.py#L551
And this pathway is only hit when a recipe is not given to the train command, for example here's a dummy run with a recipe and it completes without any errors:
test_recipe.yaml
The recipe pathway succeeds because the final validation is explicitly not invoked when a recipe is provided:
sparseml/src/sparseml/yolov8/trainers.py
Line 490 in 9c7c285
NOTE: This circumvents the error, but/and does not run the final validation pathway 😲 and should probably investigated more.
The proposed fix however, handles the failing case by wrapping
self.validator
in afunctools.partial
callable object withtrainer
information; this not only fixes the error, but also successfully runs the ultralytics'final_eval
: