Skip to content

Update validation and reduction. #234

Merged
snk4tr merged 9 commits intomasterfrom
feature/validation
Feb 25, 2021
Merged

Update validation and reduction. #234
snk4tr merged 9 commits intomasterfrom
feature/validation

Conversation

@jzakirov
Copy link
Collaborator

@jzakirov jzakirov commented Feb 10, 2021

Closes #212
Another semantic update =)

Proposed Changes

  • Add _reduction function to unify reduction process.
  • Merge _validate_features and _validate_input into one function and simplify it's interface
  • Unify docsting descriptions for reduction and data_range.

With this PR we make requirements on input tensors more strict.

image

@jzakirov jzakirov added the refactoring Change appearance the code without semantic changes label Feb 10, 2021
@jzakirov jzakirov requested a review from snk4tr February 10, 2021 19:16
@snk4tr
Copy link
Contributor

snk4tr commented Feb 15, 2021

@zakajd are you still working on this one?

@jzakirov
Copy link
Collaborator Author

@snk4tr Yeah, I'm waiting for the documentation PR to be merged so that I can update it with -o flag usage example.

@jzakirov jzakirov requested a review from denproc February 24, 2021 09:21
@jzakirov
Copy link
Collaborator Author

@snk4tr This one is ready for merge.
Main change is in piq/utils/common.py, all other 30+ files are mostly test fixes and one-line changes to adjust for new reduction and validation.

@codecov
Copy link

codecov bot commented Feb 24, 2021

Codecov Report

Merging #234 (69a150e) into master (ee5fae7) will increase coverage by 1.43%.
The diff coverage is 99.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #234      +/-   ##
==========================================
+ Coverage   93.75%   95.18%   +1.43%     
==========================================
  Files          28       28              
  Lines        1826     1766      -60     
==========================================
- Hits         1712     1681      -31     
+ Misses        114       85      -29     
Flag Coverage Δ
unittests 95.18% <99.04%> (+1.43%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
piq/base.py 88.46% <ø> (-0.83%) ⬇️
piq/utils/common.py 96.29% <96.15%> (-3.71%) ⬇️
piq/brisque.py 99.01% <100.00%> (-0.01%) ⬇️
piq/fid.py 91.22% <100.00%> (+2.89%) ⬆️
piq/fsim.py 100.00% <100.00%> (ø)
piq/gmsd.py 100.00% <100.00%> (ø)
piq/gs.py 78.66% <100.00%> (+38.94%) ⬆️
piq/haarpsi.py 100.00% <100.00%> (ø)
piq/isc.py 90.90% <100.00%> (+0.58%) ⬆️
piq/kid.py 88.77% <100.00%> (+0.23%) ⬆️
... and 11 more

snk4tr
snk4tr previously approved these changes Feb 25, 2021
Copy link
Contributor

@snk4tr snk4tr left a comment

Choose a reason for hiding this comment

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

Nice one, @zakajd.
Let me add a few tiny fixes and merge.

Args:
kernel_size: By default, the mean and covariance of a pixel is obtained
by convolution with given filter_size.
by convolution with given filter_size. Must be an odd value.
Copy link
Contributor

Choose a reason for hiding this comment

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

We require kernel_size to be odd but never check that even in the debug mode. Add will add an assertion for that.

README.rst Outdated
Assertions
----------
In PIQ we use assertions to raise meaningful messages when some component doesn't receive an input of the expected type.
This makes prototyping and debugging easier, but it might hurt a little the performance.
Copy link
Contributor

Choose a reason for hiding this comment

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

Grammatically incorrect. I will fix that in the commit later.

Suggested change
This makes prototyping and debugging easier, but it might hurt a little the performance.
This makes prototyping and debugging easier, but it might hurt the performance.

y: A target tensor. Shape :math:`(N, C, H, W)`.
reduction: Specifies the reduction type:
``'none'`` | ``'mean'`` | ``'sum'``. Default:``'mean'``
data_range: Maximum value range of images (usually 1.0 or 255).
Copy link
Contributor

Choose a reason for hiding this comment

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

Good that you removed the note about default here. It duplicates info and adds nothing besides potential confusion

Args:
kernel_size: By default, the mean and covariance of a pixel is obtained
by convolution with given filter_size.
by convolution with given filter_size. Must be an odd value.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same about odd value here

Signed-off-by: Sergey Kastryulin <snk4tr@gmail.com>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@snk4tr snk4tr merged commit d401e8c into master Feb 25, 2021
@snk4tr snk4tr deleted the feature/validation branch February 25, 2021 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Change appearance the code without semantic changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide optional validation

2 participants