-
Notifications
You must be signed in to change notification settings - Fork 402
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
More image metrics #799
Comments
i would like to work on this can you assign it to me |
Hi, @Borda Thanks for creating the issue tracker. Would love to help in this, as I also look forward to contributing to the lightning framework. I would like to begin with MSE and RMSE, if that's fine with you and everyone else. Please let me know if I can start working on these two metrics. Thanks! |
@ankitaS11 Please note we already have MSE and RMSE in the regression package: |
cool, which one do you want to take? (we have many ⚡) |
Hi, @SkafteNicki - Got it. Thank you for updating the issue as well, I can try Quality with No Reference then, just want to also make sure that it doesn't collide with @nishant42491. Nishant, curious to know if you have any metric in mind to pick up first? I can pick the others then, if that's okay. |
@Borda @SkafteNicki are we aiming for an integration or a direct torch reimplementation here? |
reimplementation, I put this package just as inspiration for what other image metrics exist... |
I'd think so as well :) @ankitaS11 @nishant42491 You can however use this package for testing :) |
@Borda @ankitaS11 may I start with implementing spatial correlation coefficient first? |
@nishant42491 sure, I'll add you to it. Open a draft PR early and ping us there if you need help :) |
thank you :) |
I would like to work on Relative Average Spectrul Error, it would be a great way for me to learn new stuff. |
Hi, @Borda I was going through the referenced repo ( Do you have any opinions on this? Just wanted to confirm if I'm moving in a right direction here. In a gist, I would like to implement UQI first, and then other metrics if that's okay with you and everyone. |
Hey @ankitaS11 in that case it definitely makes sense to go with your proposed way :) I updated the issue. Just let us know here, when I should assign new metrics to you :) |
Hi @justusschock, I am done with the implementation of |
@Borda I will work on |
@vumichien if I'm not mistaken, SAM is just the arccos of the cosine similarity which is implemented here. |
@vumichien My bad, SAM being an image metric and being about spectral characteristics, it is needed to assume NCHW shape, and using Here is some code as an excuse and to explain myself: Codeimport torch
import torchmetrics
import einops
SPECTRAL_DIM = 1
N, C, H, W = 13, 5, 32, 64
def main():
x = torch.randn(N, C, H, W)
y = torch.randn(N, C, H, W)
sam_index1 = sam_from_torchmetrics_cossim(x, y, reduction="mean")
sam_index2 = sam_from_scratch(x, y, reduction="mean")
assert torch.allclose(sam_index1, sam_index2)
def sam_from_torchmetrics_cossim(pred, target, *, reduction="mean"):
# (..., N, d) required for `torchmetrics.functional.cosine_similarity`
pred_ = einops.rearrange(pred, "n c h w -> n (h w) c")
target_ = einops.rearrange(target, "n c h w -> n (h w) c")
cossim = torchmetrics.functional.cosine_similarity(pred_, target_, reduction="none")
return reduce(cossim.arccos(), reduction=reduction)
def sam_from_scratch(pred, target, *, reduction="mean"):
return reduce(_angle(pred, target, dim=SPECTRAL_DIM), reduction=reduction)
def _angle(x1, x2, *, dim):
return _cosine_similarity(x1, x2, dim=dim).acos()
def _cosine_similarity(x1, x2, *, dim):
x1 = x1 / torch.norm(x1, p=2, dim=dim, keepdim=True)
x2 = x2 / torch.norm(x2, p=2, dim=dim, keepdim=True)
return (x1 * x2).sum(dim=dim).clamp(-1.0, 1.0)
def reduce(x, reduction):
if reduction == "mean":
return x.mean()
if reduction == "sum":
return x.sum()
if reduction is None or reduction == "none":
return x
raise ValueError(
f"Expected reduction to be one of `['mean', 'sum', None]` but got {reduction}"
)
if __name__ == "__main__":
main() |
@Borda It would be great if you can give me some reference regarding Block Sensitive - Peak Signal-to-Noise Ratio (PSNR-B). |
@SkafteNicki could you pls link some good resources? :) |
I can take a stab at Visual Information Fidelity |
Hi @soma2000-lang, |
Hi @Borda, please assign any metric that needs to be implemented to me. I see a lot of people taking a stab at most of them, so any metric which doesn't conflict with others would be great. |
@Borda, Can I add PSNR-B, if someone isn't already working on it? |
@yashika-git I have started working on it |
Great! @soma2000-lang, updated the assignment for you
@yashika-git @theja-vanka how about QNR or VIT? |
@Borda, I'd like to implement Visual Information Fidelity (VIF). |
@Borda, should Intersection over Union (IoU) and Dice Score image metric be added as well? |
yeah, I think we started it somewhere but can't find it now... in such case let's add it :) |
Would you accept a PR for one not on the list? I have an implementation of complex wavelet structural similarity (CW-SSIM) that I could contribute. (https://ieeexplore.ieee.org/abstract/document/5109651) |
Hi @rddunphy , |
F-score and Boundary-IOU would be nice to have. See #1500 |
Would you be interested in adding it? :) |
I am not familiar with the internals/standard of the library but at least I've posted in the ticket a gist to reproduce the mask to boundary util: Then I think that you could use your already available internals F and IOU utils to quickly impl the metrics. |
letss have tried, open PR with a draft with a functional version and then we can help to finish it :) |
@yashika-git How is it going with VIF? Since I currently use the piq implementation and therefore would like a torchmetrics implementation, I can take over. |
@bojobo, please feel free to takeover :) |
Hi @Borda , I was browsing issues and found this topic. I think I can add Spatial Correlation Coefficient (SCC) metric to torchmetrics if it is still needed. I am seeing that previous merge was not successful. I was wondering do you think I can try it ? |
@HoseinAkbarzadeh that would be great! |
Closing issue as all metrics have been implemented. |
🚀 Feature
just found this package and seems we have not yet all Image metrics :]
some inspiration came from https://github.com/andrewekhalel/sewar but we aim on own implementation with
torch
Alternatives
Mean Squared Error (MSE)Root Mean Sqaured Error (RMSE)Peak Signal-to-Noise Ratio (PSNR)Structural Similarity Index (SSIM)Universal Quality Image Index (UQI)Multi-scale Structural Similarity Index (MS-SSIM)Erreur Relative Globale Adimensionnelle de Synthèse (ERGAS)Spatial Correlation Coefficient (SCC)Relative Average Spectral Error (RASE)Spectral Angle Mapper (SAM)Spectral Distortion Index (D_lambda)Spatial Distortion Index (D_S)Quality with No Reference (QNR)Visual Information Fidelity (VIF)Block Sensitive - Peak Signal-to-Noise Ratio (PSNR-B)Additional context
any of these metrics would be a separate PR/addition :]
The text was updated successfully, but these errors were encountered: