Query regarding calculate_dice function for evaluation

In the calculate_dice function provided in utils.py file, include_backgroundclass=True by default.

Does that mean that the evaluation score is based on all classes INCLUDING THE BACKGROUND CLASS?

Furthermore, are the classes (nine of them) mutually exclusive? If yes, what is the purpose of the following code segment in calculate_dice function?
# Handle edge case where there are no classes to calculate Dice score for
if len(dice) == 0:
return np.nan
Will it ever return NAN?

Hi @bhaskar.dey09,

  1. Background Class Consideration: Yes, the background class is included when calculating your score, which is why the variable is set to True by default.
  2. Class Exclusivity: Ideally, the classes are exclusive. However, in practice, there can be instances where a particular facies is labeled differently in various samples. This discrepancy often arises because different geologists may have differing opinions on the classification of a sediment facies in a sample.

Regarding the len(dice) == 0 scenario, you don’t need to worry. This edge case occurs when the background class is not included in the score calculation, and both the ground truth and predicted masks contain only the background class. In such cases, the sample is discarded and not used in the final score calculation.

Best of luck Segmenting,
The ThinkOnward Team

2 Likes