Tramac / awesome-semantic-segmentation-pytorch

Semantic Segmentation on PyTorch (include FCN, PSPNet, Deeplabv3, Deeplabv3+, DANet, DenseASPP, BiSeNet, EncNet, DUNet, ICNet, ENet, OCNet, CCNet, PSANet, CGNet, ESPNet, LEDNet, DFANet)
Apache License 2.0
2.82k stars 581 forks source link

About the per class IoU #86

Open pengjizhi opened 4 years ago

pengjizhi commented 4 years ago

Hello author! Thank you for your hard work. I have some questions about the calculation of per class IoU.

  1. In the core/utils/score.py, the mIoU = area_inter / area_union. In this calculation method, how should I calculate the IoU of per class?

  2. For the voc12-segmentation dataset, there are 21 classes. Should I remove the background class when calculating mIoU, does your calculation method take the background class into account?

  3. When training the voc12-segmentation dataset, the background class number is 0, should I set ingore index = 0 in loss function(default is -1)?

I will be very grateful if you could give me a favor.

Tramac commented 4 years ago

Hi, my opinion is as follows:

  1. The mean value was calculated in thie line, IoU contains the values of per class.
  2. Both are ok, I have seen some articles comparing two mIoU at the same time (such as DRN). If your dataset is class-imbalance, I suggest to remove the background.
  3. In most cases, the background is not necessary to ignore for VOC datasets.