Advanced loss manipulation in YOLO #15710
Unanswered
ShaharJamshy
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
@ShaharJamshy thank you for reaching out. For advanced loss manipulation in YOLOv8, you can customize the loss function by modifying the training script. To handle class imbalance, consider using focal loss or class weighting. For uncertain labels, you can implement a "don't care" class by adjusting the loss computation to ignore certain classes. Label smoothing can indeed help with class distribution issues. For detailed guidance, please refer to the Ultralytics documentation. If the issue persists, ensure you are using the latest version of the package. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I’m a computer vision researcher at Scopio Labs (https://scopiolabs.com/), we are looking into YoloV8 to detect blood cells in images.
We encountered some challenges that we would like to solve using more advanced logic on the loss function, and were wondering what would be the best way to implement these solutions within the Ultralytics framework.
Examples for scenarios we want to address:
We want efficiently train a detector when the classes for the detected object are highly skewed, and we want to include enough examples of the low prevalence class without investing a lot effort labeling the high prevalence class
If we want a good coverage of the different white blood cells types in the training data we would need to sample a large number of images, labeling all the red blood cells for all these images would be impractical.
This means we have a lot of images where only white blood cells (the purple box) are labeled, and none of the red blood cells (red boxes) are.
One idea we had was, that for the images where we know only white blood cells were labeled we would ignore the loss term for every false detection that isn’t classified as a white blood cell.
Another slightly different challenge is how can we train a detector where not all the class labels are well defined
There are many cases where we have cells which are hard to label, our labelers might have difficulty deciding between a subset of the classes or even be very uncertain about the class at all.
For example, in the images below the cell in the left and right images are clear examples of two stages in the cell development process (Band and Segmented Eosinophils) while the cell in middle image is somewhat in between and hard to label.
Nevertheless, we do want instances similar to the cell in the middle image to be detected, but we want to be able to avoid providing any class information which might be inaccurate.
We thought one way to implement it is to introduce a “don’t care” class, and ignore the detection class loss for all the examples which are labeled with this class.
Given our labeled data does not accurately reflect the prevalence of the different classes in the images, we were wondering if using label smoothing to add a prior with the correct distribution would help improve our performance.
We'll greatly appreciate any insight you might have on how to implement these in Yolo, or any other ideas or feedback you might have to address these challenges.
Beta Was this translation helpful? Give feedback.
All reactions