Ignite: Adding Dice Coefficient Metric for Image Segmentation

Created on 13 Dec 2018  路  13Comments  路  Source: pytorch/ignite

I wanted to implement Dice Coefficient as a metric for image segmentation problems. any interest?

good first issue help wanted

All 13 comments

@anmolsjoshi yes, please send a PR

@vfdev-5 thanks. i'll add it to ignite.contrib.metrics

@vfdev-5 were you thinking a binary or categorical implementation for this?

I've mainly seen binary implementations only, but a few blog posts mention categorical.

@anmolsjoshi maybe it would be more interesting to implement Tversky index - generalization of Dice and Jaccard.
Categorial index makes sens too, we can tryout to implement both :)

@vfdev-5 working on this now, found an implementation here - https://github.com/kevinzakka/pytorch-goodies/blob/master/losses.py#L131-L175

Idea is that we create a general Tversky Index Metric, and then create children Metrics such as Jaccard Index and Dice Coefficient by forcing values of alpha and beta.

Tversky loss is indeed more interesting and offer more flexibility afterwards with fixed alpha and beta values.
Does using the Confusion Matrix object the best way to implement this or inheriting from _BaseClassification is better ?

@anmolsjoshi sorry, I haven't notice your link on kevinzakka's repo. His implementation seems like to be image-wise and can not be used in our update-compute paradigm.

@pldelisle we think to implement it using a confusion matrix and provide it as IoU or mIoU methods... @anmolsjoshi should be working on it...

I have also been working a bit on this (needed to implement Dice coefficient for my own project, then stumbled on this library which proposes a pretty good structure, so I decided to contribute). I've done it for the Dice Coefficient, but I struggle a bit for the Tversky Index and the relative complement.

As I can understand, the relative complement is the position N_xy in the diagonal where x=y minus everything else, for each position in the diagonal.

I just don't know how to implement this using the confusion matrix while taking into account the possibility of adding weights to each class.

Hi @vfdev-5 , I am looking to contribute to ignite.
Could you please help me by detailing out this issue please? I have gone through the conversation but couldn't understand it exactly. Would be of great help to me.

Thank you

Hi @PyExtreme thanks for the proposition.
Idea here is to provide precoded Dice Coefficient metric. It is more simple to start from Confusion Matrix and implement Dice Coefficient as it is done for IoU.
Please, take a look at our contributing rules and feel free to ask if you have a question.

@pldelisle thanks for the link, looks good !

Btw, I wonder what is the purpose of this kerosene more higher level API framework ?
Would not be better to enhance contrib module with such higher level abstractions ?

The goal of Kerosene was to support the multi-GPU and mixed precision features of Pytorch Lightning while keeping the flexibility of ignite (No strict interface for user defined models). The template method in the trainer let the user only focus on the model and makes it very simple to train new model architecture with multi-gpu, mixed-precision and automatic Visdom logging (only a model and a config file is required). We use the library at our research lab, and it's still under development.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alykhantejani picture alykhantejani  路  3Comments

Aiden-Jeon picture Aiden-Jeon  路  3Comments

andreydung picture andreydung  路  4Comments

sisp picture sisp  路  3Comments

UjwalKandi picture UjwalKandi  路  3Comments