Skip to content
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

Implement automatic class weight calculation for imbalanced distributions #2814

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

AjibolaPy
Copy link

@AjibolaPy AjibolaPy commented May 25, 2023

This pull request addresses #2703, introducing automatic class weight calculation for imbalanced datasets in the YOLOv8 project, specifically in the classification trainer. It improves model performance by dynamically determining class weights based on dataset analysis. Underrepresented classes receive higher weights, while overrepresented classes receive lower weights. Manual weight adjustments are no longer needed, streamlining the workflow and enhancing classification effectiveness. Thorough testing confirms significant improvements.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

📊 Key Changes

  • A new function class_weight has been implemented for automatic class weight calculation.
  • This function is integrated into the training process to handle class imbalance issues.
  • Manual class weight input is also accommodated as an option.

🎯 Purpose & Impact

  • The purpose is to improve model training where there is an imbalance in class distributions within the dataset.
  • Automatically computed class weights help to give minority classes more weight in the loss computation, potentially improving model accuracy on such classes.
  • Users dealing with imbalanced datasets will benefit from this update, as it can improve fairness and generalization of the model.

🌟 Summary

"New feature to automatically calculate class weights for imbalanced datasets during model training, promoting better performance for minority classes." 🏋️‍♂️📈

@github-actions
Copy link

github-actions bot commented May 25, 2023

CLA Assistant Lite bot All Contributors have signed the CLA. ✅

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hello @AjibolaPy, thank you for submitting a YOLOv8 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with ultralytics/ultralytics main branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • ✅ Verify all YOLOv8 Continuous Integration (CI) checks are passing.
  • ✅ Update YOLOv8 Docs for any new or updated features.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

See our Contributing Guide for details and let us know if you have any questions!

@AjibolaPy
Copy link
Author

I have read the CLA Document and I sign the CLA

1 similar comment
@AjibolaPy
Copy link
Author

I have read the CLA Document and I sign the CLA

Copy link
Author

@AjibolaPy AjibolaPy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused imports

Copy link
Author

@AjibolaPy AjibolaPy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused imports

Copy link
Author

@AjibolaPy AjibolaPy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused import

Copy link
Author

@AjibolaPy AjibolaPy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed block "#"

Copy link
Author

@AjibolaPy AjibolaPy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed class_weight arg

Copy link
Author

@AjibolaPy AjibolaPy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants