panel_segmentation.panel_train.TrainPanelSegmentationModel.diceCoeff

TrainPanelSegmentationModel.diceCoeff(y_true, y_pred, smooth=1)[source]

Accuracy metric is overly optimistic. IOU, dice coefficient are more suitable for semantic segmentation tasks. This function is used as the metric of similarity between the predicted mask and ground truth.

Parameters
  • y_true (nparray float) – the true mask of the image

  • y_pred (nparray float) – the predicted mask of the data

  • smooth (int) – a parameter to ensure we are not dividing by zero and also a smoothing parameter. For back propagation. If the prediction is hard threshold to 0 and 1, it is difficult to back propagate the dice loss gradient. We add this parameter to actually smooth out the loss function, making it differentiable.

Returns

dice – The metric of similarity between prediction and ground truth

Return type

float