8000 Refactor image corruption toolbox by iamksuresh · Pull Request #319 · aiverify-foundation/aiverify · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor image corruption toolbox #319

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

Merged
merged 14 commits into from
Sep 20, 2024

Conversation

iamksuresh
Copy link
@iamksuresh iamksuresh commented Sep 11, 2024

Description

  1. main.py as the main entry point
  2. moved test assests to stock-plugins root (stock-plugins/user_defined_files)
  3. refactored the folder and files structure.
  4. Users can now execute the plugin as a module
  5. Plugin will now accept comma separated assets paths (data,model,ground_truth), model classifications, ground truth value,plugin args
  6. Following plugins are refactored -
  • blur corruptions
  • digital corruptions
  • Environment corruptions
  • general corruptions

Type of Change

refactor: Code refactoring without changes in functionality

perf: Performance improvements

How to Test

Execute the below command for each plugin

cd aiverify/stock-plugins/aiverify.stock.robustness-toolbox/algorithms/<PLUGIN_NAME>/
pytest .

Checklist

Please check all the boxes that apply to this pull request using "x":

  • I have tested the changes locally and verified that they work as expected.
  • I have added or updated the necessary documentation (README, API docs, etc.).
  • I have added appropriate unit tests or functional tests for the changes made.
  • I have followed the project's coding conventions and style guidelines.
  • I have rebased my branch onto the latest commit of the main branch.
  • I have squashed or reorganized my commits into logical units.
  • I have added any necessary dependencies or packages to the project's build configuration.
  • I have performed a self-review of my own code.
  • I have read, understood and agree to the Developer Certificate of Origin below, which this project utilises.

Screenshots (if applicable)

[If the changes involve visual modifications, include screenshots or GIFs that demonstrate the changes.]

Additional Notes

[Add any additional information or context that might be relevant to reviewers.]

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
   have the right to submit it under the open source license
   indicated in the file; or

(b) The contribution is based upon previous work that, to the best
   of my knowledge, is covered under an appropriate open source
   license and I have the right under that license to submit that
   work with modifications, whether created in whole or in part
   by me, under the same open source license (unless I am
   permitted to submit under a different license), as indicated
   in the file; or

(c) The contribution was provided directly to me by some other
   person who certified (a), (b) or (c) and I have not modified
   it.

(d) I understand and agree that this project and the contribution
   are public and that a record of the contribution (including all
   personal information I submit with it, including my sign-off) is
   maintained indefinitely and may be redistributed consistent with
   this project or the open source license(s) involved.

@iamksuresh iamksuresh requested a review from timlrx September 11, 2024 16:50
Copy link
Collaborator
@timlrx timlrx left a comment

Choose a reason for hiding this comment

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

Hi Suresh, I tested the blur corruptions first. It runs fine but I think we need to refactor the directory of the output files and the display_info field in output.json as indicated in my comments. This should apply to the other algorithms as well.

Copy link
Collaborator
@timlrx timlrx left a comment

Choose a reason for hiding this comment

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

Tested aiverify_blur_corruptions, aiverify_digital_corruptions, aiverify_environment_corruptions and aiverify_general_corruptions using the example script provided in the readme. Fix testpath to testpaths and all should be good to go

@imda-peckyoke
Copy link
Contributor
imda-peckyoke commented Sep 20, 2024

I get the following errors when running pytests under the environment_corruptions algo:

ImportError while importing test module '/Users/leongpeckyoke/Projects/aiverify2/temporary/aiverify/stock-plugins/aiverify.stock.image-corruption-toolbox/algorithms/environment_corruptions/tests/e2e/test_e2e.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.venv/lib/python3.11/site-packages/wand/api.py:159: in <module>
    libraries = load_library()
.venv/lib/python3.11/site-packages/wand/api.py:148: in load_library
    raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
E   OSError: cannot find library; tried paths: []

During handling of the above exception, another exception occurred:
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/e2e/test_e2e.py:4: in <module>
    from aiverify_environment_corruptions.algo_init import AlgoInit
aiverify_environment_corruptions/algo_init.py:9: in <module>
    from aiverify_environment_corruptions.algo import Plugin
aiverify_environment_corruptions/algo.py:11: in <module>
    from aiverify_environment_corruptions.utils import environment
aiverify_environment_corruptions/utils/environment.py:8: in <module>
    from wand.api import library as wandlibrary
.venv/lib/python3.11/site-packages/wand/api.py:183: in <module>
    raise ImportError('MagickWand shared library not found.\n'
E   ImportError: MagickWand shared library not found.
E   You probably had not installed ImageMagick library.
E   Try to install:
E     brew install freetype imagemagick
_____________________________________________________________________________ ERROR collecting tests/unit_tests/test_algo.py _____________________________________________________________________________
ImportError while importing test module '/Users/leongpeckyoke/Projects/aiverify2/temporary/aiverify/stock-plugins/aiverify.stock.image-corruption-toolbox/algorithms/environment_corruptions/tests/unit_tests/test_algo.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.venv/lib/python3.11/site-packages/wand/api.py:159: in <module>
    libraries = load_library()
.venv/lib/python3.11/site-packages/wand/api.py:148: in load_library
    raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
E   OSError: cannot find library; tried paths: []

During handling of the above exception, another exception occurred:
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/unit_tests/test_algo.py:6: in <module>
    from aiverify_environment_corruptions.algo import Plugin
aiverify_environment_corruptions/algo.py:11: in <module>
    from aiverify_environment_corruptions.utils import environment
aiverify_environment_corruptions/utils/environm
8000
ent.py:8: in <module>
    from wand.api import library as wandlibrary
.venv/lib/python3.11/site-packages/wand/api.py:183: in <module>
    raise ImportError('MagickWand shared library not found.\n'
E   ImportError: MagickWand shared library not found.
E   You probably had not installed ImageMagick library.
E   Try to install:
E     brew install freetype imagemagick

Please add instruction the readme to install imagemagick as requirement for this algo. User also need to export the MAGICK_HOME environment variable.

Copy link
Contributor
@imda-peckyoke imda-peckyoke left a comment

Choose a reason for hiding this comment

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

Approve

@imda-peckyoke imda-peckyoke merged commit 762ebc2 into v2.x Sep 20, 2024
1 of 3 checks passed
@imda-peckyoke imda-peckyoke deleted the refactor-image-corruption-toolbox branch September 20, 2024 07:16
iamksuresh added a commit that referenced this pull request Nov 13, 2024
* refactoring blur-corruption - initial commit

* refactored blur and digital image corruptions

* refactoring image corruptions plugin

* remving comments

* updating the temp files path to output folder

* updating the readme files

* add relative path in results.json file

* readme update

* adding output folder to gitignore file

* updating pytest.ini file

* reviews addressed

* updating test class name to ObjectTest

---------

Co-authored-by: Suresh Kumar Kushal Raj <sureshjain@sureshs-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0