Skip to content
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

Change import FFT according to interface of torch #246

Merged
merged 13 commits into from
Apr 2, 2021
Merged

Conversation

denproc
Copy link
Collaborator

@denproc denproc commented Apr 1, 2021

Closes #245

Proposed Changes

  • Added conditional import depending on installed version of torch
  • Added CI testing on 2 pytorch versions (torch=={'1.5.1', '1.8.1'}, torchvision=={'0.6.1', '0,9,1'})
  • Changes to be compatible with torch>=1.5.1

@codecov
Copy link

codecov bot commented Apr 1, 2021

Codecov Report

Merging #246 (b488d17) into master (5586e19) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
+ Coverage   95.66%   95.68%   +0.02%     
==========================================
  Files          29       29              
  Lines        1798     1807       +9     
==========================================
+ Hits         1720     1729       +9     
  Misses         78       78              
Flag Coverage Δ
unittests 95.68% <100.00%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
piq/brisque.py 99.01% <100.00%> (ø)
piq/fsim.py 100.00% <100.00%> (ø)
piq/functional/colour_conversion.py 100.00% <100.00%> (ø)
piq/gmsd.py 100.00% <100.00%> (ø)
piq/haarpsi.py 100.00% <100.00%> (ø)
piq/mdsi.py 100.00% <100.00%> (ø)
piq/pieapp.py 100.00% <100.00%> (ø)
piq/psnr.py 80.00% <100.00%> (ø)
piq/vif.py 100.00% <100.00%> (ø)
piq/vsi.py 100.00% <100.00%> (ø)

@denproc denproc marked this pull request as ready for review April 2, 2021 09:16
@denproc denproc requested review from snk4tr and zakajd April 2, 2021 09:16
@denproc
Copy link
Collaborator Author

denproc commented Apr 2, 2021

In order to resolve blocked merging, the protection of master branch should be changed (required tests). I suggest to do it after review.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 2, 2021

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

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.

One question from my side. The rest looks good.

@@ -53,7 +53,7 @@ def brisque(x: torch.Tensor,
assert kernel_size % 2 == 1, f'Kernel size must be odd, got [{kernel_size}]'
_validate_input([x, ], dim_range=(4, 4), data_range=(0, data_range))

x = x / data_range * 255
x = x / float(data_range) * 255
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this explicit conversion necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In case of x and data_range being torch.uint8 and int, the result will be Byte for torch==1.5.1 due to classic division instead of the true_division. It will lead to zeroing the input and possible exceptions from pytorch layers, which could be incompatible with torch.Byte.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agh, I see. This is unfortunate because from one hand we don't check user's inputs but from the other we require data_range to be int of float. I think this is a good compromise though.

@snk4tr snk4tr merged commit 3debc47 into master Apr 2, 2021
@snk4tr snk4tr deleted the fix/fft_usage#245 branch April 2, 2021 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: torch.fft functionality
2 participants