-
Notifications
You must be signed in to change notification settings - Fork 419
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
Online SSIM and MS-SSIM Computation #1231
Conversation
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
for more information, see https://pre-commit.ci
I'm not sure what the best way to fix the mypy failure is, would appreciate some guidance on that. Explicitly annotating the variable as a |
@SkafteNicki I could use some eyes on this, I've been using it in production and it seems to work well |
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems strange to me, that compute
is called in update
(this kind of breaks our paradigm), although the implementation seems to be correct.
Could you also add tests against pytorch-mssim as this seems to also support batching (which is lacking in sklearn)? |
Yeah I will add tests against pytorch_msssim, do you want to leave the sklearn tests in place? BTW we found an interesting issue with pytorch_msssim while testing this PR internally. It really doesn't play nice with fp16 AMP. Torchmetrics handles it much better. Irrelevant for the test cases but thought I would point it out |
There should be a way to refactor it so that it looks more like the PSNR metric which does an I'm fine implementing that refactor if you want |
Just following up, my plan is to do the following
|
Ideally yes, as this is the most trusted lib for non-batched stuff. Maybe we can then reduce the tests compared to sklearn and add the more thorough testing with the other lib, but some sklearn tests should stay.
Sounds good to me! |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1231 +/- ##
========================================
- Coverage 86% 37% -49%
========================================
Files 193 193
Lines 11372 11406 +34
========================================
- Hits 9754 4245 -5509
- Misses 1618 7161 +5543 |
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
for more information, see https://pre-commit.ci
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
OK I did the refactoring we discussed and added test cases for SSIM against pytorch-msssim (the MS-SSIM tests were already using it) |
for more information, see https://pre-commit.ci
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing. this refactor! LGTM!
What does this PR do?
Working on #1224
Fixes #1213
This PR fixes SSIM and MS-SSIM by allowing them to compute using running stats. This will make them actually usable in real situations.
Also I fixed several bugs that I found in these modules and changed the defaults to match pytorch-msssim
All tests should pass but to be honest I'm not sure how good those tests were anyway
I verified that this matches the known-good pytorch-mssim library to ~6 decimal places with default settings which was not the case before and I will be using this code in production in the coming week to see how it does.
Before submitting
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 🙃