Skip to content

Support PSNR algorithm in checkbox-support (New)#1221

Merged
fernando79513 merged 20 commits intomainfrom
implement-psnr-algorithm-in-checkbox-support
Jul 24, 2024
Merged

Support PSNR algorithm in checkbox-support (New)#1221
fernando79513 merged 20 commits intomainfrom
implement-psnr-algorithm-in-checkbox-support

Conversation

@baconYao
Copy link
Copy Markdown
Contributor

@baconYao baconYao commented May 2, 2024

Description

Implement the PSNR algorithm in Checkbox Support by reference the OpenCV official document.

Why I propose this PR?

  • There will have a bunch of Video Codec Scenarios that rely on PSNR comparison, therefore, I reference the PSNR implementation of OpenCV.

Resolved issues

N/A

Documentation

OpenCV official document:

Tests

Implement the PSNR algorithm in Checkbox Support by reference the OpenCV
official document.
  - https://docs.opencv.org/3.4/d5/dc4/tutorial_video_input_psnr_ssim.html
@baconYao baconYao requested review from fernando79513 and kissiel May 2, 2024 06:29
@baconYao
Copy link
Copy Markdown
Contributor Author

baconYao commented May 3, 2024

Hi @kissiel and @fernando79513, I noticed that unittest cannot find the module numpy, may I know how can I solve it?

==================================== ERRORS ====================================
_____________ ERROR collecting checkbox_support/tests/test_psnr.py _____________
ImportError while importing test module '/home/runner/work/checkbox/checkbox/checkbox-support/checkbox_support/tests/test_psnr.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
checkbox_support/tests/test_psnr.py:2: in <module>
    import numpy as np
E   ModuleNotFoundError: No module named 'numpy'

@fernando79513
Copy link
Copy Markdown
Collaborator

Hi @kissiel and @fernando79513, I noticed that unittest cannot find the module numpy, may I know how can I solve it?

==================================== ERRORS ====================================
_____________ ERROR collecting checkbox_support/tests/test_psnr.py _____________
ImportError while importing test module '/home/runner/work/checkbox/checkbox/checkbox-support/checkbox_support/tests/test_psnr.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
checkbox_support/tests/test_psnr.py:2: in <module>
    import numpy as np
E   ModuleNotFoundError: No module named 'numpy'

At the moment the numpy module is not installed for checkbox support tests. On the base provider, we are installing opencv in the github runners. This can be done including the dependency on the tox.ini files.

Regarding if we should include numpy in checkbox-support, its a great point to be made. As @kissiel mentioned, numpy is quite a big library. It takes about 100MB of space, so maybe we should try to avoid including it in checkbox-support

@fernando79513 fernando79513 force-pushed the implement-psnr-algorithm-in-checkbox-support branch from 1e639fe to d251037 Compare May 22, 2024 11:09
@codecov
Copy link
Copy Markdown

codecov bot commented May 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.50%. Comparing base (ec16636) to head (9283f05).
Report is 193 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1221      +/-   ##
==========================================
+ Coverage   43.38%   43.50%   +0.11%     
==========================================
  Files         357      358       +1     
  Lines       38686    38744      +58     
  Branches     6561     6567       +6     
==========================================
+ Hits        16784    16855      +71     
+ Misses      21238    21225      -13     
  Partials      664      664              
Flag Coverage Δ
checkbox-support 53.05% <100.00%> (+0.82%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

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

Sorry for the late review. I didn't see any big issues, just some small improvements.
The only thing that we should take into account is that usually, a low PSNR means bad quality.
If we are assigning 0 to the case when there is no loss, we should also add a check for 0 when we assign the threshold on the final test.

baconYao and others added 10 commits June 14, 2024 13:32
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
@fernando79513 fernando79513 self-assigned this Jul 15, 2024
@fernando79513 fernando79513 added the waiting-for-changes The review has been completed but the PR is waiting for changes from the author label Jul 16, 2024
@fernando79513 fernando79513 force-pushed the implement-psnr-algorithm-in-checkbox-support branch from 901fa81 to 605e50d Compare July 18, 2024 11:20
fernando79513 and others added 3 commits July 18, 2024 13:28
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

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

LGTM +1!

@fernando79513 fernando79513 merged commit 9fbb0dd into main Jul 24, 2024
@fernando79513 fernando79513 deleted the implement-psnr-algorithm-in-checkbox-support branch July 24, 2024 06:57
pedro-avalos pushed a commit that referenced this pull request Jul 29, 2024
* Support PSNR algorithm in checkbox-support

Implement the PSNR algorithm in Checkbox Support by reference the OpenCV
official document.
  - https://docs.opencv.org/3.4/d5/dc4/tutorial_video_input_psnr_ssim.html

* Added opencv_python to checkbox support tox.ini

* Update the unittest of PSNR

* Handle the divide zero case and improve unittest

* Update checkbox-support/checkbox_support/scripts/psnr.py

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Update checkbox-support/checkbox_support/scripts/psnr.py

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Update checkbox-support/checkbox_support/scripts/psnr.py

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Update checkbox-support/checkbox_support/tests/test_psnr.py

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Update checkbox-support/checkbox_support/tests/test_psnr.py

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Update checkbox-support/checkbox_support/tests/test_psnr.py

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Update checkbox-support/checkbox_support/tests/test_psnr.py

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Update checkbox-support/checkbox_support/tests/test_psnr.py

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Remove psnr from toml file

* Refactor

* Patch sys.argv to mock args

* Fixed numpy version in python 10

* Fixed extension of files in test

* Add test_similar_images case

Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>

* Fix black issue

---------

Co-authored-by: ferbraher <fernando.bravo.hernandez@canonical.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-for-changes The review has been completed but the PR is waiting for changes from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants