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

[Datumaro] Add generic accuracy checker model launcher #1661

Merged
merged 18 commits into from
Jun 24, 2020

Conversation

zhiltsov-max
Copy link
Contributor

@zhiltsov-max zhiltsov-max commented Jun 6, 2020

Merge after #1714

  • Added generic model launcher with Accuracy Checker backend.
  • Added a PyTorch model example (requires some path adjustments for testing)

Motivation and context

Model support in Datumaro is extended from OpenVINO to OpenVINO, TensorFlow, PyTorch, ONNX, MxNet. Such models now can be used for auto annotation and explainable AI.

How has this been tested?

Manual test

# create a project
# copy and adjust paths in the pytorch model example
datum model add -l ac -- -c <path/to/config.yaml>
datum model run -m model-1

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) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT

@@ -0,0 +1,116 @@

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eaidova, please, take a look at AC use.

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nmanovic, can we put it here?

@coveralls
Copy link

coveralls commented Jun 6, 2020

Pull Request Test Coverage Report for Build 5861

  • 11 of 91 (12.09%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.3%) to 65.527%

Changes Missing Coverage Covered Lines Changed/Added Lines %
datumaro/datumaro/util/annotation_tools.py 2 3 66.67%
datumaro/datumaro/plugins/accuracy_checker_plugin/launcher.py 5 19 26.32%
datumaro/datumaro/plugins/accuracy_checker_plugin/details/ac.py 4 69 5.8%
Files with Coverage Reduction New Missed Lines %
datumaro/datumaro/components/extractor.py 1 91.01%
Totals Coverage Status
Change from base Build 5855: -0.3%
Covered Lines: 10927
Relevant Lines: 16272

💛 - Coveralls

@azhavoro
Copy link
Contributor

azhavoro commented Jun 8, 2020

@zhiltsov-max could you update documentation and add a couple of examples for non openvino frameworks?

@zhiltsov-max
Copy link
Contributor Author

@azhavoro, here is an example of a pytorch model. I can add examples with other frameworks in another PR.

@@ -0,0 +1,37 @@
launcher:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@azhavoro, the pytorch example.

for label, score, x0, y0, x1, y1 in zip(pred.labels, pred.scores,
pred.x_mins, pred.y_mins, pred.x_maxs, pred.y_maxs)
)
elif isinstance(pred, ac.DepthEstimationPrediction):
Copy link

Choose a reason for hiding this comment

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

not sure that it is good approach, at least it will require update on each new representation and extend code with a lot of elif statements...
Probably, condition can be converted to dict format where keys are type and value is functor for conversion or something similar.
Another approach which I can suggest to have to_dm_prediction method inside AC prediction, if it is possible (but it will require to update AC code and make AC dependent on DM...now we are working on dep reducion due to necessary to work on ARM...)

so here is something to think about...

@azhavoro
Copy link
Contributor

azhavoro commented Jun 8, 2020

Issues:

  1. Where I can find the dependencies list? Without manual installation yamlloader and nibabel packages python3 datum.py model add -h doesn't display ac as a launcher, also there are no warnings or exception messages.

    List of builtin launchers: open_vino
    
  2. python3 datum.py model add -p test -l ac
    2020-06-08 16:47:22,089 INFO: Checking the model
    2020-06-08 16:47:22,089 ERROR: join() argument must be str or bytes, not 'NoneType'
    Traceback (most recent call last):
      File "datum.py", line 8, in <module>
        sys.exit(main())
      File "/home/django/datumaro/datumaro/cli/__main__.py", line 113, in main
        return args.command(args)
      File "/home/django/datumaro/datumaro/cli/contexts/model/__init__.py", line 89, in add_command
        project.make_executable_model(args.name)
      File "/home/django/datumaro/datumaro/components/project.py", line 823, in 
    make_executable_model
        **model.options, model_dir=self.local_model_dir(name))
      File "/home/django/datumaro/datumaro/components/project.py", line 292, in make_launcher
        return self.launchers.get(name)(*args, **kwargs)
      File "/home/django/datumaro/datumaro/plugins/accuracy_checker_plugin/launcher.py", line 29, in __init__
        with open(osp.join(model_dir, config), 'r') as f:
      File "/usr/lib/python3.5/posixpath.py", line 89, in join
        genericpath._check_arg_types('join', a, *p)
      File "/usr/lib/python3.5/genericpath.py", line 143, in _check_arg_types
        (funcname, s.__class__.__name__)) from None
    TypeError: join() argument must be str or bytes, not 'NoneType'
    
  3. python3 datum.py model add -p test -l ac -- -c tests/assets/pytorch_launcher/model_config.yml
    log1.txt

  4. cd tests/assets/pytorch_launcher && python3 ~/datumaro/datum.py model add -p ~/datumaro/test -l ac -- -c model_config.yml
    log2.txt

@zhiltsov-max
Copy link
Contributor Author

Thanks for the comments.

  1. Yes, there is some problem with listing plugin dependencies. Here you only need to install Accuracy checker. Actually, it is an unfortunate coincidence that it was found in your OpenVINO env.
  2. Should be fixed.
  3. Right, in this version it is impossible to launch a model with arbitrary location without absolute path in the config.
  4. Opened a PR with fix AC: Add data mapping to CPU for PyTorch launcher when no CUDA available openvinotoolkit/open_model_zoo#1209

@zhiltsov-max zhiltsov-max changed the title [Dependent] [Datumaro] Add generic accuracy checker model launcher [Datumaro] Add generic accuracy checker model launcher Jun 15, 2020
@zhiltsov-max zhiltsov-max changed the title [Datumaro] Add generic accuracy checker model launcher [Dependent] [Datumaro] Add generic accuracy checker model launcher Jun 16, 2020
@zhiltsov-max zhiltsov-max changed the title [Dependent] [Datumaro] Add generic accuracy checker model launcher [Datumaro] Add generic accuracy checker model launcher Jun 17, 2020
Copy link
Contributor

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- datumaro/datumaro/plugins/accuracy_checker_plugin/details/representation.py  9
- datumaro/datumaro/plugins/accuracy_checker_plugin/launcher.py  3
- datumaro/datumaro/plugins/accuracy_checker_plugin/details/ac.py  9
- datumaro/tests/assets/pytorch_launcher/samplenet.py  1
         

See the complete overview on Codacy

@nmanovic nmanovic merged commit ae3b06b into develop Jun 24, 2020
@nmanovic nmanovic deleted the zm/acwb-integration-2 branch June 24, 2020 13:52
@nmanovic nmanovic restored the zm/acwb-integration-2 branch June 24, 2020 13:52
@nmanovic nmanovic deleted the zm/acwb-integration-2 branch June 24, 2020 13:52
frndmg pushed a commit to signatrix/cvat that referenced this pull request Aug 5, 2020
* Refactor inference wrapper

* Add accuracy checker launcher wrapper

* t

* rename method

* Add importer for openvino launcher

* Move openvino plugin to iecore

* add generic AC launcher

* Implement cli for AC launcher

* move ac plugin dir

* prevent tf reimport

* Fix outputs conversion

* t

* add pytorch model example

* Require config path in launcher

* Clear extra whitespace
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.

5 participants