ultralytics / ultralytics

NEW - YOLOv8 πŸš€ in PyTorch > ONNX > OpenVINO > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
25.77k stars 5.13k forks source link

How to train an OBBmodel with better results? #13767

Open B1SH0PP opened 2 weeks ago

B1SH0PP commented 2 weeks ago

Search before asking

Question

Hello, when I trained Yolov8-obb on DOTAv1.0 ​​from scratch, I still couldn't achieve good results. I trained for 300 epochs, but the map could only reach 58. Ultralytics, do you use any tricks, or do you have any training suggestions? By the way, can you share your training hyperparameters?

image image These are the hyperparameters I used, I only enabled cos_lr and multi_scale: image

Additional

No response

github-actions[bot] commented 2 weeks ago

πŸ‘‹ Hello @B1SH0PP, 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.

Install

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

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.

B1SH0PP commented 2 weeks ago

@glenn-jocher

glenn-jocher commented 2 weeks ago

Hello @B1SH0PP,

Thank you for reaching out and sharing your training experience with YOLOv8-OBB on the DOTAv1.0 dataset. Achieving optimal results can indeed be challenging, but there are several strategies and hyperparameter adjustments you can consider to improve your model's performance.

Training Tips for Better Results

  1. Learning Rate and Scheduler:

    • While cos_lr is a good choice, you might want to experiment with different learning rates and schedulers. Sometimes, a lower initial learning rate can help the model converge better.
    • Consider using a learning rate warm-up strategy to stabilize the initial training phase.
  2. Augmentation:

    • Data augmentation can significantly impact model performance. Ensure you are using a diverse set of augmentations such as rotation, scaling, flipping, and color jittering.
    • Mosaic and MixUp augmentations can also help in creating more varied training samples.
  3. Batch Size:

    • Experiment with different batch sizes. Sometimes, a larger batch size can help in better gradient estimation, but it requires more GPU memory.
  4. Hyperparameters:

    • Fine-tuning hyperparameters like momentum, weight_decay, and optimizer can also lead to better results. You can refer to the Ultralytics documentation for detailed descriptions and recommended values.
  5. Multi-Scale Training:

    • Multi-scale training is already enabled, which is great. It helps the model generalize better by training on images of different scales.
  6. Validation and Early Stopping:

    • Use validation metrics to monitor the training process and implement early stopping to prevent overfitting.

Example Hyperparameters

Here is an example of a training script with some adjusted hyperparameters:

from ultralytics import YOLO

# Load a model
model = YOLO("yolov8n-obb.pt")  # load a pretrained model

# Train the model
results = model.train(
    data="dota8.yaml",
    epochs=300,
    imgsz=640,
    lr0=0.001,
    lrf=0.01,
    momentum=0.937,
    weight_decay=0.0005,
    warmup_epochs=3.0,
    warmup_momentum=0.8,
    warmup_bias_lr=0.1,
    multi_scale=True,
    cos_lr=True,
    augment=True
)

Additional Resources

For more detailed guidance, please refer to the Oriented Bounding Boxes (OBB) documentation. This resource provides comprehensive information on training, validation, and exporting OBB models.

Feel free to experiment with these suggestions and monitor the impact on your model's performance. If you have any further questions or need additional assistance, don't hesitate to ask. Happy training! πŸš€

B1SH0PP commented 2 weeks ago

I am very happy to receive your help. Your suggestions have inspired me and I will continue to try to achieve better results.

glenn-jocher commented 2 weeks ago

Hello @B1SH0PP,

I'm glad to hear that you found the suggestions helpful! πŸŽ‰

As you continue to experiment with your YOLOv8-OBB model, remember that fine-tuning and iterative adjustments are key to achieving optimal performance. If you encounter any specific issues or have further questions during your training process, feel free to reach out.

Also, ensure that you are using the latest versions of torch and ultralytics to benefit from the latest features and bug fixes. If you run into any bugs, please provide a minimum reproducible code example as outlined in our documentation. This will help us investigate and address any issues more effectively.

Best of luck with your training, and happy experimenting! πŸš€

B1SH0PP commented 2 weeks ago

Thank you for your valuable advice, I checked my torch version and I really need to upgrade torch. image

B1SH0PP commented 2 weeks ago

I always thought that the torch version had little effect on accuracy.

glenn-jocher commented 2 weeks ago

Hello @B1SH0PP,

Thank you for your comment! While it's a common assumption that the torch version might not significantly impact accuracy, it's important to note that different versions of torch can include various optimizations, bug fixes, and new features that can affect model performance and training stability.

Upgrading to the latest versions of torch and ultralytics ensures that you benefit from these improvements and helps avoid potential compatibility issues. If you encounter any specific problems or bugs, please provide a minimum reproducible code example as outlined in our documentation. This will help us investigate and address any issues more effectively.

Feel free to continue experimenting and let us know if you have any further questions or need additional assistance. We're here to help! πŸš€