Fixed 'meta' and 'hyp' may out of order when using evolve #4657
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.
Hi, there.
Recently I have try to use the
evolve
feature of yolov5, and found out that the keys ofmeta
andhyp
maybe miss align intrain.py
. The reason is that, firstly, dictionary in python won't gurantee order. Secondly, theanchors
hyper-parameter is possible add to thehyp
dictionary in runtime (when it not be defined in hyp.yaml). And after that, all hyper-parameters afteranchors
will miss align betweenmeta
andhyp
.So, I just use the
hyp
keys to get bothgain
, which will maintain the order.We can validate this by set all
gain
ofmeta
to 0 except one that afteranchors
key. Usetranslate
key as an example (becausetranslate
andscale
are initialized with non-zero value, if a hyper-parameter initialize with 0 and it won't get mutation), it will evolve on thescale
key:🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Improving the
.gitignore
and genetic algorithm in YOLOv5.📊 Key Changes
.gitignore
to explicitly ignore thewandb/
directory.train.py
to ensure hyp keys align with meta values during mutation.🎯 Purpose & Impact
wandb
directories.The changes will make collaborating on YOLOv5 codebase cleaner and may lead to improved performance of models trained with YOLOv5 thanks to the more robust hyperparameter tuning process. 🧬✨