Based on U-net architecture, trained on Pannuke dataset.
Input image & predicted mask resolution: 256x256
U-Net: Convolutional Networks for Biomedical Image Segmentation
Loss Function:
def Dice_Loss(y_true, y_pred):
y_true = tf.cast(y_true, tf.float32)
y_pred = tf.cast(y_pred, tf.float32)
inter = tf.math.multiply(y_true, y_pred)
union = tf.math.divide(tf.math.add(
tf.reduce_sum(y_true), tf.reduce_sum(y_pred)), 2)
score = tf.math.divide(tf.reduce_sum(inter), tf.reduce_sum(union))
loss = tf.math.subtract(tf.constant(1.0), score)
return loss
Loss function inspired from: Using Intersection over Union loss to improve Binary Image Segmentation
Metric:
def Dice_Score(y_true, y_pred):
y_true = tf.cast(y_true, tf.float32)
y_pred = tf.math.greater(y_pred, 0.5)
y_pred = tf.cast(y_pred, tf.float32)
inter = tf.math.multiply(y_true, y_pred)
union = tf.math.divide(tf.math.add(
tf.reduce_sum(y_true), tf.reduce_sum(y_pred)), 2)
score = tf.math.divide(tf.reduce_sum(inter), tf.reduce_sum(union))
return score
Original Dataset (Numpy format)
Exported Dataset (PNG format) and Pretrained Model (TensorFlow)