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

Dice score as metric #1021

Merged
merged 42 commits into from May 16, 2022
Merged

Conversation

MrShevan
Copy link
Contributor

@MrShevan MrShevan commented May 10, 2022

What does this PR do?

Fixes #992

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

Hey, looking pretty good already! Thanks a lot for your implementation!
Left some minor comments. Most of them are just to use immutable types if possible :)

The only one that concerns me a bit is the one about testing :)

torchmetrics/classification/dice.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/dice.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/dice.py Outdated Show resolved Hide resolved
torchmetrics/classification/dice.py Outdated Show resolved Hide resolved
tests/classification/test_dice.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 10, 2022

Codecov Report

Merging #1021 (508fbe1) into master (6b96ebf) will decrease coverage by 0%.
The diff coverage is 80%.

@@          Coverage Diff           @@
##           master   #1021   +/-   ##
======================================
- Coverage      95%     95%   -0%     
======================================
  Files         180     181    +1     
  Lines        7828    7873   +45     
======================================
+ Hits         7435    7468   +33     
- Misses        393     405   +12     

@justusschock
Copy link
Member

Also: should we update the jaccard implementation to rely on this implementation? Calculating them like this should be faster than computing a whole conf map and J = D/(2-D)

cc @SkafteNicki

@SkafteNicki
Copy link
Member

@justusschock I would be fine on relying on the Jaccard implementation for this, however I think we should be careful extrapolating the J = D/(2-D) to all cases. I am not completely sure that this formula holds when you take class averaging, multidim averaging etc. into account. That at least need to be checked.

@Borda Borda added the enhancement New feature or request label May 10, 2022
@MrShevan
Copy link
Contributor Author

@justusschock, May I ask you for help?) I see that all failing checks caused by installing of dependencies. Could this be related to using scipy? Should I add something in PR to avoid it?

@justusschock
Copy link
Member

@Borda mind having a look on failing audio deps?

@SkafteNicki SkafteNicki added this to the v0.9 milestone May 11, 2022
@Borda Borda enabled auto-merge (squash) May 12, 2022 14:54
type fix

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
@justusschock
Copy link
Member

One more thing left to do from my side and then it's ready to go :)

Can you raise a deprecationwarning in the older implementation asking users to switch to the newer one?

@MrShevan
Copy link
Contributor Author

@justusschock thank you for your comment :) I've added deprecation warning.

@mergify mergify bot added the ready label May 15, 2022
MrShevan and others added 2 commits May 15, 2022 16:50
add DeprecationWarning

Co-authored-by: Justus Schock <12886177+justusschock@users.noreply.github.com>
torchmetrics/classification/dice.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/dice.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/dice.py Outdated Show resolved Hide resolved
torchmetrics/classification/dice.py Show resolved Hide resolved
MrShevan and others added 9 commits May 15, 2022 17:15
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
…o dice_metric_as_state_scores

# Conflicts:
#	torchmetrics/functional/classification/dice.py
@Borda Borda merged commit af5af72 into Lightning-AI:master May 16, 2022
@justusschock
Copy link
Member

@Borda there are plenty of tests that did not run on this PR. Why did you merge it like that?

@MrShevan
Copy link
Contributor Author

@justusschock Did I forget something? I can open a new one and add the necessary tests. This will be inside v0.9

@justusschock
Copy link
Member

No, it's fine now, I restarted the tests and they passed, they just weren't finished when this was merged :D

@MrShevan
Copy link
Contributor Author

Oh, i got it :) thanks for all your advice @Borda @justusschock @SkafteNicki! I get a lot of experience working on your project

@Borda
Copy link
Member

Borda commented May 16, 2022

Why did you merge it like that?

I did auto-merge so all suppose to be fine at that time... or what I missed?

@justusschock
Copy link
Member

Almost all our CI configs are not strictly required, but they didn't even run (canceled for some reason)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could you implement Dice score as metric
4 participants