-
-
Save harshnandwana/85fc8c19633b40921d8c9e873082ce7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow.keras.backend as K | |
def dice_coef(y_true, y_pred): | |
y_truef=K.flatten(y_true) | |
y_predf=K.flatten(y_pred) | |
And=K.sum(y_truef* y_predf) | |
return((2* And + 100) / (K.sum(y_truef) + K.sum(y_predf) + 100)) | |
def dice_coef_loss(y_true, y_pred): | |
return 1-dice_coef(y_true, y_pred) | |
def iou(y_true, y_pred): | |
intersection = K.sum(y_true * y_pred) | |
sum_ = K.sum(y_true + y_pred) | |
jac = (intersection + 100) / (sum_ - intersection + 100) | |
return jac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment