qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.7k stars 1.03k forks source link

How to train independent multi-classes? #308

Open datvuthanh opened 4 years ago

datvuthanh commented 4 years ago

Hi, I have a problem about how to train independent classes. That mean, I have many classes: Road, Line, traffic signs (Left,Right,Straight). goodgame_raw_965 And this mask goodgame_raw_965_L But, I want to classify and segment traffic sign with label one class in image. That looks like: goodgame_bien_bao_raw_3950 goodgame_bien_bao_raw_3950 If I label all classes in image. This makes me take long time. I want to label fast, so I label lots of frames have only traffic sign. My goal is predict all classes in image. How to train, which loss function and metrics I need? Thank you very much!

JordanMakesMaps commented 4 years ago

There isn't a way to get around labeling your data unless you have the money to pay someone else to do it for you. For the traffic signs (and maybe even the roads), you might be able to re-purpose real world datasets for training self-driving cars, and only keep the labels that correspond to traffic signs and road.

Something else you can try is training a segmentation model on one of those datasets, then once fully trained, use it to label your own private dataset and keep the labels to train another segmentation model.

If you have multiple classes you should start with using one of the categorical loss functions, maybe start with categorical cross-entropy and included weights for your classes since they are going to be unbalanced.

Metrics depends on you, what's most important. But IOU, Dice, Precision and Recall are all good, Pixel Accuracy is the only one I tell people to not put so much emphasis on because it's misleading.

Training is as easy as following the steps on the repo's readme page and also the notebooks in the examples folder.