You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having a few issues with the implementation of Spectral Distortion Index.
Since SDI is a reference free metric for super-resolution, the inputs are usually not going to be the same size, but the function throws an error if the resolutions are different. I believe only the batch and channel sizes should be validated.
As a result of the nested for loops, the implementation is very slow to run for images with many channels - I'm not sure that they can easily be vectorised, unfortunately, so maybe there's not much that can be done about this. For reference, here are execution times for the aforementioned test set:
PSNR: 32.4233 (total execution time 2.21s)
SSIM: 0.8302 (total execution time 27.60s)
MS-SSIM: 0.9573 (total execution time 35.06s)
SAM: 0.0819 (total execution time 1.37s)
SDI: nan (total execution time 16694.23s)
To Reproduce
Here's a MWE with an image that results in a nan value:
Hi @rddunphy,
Please feel free to send the fixes for 1) and also feel free to include the proposed changes for 2). I do not see a problem with adding a small epsilon to the denominator to make sure we do not divide by 0.
For 3), it is possible to get rid of the inner for-loop fairly easy by stacking the input:
stack1=torch.cat([target[:, k : k+1, :, :] forrinrange(k, length)], dim=0)
stack2=torch.cat([target[:, r : r+1, :, :] forrinrange(k, length)], dim=0)
then running universal_image_quality_index on the stack with reduction="none" and afterwards do the averaging manually. This would most likely be faster but also require much more memory because we would need to store input multiple times in memory. So not sure what to do it in this case.
🐛 Bug
I'm having a few issues with the implementation of Spectral Distortion Index.
nan
value outputs. In a set of 49 hyperspectral images I'm working with, I have 14 that result innan
. I believe this happens whenever the denominatorlower
is 0 here:https://github.com/Lightning-AI/metrics/blob/780e9afa7316ab4439b888304eb5c14fdbaacbef/src/torchmetrics/functional/image/uqi.py#L117
This is a known issue with UQI, which is the reason it was adapted into SSIM by adding a constant to the denominator. Would it make sense to add an option to use SSIM instead of UQI with SDI?
To Reproduce
Here's a MWE with an image that results in a
nan
value:sdi_test.tar.gz
Environment
conda
,pip
, build from source): 0.12.0dev, built from sourceAdditional context
I have a fix for 1) here: rddunphy@ffcea15
Let me know if I should open a PR, or have a go at fixing 2) first. Thanks!
The text was updated successfully, but these errors were encountered: