Search code examples
pythonpytorchcomputer-visionimage-segmentationfast-ai

fastai - Multiclass metric for Image Segmentation


I’m currently exploring how to apply Dice metric to a multiclass segmentation problem with fastai. I checked the concepts and discovered that Dice is really similar to the F1Score. Following this, I have two questions regarding their implementation in fastai.metrics :

  • How different are the dice() and fbeta(beta=1) outputs ?
  • Is the MultiLabelFbeta class okay for multilabel image segmentation use cases ?
  • If not, is there a metric already existing that could help me ?

Thank you very much and have a good day !


Solution

    1. The Dice metric should normally be equal to FBeta(beta=1). Depending on the framework, there may be slight differences in the implementation. However, since these are by nature very similar, they can be used interchangeably as metrics for your problem.

    2. MultiLabelFBeta can be used if you have multiple overlapping masks. That is, if your segmentation labels are not mutually exclusive.

    For example, a dog and a cat have pixels that are mutually exclusive(i.e. a pixel belonging to a cat will never belong to a dog and vice-versa). However, if you have the class 'T-shirt' and 'Human' then it is evident that you have overlapping: people wear t-shirts, so a pixel that belongs to T-Shirt may very well belong to a human being.

    1. Pay attention to the nomenclature! MultiLabel is different from MultiClass. In case of the latter, the labels are mutually exclusive; in case of the former, they are not (T-Shirt + Human example).

    If you have a multi-class segmentation problem, then Dice/FBeta are relevant metrics. If you have a multi-label segmentation problem, then MultiLabelFbeta is a good metric.