Skip to content

Conversation

@glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Sep 2, 2020

  • return hyp.scratch.yaml as default for both from scratch and finetuning training Add InfiniteDataLoader class #876 (comment)
  • simplified ckpt names to avoid appending run name to weights
  • force replot of test_batch0_gt and test_batch0_pred on final epoch

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhanced cleanup and default parameter settings in YOLOv5 training script.

📊 Key Changes

  • Added glob import to use globbing patterns for file operations.
  • Automatically remove prediction images before final evaluation to declutter the output directory.
  • Simplified the generation of result file names by improving the naming logic.
  • Set a default value for the --hyp argument to 'data/hyp.scratch.yaml', standardizing hyperparameter selection.
  • Removed redundant conditional check for assigning the opt.hyp argument.

🎯 Purpose & Impact

  • 🧹 Cleanup: Removing prediction images ensures a cleaner workspace, which helps users navigate results without confusion from outdated files.
  • 🏷️ Naming Consistency: Simplifying result file names reduces complexity and potential confusion when interpreting output files.
  • 📈 Usability: By having a default hyperparameter path, new users can start training models with sensible defaults without specifying additional arguments.
  • 🔍 Clarity: By cleaning up the code and removing unnecessary checks, the script becomes more maintainable and easier to understand, benefiting all users.

Leave line commented for future use once mystery of best finetuning hyps to apply becomes clearer.
This will allow you to see predictions final testing run after training completes in runs/exp0
@glenn-jocher
Copy link
Member Author

All updates look good, passing CI, will merge.

These are small tweaks to improve training results, visualization and usability.

@glenn-jocher glenn-jocher merged commit 281d78c into master Sep 2, 2020
@glenn-jocher glenn-jocher deleted the train_updates branch September 2, 2020 22:08
@NanoCode012
Copy link
Contributor

Hi @glenn-jocher , may I ask why you would only append n to best/last/results if opt.names is numeric?

I think I found one bug in code with the renaming.

yolov5/train.py

Lines 366 to 368 in 281d78c

fresults, flast, fbest = 'results%s.txt' % n, wdir / f'last{n}.pt', wdir / f'best{n}.pt'
for f1, f2 in zip([wdir / 'last.pt', wdir / 'best.pt', 'results.txt'], [flast, fbest, fresults]):
if os.path.exists(f1):

results.txt is not being replaced.

image

My proposed solution

fresults, flast, fbest = log_dir / f'results{n}.txt', wdir / f'last{n}.pt', wdir / f'best{n}.pt' 
for f1, f2 in zip([wdir / 'last.pt', wdir / 'best.pt', results_file], [flast, fbest, fresults]): 

Result from my proposed fix with python train.py --name 2:

image

@glenn-jocher
Copy link
Member Author

glenn-jocher commented Sep 3, 2020

@NanoCode012 ah, yes that change works better than what I have, not sure why I was treating results.txt differently. Can you do a quick PR?

The isnumeric thing is a bit of a personal hack. I'm currently keeping historical records of experiments in GCP buckets with numeric names (i.e. last241.pt, last242.pt etc), but I'm only sending the 3 files here rather than the entire runs/exp directory so I need to keep the numeric names attached for now. In the future I'm planning on switching to full log_dir saving, and then I can delete the isnumeric line, and then the weights and results should not have any name appended to them (for easier plotting and testing).

@NanoCode012
Copy link
Contributor

yes that change works better than what I have, not sure why I was treating results.txt differently. Can you do a quick PR?

Sure thing!

burglarhobbit pushed a commit to burglarhobbit/yolov5 that referenced this pull request Jan 1, 2021
* Update train.py with simplified ckpt names

* Return default hyps to hyp.scratch.yaml

Leave line commented for future use once mystery of best finetuning hyps to apply becomes clearer.

* Force test_batch*_pred.jpg replot on final epoch

This will allow you to see predictions final testing run after training completes in runs/exp0
KMint1819 pushed a commit to KMint1819/yolov5 that referenced this pull request May 12, 2021
* Update train.py with simplified ckpt names

* Return default hyps to hyp.scratch.yaml

Leave line commented for future use once mystery of best finetuning hyps to apply becomes clearer.

* Force test_batch*_pred.jpg replot on final epoch

This will allow you to see predictions final testing run after training completes in runs/exp0
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
* Update train.py with simplified ckpt names

* Return default hyps to hyp.scratch.yaml

Leave line commented for future use once mystery of best finetuning hyps to apply becomes clearer.

* Force test_batch*_pred.jpg replot on final epoch

This will allow you to see predictions final testing run after training completes in runs/exp0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants