Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit -- Adding calibration loss specific to segmentation #7819

Merged
merged 54 commits into from
Aug 8, 2024

Conversation

Bala93
Copy link
Contributor

@Bala93 Bala93 commented Jun 2, 2024

Description

Model calibration has helped in developing reliable deep learning models. In this pull request, I have added a new loss function NACL (https://arxiv.org/abs/2303.06268, https://arxiv.org/abs/2401.14487) which has shown promising results for both discriminative and calibration in segmentation.

Future Plans: Currently, MONAI has some of the alternative loss functions (Label Smoothing, and Focal Loss), but it doesn't have the calibration specific loss functions (https://arxiv.org/abs/2111.15430, https://arxiv.org/abs/2209.09641). Besides, these methods are better evaluated with calibration metrics, Expected Calibration Error (https://lightning.ai/docs/torchmetrics/stable/classification/calibration_error.html).

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Bala93 and others added 10 commits June 1, 2024 22:11
Fix the order of loss function in import statement
Fixed the formatting and minor issues.
Reorder import statements
Reorder system imports.
isort inferred one
Updated class name according to standard
Fixed the inline comment
Add datatype in functions and classes
Copy link
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I had a few comments, and the CICD errors are easy fixes I think. The test fail is from accuracy it seems which can be fixed by changing the error.

monai/losses/segcalib.py Outdated Show resolved Hide resolved
monai/losses/segcalib.py Outdated Show resolved Hide resolved
monai/losses/segcalib.py Outdated Show resolved Hide resolved
monai/losses/segcalib.py Outdated Show resolved Hide resolved
monai/losses/segcalib.py Outdated Show resolved Hide resolved
@ericspod ericspod requested a review from KumoLiu June 13, 2024 14:34
Bala93 and others added 18 commits June 14, 2024 06:32
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
Add model description.
Fixed the initialization issues with return types
Use Any instead of tensor
Import typing
Fix return type formatting
Bala93 and others added 7 commits August 5, 2024 14:25
DCO Remediation Commit for bala93 <balamuralim.1993@gmail.com>
I, Balamurali <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: c4f8283
I, bala93 <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: 8fbec82
I, bala93 <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: 7c121a0
I, bala93 <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: dccde47

Signed-off-by: bala93 <balamuralim.1993@gmail.com>
DCO Remediation Commit for bala93 <balamuralim.1993@gmail.com>

I, bala93 <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: 8fbec82
I, bala93 <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: 7c121a0
I, bala93 <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: dccde47

Signed-off-by: bala93 <balamuralim.1993@gmail.com>
DCO Remediation Commit for Balamurali <balamuralim.1993@gmail.com>

I, Balamurali <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: bc6b995

Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
DCO Remediation Commit for Balamurali <balamuralim.1993@gmail.com>

I, Balamurali <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: bc6b995

Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
I, bala93 <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: 3a00aec

Signed-off-by: bala93 <balamuralim.1993@gmail.com>
@Bala93
Copy link
Contributor Author

Bala93 commented Aug 5, 2024

Hi @Bala93 I have a few further comments, the fixes for the mypy issues should be minor and the DCO page tells you how to address that. Thanks!

Hi @ericspod, Thanks for your feedback. I have addressed all the issues. I will work on using the monai functions (for the gaussian, and mean) in some time. Until then, is it possible to merge it with the dev branch and make the loss function available ? Thank you.

@Bala93 Bala93 requested a review from ericspod August 5, 2024 23:50
docs/source/losses.rst Outdated Show resolved Hide resolved
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
Copy link
Contributor

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Overall looks good to me. Several minor inline comments.

monai/losses/nacl_loss.py Outdated Show resolved Hide resolved
monai/losses/nacl_loss.py Outdated Show resolved Hide resolved
monai/losses/nacl_loss.py Outdated Show resolved Hide resolved
monai/losses/nacl_loss.py Outdated Show resolved Hide resolved
monai/losses/nacl_loss.py Outdated Show resolved Hide resolved
monai/losses/nacl_loss.py Show resolved Hide resolved
tests/test_nacl_loss.py Outdated Show resolved Hide resolved
Bala93 and others added 2 commits August 7, 2024 01:24
* Modify the code with MeanFilter, and GaussianFilter of MONAI layers
* Add Doc string explaining the mask preparation

Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
@Bala93
Copy link
Contributor Author

Bala93 commented Aug 7, 2024

Hi @KumoLiu @ericspod. I have addressed the comments with the latest commit. Please feel free to resolve the comments if deemed solved. Thanks for your prompt response.

Copy link
Contributor

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick update, few further comments inline.

monai/losses/nacl_loss.py Outdated Show resolved Hide resolved
monai/losses/nacl_loss.py Outdated Show resolved Hide resolved
monai/losses/nacl_loss.py Show resolved Hide resolved
Bala93 and others added 2 commits August 7, 2024 06:27
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
@ericspod
Copy link
Member

ericspod commented Aug 7, 2024

Looks good now to me with the last minor comments addressed.

Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
DCO Remediation Commit for Balamurali <balamuralim.1993@gmail.com>

I, Balamurali <balamuralim.1993@gmail.com>, hereby add my Signed-off-by to this commit: 7deb2cc

Signed-off-by: Balamurali <balamuralim.1993@gmail.com>
@Bala93 Bala93 requested a review from KumoLiu August 8, 2024 06:32
Copy link
Contributor

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick update, looks good to me now. Will trigger more tests and try to merge this one.

@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 8, 2024

/build

@KumoLiu KumoLiu merged commit 660891f into Project-MONAI:dev Aug 8, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants