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

Move mpa.deploy to otx.algorithms.common #1903

Conversation

harimkang
Copy link
Contributor

Summary

Move mpa.deploy to otx.algorithms.common.adapters.mmdeploy

How to test

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below)
# Copyright (C) 2023 Intel Corporation
#
# SPDX-License-Identifier: MIT

@harimkang harimkang requested a review from a team as a code owner March 17, 2023 08:34
@github-actions github-actions bot added ALGO Any changes in OTX Algo Tasks implementation DOC Improvements or additions to documentation TEST Any changes in tests labels Mar 17, 2023
@harimkang harimkang added this to the 1.2.0 milestone Mar 17, 2023
@chuneuny-emily chuneuny-emily added the ENHANCE Enhancement of existing features label Mar 17, 2023
@harimkang
Copy link
Contributor Author

@cih9088 Hi, I'm currently working on moving the files from mpa.module to otx. I'm getting the following unit-test error while moving the deploy related codes (tests/unit/algorithms/common/adapters/mmdeploy/test_deploy_apis.py::TestMMdeployExporter::test_partition), could you please see if I'm missing something? (Some of the modified code is to fix pylint errors, please let me know if you find anything wrong. I'll fix it right away.)

    
        with tempfile.TemporaryDirectory() as tempdir:
>           MMdeployExporter.export2openvino(
                tempdir,
                build_classifier,
                config,
                deploy_config,
            )

tests/unit/algorithms/common/adapters/mmdeploy/test_deploy_apis.py:209: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
otx/algorithms/common/adapters/mmdeploy/apis.py:244: in export2openvino
    MMdeployExporter.onnx2openvino(
otx/algorithms/common/adapters/mmdeploy/apis.py:330: in onnx2openvino
    raise e
otx/algorithms/common/adapters/mmdeploy/apis.py:317: in onnx2openvino
    openvino_api.from_onnx(onnx_ready_path, output_dir, input_info, output_names, mo_options)
venv/lib/python3.9/site-packages/mmdeploy/apis/core/pipeline_manager.py:356: in _wrap
    return self.call_function(func_name_, *args, **kwargs)
venv/lib/python3.9/site-packages/mmdeploy/apis/core/pipeline_manager.py:326: in call_function
    return self.call_function_local(func_name, *args, **kwargs)
venv/lib/python3.9/site-packages/mmdeploy/apis/core/pipeline_manager.py:275: in call_function_local
    return pipe_caller(*args, **kwargs)
venv/lib/python3.9/site-packages/mmdeploy/apis/core/pipeline_manager.py:107: in __call__
    ret = func(*args, **kwargs)
venv/lib/python3.9/site-packages/mmdeploy/backend/openvino/onnx2openvino.py:114: in from_onnx
    mo_output = run(command, stdout=PIPE, stderr=PIPE, shell=True, check=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

input = None, capture_output = False, timeout = None, check = True
popenargs = ('mo --input_model="/tmp/tmp81n5d140/partition_ready.onnx" --output_dir="/tmp/tmp81n5d140" --output="" --input="input" --input_shape="[1, 3, 50, 50]" --model_name "partition" ',), kwargs = {'shell': True, 'stderr': -1, 'stdout': -1}
process = <Popen: returncode: 1 args: 'mo --input_model="/tmp/tmp81n5d140/partition_re...>, stdout = b'', stderr = b'[ ERROR ]  No node with name input\n', retcode = 1

    def run(*popenargs,
            input=None, capture_output=False, timeout=None, check=False, **kwargs):
        """Run command with arguments and return a CompletedProcess instance.
    
        The returned instance will have attributes args, returncode, stdout and
        stderr. By default, stdout and stderr are not captured, and those attributes
        will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them.
    
        If check is True and the exit code was non-zero, it raises a
        CalledProcessError. The CalledProcessError object will have the return code
        in the returncode attribute, and output & stderr attributes if those streams
        were captured.
    
        If timeout is given, and the process takes too long, a TimeoutExpired
        exception will be raised.
    
        There is an optional argument "input", allowing you to
        pass bytes or a string to the subprocess's stdin.  If you use this argument
        you may not also use the Popen constructor's "stdin" argument, as
        it will be used internally.
    
        By default, all communication is in bytes, and therefore any "input" should
        be bytes, and the stdout and stderr will be bytes. If in text mode, any
        "input" should be a string, and stdout and stderr will be strings decoded
        according to locale encoding, or by "encoding" if set. Text mode is
        triggered by setting any of text, encoding, errors or universal_newlines.
    
        The other arguments are the same as for the Popen constructor.
        """
        if input is not None:
            if kwargs.get('stdin') is not None:
                raise ValueError('stdin and input arguments may not both be used.')
            kwargs['stdin'] = PIPE
    
        if capture_output:
            if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
                raise ValueError('stdout and stderr arguments may not be used '
                                 'with capture_output.')
            kwargs['stdout'] = PIPE
            kwargs['stderr'] = PIPE
    
        with Popen(*popenargs, **kwargs) as process:
            try:
                stdout, stderr = process.communicate(input, timeout=timeout)
            except TimeoutExpired as exc:
                process.kill()
                if _mswindows:
                    # Windows accumulates the output in a single blocking
                    # read() call run on child threads, with the timeout
                    # being done in a join() on those threads.  communicate()
                    # _after_ kill() is required to collect that and add it
                    # to the exception.
                    exc.stdout, exc.stderr = process.communicate()
                else:
                    # POSIX _communicate already populated the output so
                    # far into the TimeoutExpired exception.
                    process.wait()
                raise
            except:  # Including KeyboardInterrupt, communicate handled that.
                process.kill()
                # We don't call process.wait() as .__exit__ does that for us.
                raise
            retcode = process.poll()
            if check and retcode:
>               raise CalledProcessError(retcode, process.args,
                                         output=stdout, stderr=stderr)
E               subprocess.CalledProcessError: Command 'mo --input_model="/tmp/tmp81n5d140/partition_ready.onnx" --output_dir="/tmp/tmp81n5d140" --output="" --input="input" --input_shape="[1, 3, 50, 50]" --model_name "partition" ' returned non-zero exit status 1.

../../../anaconda3/lib/python3.9/subprocess.py:528: CalledProcessError
============================================================================================================= short test summary info ==============================================================================================================
FAILED tests/unit/algorithms/common/adapters/mmdeploy/test_deploy_apis.py::TestMMdeployExporter::test_partition - subprocess.CalledProcessError: Command 'mo --input_model="/tmp/tmp81n5d140/partition_ready.onnx" --output_dir="/tmp/tmp81n5d140" --output="" --input="input" --input_shape="[1, 3, 50, 50]" --model_name "partition" ' returned non-zero exit s...
========================================================================================================== 1 failed, 12 warnings in 6.18s ==========================================================================================================

@cih9088
Copy link
Contributor

cih9088 commented Mar 20, 2023

(tests/unit/algorithms/common/adapters/mmdeploy/test_deploy_apis.py::TestMMdeployExporter::test_partition), could you please see if I'm missing something? (Some of the modified code is to fix pylint errors, please let me know if you find anything wrong. I'll fix it right away.)

@harimkang Fixed.

@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (128154f) 80.72% compared to head (e5b0bd0) 80.72%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1903   +/-   ##
========================================
  Coverage    80.72%   80.72%           
========================================
  Files          489      489           
  Lines        33388    33388           
========================================
  Hits         26951    26951           
  Misses        6437     6437           
Impacted Files Coverage Δ
.../algorithms/common/adapters/mmdeploy/utils/onnx.py 100.00% <ø> (ø)
...ommon/adapters/mmdeploy/utils/operations_domain.py 100.00% <ø> (ø)
...algorithms/common/adapters/mmdeploy/utils/utils.py 95.23% <ø> (ø)
otx/algorithms/common/adapters/mmdeploy/apis.py 90.71% <100.00%> (ø)
...orithms/common/adapters/mmdeploy/utils/mmdeploy.py 100.00% <100.00%> (ø)
...ers/mmdet/models/detectors/custom_atss_detector.py 63.01% <100.00%> (ø)
...mmdet/models/detectors/custom_maskrcnn_detector.py 36.00% <100.00%> (ø)
...t/models/detectors/custom_single_stage_detector.py 64.94% <100.00%> (ø)
...rs/mmdet/models/detectors/custom_yolox_detector.py 33.73% <100.00%> (ø)
...lgorithms/detection/adapters/mmdet/nncf/patches.py 98.80% <100.00%> (ø)
... and 6 more

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

otx/mpa/det/exporter.py Outdated Show resolved Hide resolved
otx/mpa/seg/exporter.py Outdated Show resolved Hide resolved
otx/mpa/cls/exporter.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jaegukhyun jaegukhyun left a comment

Choose a reason for hiding this comment

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

I left some minor fix suggest, If you don't want to change, then just resolve them.

@harimkang harimkang changed the base branch from develop to releases/1.1.0 March 21, 2023 01:21
@harimkang harimkang modified the milestones: 1.2.0, 1.1.0 Mar 21, 2023
@harimkang harimkang changed the title [ENHANCE] Move mpa.deploy to otx.algorithms.common Move mpa.deploy to otx.algorithms.common Mar 21, 2023
@harimkang
Copy link
Contributor Author

@jaegukhyun @JihwanEom I think we can merge this, but can you double check?

Copy link
Contributor

@sungmanc sungmanc left a comment

Choose a reason for hiding this comment

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

Looks nice to me, it seems that you resolves plenty of pre-commit issues

@harimkang harimkang merged commit abe6aae into openvinotoolkit:releases/1.1.0 Mar 21, 2023
goodsong81 added a commit that referenced this pull request Mar 28, 2023
* Bump up version to 1.1.0rc1

* Updated daily workflow (#1905)

- remove if statement to allow running on any branch by manually

* [FIX] Wrong test temp directory path (#1902)

* Fix wrong test temp directory

* Update tests/unit/algorithms/action/adapters/mmaction/utils/test_action_config_utils.py

* Update test_action_config_utils.py

* Update PR template (#1914)

* Update . location.

* Fix OTX1.1 -> Geti1.4 integration issues (#1910)

* Add dill to requirements/api.txt

* Return None instead of raising NotImplementedError in IMedia2DEntity.path

* Move utils HPO uses into HPO directory (#1912)

move utils into hpo dir

* [FIX] Add stability to explain detection (#1901)

Add stability to explain detection

* [Fix] e2e tests FQ references (#1918)

Fix FQ references

* Move mpa.deploy to otx.algorithms.common (#1903)

* Move deploy modules to otx

* test: fix mmdeploy api replacement error

* Fix pre-commit issues

* Update otx/mpa/det/exporter.py

* Update otx/mpa/exporter_mixin.py

* Update otx/mpa/seg/exporter.py

* Update otx/mpa/cls/exporter.py

* Update otx/algorithms/common/adapters/mmdeploy/utils/mmdeploy.py

* Update otx/algorithms/common/adapters/mmdeploy/utils/operations_domain.py

* Add mmcls.VisionTransformer backbone support (#1908)

* Add mmcls transformer backbones

* Fix VisionTransformeroutput check

* Add changes

* Disable recording forward hooks in inferrer

* Remove unused import

* Move semantic-segmentation related codes to otx adapters (#1911)

* Added security.md

Add the security related notification

* Update security.md

fix prettier issue

* Add custom exception class for CLI (#1919)

* Add custom exception class for CLI

* Fixed TCs for config_manager

* Correct License to Apache

* Remove temp hot key values (#1916)

* Refactor OTX classification phase 1: move modules from MPA to OTX (#1893)

* Revert TrainType typo (#1928)

* Fix Conflict

* Fix conflict

* Fix unit-tests

* Fix cli tests

* Fix cli tests

* Fix type

* Move all hooks in MPA into OTX common mmcv adapter (#1922)

* Add explanation for XAI & minor doc fixes (#1923)

* [CI] Updated daily workflow (#1904)

Updated daily workflow

- remove if statement to allow running on any branch by manually

* [FIX] re-bugfix: ATSS head loss (#1907)

re bugfix

* Fix typos

* Explanation of Explanation

* Add images & typo fixes

* Fixes from comments

* Add accuracy for OD explanation

* Tutorial update

* Add accuracy for BCCD and WGISD

* Fix

* Move utils to OTX common & adapter (#1931)

* [CI] Updated daily workflow (#1904)

Updated daily workflow

- remove if statement to allow running on any branch by manually

* [FIX] re-bugfix: ATSS head loss (#1907)

re bugfix

* Added security.md

Added the security related notification.

* Update security.md

fix prettier issue

* Move utils

* Fix typo

* Move classification unit tests to OTX tests (#1932)

* [CI] Updated daily workflow (#1904)

Updated daily workflow

- remove if statement to allow running on any branch by manually

* [FIX] re-bugfix: ATSS head loss (#1907)

re bugfix

* Added security.md

Added the security related notification.

* Update security.md

fix prettier issue

* Move classification unit tests

* Apply mocker in RandAugment TC

* Move otx.mpa.modules.ov -> otx.core.ov (#1929)

* First Refactoring

* Refactor mpa.modules.ov -> otx.core.ov

* Remove otx.mpa.modules.ov

* Fix docs & unit test paths

* Fix some import

* Add TODO comments

* Add github icon link in doc head (#1934)

* Fix invalid temp_dir inside unit tests (#1937)

* Move all model utils and dataloaders/samplers in mpa to otx adapter (#1930)

* Move stages to each algorithms (#1938)

* Move stages to each algorithms

* Change docs for action recognition (#1940)

* Change docs for action recognition

* Fix typo

* Update MoViNet related parts

* Add MoViNet performance

* Revert table include Complexity and Model size

* Fix tox to run tests on non-editable install

* Fix packaging errors including cython module build / import issues (#1936)

* Avoid cychon compile on Windows

* Fix packaging errors

* Fix pre-commit

* Remove use_develop option from tox tests

* Fix pre-commit

* Fix tox -e -> -re for clean build

* Fix import error

* Add missing __init__.py

* Fix relative -> absolute import

* Revert to editable package in tox tests

* Release 1.1.0 (#1933)

* Release OTX 1.1.0

* Update known issues in CHANGELOG.md

* Fix PR / issue # to links

* Fix pre-commit

* Bump-up version to 1.2

* Fix pre-commit

---------

Signed-off-by: Songki Choi <[email protected]>
Co-authored-by: Yunchu Lee <[email protected]>
Co-authored-by: Harim Kang <[email protected]>
Co-authored-by: Eunwoo Shin <[email protected]>
Co-authored-by: Emily Chun <[email protected]>
Co-authored-by: emily.chun <chuneuny@ikvensx012>
Co-authored-by: Sungman Cho <[email protected]>
Co-authored-by: Inhyuk Andy Cho <[email protected]>
Co-authored-by: Jaeguk Hyun <[email protected]>
Co-authored-by: Jihwan Eom <[email protected]>
Co-authored-by: Soobee Lee <[email protected]>
Co-authored-by: Galina Zalesskaya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ALGO Any changes in OTX Algo Tasks implementation DOC Improvements or additions to documentation ENHANCE Enhancement of existing features RELEASE TEST Any changes in tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants