ultralytics / ultralytics

Ultralytics YOLO11 🚀
https://docs.ultralytics.com
GNU Affero General Public License v3.0
31.47k stars 6.05k forks source link

Optimizing Training Parameters for Enhanced Performance on YOLOv8m Model with Large License Plate Character Dataset #3762

Closed newegy closed 1 year ago

newegy commented 1 year ago

Search before asking

Question

How can I optimize the training parameters for improved performance on the YOLOv8m model with a dataset of 25,000 photos, 45 classes, and approximately 250,000 annotations? The dataset focuses on characters of car license plates, but despite its size, the accuracy achieved during training is similar to that of a smaller dataset of 2,000 images. Specifically, what are the recommended values for parameters such as the initial learning rate (lr0), final learning rate (lrf), and any other relevant parameters that can enhance the model's performance?

Additional

No response

github-actions[bot] commented 1 year ago

👋 Hello @newegy, thank you for your interest in YOLOv8 🚀! We recommend a visit to the YOLOv8 Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.7 environment with PyTorch>=1.7.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 1 year ago

@newegy hyperparameter tuning for deep learning models like YOLO is a complex process that often involves a lot of trial and error. That said, there are some guidelines you might find useful:

  1. Learning rate (lr0): This is one of the most important hyperparameters. The optimal learning rate can depend on many factors, but a common initial learning rate for YOLO models is around 0.001. However, if your training is unstable or not improving, you might want to try lowering the learning rate. Some researchers also use learning rate schedules that start with a higher learning rate and then decrease it over time.

  2. Final learning rate (lrf): This is the learning rate at the end of training. A common practice is to reduce the learning rate gradually during training to help the model converge. A typical value might be 0.0001 or even lower, but again, this can depend on many factors.

  3. Batch size: Larger batch sizes can provide a more accurate estimate of the gradient, but they also require more memory. If you have enough memory, you might want to try increasing the batch size.

  4. Number of epochs: More epochs can lead to better performance, up to a point. However, too many epochs can lead to overfitting, especially if you don't have a large dataset. A common practice is to use early stopping, which means ending training when performance on a validation set stops improving.

  5. Data augmentation: Techniques like random cropping, rotations, and flips can help to create a more robust model. They can be especially useful when you're working with a small dataset.

  6. Optimizer: Different optimizers can lead to different results. The Adam optimizer is often a good choice for YOLO models, but you could also experiment with others.

For a large dataset like yours, it could be beneficial to use a tool like Optuna or Hyperopt for hyperparameter optimization. These tools can automate the process of finding the best hyperparameters for your model.

Additionally, keep in mind that achieving high accuracy in a task like license plate recognition can be challenging, and might require a large and diverse dataset. Make sure your training, validation, and test sets are representative of the data the model will encounter in production.

newegy commented 1 year ago

Thank you for answering, I already tried all above but I didn't try optuna . I'll try it and see if ill get a better result. For plate characters what do you think is the best argument?

newegy commented 1 year ago

The last question, do you think i should use segmentation rather than classification?

glenn-jocher commented 1 year ago

@newegy considering your specific task of license plate character recognition, using segmentation rather than classification largely depends on your particular use case and constraints. Both methods could potentially work well, but they come with different advantages and challenges.

  1. Classification: If you're detecting each character as a separate object, you'll be using classification. This can be simpler to train and implement, and could be sufficient if your characters are well-isolated and distinguishable. It can, however, sometimes be less accurate if the characters are compressed or overlapping, as it operates on a per bounding box basis.

  2. Segmentation: On the other hand, segmentation refers to pixel-wise prediction, which could provide more precise localization especially when characters are closely placed or overlapping. This can potentially be more accurate, but it's usually more complex and could require more computational resources.

In summary, if you're having trouble with accuracy using classification (detection), it could be worth it to try segmentation approach, but be prepared for potentially more complex training and inference processes. As always, the right approach depends on your specific problem and constraints, so experimentation is key.

github-actions[bot] commented 1 year ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

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 YOLO 🚀 and Vision AI ⭐