image-segmentation-keras icon indicating copy to clipboard operation
image-segmentation-keras copied to clipboard

Ignore background class

Open silvernox-dev opened this issue 3 years ago • 3 comments

I have a background class masked as '0'. I do not want to train it so I use flag 'ignore_zero_class' but the accuracy doesn't increase beyond 3%.

silvernox-dev avatar Sep 23 '21 22:09 silvernox-dev

I have a made quite a few changes now to make it work on binary classification for just 1 class -

  1. Updated activation to 'sigmoid'
  2. Made changes in data_loader.py so that it works with n_classes = 1 (instead of 2 which was required originally)
  3. Loss - Implemented dice loss
  4. Metric - Implemented IOU

Since >95% of the pixels was background class, the metrics that were presented by the authors were not correctly representating the training progress in my case. Hence I made the additional implementations. Planning to incorporate the Focal Loss as well. The training seems to be going fine, will post results after it is completed

silvernox-dev avatar Sep 24 '21 20:09 silvernox-dev

With all these changes, there’s areas outside the code base where the issue(s) could be. You also didn’t provide any of the new code so no one can really help besides saying double check your work.

Also softmax works for binary and multiclass. Since dice and iou is meant for class imbalanced data, I don’t see a reason for going through the hassle of ignoring the background class in a binary problem.

mavaylon1 avatar Nov 29 '21 19:11 mavaylon1

My point of doing this was to reduce the strain on the network, and make the network focus only on the necessary areas. The code required very minor changes as I explained above.

silvernox-dev avatar Apr 20 '22 22:04 silvernox-dev