-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
add pos_weight hyperparameter for dealing with imbalanced dataset #2703 #8557
Conversation
CLA Assistant Lite bot All Contributors have signed the CLA. ✅ |
I have read the CLA Document and I sign the CLA |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8557 +/- ##
==========================================
+ Coverage 75.74% 75.75% +0.01%
==========================================
Files 117 117
Lines 14693 14695 +2
==========================================
+ Hits 11129 11132 +3
+ Misses 3564 3563 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@hulkds thank you for your work! I don't have final say on if your changes will get integrated or not, but I'd like to provide some feedback for you to help improve the chances that it could get accepted. I have not tested the new code, these are just pointers from my review of the changes made.
|
@hulkds , please answer Burhan-Q's questions. We all are waiting for your improvement to be implemented. In particular those of us who use Google Colab right now have no workarounds except for over\undersampling. For his 3rd question i think it's user responsibility to use correct weights. Default weights must be ones anyway. |
@Burhan-Q thanks for your feedback!
|
@hulkds thanks for the follow up! I checked out this PR and was able to verify that it works as well for both the case when adding weights or using the default value. I tested with the It would be preferable if you could checkout this PR or push commits to your fork for the documentation updates so that everything is included with a single PR. This will help to ensure your PR has the best chance to get accepted (I can't say for certain it will tho). |
@Burhan-Q |
@hulkds yes your updates look like they should be okay. The reason I mentioned the other tasks is because they inherit from the ultralytics/ultralytics/utils/loss.py Line 250 in 906b8d3
I checked the results from the existing training (without |
This PR add a new feature to Ultralytics YOLOv8 Detection by adding pos_weight to the BCEWithLogitsLoss for dealing with imbalanced dataset.
I have read the CLA Document and I hereby sign the CLA
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Addition of class imbalance handling with
pos_weight
in loss calculation.📊 Key Changes
pos_weight
in the default settings (default.yaml
).loss.py
to consider thepos_weight
for the binary cross-entropy calculation.🎯 Purpose & Impact