Yolov5: Custom dataset with imbalanced classes.

Created on 24 Jul 2020  路  6Comments  路  Source: ultralytics/yolov5

鉂擰uestion

I have a custom dataset that has imbalanced classes: ~10K A, ~10K B, and ~100 C. It is hard to detect C class in the test set. The bounding box works on C object but with wrong lables. Is there anyway to add weight to the C class in the loss function? Or is there any other solution to increase the detection of C class?
Thank you!

Additional context

question

All 6 comments

Hello @weihuangxu, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

@weihuangxu sure, there's a number of methods that you can research online, but none of them work as well as simply collecting more training data for your underrepresented classes.

@glenn-jocher Thanks for the quick response. Unfortunately, we don't have extra data available for underrepresented classes. I found a solution to partially solve my issue.

Hi @weihuangxu, I have a similar issue with imbalanced classes in my dataset. How did you solve the issue? Did you change the class weights in the loss fx? Thanks in advance.

Hi @gizemtanriver, can you tell me where should i change the class weight?

Hi @Raian-Rahman, I actually ended up using only one of the classes in my dataset. So I am not sure how to change the class weights. Perhaps have a look at the labels_to_class_weights function in utils-->general.py.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KangHoyong picture KangHoyong  路  3Comments

linhaoqi027 picture linhaoqi027  路  4Comments

cswwp picture cswwp  路  4Comments

abhiksark picture abhiksark  路  3Comments

we1pingyu picture we1pingyu  路  3Comments