New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize parameter #11932
Comments
👋 Hello @caarmeecoorbii, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the 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. InstallPip install the pip install ultralytics EnvironmentsYOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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. |
@caarmeecoorbii hello! If you're looking to customize the learning rate when using Here's how you can explicitly set the optimizer and learning rate in your training script: yolo detect train data=coco128.yaml model=yolov8n.pt epochs=100 optimizer=sgd lr0=0.0001 This command sets the optimizer to 'SGD' and the learning rate ( |
Thank you very much. I have another question: I'm training the YOLOv8x model with my own detections on a total of 42,750 images, and then I plan to use the weights for tracking. What I don't understand is why, when I use my training weights, I get fewer detections, whereas when I use the yolov8x.pt weights, I get more detections, even though I'm training the detector with my own images. I've tried training for 1 epoch with a learning rate of 0, and I still get fewer detections than with yolov8x.pt. Do you know what could be happening? |
Hello! Thanks for reaching out with your question. 😊 It looks like you might be facing an issue with underfitting if your custom-trained model with your specific dataset yields fewer detections compared to the pre-trained yolov8x.pt model. Training for only 1 epoch, especially with a learning rate set to 0, is likely not sufficient for the model to learn effectively from your data. The learning rate being set to 0 means that the weights of the model do not get updated during training, rendering the training process ineffective. I would recommend training for more epochs and using a positive learning rate. Here’s an example command to adjust your learning rate: yolo detect train data=your_dataset.yaml model=yolov8x.yaml epochs=100 lr0=0.01 This sets the learning rate to a starting value of 0.01 and trains for 100 epochs, which should provide more opportunity for your model to learn from your dataset. Adjust the number of epochs and learning rate based on your validation results for optimal performance. |
@caarmeecoorbii hello! Thanks for updating us on your progress. It's intriguing that the pre-trained yolov8x.pt weights are performing better than your custom-trained best.pt weights. This could be due to several factors:
yolo detect predict model=best.pt conf=0.3 iou=0.5 It's often a process of tweaking and testing, so don't hesitate to experiment with these aspects. Let us know how it goes! 😊 |
Hello and thanks for providing the updates and loss graphs! 🌟 It looks like you've made some progress, which is great to hear. If you’ve already worked with learning rates, conf, and iou adjustments without the desired improvement, considering adjustments in other hyperparameters could indeed be beneficial. One parameter you might explore adjusting is the dropout rate if the model seems to be overfitting. Often, a slight increase in dropout can help regularize the model, though this needs to be finely balanced, as too much can harm your model's ability to learn. Additionally, since you're working on tracking, double-check your anchor box scales if you haven’t already. They should be well-tuned to the sizes of objects in your dataset, as mismatched anchor sizes could lead to suboptimal detection performance. Here’s a quick adjustment to add dropout: yolo detect train data=your_dataset.yaml model=yolov8x.yaml epochs=100 lr0=0.0001 dropout=0.1 Adjust |
Thank you so much! Could you provide some guidance on how to adapt anchor box dimensions? |
Hi there! Absolutely, adapting your anchor box dimensions can be very effective for improving model performance, especially if your objects have particular shapes or sizes. To adjust the anchor boxes for your dataset, you typically start by analyzing the common dimensions of your objects. This can be done by clustering the dimensions (width and height) of your ground truth boxes, a technique often done using k-means clustering. Once you have your new anchor sizes, you'll modify them in your model's configuration file (usually a anchors:
- [10,13, 16,30, 33,23] # Small anchors
- [30,61, 62,45, 59,119] # Medium anchors
- [116,90, 156,198, 373,326] # Large anchors Replace these with your calculated anchor boxes. Ensure your model is retrained or fine-tuned with these new anchors for best results. 🚀 Hope this helps! Let me know if you need more detailed steps! 😊 |
I have used the ByteTrack and BoT-SORT trackers for object tracking; I'm not using a custom tracker. I tried changing the dropout value to 0.1, but it didn't make a difference. Are there any other parameters I could try adjusting during training? |
Hello! Thanks for reaching out. Adjusting dropout might not always yield noticeable differences, especially if the model's overfitting isn't the primary issue. You could try tweaking the Here's a quick example of how you might adjust these parameters: yolo detect train data=your_dataset.yaml model=yolov8x.yaml epochs=100 lr0=0.0001 weight_decay=0.0005 momentum=0.9 Adjusting these could provide different learning dynamics that might better suit your data. Good luck, and let us know how it goes! 😊 |
Thanks! I have another question. When I do tracking, can I also adjust the values of conf and iou? What are their default values? |
Absolutely! Yes, you can adjust the yolo track model=yolov8n.pt source=path/to/video.mp4 conf=0.30 iou=0.50 |
Search before asking
Question
Hello, I noticed that in the training parameters, the learning rate 'lr0' is set to 0.01. However, I would like to change it to a lower value, for example, 0.0001. But since I have optimizer = 'auto', the learning rate I defined in 'lr0' is not taken into account. Which optimizer mode has a lower 'lr0'? Thank you.
Additional
No response
The text was updated successfully, but these errors were encountered: