-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
feat(Detection): add pos_weight parameter in BCEWithLogitsLoss #8620
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #8620 +/- ##
==========================================
- Coverage 74.29% 70.13% -4.16%
==========================================
Files 124 124
Lines 15699 15699
==========================================
- Hits 11663 11010 -653
- Misses 4036 4689 +653
Flags with carried forward coverage won't be shown. Click here to find out more. β View full report in Codecov by Sentry. |
For the record, just noticed #7655 appears to be relegated/similar |
@nattigt this feature has not yet been reviewed or released. You will see it marked as "merged" when or if it is included with the main Ultralytics branch. If you wish to use this note, you should check out our clone this Pull Request (PR). I can't tell you a timeline when this may be reviewed or added, but I just have tried to provide feedback to assist the contributor that will make it easier for the Team to review this PR. |
Can you expand on how best to use this?
Do I make a near exact representation to balance, and simply train my model like so?: Thanks in advance, sorry if this is the wrong place. |
@manicmojo hello there! π No worries, you're definitely in the right place for asking questions. π Yes, you've got the gist of how to use Your approach to calculate the Just a quick note, depending on the version of YOLOv8 you're using (since it's continuously being improved and updated), make sure to sync with the latest documentation or the specific Pull Request (PR) instructions for applying Quick example to set # Assuming this is part of your YOLOv8 model config file
pos_weight: [108.44, 316.44, ..., 138.09] And then, you would proceed to train your model as usual. Remember, handling class imbalance is a bit of trial and error, so you might need to adjust your weights and observe the results. I hope that helps! If you have more questions, feel free to ask. Happy training! π |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'd appreciate this to be released.
Thanks for this contribution - would be great to have this merged into main |
@austy81 and @CourchesneA could you both add a π to the original PR comment? I think it would be a great way to show what PRs the community have the most interest in seeing added (hoping I can get this to be something official). |
This is the new PR following this conversation: #8557
Related issues:
π οΈ PR Summary
Made with β€οΈ by Ultralytics Actions
π Summary
Added
pos_weight
hyperparameter to address class imbalance in model training.π Key Changes
pos_weight
parameter in the training documentation.default.yaml
) introducingpos_weight
as a configurable list.loss.py
file to implementpos_weight
in theBCEWithLogitsLoss
.π― Purpose & Impact
pos_weight
parameter aims to provide a mechanism to give more importance to positive examples during training, addressing scenarios with class imbalance.pos_weight
into the loss function, model training can achieve more balanced performance across classes, potentially improving accuracy for underrepresented classes.