Closed adrigrillo closed 3 years ago
π Hello @adrigrillo, thank you for your interest in YOLOv5 π! Please visit our βοΈ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.
If this is a π Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.
If this is a custom training β Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.
For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.
Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
@adrigrillo thanks for the bug report! To answer your question weights are not saved because the output of evolution is the maximum fitness evolved hyperparameters (in hyp.evolved.yaml
), not any particular generation's weights. Also practically speaking, if we evolve 300 generations we don't want 600 best.pt
and last.pt
checkpoints occupying user's hard drives.
@AyushExel can you look into this? We probably want to filter the upload artifact list to prevent attempting uploading non-existing files, or simply place the upload under an if file.exists():
statement. I do this when logging images to TensorBoard for example here on L131:
https://github.com/ultralytics/yolov5/blob/b894e69dfc341fcbfe4a307a15d6af90d90367df/utils/loggers/__init__.py#L130-L138
This is effectively silent error handling, so maybe a warning would be appropriate.
Thanks to you for the fast response and this great repo.
With regard to the checkpoint saving, saving 300 last.pt
is not desirable, I understand.
However, it could be interesting to just save the best choice, similarly to the best.pt
when training.
That is, just keep the checkpoint of the best training during the evolution process.
I do not know if this sound interesting for you or if it can be implemented at all, I may help with that if so.
Thanks again for the support π
@glenn-jocher I'll put up a fix for this today
@AyushExel thanks!
@glenn-jocher every evolve operation should start a new wandb run right? So the logic in the logger class should be like this:
if not self.opt.evolve:
wandb.log_artifact(str(best if best.exists() else last), type='model',
name='run_' + self.wandb.wandb_run.id + '_model',
aliases=['latest', 'best', 'stripped'])
self.wandb.finish_run()
else:
self.wandb = WandbLogger(self.opt)
Here, we're starting a new run if the job type is evolve
. If this seems the correct logic for evolve operation, I'll go ahead and make a PR
@AyushExel yes each generation should be a new W&B run, i.e. like this more or less from earlier https://wandb.ai/glenn-jocher/COCO128_evolve
@adrigrillo good news π! Your original issue may now be fixed β in PR #4611 by @AyushExel . To receive this update:
git pull
from within your yolov5/
directory or git clone https://github.com/ultralytics/yolov5
againmodel = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
sudo docker pull ultralytics/yolov5:latest
to update your image Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 π!
Thanks for the support!! Great work! β€οΈ
Hello again,
I have started to train a network using evolution with the last fixes, however, I am seeing in W&B panel some entries, which last around 6 seconds, that are not real trainings and that have the same hyperparameters as the following training (which is the proper training). I attach the current status of the W&B panel:
In this case, I am running my fourth evolution training, but there are this other entries (the ones with a tick) that have the same hyperparameters that the one being trained.
@adrigrillo I think these are runs from a previous evolution. By default, the evolution runs are all logged in the project called evolve
. Right now, the easiest way to fix this would be delete all the existing runs in the project evolve
before you runs another evolve operation.
@glenn-jocher I think this is related to train.py more that W&B. The evolve operation project name is hardcoded to runs/evolve
. Can we use the same logic to increment that as it is done from runs like exp, exp2 ..
and evolve, evolve2..
?
@AyushExel this is my first evolution execution, I removed all the data of previous ones. By the way, the training has continued, it is the seventh evolution, and this seems like an exponential process. When I have connected to see the status this morning, there was like 15 entries like that, so the number of them created in each iteration increases. I will send a screenshot of the next iteration when it starts, so you can have a better overview.
Here it is an example of the last evolution epoch. The youthful-frost-31
finished and the scarlet-cloud-38
is the next generation, however, some entries were created with the same hyperparameter than scarlet-cloud-38
but not trained.
On the other hand, the evolve.csv
is fine and its content is the following:
metrics/precision, metrics/recall, metrics/mAP_0.5,metrics/mAP_0.5:0.95, val/box_loss, val/obj_loss, val/cls_loss, lr0, lrf, momentum, weight_decay, warmup_epochs, warmup_momentum, warmup_bias_lr, box, cls, cls_pw, obj, obj_pw, iou_t, anchor_t, fl_gamma, hsv_h, hsv_s, hsv_v, degrees, translate, scale, shear, perspective, flipud, fliplr, mosaic, mixup, copy_paste, anchors
0.81925, 0.70942, 0.75805, 0.27809, 0.036646, 0.0099101, 0, 0.0032, 0.12, 0.843, 0.00036, 2, 0.5, 0.05, 0.0296, 0.243, 0.631, 0.301, 0.911, 0.2, 2.91, 0, 0.0138, 0.664, 0.464, 0.373, 0.245, 0.898, 0.602, 0, 0.00856, 0.5, 0, 0, 0, 3
0.79268, 0.6951, 0.7431, 0.27521, 0.031051, 0.010902, 0, 0.0032, 0.08043, 0.83663, 0.00033, 2, 0.5, 0.05, 0.02471, 0.243, 0.61043, 0.31605, 0.91078, 0.2, 2.91, 0, 0.0138, 0.63292, 0.39487, 0.373, 0.24776, 0.78212, 0.64656, 0, 0.00856, 0.55101, 0, 0, 0, 2.6399
0.81605, 0.70202, 0.74504, 0.26297, 0.037137, 0.009993, 0, 0.00324, 0.12941, 0.8351, 0.00034, 1.8201, 0.48677, 0.0506, 0.0296, 0.27147, 0.631, 0.30654, 0.92631, 0.2, 2.91, 0, 0.0138, 0.68216, 0.46771, 0.37864, 0.23707, 0.9, 0.62485, 0, 0.00856, 0.53214, 0, 0, 0, 2.9352
0.79261, 0.70447, 0.74964, 0.28126, 0.036218, 0.0088652, 0, 0.00333, 0.12081, 0.83871, 0.00033, 1.8563, 0.52175, 0.04418, 0.02946, 0.26268, 0.631, 0.28001, 0.88013, 0.2, 2.8398, 0, 0.0138, 0.9, 0.32603, 0.35549, 0.27948, 0.9, 0.82348, 0, 0.00856, 0.49653, 0, 0, 0, 2.9352
0.8213, 0.71487, 0.76806, 0.28912, 0.035931, 0.0088009, 0, 0.00333, 0.12081, 0.83844, 0.00033, 1.8557, 0.52147, 0.04418, 0.02946, 0.26268, 0.63098, 0.28, 0.88013, 0.2, 2.84, 0, 0.0138, 0.9, 0.32606, 0.35556, 0.27958, 0.9, 0.82356, 0, 0.00856, 0.49682, 0, 0, 0, 2.9347
0.82111, 0.72178, 0.76718, 0.28682, 0.036201, 0.0088806, 0, 0.00333, 0.12486, 0.85711, 0.00037, 2.0089, 0.52175, 0.03742, 0.02946, 0.30368, 0.65203, 0.28479, 0.88013, 0.2, 3.2728, 0, 0.0138, 0.68502, 0.36822, 0.33785, 0.30277, 0.9, 0.74634, 0, 0.00856, 0.60786, 0, 0, 0, 3.2501
0.82704, 0.70128, 0.75458, 0.27516, 0.037025, 0.0074416, 0, 0.00324, 0.12941, 0.8338, 0.00042, 1.7072, 0.48477, 0.05007, 0.0296, 0.30891, 0.73137, 0.22803, 0.92573, 0.2, 2.8161, 0, 0.0138, 0.60412, 0.38516, 0.39254, 0.28341, 0.77613, 0.63828, 0, 0.00856, 0.50556, 0, 0, 0, 3.5649
@AyushExel --evolve
will log locally to runs/evolve/exp with incrementing exp names, i.e. in our colab notebook you can run 3 independent evolutions in series (each for 4 generations) which will log to runs/evolve/exp, runs/evolve/exp2, runs/evolve/exp3:
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb
!python train.py --img 640 --batch 16 --epochs 2 --data coco128.yaml --weights yolov5s.pt --cache --evolve 4
!python train.py --img 640 --batch 16 --epochs 2 --data coco128.yaml --weights yolov5s.pt --cache --evolve 4
!python train.py --img 640 --batch 16 --epochs 2 --data coco128.yaml --weights yolov5s.pt --cache --evolve 4
π Bug
The evolution process fails at the end of the first iteration due to wandb failing to found
last.pt
, which does not exist. The problem is originated in the callback to end the training, that calls the wandb logger and which tries to upload the weight files.Here a doubt arises, why is the model not saved, I mean the
last.pt
, during the evolution process. In this way, the trained model cannot be recovered after training.To Reproduce (REQUIRED)
Input:
Just execute the training process with the 'evolve' flag activated and wandb configured.
Output:
Expected behavior
I expect the
last.pt
to be saved and the training to continue.Environment