Skip to content

[ISBI2020] Kappa loss for skin lesion segmentation in fully convolutional network

License

Notifications You must be signed in to change notification settings

jizhang02/Kappa-loss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Kappa-loss

In this work, we propose a metric-inspired loss function, based on the Kappa index. Unlike the Dice loss, a standard loss used in image segmentation CNN, the Kappa loss takes into account all the pixels in the image, including the true negative.

👉 The method has been accepted in ISBI2020, Slides.
👉 The paper can be viewed on ResearchGate.
👉 Formula:

👉 Code:

TensorFlow

import tensorflow as tf

def Kappa_loss(y_true, y_pred, N=224*224):
    Gi = tf.reshape(y_true, shape=(-1,))
    Pi = tf.reshape(y_pred, shape=(-1,))
    numerator = 2 * tf.reduce_sum(Pi * Gi) - tf.reduce_sum(Pi) * tf.reduce_sum(Gi) / N
    denominator = tf.reduce_sum(Pi * Pi) + tf.reduce_sum(Gi * Gi) - 2 * tf.reduce_sum(Pi * Gi) / N
    loss = 1 - numerator / denominator
    return loss

Keras

import keras
from keras import backend as K

def Kappa_loss(y_true, y_pred, N=224*224):
    Gi = K.flatten(y_true)
    Pi = K.flatten(y_pred)
    numerator = 2 * K.sum(Pi * Gi) - K.sum(Pi) * K.sum(Gi) / N
    denominator = K.sum(Pi * Pi) + K.sum(Gi * Gi) - 2 * K.sum(Pi * Gi) / N
    loss = 1 - numerator / denominator
    return loss

PyTorch

import torch

def Kappa_loss(outputs, targets,  N=224*224):
    outputs = outputs.view(-1)
    targets = targets.view(-1)
    numerator = 2 * (outputs * targets).sum() - outputs.sum() * targets.sum / N
    denominator = (outputs * outputs).sum() + (targets * targets).sum() - 2 * (outputs * targets).sum() / N
    loss = 1 - numerator / denominator
    return loss

Requirements

  • Python 3.*
  • Tensorflow or Keras or Pytorch

Citation

@inproceedings{zhang2020kappa,  
  title={Kappa loss for skin lesion segmentation in fully convolutional network},  
  author={Zhang, Jing and Petitjean, Caroline and Ainouz, Samia},  
  booktitle={2020 IEEE 17th International Symposium on Biomedical Imaging (ISBI)},  
  pages={2001--2004},  
  year={2020},  
  organization={IEEE}  
}

About

[ISBI2020] Kappa loss for skin lesion segmentation in fully convolutional network

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published