ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
51.23k stars 16.44k forks source link

Fine Tuning a model #3750

Closed Yassine-Fak closed 3 years ago

Yassine-Fak commented 3 years ago

Hi @glenn-jocher,

Thank you so much for this repository and this amazing Job.

I am using yolov5x to make some predictions (one class) on aerial images (20 cm resolution).

I have a base model that I trained using the Transfer Learning.

My goal is to Fine Tune this base model, using more data.

To Fine Tune this base model, I use the file train.py and I start the training from the base model (the one I got using the Transfer Learning)

My questions are:

• Do you have any advice to give me to get better results when fine tuning a model?

• You use the One Cycle Learning Rate to train the model, can you explain to me please in a few words how to change that? I mean, how to Fine Tune a model using a decreasing function for the learning rate instead of the One Cycle Learning Rate?

• What are the others parameters that I have to change/adjust when I fine tune a model?

Thank you in advance for your help.

glenn-jocher commented 3 years ago

@Yassine-Fak you can use --linear-lr for a linear ramp from lr0 to final lr instead of OneCycle. Our full recommendations for best training results are below. Good luck.

python train.py --linear-lr

👋 Hello! Thanks for asking about improving YOLOv5 🚀 training results. Most of the time good results can be obtained with no changes to the models or training settings, provided your dataset is sufficiently large and well labelled. If at first you don't get good results, there are steps you might be able to take to improve, but we always recommend users first train with all default settings before considering any changes. This helps establish a performance baseline and spot areas for improvement.

If you have questions about your training results we recommend you provide the maximum amount of information possible if you expect a helpful response, including results plots (train losses, val losses, P, R, mAP), PR curve, confusion matrix, training mosaics, test results and dataset statistics images such as labels.png. All of these are located in your project/name directory, typically yolov5/runs/train/exp.

We've put together a full guide for users looking to get the best results on their YOLOv5 trainings below.

Dataset

COCO Analysis

Model Selection

Larger models like YOLOv5x and YOLOv5x6 will produce better results in nearly all cases, but have more parameters, require more CUDA memory to train, and are slower to run. For mobile deployments we recommend YOLOv5s/m, for cloud deployments we recommend YOLOv5l/x. See our README table for a full comparison of all models.

YOLOv5 Models

Training Settings

Before modifying anything, first train with default settings to establish a performance baseline. A full list of train.py settings can be found in the train.py argparser.

Further Reading

If you'd like to know more a good place to start is Karpathy's 'Recipe for Training Neural Networks', which has great ideas for training that apply broadly across all ML domains: http://karpathy.github.io/2019/04/25/recipe/

github-actions[bot] commented 3 years ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!