I'm solving a binary segmentation problem with Keras (w. tf backend). How can I add more weight to the center of each area of mask?
I've tried dice coef with added cv2.erode()
, but it doesn't work
def dice_coef_eroded(y_true, y_pred):
kernel = (3, 3)
y_true = cv2.erode(y_true.eval(), kernel, iterations=1)
y_pred = cv2.erode(y_pred.eval(), kernel, iterations=1)
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
intersection = K.sum(y_true_f * y_pred_f)
return (2. * intersection + 1) / (K.sum(y_true_f) + K.sum(y_pred_f) + 1)
Keras 2.1.3, tensorflow 1.4