[Python] Good performance with Accuracy but not with Dice loss in Image Segmentation

Discussão em 'Python' iniciado por Stack, Dezembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    I'm doing image segmentation with U-Net like architecture on Tensorflow w/Keras but I'm new in Deep Learning.
    I've got this dataset with the following set shapes:

    • Train : X : (175250, 30, 30, 6) Y: (175250, 30, 30)
    • Validation: X: (29200, 30, 30, 6) Y: (29200, 30, 30)
    • Test : X: (29200, 30, 30, 6) Y: (29200, 30, 30)

    Got some examples of these images and each channel, further down.

    --> with 20% positive examples and 80% negative examples equally in each set

    I run some series but for the best filter combination it made the plot for BCE with good accuracy: [​IMG]

    The plot for custom functions, Dice_Loss by Dice_Coeff:

    [​IMG]

    And some images generated from the best model trained with test images:

    [​IMG]

    The problem is when I change to dice loss and coefficient, there aren´t good predictions as we seen in the image plot and now it isn´t in the image prediction as we may see. [​IMG]

    Why it performs so badly in the dice loss? What other function do you recommend?

    My dice loss and coefficient function:


    def dice_coeff(y_true, y_pred, smooth=1):
    intersection = K.sum(K.abs(y_true * y_pred), axis=-1)
    return (2. * intersection + smooth) / (K.sum(K.square(y_true),-1) + K.sum(K.square(y_pred),-1) + smooth)


    def dice_loss(y_true, y_pred):
    return 1-dice_coeff(y_true, y_pred)​

    Continue reading...

Compartilhe esta Página