Skip to content

enhance: add reduction='none' to vif metric#3196

Merged
Borda merged 45 commits into
Lightning-AI:masterfrom
iamkulbhushansingh:feat/vif-reduction-none
Aug 6, 2025
Merged

enhance: add reduction='none' to vif metric#3196
Borda merged 45 commits into
Lightning-AI:masterfrom
iamkulbhushansingh:feat/vif-reduction-none

Conversation

@iamkulbhushansingh

@iamkulbhushansingh iamkulbhushansingh commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Enhances the Visual Information Fidelity (VIF) metric by adding support for reduction='none'.
This allows users to retrieve per-sample metric values instead of only reduced tensor outputs, bringing the VIF metric in line with other metrics that already support reduction modes.

Fixes #3194


Before submitting
  • Was this discussed/agreed via a GitHub issue? (not required for minor typos or docs)
  • Did you read the contributor guidelines?
  • Did you make sure to update the documentation (docstrings + examples)?
  • Did you write unit tests for the new feature?

Why is this needed?

  • reduction='none' enables batch-level debugging, per-sample metric analysis, and flexible custom aggregations.
  • Maintains API consistency with other TorchMetrics metrics that already support multiple reduction modes.

Additional Context

  • Added unit tests covering reduction='none' behavior for VIF.
  • Updated docstring in python file.

Did you have fun?

That was my first Open Source Commit. 💯


📚 Documentation preview 📚: https://torchmetrics--3196.org.readthedocs.build/en/3196/

Kulbhushan Singh added 2 commits July 30, 2025 01:34
- Implemented `reduction='none'` option for VIF metric to return per-image scores.
- Added unit tests to validate output shape and correctness.
@codecov

codecov Bot commented Jul 30, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 68%. Comparing base (5e6081f) to head (f4bf751).
⚠️ Report is 48 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (5e6081f) and HEAD (f4bf751). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (5e6081f) HEAD (f4bf751)
gpu 2 0
unittest 2 0
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #3196      +/-   ##
=========================================
- Coverage      99%     68%     -31%     
=========================================
  Files          15     349     +334     
  Lines         195   19891   +19696     
=========================================
+ Hits          194   13617   +13423     
- Misses          1    6274    +6273     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/torchmetrics/image/vif.py Outdated
Comment thread src/torchmetrics/image/vif.py Outdated
Comment thread src/torchmetrics/image/vif.py Outdated
@rittik9

rittik9 commented Jul 31, 2025

Copy link
Copy Markdown
Collaborator

Also I think it'll be good if we add same reduction options to functional interface as well for consistency...

Comment thread src/torchmetrics/image/vif.py

@iamkulbhushansingh iamkulbhushansingh left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for corrections.

@iamkulbhushansingh

Copy link
Copy Markdown
Contributor Author

Adding the reduction option to functional interface.

…ormation_fidelity

- Updated functional VIF implementation to support `reduction='none'`
- Now returns per-sample VIF scores when reduction is set to 'none'
- Retains existing behaviour with 'elementwise_mean' reduction
- Improved docstrings and error handling for input validation
@rittik9

rittik9 commented Aug 3, 2025

Copy link
Copy Markdown
Collaborator

/home/runner/work/torchmetrics/torchmetrics/src/torchmetrics/functional/image/vif.py:docstring of torchmetrics.functional.image.vif.visual_information_fidelity:: WARNING: py:class reference target not found: Tensor containing the VIF score
/home/runner/work/torchmetrics/torchmetrics/src/torchmetrics/functional/image/vif.py:docstring of torchmetrics.functional.image.vif.visual_information_fidelity:: WARNING: py:class reference target not found: s

@iamkulbhushansingh mind checking the above warning?

@iamkulbhushansingh

Copy link
Copy Markdown
Contributor Author

let me check!

@rittik9 rittik9 changed the title enh(VIF): add reduction='none' option with tests enhance: add reduction='none' to vif metric Aug 3, 2025
@Borda
Borda requested a review from SkafteNicki August 4, 2025 08:38
@Borda
Borda enabled auto-merge (squash) August 4, 2025 08:45
@mergify mergify Bot added the ready label Aug 4, 2025
@Borda
Borda disabled auto-merge August 6, 2025 22:10
@Borda
Borda merged commit 40a694d into Lightning-AI:master Aug 6, 2025
63 of 64 checks passed
Borda added a commit that referenced this pull request Aug 7, 2025
* feat(VIF): add support for reduction='none'
* Enhancement(vif): add support for reduction='none'
* Apply suggestions from code review

---------

Co-authored-by: Kulbhushan Singh <[email protected]>
Co-authored-by: Rittik Panda <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Nicki Skafte Detlefsen <[email protected]>
Co-authored-by: Jirka Borovec <[email protected]>
Co-authored-by: Jirka B <[email protected]>
(cherry picked from commit 40a694d)
Borda added a commit that referenced this pull request Aug 7, 2025
* feat(VIF): add support for reduction='none'
* Enhancement(vif): add support for reduction='none'
* Apply suggestions from code review

---------

Co-authored-by: Kulbhushan Singh <[email protected]>
Co-authored-by: Rittik Panda <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Nicki Skafte Detlefsen <[email protected]>
Co-authored-by: Jirka Borovec <[email protected]>
Co-authored-by: Jirka B <[email protected]>
(cherry picked from commit 40a694d)
@iamkulbhushansingh
iamkulbhushansingh deleted the feat/vif-reduction-none branch August 15, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Add per-image reduction option to VisualInformationFidelity

4 participants