diff --git a/README.md b/README.md index 352b66b8b90..adb6bd23f42 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # [OpenVINO™ Toolkit](https://01.org/openvinotoolkit) - Open Model Zoo repository -[![Stable release](https://img.shields.io/badge/version-2021.2-green.svg)](https://github.com/opencv/open_model_zoo/releases/tag/2021.2) +[![Stable release](https://img.shields.io/badge/version-2021.2-green.svg)](https://github.com/openvinotoolkit/open_model_zoo/releases/tag/2021.2) [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/open_model_zoo/community) [![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE) @@ -31,7 +31,7 @@ Open Model Zoo is licensed under [Apache License Version 2.0](LICENSE). We welcome community contributions to the Open Model Zoo repository. If you have an idea how to improve the product, please share it with us doing the following steps: * Make sure you can build the product and run all the demos with your patch. * In case of a larger feature, provide a relevant demo. -* Submit a pull request at https://github.com/opencv/open_model_zoo/pulls +* Submit a pull request at https://github.com/openvinotoolkit/open_model_zoo/pulls You can find additional information about model contribution [here](CONTRIBUTING.md). @@ -42,7 +42,7 @@ Open Model Zoo is licensed under Apache License, Version 2.0. By contributing to ## Support Please report questions, issues and suggestions using: * [\#open_model_zoo](https://stackoverflow.com/search?q=%23open_model_zoo) tag on StackOverflow* -* [GitHub* Issues](https://github.com/opencv/open_model_zoo/issues) +* [GitHub* Issues](https://github.com/openvinotoolkit/open_model_zoo/issues) * [Forum](https://software.intel.com/en-us/forums/intel-distribution-of-openvino-toolkit) * [Gitter](https://gitter.im/open_model_zoo/community) diff --git a/ci/get-jobs-for-changes.py b/ci/get-jobs-for-changes.py index f690e0b3cfb..7a21a958d96 100755 --- a/ci/get-jobs-for-changes.py +++ b/ci/get-jobs-for-changes.py @@ -52,13 +52,17 @@ def main(): jobs = {} for changed_file in changed_files: - if models_dir in changed_file.parents and changed_file.name == "model.yml": + if models_dir in changed_file.parents and \ + (changed_file.name == "model.yml" or changed_file.suffix == ".py"): if Path(changed_file).exists(): # it might've been deleted in the branch - jobs.setdefault("models", []).append(changed_file.parent.name) + jobs.setdefault("models", set()).add(changed_file.parent.name) else: # make sure no models.lst files reference the deleted model jobs["models_lst"] = True + if "models" in jobs: + jobs["models"] = sorted(jobs["models"]) # JSON can't work with a set + git_check_attr_output = subprocess.run( ["git", "check-attr", "--stdin", "-z", "--all"], input=git_diff_output, stdout=subprocess.PIPE, check=True).stdout diff --git a/ci/requirements-ac-test.txt b/ci/requirements-ac-test.txt index 20b6eb7fc2d..621e363a347 100644 --- a/ci/requirements-ac-test.txt +++ b/ci/requirements-ac-test.txt @@ -1,42 +1,48 @@ # use update-requirements.py to update this file atomicwrites==1.4.0 # via -r tools/accuracy_checker/requirements-test.in -attrs==19.3.0 # via pytest +attrs==20.2.0 # via pytest +certifi==2020.6.20 # via matplotlib +click==7.1.2 # via nltk cycler==0.10.0 # via matplotlib decorator==4.4.2 # via networkx editdistance==0.5.3 # via -r tools/accuracy_checker/requirements.in +fast-ctc-decode==0.2.5 # via -r tools/accuracy_checker/requirements.in imageio==2.9.0 # via scikit-image -importlib-metadata==1.7.0 # via pluggy, pytest -joblib==0.14.1 # via scikit-learn -kiwisolver==1.1.0 # via matplotlib -matplotlib==3.0.3 # via scikit-image -more-itertools==8.4.0 # via pytest -networkx==2.4 # via scikit-image -nibabel==3.0.2 # via -r tools/accuracy_checker/requirements.in -numpy==1.17.5 # via -r tools/accuracy_checker/requirements-core.in, imageio, matplotlib, nibabel, pywavelets, scikit-learn, scipy -packaging==20.4 # via pytest -pathlib2==2.3.5 # via pytest -pillow==7.2.0 # via -r tools/accuracy_checker/requirements.in, imageio, scikit-image +importlib-metadata==2.0.0 # via pluggy, pytest +joblib==0.17.0 # via nltk, scikit-learn +kiwisolver==1.2.0 # via matplotlib +matplotlib==3.3.2 # via scikit-image +more-itertools==8.5.0 # via pytest +networkx==2.5 # via scikit-image +nibabel==3.1.1 # via -r tools/accuracy_checker/requirements.in +nltk==3.5 # via -r tools/accuracy_checker/requirements.in +numpy==1.17.5 # via -r tools/accuracy_checker/requirements-core.in, imageio, matplotlib, nibabel, parasail, pywavelets, scikit-image, scikit-learn, scipy, tifffile +packaging==20.4 # via nibabel, pytest +parasail==1.2 # via -r tools/accuracy_checker/requirements.in +pillow==8.0.0 # via -r tools/accuracy_checker/requirements-core.in, imageio, matplotlib, scikit-image pluggy==0.13.1 # via pytest -py-cpuinfo==4.0.0 # via -r tools/accuracy_checker/requirements.in +py-cpuinfo==7.0.0 # via -r tools/accuracy_checker/requirements.in py==1.9.0 # via pytest pydicom==2.0.0 # via -r tools/accuracy_checker/requirements.in pyparsing==2.4.7 # via matplotlib, packaging +pypi-kenlm==0.1.20190403 # via -r tools/accuracy_checker/requirements.in pytest-mock==2.0.0 # via -r tools/accuracy_checker/requirements-test.in pytest==5.4.3 # via -r tools/accuracy_checker/requirements-test.in, pytest-mock python-dateutil==2.8.1 # via matplotlib pywavelets==1.1.1 # via scikit-image pyyaml==5.3.1 # via -r tools/accuracy_checker/requirements-core.in -scikit-image==0.15.0 # via -r tools/accuracy_checker/requirements.in -scikit-learn==0.22.2.post1 # via -r tools/accuracy_checker/requirements.in -scipy==1.4.1 # via -r tools/accuracy_checker/requirements.in, scikit-image, scikit-learn +regex==2020.10.15 # via nltk +scikit-image==0.17.2 # via -r tools/accuracy_checker/requirements.in +scikit-learn==0.23.2 # via -r tools/accuracy_checker/requirements.in +scipy==1.5.2 # via -r tools/accuracy_checker/requirements.in, scikit-image, scikit-learn sentencepiece==0.1.91 # via -r tools/accuracy_checker/requirements.in -shapely==1.7.0 # via -r tools/accuracy_checker/requirements.in -six==1.15.0 # via packaging, pathlib2, python-dateutil -tokenizers==0.8.0 # via -r tools/accuracy_checker/requirements.in -tqdm==4.47.0 # via -r tools/accuracy_checker/requirements.in +shapely==1.7.1 # via -r tools/accuracy_checker/requirements.in +six==1.15.0 # via packaging, python-dateutil +threadpoolctl==2.1.0 # via scikit-learn +tifffile==2020.9.3 # via scikit-image +tokenizers==0.9.1 # via -r tools/accuracy_checker/requirements.in +tqdm==4.50.2 # via -r tools/accuracy_checker/requirements.in, nltk wcwidth==0.2.5 # via pytest -zipp==1.2.0 # via importlib-metadata - -# The following packages are considered to be unsafe in a requirements file: -# setuptools +wheel==0.35.1 # via parasail +zipp==3.3.0 # via importlib-metadata diff --git a/ci/requirements-ac.txt b/ci/requirements-ac.txt index 4071174321f..d5c53b2625c 100644 --- a/ci/requirements-ac.txt +++ b/ci/requirements-ac.txt @@ -1,30 +1,38 @@ # use update-requirements.py to update this file +certifi==2020.6.20 # via matplotlib +click==7.1.2 # via nltk cycler==0.10.0 # via matplotlib decorator==4.4.2 # via networkx editdistance==0.5.3 # via -r tools/accuracy_checker/requirements.in +fast-ctc-decode==0.2.5 # via -r tools/accuracy_checker/requirements.in imageio==2.9.0 # via scikit-image -joblib==0.14.1 # via scikit-learn -kiwisolver==1.1.0 # via matplotlib -matplotlib==3.0.3 # via scikit-image -networkx==2.4 # via scikit-image -nibabel==3.0.2 # via -r tools/accuracy_checker/requirements.in -numpy==1.17.5 # via -r tools/accuracy_checker/requirements-core.in, imageio, matplotlib, nibabel, pywavelets, scikit-learn, scipy -pillow==7.2.0 # via -r tools/accuracy_checker/requirements.in, imageio, scikit-image -py-cpuinfo==4.0.0 # via -r tools/accuracy_checker/requirements.in +joblib==0.17.0 # via nltk, scikit-learn +kiwisolver==1.2.0 # via matplotlib +matplotlib==3.3.2 # via scikit-image +networkx==2.5 # via scikit-image +nibabel==3.1.1 # via -r tools/accuracy_checker/requirements.in +nltk==3.5 # via -r tools/accuracy_checker/requirements.in +numpy==1.17.5 # via -r tools/accuracy_checker/requirements-core.in, imageio, matplotlib, nibabel, parasail, pywavelets, scikit-image, scikit-learn, scipy, tifffile +packaging==20.4 # via nibabel +parasail==1.2 # via -r tools/accuracy_checker/requirements.in +pillow==8.0.0 # via -r tools/accuracy_checker/requirements-core.in, imageio, matplotlib, scikit-image +py-cpuinfo==7.0.0 # via -r tools/accuracy_checker/requirements.in pydicom==2.0.0 # via -r tools/accuracy_checker/requirements.in -pyparsing==2.4.7 # via matplotlib +pyparsing==2.4.7 # via matplotlib, packaging +pypi-kenlm==0.1.20190403 # via -r tools/accuracy_checker/requirements.in python-dateutil==2.8.1 # via matplotlib pywavelets==1.1.1 # via scikit-image pyyaml==5.3.1 # via -r tools/accuracy_checker/requirements-core.in -scikit-image==0.15.0 # via -r tools/accuracy_checker/requirements.in -scikit-learn==0.22.2.post1 # via -r tools/accuracy_checker/requirements.in -scipy==1.4.1 # via -r tools/accuracy_checker/requirements.in, scikit-image, scikit-learn +regex==2020.10.15 # via nltk +scikit-image==0.17.2 # via -r tools/accuracy_checker/requirements.in +scikit-learn==0.23.2 # via -r tools/accuracy_checker/requirements.in +scipy==1.5.2 # via -r tools/accuracy_checker/requirements.in, scikit-image, scikit-learn sentencepiece==0.1.91 # via -r tools/accuracy_checker/requirements.in -shapely==1.7.0 # via -r tools/accuracy_checker/requirements.in -six==1.15.0 # via python-dateutil -tokenizers==0.8.0 # via -r tools/accuracy_checker/requirements.in -tqdm==4.47.0 # via -r tools/accuracy_checker/requirements.in - -# The following packages are considered to be unsafe in a requirements file: -# setuptools +shapely==1.7.1 # via -r tools/accuracy_checker/requirements.in +six==1.15.0 # via packaging, python-dateutil +threadpoolctl==2.1.0 # via scikit-learn +tifffile==2020.9.3 # via scikit-image +tokenizers==0.9.1 # via -r tools/accuracy_checker/requirements.in +tqdm==4.50.2 # via -r tools/accuracy_checker/requirements.in, nltk +wheel==0.35.1 # via parasail diff --git a/ci/requirements-conversion.txt b/ci/requirements-conversion.txt index 3ba397e4b6d..50c2d1a2735 100644 --- a/ci/requirements-conversion.txt +++ b/ci/requirements-conversion.txt @@ -1,53 +1,53 @@ # use update-requirements.py to update this file -absl-py==0.9.0 # via tensorboard, tensorflow +absl-py==0.10.0 # via tensorboard, tensorflow astunparse==1.6.3 # via tensorflow cachetools==4.1.1 # via google-auth certifi==2020.6.20 # via requests chardet==3.0.4 # via requests decorator==4.4.2 # via networkx -defusedxml==0.6.0 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements.txt -future==0.18.2 # via -r tools/downloader/requirements-caffe2.in +defusedxml==0.6.0 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_caffe.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_mxnet.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_onnx.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_tf2.txt +future==0.18.2 # via -r tools/downloader/requirements-caffe2.in, torch gast==0.3.3 # via tensorflow google-auth-oauthlib==0.4.1 # via tensorboard -google-auth==1.18.0 # via google-auth-oauthlib, tensorboard +google-auth==1.22.1 # via google-auth-oauthlib, tensorboard google-pasta==0.2.0 # via tensorflow graphviz==0.8.4 # via mxnet -grpcio==1.30.0 # via tensorboard, tensorflow +grpcio==1.32.0 # via tensorboard, tensorflow h5py==2.10.0 # via tensorflow idna==2.10 # via requests -importlib-metadata==1.7.0 # via markdown +importlib-metadata==2.0.0 # via markdown keras-preprocessing==1.1.2 # via tensorflow -markdown==3.2.2 # via tensorboard -mxnet==1.5.1 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements.txt -networkx==2.4 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements.txt -numpy==1.18.5 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements.txt, h5py, keras-preprocessing, mxnet, onnx, opt-einsum, scipy, tensorboard, tensorflow, torch, torchvision +markdown==3.3.1 # via tensorboard +mxnet==1.5.1 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_mxnet.txt +networkx==2.5 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_caffe.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_mxnet.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_onnx.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_tf2.txt +numpy==1.18.5 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_caffe.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_mxnet.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_onnx.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_tf2.txt, h5py, keras-preprocessing, mxnet, onnx, opt-einsum, scipy, tensorboard, tensorflow, torch, torchvision oauthlib==3.1.0 # via requests-oauthlib -onnx==1.7.0 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements.txt, -r tools/downloader/requirements-caffe2.in, -r tools/downloader/requirements-pytorch.in -opt-einsum==3.2.1 # via tensorflow -pillow==7.2.0 # via torchvision -protobuf==3.12.2 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements.txt, onnx, tensorboard, tensorflow +onnx==1.7.0 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_onnx.txt, -r tools/downloader/requirements-caffe2.in, -r tools/downloader/requirements-pytorch.in +opt-einsum==3.3.0 # via tensorflow +pillow==8.0.0 # via torchvision +protobuf==3.13.0 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_caffe.txt, onnx, tensorboard, tensorflow pyasn1-modules==0.2.8 # via google-auth pyasn1==0.4.8 # via pyasn1-modules, rsa requests-oauthlib==1.3.0 # via google-auth-oauthlib requests==2.24.0 # via mxnet, requests-oauthlib, tensorboard rsa==4.6 # via google-auth -scipy==1.4.1 # via -r tools/downloader/requirements-pytorch.in, tensorflow -six==1.15.0 # via absl-py, astunparse, google-auth, google-pasta, grpcio, h5py, keras-preprocessing, onnx, protobuf, tensorboard, tensorflow, test-generator, torchvision +scipy==1.5.2 # via -r tools/downloader/requirements-pytorch.in +six==1.15.0 # via absl-py, astunparse, google-auth, google-pasta, grpcio, h5py, keras-preprocessing, onnx, protobuf, tensorboard, tensorflow, test-generator tensorboard-plugin-wit==1.7.0 # via tensorboard -tensorboard==2.2.2 # via tensorflow -tensorflow-estimator==2.2.0 # via tensorflow -tensorflow==2.2.0 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements.txt +tensorboard==2.3.0 # via tensorflow +tensorflow-estimator==2.3.0 # via tensorflow +tensorflow==2.3.1 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_tf2.txt termcolor==1.1.0 # via tensorflow -test-generator==0.1.1 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements.txt -torch==1.4.0 # via -r tools/downloader/requirements-caffe2.in, -r tools/downloader/requirements-pytorch.in, torchvision -torchvision==0.5.0 # via -r tools/downloader/requirements-pytorch.in -typing-extensions==3.7.4.2 # via onnx -urllib3==1.25.9 # via requests +test-generator==0.1.1 # via -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_caffe.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_mxnet.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_onnx.txt, -r ${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/requirements_tf2.txt +torch==1.6.0 # via -r tools/downloader/requirements-caffe2.in, -r tools/downloader/requirements-pytorch.in, torchvision +torchvision==0.7.0 # via -r tools/downloader/requirements-pytorch.in +typing-extensions==3.7.4.3 # via onnx +urllib3==1.25.10 # via requests werkzeug==1.0.1 # via tensorboard -wheel==0.34.2 # via astunparse, tensorboard, tensorflow +wheel==0.35.1 # via astunparse, tensorboard, tensorflow wrapt==1.12.1 # via tensorflow -zipp==1.2.0 # via importlib-metadata +zipp==3.3.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/ci/requirements-demos.txt b/ci/requirements-demos.txt index 08ae8b120d7..cd5e0e54e54 100644 --- a/ci/requirements-demos.txt +++ b/ci/requirements-demos.txt @@ -1,33 +1,33 @@ # use update-requirements.py to update this file -absl-py==0.9.0 # via tensorboard -attrs==19.3.0 # via pytest +absl-py==0.10.0 # via tensorboard +attrs==20.2.0 # via pytest cachetools==4.1.1 # via google-auth -certifi==2020.6.20 # via requests +certifi==2020.6.20 # via matplotlib, requests chardet==3.0.4 # via requests cycler==0.10.0 # via matplotlib flake8-import-order==0.18.1 # via motmetrics -flake8==3.8.3 # via motmetrics +flake8==3.8.4 # via motmetrics google-auth-oauthlib==0.4.1 # via tensorboard -google-auth==1.18.0 # via google-auth-oauthlib, tensorboard -grpcio==1.30.0 # via tensorboard +google-auth==1.22.1 # via google-auth-oauthlib, tensorboard +grpcio==1.32.0 # via tensorboard idna==2.10 # via requests -importlib-metadata==1.7.0 # via flake8, markdown, pluggy, pytest -joblib==0.14.1 # via scikit-learn -kiwisolver==1.1.0 # via matplotlib -markdown==3.2.2 # via tensorboard -matplotlib==3.0.3 # via -r demos/python_demos/requirements.txt +importlib-metadata==2.0.0 # via flake8, markdown, pluggy, pytest +iniconfig==1.1.1 # via pytest +joblib==0.17.0 # via scikit-learn +kiwisolver==1.2.0 # via matplotlib +markdown==3.3.1 # via tensorboard +matplotlib==3.3.2 # via -r demos/python_demos/requirements.txt mccabe==0.6.1 # via flake8 -more-itertools==8.4.0 # via pytest motmetrics==1.2.0 # via -r demos/python_demos/requirements.txt -nibabel==3.0.2 # via -r demos/python_demos/requirements.txt -numpy==1.18.5 ; python_version >= "3.4" # via -r ${INTEL_OPENVINO_DIR}/python/requirements.txt, -r demos/python_demos/requirements.txt, matplotlib, motmetrics, nibabel, pandas, scikit-learn, scipy, tensorboard, tensorboardx +nibabel==3.1.1 # via -r demos/python_demos/requirements.txt +numpy==1.19.2 ; python_version >= "3.4" # via -r ${INTEL_OPENVINO_DIR}/python/requirements.txt, -r demos/python_demos/requirements.txt, matplotlib, motmetrics, nibabel, pandas, scikit-learn, scipy, tensorboard, tensorboardx oauthlib==3.1.0 # via requests-oauthlib -packaging==20.4 # via pytest -pandas==0.24.2 # via motmetrics -pathlib2==2.3.5 # via pytest +packaging==20.4 # via nibabel, pytest +pandas==1.1.3 # via motmetrics +pillow==8.0.0 # via matplotlib pluggy==0.13.1 # via pytest -protobuf==3.12.2 # via tensorboard, tensorboardx +protobuf==3.13.0 # via tensorboard, tensorboardx py-cpuinfo==7.0.0 # via pytest-benchmark py==1.9.0 # via pytest pyasn1-modules==0.2.8 # via google-auth @@ -36,25 +36,26 @@ pycodestyle==2.6.0 # via flake8, flake8-import-order pyflakes==2.2.0 # via flake8 pyparsing==2.4.7 # via matplotlib, packaging pytest-benchmark==3.2.3 # via motmetrics -pytest==5.4.3 # via motmetrics, pytest-benchmark +pytest==6.1.1 # via motmetrics, pytest-benchmark python-dateutil==2.8.1 # via matplotlib, pandas pytz==2020.1 # via pandas requests-oauthlib==1.3.0 # via google-auth-oauthlib requests==2.24.0 # via requests-oauthlib, tensorboard rsa==4.6 # via google-auth -scikit-learn==0.22.2.post1 # via -r demos/python_demos/requirements.txt -scipy==1.4.1 # via -r demos/python_demos/requirements.txt, motmetrics, scikit-learn -six==1.15.0 # via absl-py, google-auth, grpcio, packaging, pathlib2, protobuf, python-dateutil, tensorboard, tensorboardx +scikit-learn==0.23.2 # via -r demos/python_demos/requirements.txt +scipy==1.5.2 # via -r demos/python_demos/requirements.txt, motmetrics, scikit-learn +six==1.15.0 # via absl-py, google-auth, grpcio, packaging, protobuf, python-dateutil, tensorboard, tensorboardx tensorboard-plugin-wit==1.7.0 # via tensorboard -tensorboard==2.2.2 # via -r demos/python_demos/requirements.txt +tensorboard==2.3.0 # via -r demos/python_demos/requirements.txt tensorboardx==2.1 # via -r demos/python_demos/requirements.txt -tqdm==4.47.0 # via -r demos/python_demos/requirements.txt -urllib3==1.25.9 # via requests -wcwidth==0.2.5 # via pytest +threadpoolctl==2.1.0 # via scikit-learn +toml==0.10.1 # via pytest +tqdm==4.50.2 # via -r demos/python_demos/requirements.txt +urllib3==1.25.10 # via requests werkzeug==1.0.1 # via tensorboard -wheel==0.34.2 # via tensorboard +wheel==0.35.1 # via tensorboard xmltodict==0.12.0 # via motmetrics -zipp==1.2.0 # via importlib-metadata +zipp==3.3.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/ci/requirements-downloader.txt b/ci/requirements-downloader.txt index 6af9c02fd7f..f8c2503d31a 100644 --- a/ci/requirements-downloader.txt +++ b/ci/requirements-downloader.txt @@ -5,4 +5,4 @@ chardet==3.0.4 # via requests idna==2.10 # via requests pyyaml==5.3.1 # via -r tools/downloader/requirements.in requests==2.24.0 # via -r tools/downloader/requirements.in -urllib3==1.25.9 # via requests +urllib3==1.25.10 # via requests diff --git a/ci/update-requirements.py b/ci/update-requirements.py index 5d180205ed2..9797eb767fb 100755 --- a/ci/update-requirements.py +++ b/ci/update-requirements.py @@ -18,7 +18,7 @@ # Package dependencies can vary depending on the Python version. # We thus have to run pip-compile with the lowest Python version that # the project supports. -EXPECTED_PYTHON_VERSION = (3, 5) +EXPECTED_PYTHON_VERSION = (3, 6) repo_root = Path(__file__).resolve().parent.parent script_name = Path(__file__).name @@ -69,7 +69,8 @@ def pc(target, *sources): 'tools/accuracy_checker/requirements-core.in') pc('ci/requirements-conversion.txt', 'tools/downloader/requirements-pytorch.in', 'tools/downloader/requirements-caffe2.in', - openvino_dir / 'deployment_tools/model_optimizer/requirements.txt') + *(openvino_dir / f'deployment_tools/model_optimizer/requirements_{suffix}.txt' + for suffix in ['caffe', 'mxnet', 'onnx', 'tf2'])) pc('ci/requirements-demos.txt', 'demos/python_demos/requirements.txt', openvino_dir / 'python/requirements.txt') pc('ci/requirements-downloader.txt', diff --git a/datasets.md b/datasets.md index c97526e7480..17dba4c1897 100644 --- a/datasets.md +++ b/datasets.md @@ -36,7 +36,7 @@ To use this dataset with OMZ tools, make sure `` contains the follo * `imagenet_1000_classes_2015` used for evaluation models trained on ILSVRC 2015 dataset with 1000 classes. (model examples: [`se-resnet-152`](models/public/se-resnet-152/se-resnet-152.md), [`se-resnext-50`](models/public/se-resnext-50/se-resnext-50.md)) * `imagenet_1001_classes` used for evaluation models trained on ILSVRC 2012 dataset with 1001 classes (background label + original labels). (model examples: [`googlenet-v2-tf`](models/public/googlenet-v2-tf/googlenet-v2-tf.md), [`resnet-50-tf`](models/public/resnet-50-tf/resnet-50-tf.md)) -## [Common Objects in Context (COCO)](http://cocodataset.org/#home) +## [Common Objects in Context (COCO)](https://cocodataset.org/#home) ### How download dataset diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index e5f1723101d..afb3ba969c0 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -214,7 +214,7 @@ list(REMOVE_ITEM samples_dirs common thirdparty) add_samples_to_build(${samples_dirs}) if(ENABLE_PYTHON) - find_package(PythonInterp 3.5 REQUIRED) + find_package(PythonInterp 3.6 REQUIRED) find_package(PythonLibs "${PYTHON_VERSION_STRING}" EXACT REQUIRED) execute_process( diff --git a/demos/classification_demo/models.lst b/demos/classification_demo/models.lst index ec275a42369..1a7012ab64b 100644 --- a/demos/classification_demo/models.lst +++ b/demos/classification_demo/models.lst @@ -56,6 +56,7 @@ se-resnet-152 se-resnet-50 se-resnext-101 se-resnext-50 +shufflenet-v2-x1.0 squeezenet1.0 squeezenet1.1 squeezenet1.1-caffe2 diff --git a/demos/python_demos/bert_question_answering_demo/README.md b/demos/python_demos/bert_question_answering_demo/README.md index 21d209825b9..38a283b0918 100644 --- a/demos/python_demos/bert_question_answering_demo/README.md +++ b/demos/python_demos/bert_question_answering_demo/README.md @@ -85,7 +85,7 @@ One specific flavor of that is so called "distilled" model (for that reason it c but don't get confused as it is still originated from the BERT Large) that is indeed substantially smaller and faster. The demo also works fine with [official MLPerf* BERT ONNX models fine-tuned on the Squad dataset]( -https://github.com/mlperf/inference/tree/master/v0.7/language/bert). +https://github.com/mlperf/inference/tree/master/language/bert). Unlike [[Open Model Zoo Models](../../../models/intel/index.md) that come directly as the Intermediate Representation (IR), the MLPerf models should be explicitly converted with [OpenVINO Model Optimizer](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html). diff --git a/demos/python_demos/colorization_demo/colorization_demo.py b/demos/python_demos/colorization_demo/colorization_demo.py index 6bd2535a0cb..ad6c8ddd11c 100755 --- a/demos/python_demos/colorization_demo/colorization_demo.py +++ b/demos/python_demos/colorization_demo/colorization_demo.py @@ -132,7 +132,7 @@ def build_arg(): cv.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv.LINE_AA) colorize_image = cv.putText(colorize_image, 'Colorize', (25, 50), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv.LINE_AA) - lab_image = cv.putText(lab_image, 'LAB interpetation', (25, 50), + lab_image = cv.putText(lab_image, 'LAB interpretation', (25, 50), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv.LINE_AA) ir_image = [cv.hconcat([original_image, grayscale_image]), diff --git a/demos/python_demos/human_pose_estimation_3d_demo/modules/parse_poses.py b/demos/python_demos/human_pose_estimation_3d_demo/modules/parse_poses.py index d49a16bc2b6..19fce65e6f0 100644 --- a/demos/python_demos/human_pose_estimation_3d_demo/modules/parse_poses.py +++ b/demos/python_demos/human_pose_estimation_3d_demo/modules/parse_poses.py @@ -60,10 +60,10 @@ def get_root_relative_poses(inference_results): poses_2d.append(pose_2d) poses_2d = np.array(poses_2d) - keypoint_treshold = 0.1 + keypoint_threshold = 0.1 poses_3d = np.ones((len(poses_2d), num_kpt_panoptic * 4), dtype=np.float32) * -1 for pose_id in range(poses_3d.shape[0]): - if poses_2d[pose_id, 2] <= keypoint_treshold: + if poses_2d[pose_id, 2] <= keypoint_threshold: continue pose_3d = poses_3d[pose_id] neck_2d = poses_2d[pose_id, 0:2].astype(np.int32) @@ -78,7 +78,7 @@ def get_root_relative_poses(inference_results): # refine keypoints coordinates at corresponding limbs locations for limb in limbs: for kpt_id_from in limb: - if poses_2d[pose_id, kpt_id_from * 3 + 2] <= keypoint_treshold: + if poses_2d[pose_id, kpt_id_from * 3 + 2] <= keypoint_threshold: continue for kpt_id_where in limb: kpt_from_2d = poses_2d[pose_id, kpt_id_from * 3:kpt_id_from * 3 + 2].astype(np.int32) diff --git a/demos/python_demos/image_retrieval_demo/README.md b/demos/python_demos/image_retrieval_demo/README.md index fa0254fe764..f47173c60be 100644 --- a/demos/python_demos/image_retrieval_demo/README.md +++ b/demos/python_demos/image_retrieval_demo/README.md @@ -73,7 +73,7 @@ python image_retrieval_demo.py \ --ground_truth text_label ``` -An example of file listing gallery images can be found [here](https://github.com/opencv/openvino_training_extensions/blob/develop/tensorflow_toolkit/image_retrieval/data/gallery/gallery.txt). +An example of file listing gallery images can be found [here](https://github.com/openvinotoolkit/training_extensions/blob/develop/tensorflow_toolkit/image_retrieval/data/gallery/gallery.txt). Examples of videos can be found [here](https://github.com/19900531/test). diff --git a/demos/python_demos/instance_segmentation_demo/README.md b/demos/python_demos/instance_segmentation_demo/README.md index 5cdecdaebef..a76a513aadb 100644 --- a/demos/python_demos/instance_segmentation_demo/README.md +++ b/demos/python_demos/instance_segmentation_demo/README.md @@ -1,7 +1,7 @@ # Instance Segmentation Python* Demo This demo shows how to run Instance Segmentation models from `Detectron` or `maskrcnn-benchmark` using OpenVINO™. -These models should be obtained through [OpenVINO™ Training Extensions (OTE)](https://github.com/opencv/openvino_training_extensions/tree/develop/pytorch_toolkit/instance_segmentation#get-pretrained-models). +These models should be obtained through [OpenVINO™ Training Extensions (OTE)](https://github.com/openvinotoolkit/training_extensions/tree/develop/pytorch_toolkit/instance_segmentation#get-pretrained-models). > **NOTE**: Only batch size of 1 is supported. diff --git a/demos/python_demos/monodepth_demo/models.lst b/demos/python_demos/monodepth_demo/models.lst index b41b3069967..12e2402681c 100644 --- a/demos/python_demos/monodepth_demo/models.lst +++ b/demos/python_demos/monodepth_demo/models.lst @@ -1,2 +1,3 @@ # This file can be used with the --list option of the model downloader. +fcrn-dp-nyu-depth-v2-tf midasnet diff --git a/demos/python_demos/monodepth_demo/monodepth_demo.py b/demos/python_demos/monodepth_demo/monodepth_demo.py index 483f32ff5eb..ff226bc8787 100755 --- a/demos/python_demos/monodepth_demo/monodepth_demo.py +++ b/demos/python_demos/monodepth_demo/monodepth_demo.py @@ -73,7 +73,7 @@ def main(): # processing output blob log.info("processing output blob") - disp = res[out_blob][0] + disp = np.squeeze(res[out_blob][0]) # resize disp to input resolution disp = cv2.resize(disp, (input_width, input_height), cv2.INTER_CUBIC) diff --git a/demos/python_demos/multi_camera_multi_target_tracking/README.md b/demos/python_demos/multi_camera_multi_target_tracking/README.md index 53100a8901e..abb5e7802af 100644 --- a/demos/python_demos/multi_camera_multi_target_tracking/README.md +++ b/demos/python_demos/multi_camera_multi_target_tracking/README.md @@ -173,7 +173,7 @@ The demo provides tools for measure quality of the multi camera multi target tra For MOT metrics evaluation we use [py-motmetrics](https://github.com/cheind/py-motmetrics) module. It is necessary to have ground truth annotation file for the evaluation. Supported format -of the ground truth annotation can be obtained via the annotation tool [CVAT](https://github.com/opencv/cvat). +of the ground truth annotation can be obtained via the annotation tool [CVAT](https://github.com/openvinotoolkit/cvat). The annotation must includes the following labels and attributes: ```json [ diff --git a/demos/python_demos/object_detection_demo_ssd_async/object_detection_demo_ssd_async.py b/demos/python_demos/object_detection_demo_ssd_async/object_detection_demo_ssd_async.py index 9f8e9612ad0..c56ad19321b 100755 --- a/demos/python_demos/object_detection_demo_ssd_async/object_detection_demo_ssd_async.py +++ b/demos/python_demos/object_detection_demo_ssd_async/object_detection_demo_ssd_async.py @@ -267,10 +267,10 @@ def preprocess(self, inputs): def postprocess(self, outputs, meta): detections = self.output_parser(outputs) - orginal_image_shape = meta['original_shape'] + original_image_shape = meta['original_shape'] resized_image_shape = meta['resized_shape'] - scale_x = self.w / resized_image_shape[1] * orginal_image_shape[1] - scale_y = self.h / resized_image_shape[0] * orginal_image_shape[0] + scale_x = self.w / resized_image_shape[1] * original_image_shape[1] + scale_y = self.h / resized_image_shape[0] * original_image_shape[0] for detection in detections: detection.xmin *= scale_x detection.xmax *= scale_x diff --git a/demos/python_demos/sound_classification_demo/README.md b/demos/python_demos/sound_classification_demo/README.md index 03d48d5a2c0..9a87968b002 100644 --- a/demos/python_demos/sound_classification_demo/README.md +++ b/demos/python_demos/sound_classification_demo/README.md @@ -4,7 +4,7 @@ Demo application for sound classification algorithm. ## How It Works -Upon the start-up the demo application reads command line parameters and loads a network to Inference engine. It uses only audiofiles in `wav` format. Audio should be converted to model's sample rate using `-sr/--samplerate` option, if sample rate of audio differs from sample rate of model (e.g. [AclNet](../../../model/public/aclnet/aclnet.md) expected 16kHz audio). After reading the audio, it is sliced into clips to fit model input (clips are allowed to overlap with `-ol/--overlap` option) and each clip is processed separately with its own prediction. +Upon the start-up the demo application reads command line parameters and loads a network to Inference engine. It uses only audiofiles in `wav` format. Audio should be converted to model's sample rate using `-sr/--samplerate` option, if sample rate of audio differs from sample rate of model (e.g. [AclNet](../../../models/public/aclnet/aclnet.md) expected 16kHz audio). After reading the audio, it is sliced into clips to fit model input (clips are allowed to overlap with `-ol/--overlap` option) and each clip is processed separately with its own prediction. ## Running diff --git a/demos/python_demos/speech_recognition_demo/ctcdecode-numpy/CMakeLists.txt b/demos/python_demos/speech_recognition_demo/ctcdecode-numpy/CMakeLists.txt index 0cfd35d9d46..4b9ae3bb219 100644 --- a/demos/python_demos/speech_recognition_demo/ctcdecode-numpy/CMakeLists.txt +++ b/demos/python_demos/speech_recognition_demo/ctcdecode-numpy/CMakeLists.txt @@ -5,7 +5,7 @@ execute_process( COMMAND "${PYTHON_EXECUTABLE}" -m pip install . WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/python_demos/speech_recognition_demo/ctcdecode-numpy -RESULT_VARIABLE CTCDECODE_NUMPY_INTALL_FAILED) -if(CTCDECODE_NUMPY_INTALL_FAILED) +RESULT_VARIABLE CTCDECODE_NUMPY_INSTALL_FAILED) +if(CTCDECODE_NUMPY_INSTALL_FAILED) message(FATAL_ERROR "Failed to pip-install ctcdecode_numpy package") endif() diff --git a/demos/python_demos/speech_recognition_demo/speech_recognition_demo.py b/demos/python_demos/speech_recognition_demo/speech_recognition_demo.py index 6e8ff534336..1eed73882fb 100755 --- a/demos/python_demos/speech_recognition_demo/speech_recognition_demo.py +++ b/demos/python_demos/speech_recognition_demo/speech_recognition_demo.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This file is based in part on deepspeech_openvino_0.5.py by Feng Yen-Chang at -# https://github.com/opencv/open_model_zoo/pull/419, commit 529805d011d9b405f142b2b40f4d202bd403a4f1 on Sep 19, 2019. +# https://github.com/openvinotoolkit/open_model_zoo/pull/419, commit 529805d011d9b405f142b2b40f4d202bd403a4f1 on Sep 19, 2019. # import time import wave diff --git a/demos/python_demos/speech_recognition_demo/utils/audio_features.py b/demos/python_demos/speech_recognition_demo/utils/audio_features.py index 92355c559c9..d97024b3bb9 100644 --- a/demos/python_demos/speech_recognition_demo/utils/audio_features.py +++ b/demos/python_demos/speech_recognition_demo/utils/audio_features.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This file is based in its major part on speech_features.py by Feng Yen-Chang at -# https://github.com/opencv/open_model_zoo/pull/419, commit 529805d011d9b405f142b2b40f4d202bd403a4f1 on Sep 19, 2019. +# https://github.com/openvinotoolkit/open_model_zoo/pull/419, commit 529805d011d9b405f142b2b40f4d202bd403a4f1 on Sep 19, 2019. # ################################################## diff --git a/demos/python_demos/speech_recognition_demo/utils/deep_speech_pipeline.py b/demos/python_demos/speech_recognition_demo/utils/deep_speech_pipeline.py index 52efe6d51d1..aa63787b670 100644 --- a/demos/python_demos/speech_recognition_demo/utils/deep_speech_pipeline.py +++ b/demos/python_demos/speech_recognition_demo/utils/deep_speech_pipeline.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This file is based in part on deepspeech_openvino_0.5.py by Feng Yen-Chang at -# https://github.com/opencv/open_model_zoo/pull/419, commit 529805d011d9b405f142b2b40f4d202bd403a4f1 on Sep 19, 2019. +# https://github.com/openvinotoolkit/open_model_zoo/pull/419, commit 529805d011d9b405f142b2b40f4d202bd403a4f1 on Sep 19, 2019. # import os.path diff --git a/demos/smart_classroom_demo/src/action_detector.cpp b/demos/smart_classroom_demo/src/action_detector.cpp index 1b71d0ad5af..3e9811d8b32 100644 --- a/demos/smart_classroom_demo/src/action_detector.cpp +++ b/demos/smart_classroom_demo/src/action_detector.cpp @@ -97,8 +97,8 @@ ActionDetection::ActionDetection(const ActionDetectorConfig& config) const auto anchor_dims = outputInfo[glob_anchor_name]->getDims(); anchor_height = new_network_ ? anchor_dims[2] : anchor_dims[1]; anchor_width = new_network_ ? anchor_dims[3] : anchor_dims[2]; - std::size_t action_dimention_idx = new_network_ ? 1 : 3; - if (anchor_dims[action_dimention_idx] != config_.num_action_classes) { + std::size_t action_dimension_idx = new_network_ ? 1 : 3; + if (anchor_dims[action_dimension_idx] != config_.num_action_classes) { throw std::logic_error("The number of specified actions and the number of actions predicted by " "the Person/Action Detection Retail model must match"); } diff --git a/demos/tests/run_tests.py b/demos/tests/run_tests.py index 9caa673a7c5..9dd0508ab53 100755 --- a/demos/tests/run_tests.py +++ b/demos/tests/run_tests.py @@ -22,7 +22,7 @@ https://drive.google.com/open?id=1A2IU8Sgea1h3fYLpYtFb2v7NYdMjvEhU); * a "ILSVRC2012_img_val" subdirectory with the ILSVRC2012 dataset; * a "Image_Retrieval" subdirectory with image retrieval dataset (images, videos) (see https://github.com/19900531/test) - and list of images (see https://github.com/opencv/openvino_training_extensions/blob/develop/tensorflow_toolkit/image_retrieval/data/gallery/gallery.txt) + and list of images (see https://github.com/openvinotoolkit/training_extensions/blob/develop/tensorflow_toolkit/image_retrieval/data/gallery/gallery.txt) """ import argparse diff --git a/models/intel/faster-rcnn-resnet101-coco-sparse-60-0001/description/faster-rcnn-resnet101-coco-sparse-60-0001.md b/models/intel/faster-rcnn-resnet101-coco-sparse-60-0001/description/faster-rcnn-resnet101-coco-sparse-60-0001.md index ce54770151c..e2b8bd23db8 100644 --- a/models/intel/faster-rcnn-resnet101-coco-sparse-60-0001/description/faster-rcnn-resnet101-coco-sparse-60-0001.md +++ b/models/intel/faster-rcnn-resnet101-coco-sparse-60-0001/description/faster-rcnn-resnet101-coco-sparse-60-0001.md @@ -17,7 +17,7 @@ The model input is a blob that consists of a single image of `1x3x800x1280` in t | MParams | 52.79 | | Source framework | TensorFlow\* | -See Average Precision metric description at [COCO: Common Objects in Context](http://cocodataset.org/#detection-eval). The primary challenge metric is used. Tested on the COCO validation dataset. +See Average Precision metric description at [COCO: Common Objects in Context](https://cocodataset.org/#detection-eval). The primary challenge metric is used. Tested on the COCO validation dataset. ## Performance diff --git a/models/intel/human-pose-estimation-0001/description/human-pose-estimation-0001.md b/models/intel/human-pose-estimation-0001/description/human-pose-estimation-0001.md index 05562a609cd..d7bcd453c03 100644 --- a/models/intel/human-pose-estimation-0001/description/human-pose-estimation-0001.md +++ b/models/intel/human-pose-estimation-0001/description/human-pose-estimation-0001.md @@ -19,7 +19,7 @@ The pose may contain up to 18 keypoints: ears, eyes, nose, neck, shoulders, elbo | MParams | 4.099 | | Source framework | Caffe* | -Average Precision metric described in [COCO Keypoint Evaluation site](http://cocodataset.org/#keypoints-eval). +Average Precision metric described in [COCO Keypoint Evaluation site](https://cocodataset.org/#keypoints-eval). Tested on a COCO validation subset from the original paper [Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields](https://arxiv.org/abs/1611.08050). diff --git a/models/intel/index.md b/models/intel/index.md index 7837945d803..eb9c45230e2 100644 --- a/models/intel/index.md +++ b/models/intel/index.md @@ -2,7 +2,7 @@ OpenVINO™ toolkit provides a set of pre-trained models that you can use for learning and demo purposes or for developing deep learning -software. Most recent version is available in the [repo on Github](https://github.com/opencv/open_model_zoo). +software. Most recent version is available in the [repo on Github](https://github.com/openvinotoolkit/open_model_zoo). The models can be downloaded via Model Downloader (`/deployment_tools/open_model_zoo/tools/downloader`). diff --git a/models/intel/instance-segmentation-security-0010/description/instance-segmentation-security-0010.md b/models/intel/instance-segmentation-security-0010/description/instance-segmentation-security-0010.md index 6a9f78ed968..34ad4d88314 100644 --- a/models/intel/instance-segmentation-security-0010/description/instance-segmentation-security-0010.md +++ b/models/intel/instance-segmentation-security-0010/description/instance-segmentation-security-0010.md @@ -25,7 +25,7 @@ in all ROI-wise heads. | Source framework | PyTorch\* | Average Precision (AP) is defined and measured according to standard -[MS COCO evaluation procedure](http://cocodataset.org/#detection-eval). +[MS COCO evaluation procedure](https://cocodataset.org/#detection-eval). ## Performance diff --git a/models/intel/instance-segmentation-security-0050/description/instance-segmentation-security-0050.md b/models/intel/instance-segmentation-security-0050/description/instance-segmentation-security-0050.md index 8241ee81b1a..15da7bea4f2 100644 --- a/models/intel/instance-segmentation-security-0050/description/instance-segmentation-security-0050.md +++ b/models/intel/instance-segmentation-security-0050/description/instance-segmentation-security-0050.md @@ -22,7 +22,7 @@ and light-weight RPN. | Source framework | PyTorch\* | Average Precision (AP) is defined and measured according to standard -[MS COCO evaluation procedure](http://cocodataset.org/#detection-eval). +[MS COCO evaluation procedure](https://cocodataset.org/#detection-eval). ## Performance diff --git a/models/intel/instance-segmentation-security-0083/description/instance-segmentation-security-0083.md b/models/intel/instance-segmentation-security-0083/description/instance-segmentation-security-0083.md index 2fea5680d1a..2119c225cf6 100644 --- a/models/intel/instance-segmentation-security-0083/description/instance-segmentation-security-0083.md +++ b/models/intel/instance-segmentation-security-0083/description/instance-segmentation-security-0083.md @@ -24,7 +24,7 @@ Feature Pyramid Networks block for feature maps refinement. | Source framework | PyTorch\* | Average Precision (AP) is defined and measured according to standard -[MS COCO evaluation procedure](http://cocodataset.org/#detection-eval). +[MS COCO evaluation procedure](https://cocodataset.org/#detection-eval). ## Performance diff --git a/models/intel/instance-segmentation-security-1025/description/instance-segmentation-security-1025.md b/models/intel/instance-segmentation-security-1025/description/instance-segmentation-security-1025.md index beeb69b3323..009063ee57a 100644 --- a/models/intel/instance-segmentation-security-1025/description/instance-segmentation-security-1025.md +++ b/models/intel/instance-segmentation-security-1025/description/instance-segmentation-security-1025.md @@ -22,7 +22,7 @@ SERes detection head, and dual attention segmentation head. | Source framework | PyTorch\* | Average Precision (AP) is defined and measured according to the standard -[MS COCO evaluation procedure](http://cocodataset.org/#detection-eval). +[MS COCO evaluation procedure](https://cocodataset.org/#detection-eval). ## Performance diff --git a/models/intel/pedestrian-and-vehicle-detector-adas-0001/description/pedestrian-and-vehicle-detector-adas-0001.md b/models/intel/pedestrian-and-vehicle-detector-adas-0001/description/pedestrian-and-vehicle-detector-adas-0001.md index dd3ba419aa0..ae0023b02a8 100644 --- a/models/intel/pedestrian-and-vehicle-detector-adas-0001/description/pedestrian-and-vehicle-detector-adas-0001.md +++ b/models/intel/pedestrian-and-vehicle-detector-adas-0001/description/pedestrian-and-vehicle-detector-adas-0001.md @@ -21,7 +21,7 @@ Pedestrian and vehicle detection network based on MobileNet v1.0 + SSD. | Source framework | Caffe* | Average Precision (AP) metric is described in: Mark Everingham et al. -[The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +[The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on challenging internal datasets with 1001 pedestrian and 12585 vehicles to detect. diff --git a/models/intel/pedestrian-detection-adas-0002/description/pedestrian-detection-adas-0002.md b/models/intel/pedestrian-detection-adas-0002/description/pedestrian-detection-adas-0002.md index befab052cab..98b8c485105 100644 --- a/models/intel/pedestrian-detection-adas-0002/description/pedestrian-detection-adas-0002.md +++ b/models/intel/pedestrian-detection-adas-0002/description/pedestrian-detection-adas-0002.md @@ -20,7 +20,7 @@ Pedestrian detection network based on SSD framework with tuned MobileNet v1 as a | Source framework | Caffe* | Average Precision metric described in: Mark Everingham et al. -[The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +[The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on an internal dataset with 1001 pedestrian to detect. diff --git a/models/intel/vehicle-detection-adas-0002/description/vehicle-detection-adas-0002.md b/models/intel/vehicle-detection-adas-0002/description/vehicle-detection-adas-0002.md index 30e9e7f16fb..9ea42ebc320 100644 --- a/models/intel/vehicle-detection-adas-0002/description/vehicle-detection-adas-0002.md +++ b/models/intel/vehicle-detection-adas-0002/description/vehicle-detection-adas-0002.md @@ -19,7 +19,7 @@ This is a vehicle detection network based on an SSD framework with tuned MobileN | MParams | 1.079 | | Source framework | Caffe* | -For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on a challenging internal dataset with 3000 images and 12585 vehicles to detect. diff --git a/models/intel/yolo-v2-ava-0001/description/yolo-v2-ava-0001.md b/models/intel/yolo-v2-ava-0001/description/yolo-v2-ava-0001.md index 804b0e0fb87..c995c986dc3 100644 --- a/models/intel/yolo-v2-ava-0001/description/yolo-v2-ava-0001.md +++ b/models/intel/yolo-v2-ava-0001/description/yolo-v2-ava-0001.md @@ -14,7 +14,7 @@ This is a reimplemented and retrained version of the [YOLO v2](https://arxiv.org | Flops | 48.29Bn\* | | Source framework | TensorFlow\* | -For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on the VOC 2012 validation dataset. ## Performance diff --git a/models/intel/yolo-v2-ava-sparse-35-0001/description/yolo-v2-ava-sparse-35-0001.md b/models/intel/yolo-v2-ava-sparse-35-0001/description/yolo-v2-ava-sparse-35-0001.md index b9ee7cfe293..c72c3f7b1ae 100644 --- a/models/intel/yolo-v2-ava-sparse-35-0001/description/yolo-v2-ava-sparse-35-0001.md +++ b/models/intel/yolo-v2-ava-sparse-35-0001/description/yolo-v2-ava-sparse-35-0001.md @@ -15,7 +15,7 @@ This is a reimplemented and retrained version of the [YOLO v2](https://arxiv.org | Flops | 48.29Bn* | | Source framework | TensorFlow\* | -For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on the VOC 2012 validation dataset. ## Performance diff --git a/models/intel/yolo-v2-ava-sparse-70-0001/description/yolo-v2-ava-sparse-70-0001.md b/models/intel/yolo-v2-ava-sparse-70-0001/description/yolo-v2-ava-sparse-70-0001.md index 90f6665c33a..35d0cdd8ae1 100644 --- a/models/intel/yolo-v2-ava-sparse-70-0001/description/yolo-v2-ava-sparse-70-0001.md +++ b/models/intel/yolo-v2-ava-sparse-70-0001/description/yolo-v2-ava-sparse-70-0001.md @@ -15,7 +15,7 @@ This is a reimplemented and retrained version of the [YOLO v2](https://arxiv.org | Flops | 48.29Bn* | | Source framework | TensorFlow\* | -For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on the VOC 2012 validation dataset. ## Performance diff --git a/models/intel/yolo-v2-tiny-ava-0001/description/yolo-v2-tiny-ava-0001.md b/models/intel/yolo-v2-tiny-ava-0001/description/yolo-v2-tiny-ava-0001.md index 05778adfc16..834599a0d54 100644 --- a/models/intel/yolo-v2-tiny-ava-0001/description/yolo-v2-tiny-ava-0001.md +++ b/models/intel/yolo-v2-tiny-ava-0001/description/yolo-v2-tiny-ava-0001.md @@ -14,7 +14,7 @@ This is a reimplemented and retrained version of the [tiny YOLO v2](https://arxi | Flops | 6.97Bn* | | Source framework | TensorFlow\* | -For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on the VOC 2012 validation dataset. ## Performance diff --git a/models/intel/yolo-v2-tiny-ava-sparse-30-0001/description/yolo-v2-tiny-ava-sparse-30-0001.md b/models/intel/yolo-v2-tiny-ava-sparse-30-0001/description/yolo-v2-tiny-ava-sparse-30-0001.md index f24482e274a..c632728876a 100644 --- a/models/intel/yolo-v2-tiny-ava-sparse-30-0001/description/yolo-v2-tiny-ava-sparse-30-0001.md +++ b/models/intel/yolo-v2-tiny-ava-sparse-30-0001/description/yolo-v2-tiny-ava-sparse-30-0001.md @@ -15,7 +15,7 @@ This is a reimplemented and retrained version of the [tiny YOLO v2](https://arxi | Flops | 6.97Bn* | | Source framework | TensorFlow\* | -For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on the VOC 2012 validation dataset. ## Performance diff --git a/models/intel/yolo-v2-tiny-ava-sparse-60-0001/description/yolo-v2-tiny-ava-sparse-60-0001.md b/models/intel/yolo-v2-tiny-ava-sparse-60-0001/description/yolo-v2-tiny-ava-sparse-60-0001.md index 09389d3df65..d77f2af6db9 100644 --- a/models/intel/yolo-v2-tiny-ava-sparse-60-0001/description/yolo-v2-tiny-ava-sparse-60-0001.md +++ b/models/intel/yolo-v2-tiny-ava-sparse-60-0001/description/yolo-v2-tiny-ava-sparse-60-0001.md @@ -15,7 +15,7 @@ This is a reimplemented and retrained version of the [tiny YOLO v2](https://arxi | Flops | 6.97Bn* | | Source framework | TensorFlow\* | -For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf). +For Average Precision metric description, see [The PASCAL Visual Object Classes (VOC) Challenge](https://doi.org/10.1007/s11263-009-0275-4). Tested on the VOC 2012 validation dataset. ## Performance diff --git a/models/public/densenet-121-caffe2/densenet-121-caffe2.md b/models/public/densenet-121-caffe2/densenet-121-caffe2.md index afa5646885f..e22b4299f95 100644 --- a/models/public/densenet-121-caffe2/densenet-121-caffe2.md +++ b/models/public/densenet-121-caffe2/densenet-121-caffe2.md @@ -5,7 +5,7 @@ This is a Caffe2\* version of `densenet-121` model, one of the DenseNet group of models designed to perform image classification. This model was converted from Caffe\* to Caffe2\* format. -For details see repository , +For details see repository , paper . ## Example @@ -68,5 +68,5 @@ probability for each class in logits format. ## Legal Information The original model is distributed under the -[Apache License, Version 2.0](https://raw.githubusercontent.com/caffe2/models/master/LICENSE). +[Apache License, Version 2.0](https://raw.githubusercontent.com/facebookarchive/models/master/LICENSE). A copy of the license is provided in [APACHE-2.0.txt](../licenses/APACHE-2.0.txt). diff --git a/models/public/densenet-121-caffe2/model.yml b/models/public/densenet-121-caffe2/model.yml index c8f5f456aed..2a64f23f55e 100644 --- a/models/public/densenet-121-caffe2/model.yml +++ b/models/public/densenet-121-caffe2/model.yml @@ -15,7 +15,7 @@ description: >- This is a Caffe2* version of "densenet-121" model, one of the DenseNet group of models designed to perform image classification. This model was converted from Caffe* - to Caffe2* format. For details see repository , + to Caffe2* format. For details see repository , paper . task_type: classification files: @@ -42,4 +42,4 @@ model_optimizer_args: - --mean_values=data[103.94,116.78,123.68] - --scale_values=data[58.8235294] - --input_model=$conv_dir/densenet-121-caffe2.onnx -license: https://raw.githubusercontent.com/caffe2/models/master/LICENSE +license: https://raw.githubusercontent.com/facebookarchive/models/master/LICENSE diff --git a/models/public/fcrn-dp-nyu-depth-v2-tf/accuracy-check.yml b/models/public/fcrn-dp-nyu-depth-v2-tf/accuracy-check.yml new file mode 100644 index 00000000000..55846148e57 --- /dev/null +++ b/models/public/fcrn-dp-nyu-depth-v2-tf/accuracy-check.yml @@ -0,0 +1,20 @@ +models: + - name: fcrn-dp-nyu-depth-v2-tf + launchers: + - framework: dlsdk + adapter: mono_depth + datasets: + - name: NYU_Depth_V2 + preprocessing: + - type: resize + use_pillow: true + dst_height: 228 + dst_width: 304 + postprocessing: + - type: resize_prediction_depth_map + metrics: + - type: rmse + - type: log10_error + name: log10 + - type: mape + name: rel diff --git a/models/public/fcrn-dp-nyu-depth-v2-tf/fcrn-dp-nyu-depth-v2-tf.md b/models/public/fcrn-dp-nyu-depth-v2-tf/fcrn-dp-nyu-depth-v2-tf.md new file mode 100644 index 00000000000..2dd494f53bd --- /dev/null +++ b/models/public/fcrn-dp-nyu-depth-v2-tf/fcrn-dp-nyu-depth-v2-tf.md @@ -0,0 +1,111 @@ +# fcrn-dp-nyu-depth-v2-tf + +## Use Case and High-Level Description + +This is a model for monocular depth estimation trained on the NYU Depth V2 dataset, + as described in the paper [Deeper Depth Prediction with Fully Convolutional Residual Networks](https://arxiv.org/abs/1606.00373), where it is referred to as ResNet-UpProj. + The model input is a single color image. + The model output is an inverse depth map that is defined up to an unknown scale factor. More details can be found in the [following repository](https://github.com/iro-cp/FCRN-DepthPrediction). + + +## Specification + +| Metric | Value | +|-------------------|---------------| +| Type | Monodepth | +| GFLOPs | 63.5421 | +| MParams | 34.5255 | +| Source framework | TensorFlow\* | + +## Accuracy + +| Metric | Value | +| ------ | ----- | +| [RMSE](https://en.wikipedia.org/wiki/Root-mean-square_deviation) | 0.573 | +| log10 | 0.055 | +| rel | 0.127 | + +Accuracy numbers obtained on NUY Depth V2 dataset. +The `log10` metric is logarithmic absolute error, defined as `abs(log10(gt) - log10(pred))`, +where `gt` - ground truth depth map, `pred` - predicted depth map. +The `rel` metric is relative absolute error defined as absolute error normalized on ground truth depth map values +(`abs(gt - pred) / gt`, where `gt` - ground truth depth map, `pred` - predicted depth map). + + +## Input + +### Original Model + +Image, name - `Placeholder`, shape - `1,228,304,3`, format is `B,H,W,C` where: + +- `B` - batch size +- `C` - channel +- `H` - height +- `W` - width + +Channel order is `RGB`. + +### Converted Model + +Image, name - `Placeholder`, shape - `1,3,228,304`, format is `B,C,H,W` where: + +- `B` - batch size +- `C` - channel +- `H` - height +- `W` - width + +Channel order is `BGR`. + +## Output + +### Original Model + +Inverse depth map, name - `ConvPred/ConvPred`, shape - `1,128,160`, format is `B,H,W` where: + +- `B` - batch size +- `H` - height +- `W` - width + +Inverse depth map is defined up to an unknown scale factor. + +### Converted Model + +Inverse depth map, name - `ConvPred/ConvPred`, shape - `1,128,160`, format is `B,H,W` where: + +- `B` - batch size +- `H` - height +- `W` - width + +Inverse depth map is defined up to an unknown scale factor. + +## Legal Information + +The original model is released under the following [license](https://raw.githubusercontent.com/iro-cp/FCRN-DepthPrediction/master/LICENSE): + +``` +Copyright (c) 2016, Iro Laina +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` + +[*] Other names and brands may be claimed as the property of others. diff --git a/models/public/fcrn-dp-nyu-depth-v2-tf/model.yml b/models/public/fcrn-dp-nyu-depth-v2-tf/model.yml new file mode 100644 index 00000000000..6a4727b67bb --- /dev/null +++ b/models/public/fcrn-dp-nyu-depth-v2-tf/model.yml @@ -0,0 +1,38 @@ +# Copyright (c) 2020 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +description: >- + FCRN ResNet50 UpProj is a model for monocular depth estimation trained by NYU Depth V2 dataset; + as described in the paper "Deeper Depth Prediction with Fully Convolutional Residual Networks" + . + The model input is a blob that consists of a single image of "1x228x304x3" in RGB order. + The model output is an inverse depth map that is defined up to an unknown scale factor. +task_type: monocular_depth_estimation +framework: tf +files: + - name: NYU_FCRN-checkpoint.zip + size: 472588519 + sha256: 9d97ed165c4a5b3f085eb83b8814de1e883c6348da60da4b2568ddd64bb2d5c4 + source: http://campar.in.tum.de/files/rupprecht/depthpred/NYU_FCRN-checkpoint.zip +postprocessing: + - $type: unpack_archive + format: zip + file: NYU_FCRN-checkpoint.zip +model_optimizer_args: + - --input=Placeholder + - --reverse_input_channels + - --input_shape=[1,228,304,3] + - --output=ConvPred/ConvPred + - --input_meta=$dl_dir/NYU_FCRN.ckpt.meta +license: https://raw.githubusercontent.com/iro-cp/FCRN-DepthPrediction/master/LICENSE diff --git a/models/public/googlenet-v2-tf/accuracy-check.yml b/models/public/googlenet-v2-tf/accuracy-check.yml index b8b1ed9d7e7..b6add3c2c78 100644 --- a/models/public/googlenet-v2-tf/accuracy-check.yml +++ b/models/public/googlenet-v2-tf/accuracy-check.yml @@ -16,6 +16,6 @@ models: - name: accuracy@top1 type: accuracy top_k: 1 - - name: acciracy@top5 + - name: accuracy@top5 type: accuracy top_k: 5 diff --git a/models/public/i3d-rgb-tf/accuracy-check.yml b/models/public/i3d-rgb-tf/accuracy-check.yml index 23e25f3a3e9..d042ddaa715 100644 --- a/models/public/i3d-rgb-tf/accuracy-check.yml +++ b/models/public/i3d-rgb-tf/accuracy-check.yml @@ -1,5 +1,5 @@ models: - - name: i3d-rgb-tf + - name: i3d-rgb launchers: - framework: dlsdk adapter: classification diff --git a/models/public/index.md b/models/public/index.md index ea2f1d83c86..a5dbbe144b9 100644 --- a/models/public/index.md +++ b/models/public/index.md @@ -2,7 +2,7 @@ OpenVINO™ toolkit provides a set of public models that you can use for learning and demo purposes or for developing deep learning -software. Most recent version is available in the [repo on Github](https://github.com/opencv/open_model_zoo). +software. Most recent version is available in the [repo on Github](https://github.com/openvinotoolkit/open_model_zoo). The models can be downloaded via Model Downloader (`/deployment_tools/open_model_zoo/tools/downloader`). @@ -57,6 +57,7 @@ The models can be downloaded via Model Downloader | SE-ResNet 152 | Caffe\* | [se-resnet-152](./se-resnet-152/se-resnet-152.md) | 78.506%/94.45% | 22.709 | 66.746 | | SE-ResNeXt 50 | Caffe\* | [se-resnext-50](./se-resnext-50/se-resnext-50.md) | 78.968%/94.63% | 8.533 | 27.526| | SE-ResNeXt 101 | Caffe\* | [se-resnext-101](./se-resnext-101/se-resnext-101.md) | 80.168%/95.19% | 16.054 | 48.886 | +| Shufflenet V2 x1.0 | PyTorch\* | [shufflenet-v2-x1.0](./shufflenet-v2-x1.0/shufflenet-v2-x1.0.md) | 69.36%/88.32% | 0.2957 | 2.2705 | | SqueezeNet v1.0 | Caffe\* | [squeezenet1.0](./squeezenet1.0/squeezenet1.0.md)| 57.684%/80.38%| 1.737 | 1.248 | | SqueezeNet v1.1 | Caffe\*
Caffe2\* | [squeezenet1.1](./squeezenet1.1/squeezenet1.1.md)
[squeezenet1.1-caffe2](./squeezenet1.1-caffe2/squeezenet1.1-caffe2.md)| 58.382%/81%
56.502%/79.576% | 0.785 | 1.236 | | VGG 16 | Caffe\* | [vgg16](./vgg16/vgg16.md) | 70.968%/89.878% | 30.974 | 138.358 | @@ -169,6 +170,7 @@ Since this task contains - in the general setting - some ambiguity, the resultin | Model Name | Implementation | OMZ Model Name | Accuracy | GFlops | mParams | | --------------------------- | -------------- | ----------------------------- | -------- | --------- | ------- | | midasnet | PyTorch\* | [midasnet](./midasnet/midasnet.md)| 7.5878| 207.4915 | 104.0814 | +| FCRN ResNet50-Upproj | TensorFlow\* | [fcrn-dp-nyu-depth-v2-tf](./fcrn-dp-nyu-depth-v2-tf/fcrn-dp-nyu-depth-v2-tf.md)| 0.573 | 63.5421 | 34.5255 | ## Image Inpainting diff --git a/models/public/resnest-50-pytorch/accuracy-check.yml b/models/public/resnest-50-pytorch/accuracy-check.yml index 182f45d678f..bc132ba80c9 100644 --- a/models/public/resnest-50-pytorch/accuracy-check.yml +++ b/models/public/resnest-50-pytorch/accuracy-check.yml @@ -24,6 +24,6 @@ models: - name: accuracy@top1 type: accuracy top_k: 1 - - name: acciracy@top5 + - name: accuracy@top5 type: accuracy top_k: 5 diff --git a/models/public/resnet-50-caffe2/model.yml b/models/public/resnet-50-caffe2/model.yml index e8301e2b8c3..d67334b69a0 100644 --- a/models/public/resnet-50-caffe2/model.yml +++ b/models/public/resnet-50-caffe2/model.yml @@ -15,7 +15,7 @@ description: >- This is a Caffe2* version of the ResNet-50 model, designed to perform image classification. This model was converted from Caffe* to Caffe2* format. For details see repository - , paper . + , paper . task_type: classification files: - name: predict_net.pb @@ -41,4 +41,4 @@ model_optimizer_args: - --mean_values=gpu_0/data[103.53,116.28,123.675] - --scale_values=gpu_0/data[57.375,57.12,58.395] - --input_model=$conv_dir/resnet-50-caffe2.onnx -license: https://raw.githubusercontent.com/caffe2/models/master/LICENSE +license: https://raw.githubusercontent.com/facebookarchive/models/master/LICENSE diff --git a/models/public/resnet-50-caffe2/resnet-50-caffe2.md b/models/public/resnet-50-caffe2/resnet-50-caffe2.md index aa23ddb1a9b..4713c658407 100644 --- a/models/public/resnet-50-caffe2/resnet-50-caffe2.md +++ b/models/public/resnet-50-caffe2/resnet-50-caffe2.md @@ -4,7 +4,7 @@ This is a Caffe2\* version of the ResNet-50 model, designed to perform image classification. This model was converted from Caffe\* to Caffe2\* format. -For details see repository , +For details see repository , paper . ## Example @@ -71,5 +71,5 @@ Object classifier according to ImageNet classes, name - `gpu_0/softmax`, shape ## Legal Information The original model is distributed under the -[Apache License, Version 2.0](https://raw.githubusercontent.com/caffe2/models/master/LICENSE). +[Apache License, Version 2.0](https://raw.githubusercontent.com/facebookarchive/models/master/LICENSE). A copy of the license is provided in [APACHE-2.0.txt](../licenses/APACHE-2.0.txt). diff --git a/models/public/shufflenet-v2-x1.0/accuracy-check.yml b/models/public/shufflenet-v2-x1.0/accuracy-check.yml new file mode 100644 index 00000000000..cd144946871 --- /dev/null +++ b/models/public/shufflenet-v2-x1.0/accuracy-check.yml @@ -0,0 +1,29 @@ +models: + - name: shufflenet-v2-x1.0 + + launchers: + - framework: dlsdk + adapter: classification + + datasets: + - name: imagenet_1000_classes + reader: pillow_imread + + preprocessing: + - type: resize + size: 256 + aspect_ratio_scale: greater + use_pillow: true + interpolation: BILINEAR + - type: crop + size: 224 + use_pillow: true + - type: rgb_to_bgr + + metrics: + - name: accuracy@top1 + type: accuracy + top_k: 1 + - name: accuracy@top5 + type: accuracy + top_k: 5 diff --git a/models/public/shufflenet-v2-x1.0/model.yml b/models/public/shufflenet-v2-x1.0/model.yml new file mode 100644 index 00000000000..ce8e93c840f --- /dev/null +++ b/models/public/shufflenet-v2-x1.0/model.yml @@ -0,0 +1,50 @@ +# Copyright (c) 2020 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +description: >- + Shufflenet V2 x1.0 is image classification model pretrained on ImageNet dataset. + This is PyTorch implementation based on architecture described in paper "ShuffleNet + V2: Practical Guidelines for Efficient CNN Architecture Design" + in TorchVision package (see here ). + + The model input is a blob that consists of a single image of "1x3x224x224" in RGB + order. + + The model output is typical object classifier for the 1000 different classifications + matching with those in the ImageNet database. + +task_type: classification +files: + - name: shufflenetv2_x1-5666bf0f80.pth + sha256: 5666bf0f80d1e7f8fb61f6a65742b9c27c37f3208c1f087cdcd7c1ec1aa8b848 + size: 9218294 + source: https://download.pytorch.org/models/shufflenetv2_x1-5666bf0f80.pth +framework: pytorch +conversion_to_onnx_args: + - --model-path=$dl_dir + - --model-name=shufflenet_v2_x1_0 + - --weights=$dl_dir/shufflenetv2_x1-5666bf0f80.pth + - --import-module=torchvision.models + - --input-shape=1,3,224,224 + - --output-file=$conv_dir/shufflenet-v2-x1.0.onnx + - --input-names=input + - --output-names=output +model_optimizer_args: + - --input=input + - --mean_values=input[123.675,116.28,103.53] + - --scale_values=input[58.395,57.12,57.375] + - --reverse_input_channels + - --output=output + - --input_model=$conv_dir/shufflenet-v2-x1.0.onnx +license: https://raw.githubusercontent.com/pytorch/vision/master/LICENSE diff --git a/models/public/shufflenet-v2-x1.0/shufflenet-v2-x1.0.md b/models/public/shufflenet-v2-x1.0/shufflenet-v2-x1.0.md new file mode 100644 index 00000000000..018fc77cc84 --- /dev/null +++ b/models/public/shufflenet-v2-x1.0/shufflenet-v2-x1.0.md @@ -0,0 +1,104 @@ +# shufflenet-v2-x1.0 + +## Use Case and High-Level Description + +Shufflenet V2 x1.0 is image classification model pretrained on ImageNet dataset. This is PyTorch implementation based on architecture described in paper ["ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design"](https://arxiv.org/pdf/1807.11164.pdf) in TorchVision package (see [here](https://github.com/pytorch/vision)). + +The model input is a blob that consists of a single image of "1x3x224x224" in RGB order. + +The model output is typical object classifier for the 1000 different classifications matching with those in the ImageNet database. + +## Example + +## Specification + +| Metric | Value | +| ---------------- | -------------- | +| Type | Classification | +| GFLOPs | 0.2957 | +| MParams | 2.2705 | +| Source framework | PyTorch\* | + +## Accuracy + +| Metric | Value | +| ------ | ----- | +| Top 1 | 69.36% | +| Top 5 | 88.32% | + +## Performance + +## Input + +### Original model + +Image, name - `input`, shape - `1,3,224,224`, format is `B,C,H,W` where: + +- `B` - batch size +- `C` - channel +- `H` - height +- `W` - width + +Channel order is `RGB`. +Mean values - [123.675,116.28,103.53], scale values - [58.395,57.12,57.375]. + +### Converted model + +Image, name - `input`, shape - `1,3,224,224`, format is `B,C,H,W` where: + +- `B` - batch size +- `C` - channel +- `H` - height +- `W` - width + +Channel order is `BGR` + +## Output + +### Original model + +Object classifier according to ImageNet classes, name - `output`, shape - `1,1000`, output data format is `B,C` where: + +- `B` - batch size +- `C` - Predicted probabilities for each class in [0, 1] range + +### Converted model + +The converted model has the same parameters as the original model. + +## Legal Information + +The original model is distributed under the following +[license](https://raw.githubusercontent.com/pytorch/vision/master/LICENSE): + +``` +BSD 3-Clause License + +Copyright (c) Soumith Chintala 2016, +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` diff --git a/models/public/squeezenet1.1-caffe2/model.yml b/models/public/squeezenet1.1-caffe2/model.yml index 22e44fd739b..92c8be10647 100644 --- a/models/public/squeezenet1.1-caffe2/model.yml +++ b/models/public/squeezenet1.1-caffe2/model.yml @@ -15,7 +15,7 @@ description: >- This is a Caffe2* version of "squeezenet1.1" model, designed to perform image classification. This model was converted from Caffe* to Caffe2* format. For details see repository - , paper . + , paper . task_type: classification files: - name: predict_net.pb @@ -40,4 +40,4 @@ model_optimizer_args: - --mean_values=data[103.96,116.78,123.68] - --input_model=$conv_dir/squeezenet1.1-caffe2.onnx quantizable: yes -license: https://raw.githubusercontent.com/caffe2/models/master/LICENSE +license: https://raw.githubusercontent.com/facebookarchive/models/master/LICENSE diff --git a/models/public/squeezenet1.1-caffe2/squeezenet1.1-caffe2.md b/models/public/squeezenet1.1-caffe2/squeezenet1.1-caffe2.md index be5bdf48993..dae4e22fac1 100644 --- a/models/public/squeezenet1.1-caffe2/squeezenet1.1-caffe2.md +++ b/models/public/squeezenet1.1-caffe2/squeezenet1.1-caffe2.md @@ -4,7 +4,7 @@ This is a Caffe2\* version of `squeezenet1.1` model, designed to perform image classification. This model was converted from Caffe\* to Caffe2\* format. -For details see repository , +For details see repository , paper . ## Example @@ -71,5 +71,5 @@ Object classifier according to ImageNet classes, name - `softmaxout`, shape - `1 ## Legal Information The original model is distributed under the -[Apache License, Version 2.0](https://raw.githubusercontent.com/caffe2/models/master/LICENSE). +[Apache License, Version 2.0](https://raw.githubusercontent.com/facebookarchive/models/master/LICENSE). A copy of the license is provided in [APACHE-2.0.txt](../licenses/APACHE-2.0.txt). diff --git a/models/public/ssd-resnet34-1200-onnx/ssd-resnet34-1200-onnx.md b/models/public/ssd-resnet34-1200-onnx/ssd-resnet34-1200-onnx.md index e52a5dd910c..dd7b7e900e7 100644 --- a/models/public/ssd-resnet34-1200-onnx/ssd-resnet34-1200-onnx.md +++ b/models/public/ssd-resnet34-1200-onnx/ssd-resnet34-1200-onnx.md @@ -52,7 +52,7 @@ Channel order is `BGR`. ## Output -> **NOTE** output format changes after Model Optimizer conversion. To find detailed explanation of changes, go to [Model Optimizer development guide](http://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Object_Detection_API_Models.html) +> **NOTE** output format changes after Model Optimizer conversion. To find detailed explanation of changes, go to [Model Optimizer development guide](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Object_Detection_API_Models.html) ### Original model diff --git a/models/public/ssd_resnet50_v1_fpn_coco/model.yml b/models/public/ssd_resnet50_v1_fpn_coco/model.yml index cf06e9167b5..38818d9b151 100644 --- a/models/public/ssd_resnet50_v1_fpn_coco/model.yml +++ b/models/public/ssd_resnet50_v1_fpn_coco/model.yml @@ -15,7 +15,7 @@ description: >- The "ssd_resnet50_v1_fpn_coco" model is a SSD FPN object detection architecture based on ResNet-50. The model has been trained from the Common Objects in Context - (COCO) image dataset. For details see the repository + (COCO) image dataset. For details see the repository and paper . task_type: detection files: diff --git a/models/public/ssd_resnet50_v1_fpn_coco/ssd_resnet50_v1_fpn_coco.md b/models/public/ssd_resnet50_v1_fpn_coco/ssd_resnet50_v1_fpn_coco.md index 8e79f578d66..7013e79d753 100644 --- a/models/public/ssd_resnet50_v1_fpn_coco/ssd_resnet50_v1_fpn_coco.md +++ b/models/public/ssd_resnet50_v1_fpn_coco/ssd_resnet50_v1_fpn_coco.md @@ -4,7 +4,7 @@ The `ssd_resnet50_v1_fpn_coco` model is a SSD FPN object detection architecture based on ResNet-50. The model has been trained from the Common Objects in Context (COCO) image dataset. -For details see the [repository](https://github.com/tensorflow/models/blob/master/research/object_detection) +For details see the [repository](https://github.com/tensorflow/models/tree/master/research/object_detection) and [paper](https://arxiv.org/abs/1708.02002). ## Example diff --git a/models/public/vgg19-caffe2/model.yml b/models/public/vgg19-caffe2/model.yml index ceab5b3169d..475d5bf1b39 100644 --- a/models/public/vgg19-caffe2/model.yml +++ b/models/public/vgg19-caffe2/model.yml @@ -15,7 +15,7 @@ description: >- This is a Caffe2* version of "vgg19" model, designed to perform image classification. This model was converted from Caffe* to Caffe2* format. For details see repository - , paper . + , paper . task_type: classification files: - name: predict_net.pb @@ -40,4 +40,4 @@ model_optimizer_args: - --input=data - --mean_values=data[103.939,116.779,123.68] - --input_model=$conv_dir/vgg19-caffe2.onnx -license: https://raw.githubusercontent.com/caffe2/models/master/LICENSE +license: https://raw.githubusercontent.com/facebookarchive/models/master/LICENSE diff --git a/models/public/vgg19-caffe2/vgg19-caffe2.md b/models/public/vgg19-caffe2/vgg19-caffe2.md index b039fd9c9f0..00321351696 100644 --- a/models/public/vgg19-caffe2/vgg19-caffe2.md +++ b/models/public/vgg19-caffe2/vgg19-caffe2.md @@ -4,7 +4,7 @@ This is a Caffe2\* version of `vgg19` model, designed to perform image classification. This model was converted from Caffe\* to Caffe2\* format. -For details see repository , +For details see repository , paper . ## Example @@ -70,5 +70,5 @@ Object classifier according to ImageNet classes, name - `prob`, shape - `1,1000` ## Legal Information The original model is distributed under the -[Apache License, Version 2.0](https://raw.githubusercontent.com/caffe2/models/master/LICENSE). +[Apache License, Version 2.0](https://raw.githubusercontent.com/facebookarchive/models/master/LICENSE). A copy of the license is provided in [APACHE-2.0.txt](../licenses/APACHE-2.0.txt). diff --git a/models/public/yolo-v2-tf/accuracy-check.yml b/models/public/yolo-v2-tf/accuracy-check.yml index 1ada7681810..87f1cc17ab2 100644 --- a/models/public/yolo-v2-tf/accuracy-check.yml +++ b/models/public/yolo-v2-tf/accuracy-check.yml @@ -4,7 +4,7 @@ models: launchers: - framework: tf model: yolo-v2.pb - output_names: [conv2d_23/BiasAdd] + output_names: [conv2d_22/BiasAdd] adapter: type: yolo_v2 anchors: "0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828" diff --git a/models/public/yolo-v2-tf/keras_to_tensorflow.py.patch b/models/public/yolo-v2-tf/keras_to_tensorflow.py.patch deleted file mode 100644 index c9f76349934..00000000000 --- a/models/public/yolo-v2-tf/keras_to_tensorflow.py.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/keras_to_tensorflow.py b/keras_to_tensorflow.py -index c66cbbd..6290ed5 100644 ---- a/keras_to_tensorflow.py -+++ b/keras_to_tensorflow.py -@@ -16,7 +16,7 @@ from pathlib import Path - from absl import app - from absl import flags - from absl import logging --import keras -+from tensorflow import keras - from keras import backend as K - from keras.models import model_from_json, model_from_yaml diff --git a/models/public/yolo-v2-tf/model.yml b/models/public/yolo-v2-tf/model.yml index c72a06600e0..a356625dceb 100644 --- a/models/public/yolo-v2-tf/model.yml +++ b/models/public/yolo-v2-tf/model.yml @@ -14,20 +14,20 @@ description: >- YOLO v2 is a real-time object detection model implemented with Keras* from this - repository and converted to TensorFlow* - framework. This model was pretrained on COCO* dataset with 80 classes. + repository and converted to + TensorFlow* framework. This model was pretrained on COCO* dataset with 80 classes. task_type: detection files: - name: yolo-v2.pb - size: 204013999 - sha256: 973d0d531dace080d7dd8028c875e0224b504d44c279da2da55d1db183bd7f64 - source: https://download.01.org/opencv/public_models/022020/yolo_v2/yolov2.pb + size: 203970473 + sha256: 37163e414a912ecc44ebdcf40ff172c748cfb08264141eadad1fdaf3f96ba369 + source: https://download.01.org/opencv/public_models/102020/yolo-v2-tf/yolo-v2.pb model_optimizer_args: - --input_shape=[1,608,608,3] - - --input=input_1 - - --scale_values=input_1[255] + - --input=image_input + - --scale_values=image_input[255] - --reverse_input_channels - --transformations_config=$mo_dir/extensions/front/tf/yolo_v2.json - --input_model=$dl_dir/yolo-v2.pb framework: tf -license: https://raw.githubusercontent.com/shaqian/tfjs-yolo/master/LICENSE +license: https://raw.githubusercontent.com/david8862/keras-YOLOv3-model-set/master/LICENSE diff --git a/models/public/yolo-v2-tf/yolo-v2-tf.md b/models/public/yolo-v2-tf/yolo-v2-tf.md index 8d6b84f9b11..89808c648ed 100644 --- a/models/public/yolo-v2-tf/yolo-v2-tf.md +++ b/models/public/yolo-v2-tf/yolo-v2-tf.md @@ -2,30 +2,27 @@ ## Use Case and High-Level Description -YOLO v2 is a real-time object detection model implemented with Keras\* from this [repository](https://github.com/allanzelener/YAD2K) and converted to TensorFlow\* framework. This model was pretrained on COCO\* dataset with 80 classes. +YOLO v2 is a real-time object detection model implemented with Keras\* from this [repository](https://github.com/david8862/keras-YOLOv3-model-set) and converted to TensorFlow\* framework. This model was pretrained on COCO\* dataset with 80 classes. ## Conversion -1. Download or clone the official [repository](https://github.com/allanzelener/YAD2K) (tested on `a42c760` commit). -2. Follow the instructions in the README.md file in that repository to get original model and convert it to Keras\* format. -3. Convert the produced model to protobuf format. +1. Download or clone the original [repository](https://github.com/david8862/keras-YOLOv3-model-set) (tested on `d38c3d8` commit). +2. Use the following commands to get original model (named `yolov2` in repository) and convert it to Keras\* format (see details in the [README.md](https://github.com/david8862/keras-YOLOv3-model-set/blob/d38c3d865f7190ee9b19a30e91f2b750a31320c1/README.md) file in the official repository): - 1. Get conversion script from [repository](https://github.com/amir-abdi/keras_to_tensorflow): - ```buildoutcfg - git clone https://github.com/amir-abdi/keras_to_tensorflow + 1. Download YOLO v2 weights: ``` - 1. (Optional) Checkout the commit that the conversion was tested on: + wget -O weights/yolov2.weights https://pjreddie.com/media/files/yolov2.weights ``` - git checkout c84150 - ``` - 1. Apply `keras_to_tensorflow.py.patch`: - ``` - git apply keras_to_tensorflow.py.patch - ``` - 1. Run script: + + 2. Convert model weights to Keras\*: ``` - python keras_to_tensorflow.py --input_model=.h5 --output_model=.pb + python tools/model_converter/convert.py cfg/yolov2.cfg weights/yolov2.weights weights/yolov2.h5 ``` +3. Convert model to protobuf: + ``` + python tools/model_converter/keras_to_tensorflow.py --input_model weights/yolov2.h5 --output_model=weights/yolo-v2.pb + ``` + ## Specification @@ -43,7 +40,7 @@ Accuracy metrics obtained on COCO\* validation dataset for converted model. | Metric | Value | | ------ | ------| | mAP | 53.15% | -| [COCO\* mAP](http://cocodataset.org/#detection-eval) | 56.5% | +| [COCO\* mAP](https://cocodataset.org/#detection-eval) | 56.5% | ## Performance @@ -51,7 +48,7 @@ Accuracy metrics obtained on COCO\* validation dataset for converted model. ### Original model -Image, name - `input_1`, shape - `1,608,608,3`, format is `B,H,W,C` where: +Image, name - `image_input`, shape - `1,608,608,3`, format is `B,H,W,C` where: - `B` - batch size - `H` - height @@ -63,7 +60,7 @@ Scale value - 255. ### Converted model -Image, name - `input_1`, shape - `1,3,608,608`, format is `B,C,H,W` where: +Image, name - `image_input`, shape - `1,3,608,608`, format is `B,C,H,W` where: - `B` - batch size - `C` - channel @@ -76,7 +73,7 @@ Channel order is `BGR`. ### Original model -The array of detection summary info, name - `conv2d_23/BiasAdd`, shape - `1,19,19,425`, format is `B,Cx,Cy,N*85` where +The array of detection summary info, name - `conv2d_22/BiasAdd`, shape - `1,19,19,425`, format is `B,Cx,Cy,N*85` where - `B` - batch size - `Cx`, `Cy` - cell index - `N` - number of detection boxes for cell @@ -91,7 +88,7 @@ The anchor values are `0.57273,0.677385, 1.87446,2.06253, 3.33843,5.47434, 7.882 ### Converted model -The array of detection summary info, name - `conv2d_23/BiasAdd/YoloRegion`, shape - `1,153425`, which could be reshaped to `1,425,19,19` with format `B,N*85,Cx,Cy` where +The array of detection summary info, name - `conv2d_22/BiasAdd/YoloRegion`, shape - `1,153425`, which could be reshaped to `1,425,19,19` with format `B,N*85,Cx,Cy` where - `B` - batch size - `N` - number of detection boxes for cell - `Cx`, `Cy` - cell index @@ -107,23 +104,32 @@ The anchor values are `0.57273,0.677385, 1.87446,2.06253, 3.33843,5.47434, 7.882 ## Legal Information The original model is distributed under the following -[license](https://raw.githubusercontent.com/allanzelener/YAD2K/master/LICENSE): +[license](https://raw.githubusercontent.com/david8862/keras-YOLOv3-model-set/master/LICENSE): ``` -COPYRIGHT +MIT License + +Copyright (c) 2019 david8862 -All contributions by Allan Zelener: -Copyright (c) 2017, Allan Zelener. -All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -All other contributions: -Copyright (c) 2017, the respective contributors. -All rights reserved. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -Each contributor holds copyright over their respective contributions. -The project versioning (Git) records all such contribution source information. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` -LICENSE The MIT License (MIT) diff --git a/models/public/yolo-v2-tiny-tf/keras_to_tensorflow.py.patch b/models/public/yolo-v2-tiny-tf/keras_to_tensorflow.py.patch deleted file mode 100644 index c9f76349934..00000000000 --- a/models/public/yolo-v2-tiny-tf/keras_to_tensorflow.py.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/keras_to_tensorflow.py b/keras_to_tensorflow.py -index c66cbbd..6290ed5 100644 ---- a/keras_to_tensorflow.py -+++ b/keras_to_tensorflow.py -@@ -16,7 +16,7 @@ from pathlib import Path - from absl import app - from absl import flags - from absl import logging --import keras -+from tensorflow import keras - from keras import backend as K - from keras.models import model_from_json, model_from_yaml diff --git a/models/public/yolo-v2-tiny-tf/model.yml b/models/public/yolo-v2-tiny-tf/model.yml index 0b1c4441ba9..fb3846ca85f 100644 --- a/models/public/yolo-v2-tiny-tf/model.yml +++ b/models/public/yolo-v2-tiny-tf/model.yml @@ -13,21 +13,62 @@ # limitations under the License. description: >- - YOLO v2 Tiny is a real-time object detection model from TensorFlow.js* framework. - This model was pretrained on COCO* dataset with 80 classes. + YOLO v2 Tiny is a real-time object detection model implemented with Keras* from + this repository and converted + to TensorFlow* framework. This model was pretrained on COCO* dataset with 80 classes. task_type: detection files: - - name: yolo-v2-tiny.pb - size: 44962543 - sha256: 84ccafde4a5ae0d41a0f201342814718bd35bac52492a0e72c175fecf4231e58 - source: https://download.01.org/opencv/public_models/082020/yolo-v2-tiny-tf/yolo-v2-tiny.pb + - name: yolov2-tiny.weights + size: 44948600 + sha256: 16f4e870f1aed83f0089cb69bfda6b53cb7b2a4a01721be56eaf5c899dfac45f + source: https://pjreddie.com/media/files/yolov2-tiny.weights + - name: keras-YOLOv3-model-set/tools/model_converter/convert.py + size: 12937 + sha256: 12350fbfa942b66fad8a80af100bc14605c9cdcd8508f3eb5cf26647f64d733e + source: https://github.com/david8862/keras-YOLOv3-model-set/raw/d38c3d865f7190ee9b19a30e91f2b750a31320c1/tools/model_converter/convert.py + - name: keras-YOLOv3-model-set/tools/model_converter/keras_to_tensorflow.py + size: 8370 + sha256: 1cc02cf4ec76760c05bc1635654247ba56b9a1864b63fd05534b836bc93e44e7 + source: https://github.com/david8862/keras-YOLOv3-model-set/raw/d38c3d865f7190ee9b19a30e91f2b750a31320c1/tools/model_converter/keras_to_tensorflow.py + - name: keras-YOLOv3-model-set/common/utils.py + size: 5002 + sha256: 90146775879f294e1f1a82c7e35a5be29d815b7a9b14dbe12ba29dd16b3d10a8 + source: https://github.com/david8862/keras-YOLOv3-model-set/raw/d38c3d865f7190ee9b19a30e91f2b750a31320c1/common/utils.py + - name: keras-YOLOv3-model-set/cfg/yolov2-tiny.cfg + size: 1488 + sha256: 58e8f4390c8080a90a40f3b7ec5868ee9ae32519f3c08f57d104e494de04b34d + source: https://github.com/david8862/keras-YOLOv3-model-set/raw/d38c3d865f7190ee9b19a30e91f2b750a31320c1/cfg/yolov2-tiny.cfg +postprocessing: + # disable imports that aren't needed for this model and code that uses them + - $type: regex_replace + file: keras-YOLOv3-model-set/tools/model_converter/convert.py + pattern: 'from yolo4\.' + replacement: '# \g<0>' + - $type: regex_replace + file: keras-YOLOv3-model-set/common/utils.py + pattern: 'import cv2,|from (matplotlib|PIL|common\.backbones|yolo4)\b' + replacement: '# \g<0>' + - $type: regex_replace + file: keras-YOLOv3-model-set/common/utils.py + pattern: '''(swish|hard_\w+|mish)''' + replacement: '# \g<0>' + + # patch TensorFlow 2 compatibility + - $type: regex_replace + file: keras-YOLOv3-model-set/tools/model_converter/keras_to_tensorflow.py + pattern: 'import tensorflow as tf' + replacement: 'import tensorflow.compat.v1 as tf\ntf.disable_v2_behavior()' + - $type: regex_replace + file: keras-YOLOv3-model-set/tools/model_converter/keras_to_tensorflow.py + pattern: 'from tensorflow\.keras\b' + replacement: 'from tensorflow.compat.v1.keras' model_optimizer_args: - --input_shape=[1,416,416,3] - --input=image_input - --scale_values=image_input[255] - --reverse_input_channels - --transformations_config=$mo_dir/extensions/front/tf/yolo_v2_tiny.json - - --input_model=$dl_dir/yolo-v2-tiny.pb + - --input_model=$conv_dir/yolo-v2-tiny.pb framework: tf quantizable: yes license: https://raw.githubusercontent.com/david8862/keras-YOLOv3-model-set/master/LICENSE diff --git a/models/public/yolo-v2-tiny-tf/pre-convert.py b/models/public/yolo-v2-tiny-tf/pre-convert.py new file mode 100755 index 00000000000..680980c36f9 --- /dev/null +++ b/models/public/yolo-v2-tiny-tf/pre-convert.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2020 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +import argparse +import subprocess +import sys + +from pathlib import Path + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('input_dir', type=Path) + parser.add_argument('output_dir', type=Path) + args = parser.parse_args() + + subprocess.run([sys.executable, '--', + str(args.input_dir / 'keras-YOLOv3-model-set/tools/model_converter/convert.py'), + '--', + str(args.input_dir / 'keras-YOLOv3-model-set/cfg/yolov2-tiny.cfg'), + str(args.input_dir / 'yolov2-tiny.weights'), + str(args.output_dir / 'yolo-v2-tiny.h5'), + ], check=True) + + subprocess.run([sys.executable, '--', + str(args.input_dir / 'keras-YOLOv3-model-set/tools/model_converter/keras_to_tensorflow.py'), + '--input_model={}'.format(args.output_dir / 'yolo-v2-tiny.h5'), + '--output_model={}'.format(args.output_dir / 'yolo-v2-tiny.pb'), + ], check=True); + +if __name__ == '__main__': + main() diff --git a/models/public/yolo-v2-tiny-tf/yolo-v2-tiny-tf.md b/models/public/yolo-v2-tiny-tf/yolo-v2-tiny-tf.md index 8e71d08f45f..a3b94c2a8d4 100644 --- a/models/public/yolo-v2-tiny-tf/yolo-v2-tiny-tf.md +++ b/models/public/yolo-v2-tiny-tf/yolo-v2-tiny-tf.md @@ -4,25 +4,6 @@ YOLO v2 Tiny is a real-time object detection model implemented with Keras\* from this [repository](https://github.com/david8862/keras-YOLOv3-model-set) and converted to TensorFlow\* framework. This model was pretrained on COCO\* dataset with 80 classes. -## Conversion - -1. Download or clone the original [repository](https://github.com/david8862/keras-YOLOv3-model-set) (tested on `d38c3d8` commit). -2. Use the following commands to get original model (named `yolov2_tiny` in repository) and convert it to Keras\* format (see details in the [README.md](https://github.com/david8862/keras-YOLOv3-model-set/blob/d38c3d865f7190ee9b19a30e91f2b750a31320c1/README.md) file in the official repository): - - 1. Download YOLO v2 Tiny weights: - ``` - wget -O weights/yolov2-tiny.weights https://pjreddie.com/media/files/yolov2-tiny.weights - ``` - - 2. Convert model weights to Keras\*: - ``` - python tools/model_converter/convert.py cfg/yolov2-tiny.cfg weights/yolov2-tiny.weights weights/yolov2-tiny.h5 - ``` -3. Convert model to protobuf: - ``` - python tools/model_converter/keras_to_tensorflow.py --input_model weights/yolov2-tiny.h5 --output_model=weights/yolo-v2-tiny.pb - ``` - ## Specification | Metric | Value | @@ -39,7 +20,7 @@ Accuracy metrics obtained on COCO\* validation dataset for converted model. | Metric | Value | | ------ | ------| | mAP | 27.34% | -| [COCO\* mAP](http://cocodataset.org/#detection-eval) | 29.11% | +| [COCO\* mAP](https://cocodataset.org/#detection-eval) | 29.11% | ## Input diff --git a/models/public/yolo-v3-tf/keras_to_tensorflow.py.patch b/models/public/yolo-v3-tf/keras_to_tensorflow.py.patch deleted file mode 100644 index c9f76349934..00000000000 --- a/models/public/yolo-v3-tf/keras_to_tensorflow.py.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/keras_to_tensorflow.py b/keras_to_tensorflow.py -index c66cbbd..6290ed5 100644 ---- a/keras_to_tensorflow.py -+++ b/keras_to_tensorflow.py -@@ -16,7 +16,7 @@ from pathlib import Path - from absl import app - from absl import flags - from absl import logging --import keras -+from tensorflow import keras - from keras import backend as K - from keras.models import model_from_json, model_from_yaml diff --git a/models/public/yolo-v3-tf/yolo-v3-tf.md b/models/public/yolo-v3-tf/yolo-v3-tf.md index f2495b58705..be368103584 100644 --- a/models/public/yolo-v3-tf/yolo-v3-tf.md +++ b/models/public/yolo-v3-tf/yolo-v3-tf.md @@ -6,36 +6,22 @@ YOLO v3 is a real-time object detection model implemented with Keras\* from this ## Conversion -1. Download or clone the official [repository](https://github.com/david8862/keras-YOLOv3-model-set) (tested on `ffede5` commit). -2. Use the following commands to get original model (named `yolov3` in repository) and convert it to Keras\* format (see details in the [README.md](https://github.com/david8862/keras-YOLOv3-model-set/blob/ffede5d316568479610b75a3424e2a7b81f0209b/README.md) file in the official repository): +1. Download or clone the official [repository](https://github.com/david8862/keras-YOLOv3-model-set) (tested on `d38c3d8` commit). +2. Use the following commands to get original model (named `yolov3` in repository) and convert it to Keras\* format (see details in the [README.md](https://github.com/david8862/keras-YOLOv3-model-set/blob/d38c3d865f7190ee9b19a30e91f2b750a31320c1/README.md) file in the official repository): 1. Download YOLO v3 weights: ``` wget -O weights/yolov3.weights https://pjreddie.com/media/files/yolov3.weights ``` - 1. Convert model weights to Keras\*: + 2. Convert model weights to Keras\*: ``` - python tools/convert.py cfg/yolov3.cfg weights/yolov3.weights weights/yolov3.h5 - ``` -3. Convert the produced model to protobuf format. - - 1. Get conversion script from [repository](https://github.com/amir-abdi/keras_to_tensorflow): - ```buildoutcfg - git clone https://github.com/amir-abdi/keras_to_tensorflow - ``` - 1. (Optional) Checkout the commit that the conversion was tested on: - ``` - git checkout c841508a88faa5aa1ffc7a4947c3809ea4ec1228 - ``` - 1. Apply `keras_to_tensorflow.py.patch`: - ``` - git apply keras_to_tensorflow.py.patch - ``` - 1. Run script: - ``` - python keras_to_tensorflow.py --input_model=yolov3.h5 --output_model=yolov3.pb + python tools/model_converter/convert.py cfg/yolov3.cfg weights/yolov3.weights weights/yolov3.h5 ``` +3. Convert model to protobuf: + ``` + python tools/model_converter/keras_to_tensorflow.py --input_model weights/yolov3.h5 --output_model=weights/yolo-v3.pb + ``` ## Specification @@ -54,7 +40,7 @@ Accuracy metrics obtained on COCO\* validation dataset for converted model. | Metric | Value | | ------ | ------| | mAP | 62.27% | -| [COCO\* mAP](http://cocodataset.org/#detection-eval) | 67.7% | +| [COCO\* mAP](https://cocodataset.org/#detection-eval) | 67.7% | ## Input diff --git a/models/public/yolo-v3-tiny-tf/yolo-v3-tiny-tf.md b/models/public/yolo-v3-tiny-tf/yolo-v3-tiny-tf.md index 9f26c7d69c0..04912f4deb2 100644 --- a/models/public/yolo-v3-tiny-tf/yolo-v3-tiny-tf.md +++ b/models/public/yolo-v3-tiny-tf/yolo-v3-tiny-tf.md @@ -18,7 +18,7 @@ YOLO v3 Tiny is a real-time object detection model implemented with Keras\* from 2. Convert model weights to Keras\*: ``` - python tools/model_converter/convert.py cfg/yolov3.cfg weights/yolov3-tiny.weights weights/yolov3-tiny.h5 + python tools/model_converter/convert.py cfg/yolov3-tiny.cfg weights/yolov3-tiny.weights weights/yolov3-tiny.h5 ``` 3. Convert model to protobuf: ``` @@ -42,7 +42,7 @@ Accuracy metrics obtained on COCO\* validation dataset for converted model. | Metric | Value | | ------ | ------| | mAP | 35.9% | -| [COCO\* mAP](http://cocodataset.org/#detection-eval) | 39.7% | +| [COCO\* mAP](https://cocodataset.org/#detection-eval) | 39.7% | ## Input diff --git a/tools/accuracy_checker/README.md b/tools/accuracy_checker/README.md index a3b1f10aeb2..468d765e56e 100644 --- a/tools/accuracy_checker/README.md +++ b/tools/accuracy_checker/README.md @@ -156,7 +156,7 @@ models: - name: dataset_name ``` Optionally you can use global configuration. It can be useful for avoiding duplication if you have several models which should be run on the same dataset. -Example of global definitions file can be found here. Global definitions will be merged with evaluation config in the runtime by dataset name. +Example of global definitions file can be found here. Global definitions will be merged with evaluation config in the runtime by dataset name. Parameters of global configuration can be overwritten by local config (e.g. if in definitions specified resize with destination size 224 and in the local config used resize with size 227, the value in config - 227 will be used as resize parameter) You can use field `global_definitions` for specifying path to global definitions directly in the model config or via command line arguments (`-d`, `--definitions`). @@ -185,7 +185,7 @@ If your dataset data is a well-known competition problem (COCO, Pascal VOC, and it is reasonable to declare it in some global configuration file (*definition* file). This way in your local configuration file you can provide only `name` and all required steps will be picked from global one. To pass path to this global configuration use `--definition` argument of CLI. -If you want to evaluate models using prepared config files and well-known datasets, you need to organize folders with validation datasets in a certain way. More detailed information about dataset preparation you can find in Dataset Preparation Guide. +If you want to evaluate models using prepared config files and well-known datasets, you need to organize folders with validation datasets in a certain way. More detailed information about dataset preparation you can find in Dataset Preparation Guide. Each dataset must have: diff --git a/tools/accuracy_checker/accuracy_checker/adapters/README.md b/tools/accuracy_checker/accuracy_checker/adapters/README.md index e97f8e72af7..b3b5912491d 100644 --- a/tools/accuracy_checker/accuracy_checker/adapters/README.md +++ b/tools/accuracy_checker/accuracy_checker/adapters/README.md @@ -259,8 +259,9 @@ AccuracyChecker supports following set of adapters: * `texts_out` - name of output layer with texts. * `confidence_threshold` - confidence threshold that is used to filter out detected instances. * `yolact` - converting raw outputs of Yolact model to to combination of `DetectionPrediction` and `CoCocInstanceSegmentationPrediction`. - * `loc_out` - name of output layer which contains box locations. - * `prior_out` - name of output layer which contains prior boxes. + * `loc_out` - name of output layer which contains box locations, optional if boxes decoding embedded into model. + * `prior_out` - name of output layer which contains prior boxes, optional if boxes decoding embedded into model. + * `boxes_out` - name of output layer which contains decoded output boxes, optional if model has `prior` a `loc` outputs for boxes decoding. * `conf_out` - name of output layer which contains confidence scores for all classes for each box. * `mask_out` - name of output layer which contains instance masks. * `proto_out` - name of output layer which contains proto for masks calculation. diff --git a/tools/accuracy_checker/accuracy_checker/adapters/yolact.py b/tools/accuracy_checker/accuracy_checker/adapters/yolact.py index a711d87616e..47378bbc41d 100644 --- a/tools/accuracy_checker/accuracy_checker/adapters/yolact.py +++ b/tools/accuracy_checker/accuracy_checker/adapters/yolact.py @@ -17,7 +17,7 @@ import cv2 import numpy as np -from ..config import StringField, NumberField +from ..config import StringField, NumberField, ConfigError from ..postprocessor import NMS from ..representation import DetectionPrediction, CoCocInstanceSegmentationPrediction, ContainerPrediction from ..utils import UnsupportedPackage @@ -35,9 +35,10 @@ class YolactAdapter(Adapter): def parameters(cls): params = super().parameters() params.update({ - 'loc_out': StringField(description='name of output with box locations'), + 'boxes_out': StringField(description='name of output with decoded boxes', optional=True), + 'loc_out': StringField(description='name of output with box locations', optional=True), 'conf_out': StringField(description='name of output with confidence scores'), - 'prior_out': StringField(description='name of output with prior boxes'), + 'prior_out': StringField(description='name of output with prior boxes', optional=True), 'mask_out': StringField(description='name of output with masks'), 'proto_out': StringField(description='name of output with proto for masks calculation'), 'confidence_threshold': NumberField( @@ -56,21 +57,25 @@ def configure(self): self.loc_out = self.get_value_from_config('loc_out') self.conf_out = self.get_value_from_config('conf_out') self.prior_out = self.get_value_from_config('prior_out') + self.boxes_out = self.get_value_from_config('boxes_out') self.mask_out = self.get_value_from_config('mask_out') self.proto_out = self.get_value_from_config('proto_out') self.conf_thresh = self.get_value_from_config('confidence_threshold') self.max_num_detections = self.get_value_from_config('max_detections') + if not self.loc_out and not self.prior_out and not self.boxes_out: + raise ConfigError('loc_out and prior_out or boxes_out should be provided') + if not self.boxes_out and not (self.prior_out and self.loc_out): + raise ConfigError('both loc_out and prior_out should be provided') def process(self, raw, identifiers, frame_meta): raw_outputs = self._extract_predictions(raw, frame_meta) - prior_boxes = raw_outputs[self.prior_out] result = [] - for identifier, locs, conf, masks, proto, meta in zip( - identifiers, raw_outputs[self.loc_out], raw_outputs[self.conf_out], + for batch_id, (identifier, conf, masks, proto, meta) in enumerate(zip( + identifiers, raw_outputs[self.conf_out], raw_outputs[self.mask_out], raw_outputs[self.proto_out], frame_meta - ): + )): h, w, _ = meta['image_size'] - boxes = self.decode_boxes(locs, prior_boxes) + boxes = self.get_boxes(batch_id, raw_outputs) conf = np.transpose(conf) cur_scores = conf[1:, :] conf_scores = np.max(cur_scores, axis=0) @@ -179,6 +184,15 @@ def decode_boxes(loc, priors): return boxes + def get_boxes(self, batch_id, raw_outputs): + if self.boxes_out: + boxes = raw_outputs[self.boxes_out][batch_id] + else: + prior_boxes = raw_outputs[self.prior_out] + locs = raw_outputs[self.loc_out][batch_id] + boxes = self.decode_boxes(locs, prior_boxes) + return boxes + @staticmethod def mask_proto_mask_activation(masks): return 1 / (1 + np.exp(-masks)) diff --git a/tools/accuracy_checker/accuracy_checker/annotation_converters/README.md b/tools/accuracy_checker/accuracy_checker/annotation_converters/README.md index d0b60259427..4bd95fb759a 100644 --- a/tools/accuracy_checker/accuracy_checker/annotation_converters/README.md +++ b/tools/accuracy_checker/accuracy_checker/annotation_converters/README.md @@ -230,25 +230,25 @@ The main difference between this converter and `super_resolution` in data organi * `data_dir` - path to dataset root directory. * `gallery_annotation_file` - file with gallery images and IDs concordance in txt format (Optional, default value is `/gallery/list.txt`) * `queries_annotation_file` - file with queries images and IDs concordance in txt format (Optional, default value is `/queries/list.txt`) -* `cvat_object_detection` - converts [CVAT XML annotation version 1.1](https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `DetectionAnnotation`. +* `cvat_object_detection` - converts [CVAT XML annotation version 1.1](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `DetectionAnnotation`. * `annotation_file` - path to xml file in appropriate format. * `has_background` - allows prepend original labels with special class represented background and convert dataset for n+1 classes instead n (default value is True). * `dataset_meta_file` - path path to json file with dataset meta (e.g. label_map, color_encoding).Optional, more details in [Customizing dataset meta](#customizing-dataset-meta) section. -* `cvat_attributes_recognition` - converts [CVAT XML annotation version 1.1](https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `ClassificationAnnotation` or `ContainerAnnotation` with `ClassificationAnnotation` as value type and attribute names as keys (in multiple attributes case). Used bbox attributes as annotation classes. +* `cvat_attributes_recognition` - converts [CVAT XML annotation version 1.1](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `ClassificationAnnotation` or `ContainerAnnotation` with `ClassificationAnnotation` as value type and attribute names as keys (in multiple attributes case). Used bbox attributes as annotation classes. * `annotation_file` - path to xml file in appropriate format. * `label` - the dataset label which will be used for attributes collection (e.g. if your dataset contains 2 labels: `face` and `person` and you want recognise attributes for face, you should use `face` as value for this parameter). -* `cvat_age_gender` - converts [CVAT XML annotation version 1.1](https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images which represent dataset for age gender recognition to `ContainerAnnotation` with `ClassificationAnnotation` for gender recognition, `ClassificationAnnotation` for age classification and `RegeressionAnnotation` for age regression. The identifiers for representations following: `gender_annotation`, `age_class_annotation`, `age_regression_annotation`. +* `cvat_age_gender` - converts [CVAT XML annotation version 1.1](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images which represent dataset for age gender recognition to `ContainerAnnotation` with `ClassificationAnnotation` for gender recognition, `ClassificationAnnotation` for age classification and `RegeressionAnnotation` for age regression. The identifiers for representations following: `gender_annotation`, `age_class_annotation`, `age_regression_annotation`. * `annotation_file` - path to xml file in appropriate format. -* `cvat_facial_landmarks` - converts [CVAT XML annotation version 1.1](https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `FacialLandmarksAnnotation`. +* `cvat_facial_landmarks` - converts [CVAT XML annotation version 1.1](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `FacialLandmarksAnnotation`. * `annotation_file` - path to xml file in appropriate format. -* `cvat_pose_estimation` - converts [CVAT XML annotation version 1.1](https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `PoseEstimationAnnotation`. +* `cvat_pose_estimation` - converts [CVAT XML annotation version 1.1](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `PoseEstimationAnnotation`. * `annotation_file` - path to xml file in appropriate format. -* `cvat_text_recognition` - converts [CVAT XML annotation version 1.1](https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `CharacterRecognitionAnnotation`. +* `cvat_text_recognition` - converts [CVAT XML annotation version 1.1](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `CharacterRecognitionAnnotation`. * `annotation_file` - path to xml file in appropriate format. -* `cvat_binary_multilabel_attributes_recognition` - converts [CVAT XML annotation version 1.1](https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `MultiLabelRecognitionAnnotation`. Used bbox attributes as annotation classes. Each attribute field should contains `T` or `F` values for attribute existence/non-existence on the image respectively. +* `cvat_binary_multilabel_attributes_recognition` - converts [CVAT XML annotation version 1.1](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) format for images to `MultiLabelRecognitionAnnotation`. Used bbox attributes as annotation classes. Each attribute field should contains `T` or `F` values for attribute existence/non-existence on the image respectively. * `annotation_file` - path to xml file in appropriate format. * `label` - the dataset label which will be used for attributes collection (e.g. if your dataset contains 2 labels: `face` and `person` and you want recognise attributes for face, you should use `face` as value for this parameter). -* `cvat_person_detection_action_recognition` converts dataset with [CVAT XML annotation version 1.1](https://github.com/opencv/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) for person detection and action recognition task to `ContainerAnnotation` with `DetectionAnnotation` for person detection quality estimation named `person_annotation` and `ActionDetectionAnnotation` for action recognition named `action_annotation`. +* `cvat_person_detection_action_recognition` converts dataset with [CVAT XML annotation version 1.1](https://github.com/openvinotoolkit/cvat/blob/develop/cvat/apps/documentation/xml_format.md#xml-annotation-format) for person detection and action recognition task to `ContainerAnnotation` with `DetectionAnnotation` for person detection quality estimation named `person_annotation` and `ActionDetectionAnnotation` for action recognition named `action_annotation`. * `annotation_file` - path to xml file with ground truth. * `use_case` - use case, which determines the dataset label map. Supported range actions: * `common_3_actions`(seating, standing, raising hand) @@ -314,7 +314,7 @@ The main difference between this converter and `super_resolution` in data organi * `annotattion_file` - path to annotation file in tf records format. * `cmu_panoptic_keypoints` - converts CMU Panoptic dataset to `PoseEstimation3dAnnotation` format. * `data_dir` - dataset root directory, which contain subdirectories with validation scenes data. -* `clip_action_recognition` - converts annotation video-based action recognition datasets. Before conversion validation set should be preprocessed using approach described [here](https://github.com/opencv/openvino_training_extensions/tree/develop/pytorch_toolkit/action_recognition#preparation). +* `clip_action_recognition` - converts annotation video-based action recognition datasets. Before conversion validation set should be preprocessed using approach described [here](https://github.com/openvinotoolkit/training_extensions/tree/develop/pytorch_toolkit/action_recognition#preparation). * `annotation_file` - path to annotation file in json format. * `data_dir` - path to directory with prepared data (e. g. data/kinetics/frames_data). * `clips_per_video` - number of clips per video (Optional, default 3). @@ -388,6 +388,8 @@ The main difference between this converter and `super_resolution` in data organi * `ref_file` - npy file with reference sequence. * `num_chunks` - subset size for usage in validation, if not provided the whole dataset will be used. * `alphabet` - alphabet for sequence decoding (Optional, default ["N", "A", "C", "G", "T"]). +* `place_recognition` - converts dataset for image based localization task to `PlaceRecognitionAnnotation` + * `subset_file` - matlab file contains info about subset used in validation. ## Customizing Dataset Meta There are situations when we need customize some default dataset parameters (e.g. replace original dataset label map with own.) diff --git a/tools/accuracy_checker/accuracy_checker/annotation_converters/__init__.py b/tools/accuracy_checker/accuracy_checker/annotation_converters/__init__.py index e487eec505c..0fb7cf6dca8 100644 --- a/tools/accuracy_checker/accuracy_checker/annotation_converters/__init__.py +++ b/tools/accuracy_checker/accuracy_checker/annotation_converters/__init__.py @@ -84,6 +84,7 @@ from .features_regression import FeaturesRegressionConverter from .nyu_depth import NYUDepthV2Converter from .dna_seq import DNASequenceDatasetConverter +from .place_recognition import PlaceRecognitionDatasetConverter __all__ = [ 'BaseFormatConverter', @@ -157,4 +158,5 @@ 'FeaturesRegressionConverter', 'Im2latexDatasetConverter', 'DNASequenceDatasetConverter', + 'PlaceRecognitionDatasetConverter' ] diff --git a/tools/accuracy_checker/accuracy_checker/annotation_converters/action_recognition.py b/tools/accuracy_checker/accuracy_checker/annotation_converters/action_recognition.py index a1ad0154f7c..2bccb08ae7a 100644 --- a/tools/accuracy_checker/accuracy_checker/annotation_converters/action_recognition.py +++ b/tools/accuracy_checker/accuracy_checker/annotation_converters/action_recognition.py @@ -15,11 +15,12 @@ """ from collections import OrderedDict +import warnings from ..utils import read_json, read_txt, check_file_existence from ..representation import ClassificationAnnotation from ..data_readers import ClipIdentifier -from ..config import PathField, NumberField, StringField, BoolField +from ..config import PathField, NumberField, StringField, BoolField, ConfigError from .format_converter import BaseFormatConverter, ConverterReturn, verify_label_map @@ -50,7 +51,11 @@ def parameters(cls): 'dataset_meta_file': PathField( description='path to json file with dataset meta (e.g. label_map)', optional=True ), - 'numpy_input': BoolField(description='use numpy arrays instead of images', optional=True, default=False), + 'numpy_input': BoolField(description='use numpy arrays as input', optional=True, default=False), + 'two_stream_input': BoolField(description='use two streams: images and numpy arrays as input', + optional=True, default=False), + 'image_subpath': StringField(description="sub-directory for images", optional=True), + 'numpy_subpath': StringField(description="sub-directory for numpy arrays", optional=True), 'num_samples': NumberField( description='number of samples used for annotation', optional=True, value_type=int, min_value=1 ) @@ -67,11 +72,38 @@ def configure(self): self.subset = self.get_value_from_config('subset') self.dataset_meta = self.get_value_from_config('dataset_meta_file') self.numpy_input = self.get_value_from_config('numpy_input') + self.two_stream_input = self.get_value_from_config('two_stream_input') + self.numpy_subdir = self.get_value_from_config('numpy_subpath') + self.image_subdir = self.get_value_from_config('image_subpath') self.num_samples = self.get_value_from_config('num_samples') + if self.numpy_subdir and (self.numpy_input or + self.two_stream_input) and not (self.data_dir / self.numpy_subdir).exists(): + raise ConfigError('Please check numpy_subpath or data_dir. ' + 'Path {} does not exist'.format(self.data_dir / self.numpy_subdir)) + + if self.image_subdir and (not self.numpy_input or + self.two_stream_input) and not (self.data_dir / self.image_subdir).exists(): + raise ConfigError('Please check image_subpath or data_dir. ' + 'Path {} does not exist'.format(self.data_dir / self.image_subdir)) + + if self.two_stream_input: + if not self.numpy_subdir: + raise ConfigError('numpy_subpath should be provided in case of using two streams') + + if not self.image_subdir: + raise ConfigError('image_subpath should be provided in case of using two streams') + else: + if self.numpy_input and self.numpy_subdir: + warnings.warn("numpy_subpath is provided. " + "Make sure that data_source is {}".format(self.data_dir / self.numpy_subdir)) + if not self.numpy_input and self.image_subdir: + warnings.warn("image_subpath is provided. " + "Make sure that data_source is {}".format(self.data_dir / self.image_subdir)) + def convert(self, check_content=False, progress_callback=None, progress_interval=100, **kwargs): full_annotation = read_json(self.annotation_file, object_pairs_hook=OrderedDict) - data_ext = 'jpg' if not self.numpy_input else 'npy' + data_ext, data_dir = self.get_ext_and_dir() label_map = dict(enumerate(full_annotation['labels'])) if self.dataset_meta: dataset_meta = read_json(self.dataset_meta) @@ -83,41 +115,13 @@ def convert(self, check_content=False, progress_callback=None, progress_interval video_names, annotations = self.get_video_names_and_annotations(full_annotation['database'], self.subset) class_to_idx = {v: k for k, v in label_map.items()} - videos = [] - for video_name, annotation in zip(video_names, annotations): - video_path = self.data_dir / video_name - if not video_path.exists(): - continue - - n_frames_file = video_path / 'n_frames' - n_frames = ( - int(read_txt(n_frames_file)[0].rstrip('\n\r')) if n_frames_file.exists() - else len(list(video_path.glob('*.{}'.format(data_ext)))) - ) - if n_frames <= 0: - continue - - begin_t = 1 - end_t = n_frames - sample = { - 'video': video_path, - 'video_name': video_name, - 'segment': [begin_t, end_t], - 'n_frames': n_frames, - 'video_id': video_name, - 'label': class_to_idx[annotation['label']] - } - - videos.append(sample) - if self.num_samples and len(videos) == self.num_samples: - break - + videos = self.get_videos(video_names, annotations, class_to_idx, data_dir, data_ext) videos = sorted(videos, key=lambda v: v['video_id'].split('/')[-1]) clips = [] for video in videos: - for clip in self.get_clips(video, self.clips_per_video, self.clip_duration, self.temporal_stride, data_ext): - clips.append(clip) + clips.extend(self.get_clips(video, self.clips_per_video, + self.clip_duration, self.temporal_stride, data_ext)) annotations = [] num_iterations = len(clips) @@ -125,43 +129,108 @@ def convert(self, check_content=False, progress_callback=None, progress_interval for clip_idx, clip in enumerate(clips): if progress_callback is not None and clip_idx % progress_interval: progress_callback(clip_idx * 100 / num_iterations) - identifier = ClipIdentifier(clip['video_name'], clip_idx, clip['frames']) + identifier = [] + for ext in data_ext: + identifier.append(ClipIdentifier(clip['video_name'], clip_idx, clip['frames_{}'.format(ext)])) if check_content: - content_errors.extend([ - '{}: does not exist'.format(self.data_dir / frame) - for frame in clip['frames'] if not check_file_existence(self.data_dir / frame) - ]) + for ext, dir_ in zip(data_ext, data_dir): + content_errors.extend([ + '{}: does not exist'.format(dir_ / frame) + for frame in clip['frames_{}'.format(ext)] if not check_file_existence(dir_ / frame) + ]) + if len(identifier) == 1: + identifier = identifier[0] + annotations.append(ClassificationAnnotation(identifier, clip['label'])) return ConverterReturn(annotations, {'label_map': label_map}, content_errors) - @staticmethod - def get_clips(video, clips_per_video, clip_duration, temporal_stride=1, file_ext='jpg'): - shift = int(file_ext == 'npy') - num_frames = video['n_frames'] - shift - clip_duration *= temporal_stride - - if clips_per_video == 0: - step = clip_duration - else: - step = max(1, (num_frames - clip_duration) // (clips_per_video - 1)) + def get_ext_and_dir(self): + if self.two_stream_input: + return ['jpg', 'npy'], [self.data_dir / self.image_subdir, self.data_dir / self.numpy_subdir] - for clip_start in range(1, 1 + clips_per_video * step, step): - clip_end = min(clip_start + clip_duration, num_frames + 1) + if self.numpy_input: + return ['npy'], [self.data_dir / self.numpy_subdir if self.numpy_subdir else self.data_dir] - clip_idxs = list(range(clip_start, clip_end)) + return ['jpg'], [self.data_dir / self.image_subdir if self.image_subdir else self.data_dir] - if not clip_idxs: - return + def get_videos(self, video_names, annotations, class_to_idx, data_dir, data_ext): + videos = [] + for video_name, annotation in zip(video_names, annotations): + video_info = { + 'video_name': video_name, + 'video_id': video_name, + 'label': class_to_idx[annotation['label']] + } + for dir_, ext in zip(data_dir, data_ext): + video_path = dir_ / video_name + if not video_path.exists(): + video_info.clear() + continue + + n_frames_file = video_path / 'n_frames' + n_frames = ( + int(read_txt(n_frames_file)[0].rstrip('\n\r')) if n_frames_file.exists() + else len(list(video_path.glob('*.{}'.format(ext)))) + ) + if n_frames <= 0: + video_info.clear() + continue + + begin_t = 1 + end_t = n_frames + sample = { + 'video_{}'.format(ext): video_path, + 'segment_{}'.format(ext): [begin_t, end_t], + 'n_frames_{}'.format(ext): n_frames, + } + video_info.update(sample) + + if video_info: + videos.append(video_info) + if self.num_samples and len(videos) == self.num_samples: + break + return videos - # loop clip if it is shorter than clip_duration - while len(clip_idxs) < clip_duration: - clip_idxs = (clip_idxs * 2)[:clip_duration] + @staticmethod + def get_clips(video, clips_per_video, clip_duration, temporal_stride=1, file_ext='jpg'): + clip_duration *= temporal_stride + frames_ext = {} + for ext in file_ext: + frames = [] + shift = int(ext == 'npy') + num_frames = video['n_frames_{}'.format(ext)] - shift + + if clips_per_video == 0: + step = clip_duration + else: + step = max(1, (num_frames - clip_duration) // (clips_per_video - 1)) + for clip_start in range(1, 1 + clips_per_video * step, step): + clip_end = min(clip_start + clip_duration, num_frames + 1) + + clip_idxs = list(range(clip_start, clip_end)) + + if not clip_idxs: + return [] + + # loop clip if it is shorter than clip_duration + while len(clip_idxs) < clip_duration: + clip_idxs = (clip_idxs * 2)[:clip_duration] + + frames_idx = clip_idxs[::temporal_stride] + frames.append(['image_{:05d}.{}'.format(frame_idx, ext) for frame_idx in frames_idx]) + frames_ext.update({ + ext: frames + }) - clip = dict(video) - frames_idx = clip_idxs[::temporal_stride] - clip['frames'] = ['image_{:05d}.{}'.format(frame_idx, file_ext) for frame_idx in frames_idx] - yield clip + clips = [] + for key, value in frames_ext.items(): + if not clips: + for _ in range(len(value)): + clips.append(dict(video)) + for val, clip in zip(value, clips): + clip['frames_{}'.format(key)] = val + return clips @staticmethod def get_video_names_and_annotations(data, subset): diff --git a/tools/accuracy_checker/accuracy_checker/annotation_converters/convert.py b/tools/accuracy_checker/accuracy_checker/annotation_converters/convert.py index a780c398cfc..c327e4ee9fd 100644 --- a/tools/accuracy_checker/accuracy_checker/annotation_converters/convert.py +++ b/tools/accuracy_checker/accuracy_checker/annotation_converters/convert.py @@ -24,7 +24,9 @@ import numpy as np -from ..representation import ReIdentificationClassificationAnnotation, ReIdentificationAnnotation +from ..representation import ( + ReIdentificationClassificationAnnotation, ReIdentificationAnnotation +) from ..utils import get_path, OrderedSet from ..data_analyzer import BaseDataAnalyzer from .format_converter import BaseFormatConverter @@ -150,6 +152,33 @@ def make_subset_reid(annotation, size, shuffle=True): return list(subsample_set) +def make_subset_ibl(annotation, size, shuffle=True): + subsample_set = OrderedSet() + query_annotations = [ann for ann in annotation if ann.query] + potential_ann_ind = np.random.choice(len(annotation), size, replace=False) if shuffle else np.arange(size) + for ann_ind in potential_ann_ind: + selected_annotation = annotation[ann_ind] + if not selected_annotation.query: + query_for_place = [query_annotations[idx] for idx in selected_annotation.query_id] + pairs_set = OrderedSet(query_for_place) + else: + gallery_for_place = [ + ann for ann in annotation if not ann.query and selected_annotation.query_id in ann.query_id + ] + pairs_set = OrderedSet(gallery_for_place) + subsample_set.add(selected_annotation) + intersection = subsample_set & pairs_set + subsample_set |= pairs_set + if len(subsample_set) == size: + break + if len(subsample_set) > size: + pairs_set.add(selected_annotation) + to_delete = pairs_set - intersection + subsample_set -= to_delete + + return list(subsample_set) + + def main(): main_argparser = build_argparser() args, _ = main_argparser.parse_known_args() diff --git a/tools/accuracy_checker/accuracy_checker/annotation_converters/place_recognition.py b/tools/accuracy_checker/accuracy_checker/annotation_converters/place_recognition.py new file mode 100644 index 00000000000..c69830b840d --- /dev/null +++ b/tools/accuracy_checker/accuracy_checker/annotation_converters/place_recognition.py @@ -0,0 +1,68 @@ +"""" +Copyright (c) 2018-2020 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +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. +""" +import numpy as np + +from .format_converter import BaseFormatConverter, ConverterReturn +from ..utils import loadmat, check_file_existence +from ..representation import PlaceRecognitionAnnotation +from ..config import PathField + + +class PlaceRecognitionDatasetConverter(BaseFormatConverter): + __provider__ = 'place_recognition' + + @classmethod + def parameters(cls): + params = super().parameters() + params.update({ + 'split_file': PathField(), + 'images_dir': PathField(is_directory=True, optional=True) + }) + return params + + def configure(self): + self.split_file = self.get_value_from_config('split_file') + self.data_dir = self.get_value_from_config('images_dir') or self.split_file.parent + + def convert(self, check_content=False, progress_callback=None, progress_interval=100, **kwargs): + queries, loc_query, gallery, loc_gallery = self.read_db() + annotations = [] + num_iterations = len(queries) + len(gallery) + content_errors = None if not check_content else [] + for idx, (image, utm) in enumerate(zip(gallery, loc_gallery)): + if check_content and not check_file_existence(self.data_dir / image): + content_errors.append('{}: des not exist'.format(self.data_dir / image)) + annotations.append(PlaceRecognitionAnnotation(image, utm, False)) + if progress_callback and idx % progress_interval == 0: + progress_callback(idx * 100 / num_iterations) + for idx, (image, utm) in enumerate(zip(queries, loc_query)): + image = 'queries_real/'+image + if check_content and not check_file_existence(self.data_dir / image): + content_errors.append('{}: des not exist'.format(self.data_dir / image)) + annotations.append(PlaceRecognitionAnnotation(image, utm, True)) + if progress_callback and (idx + len(gallery)) % progress_callback == 0: + progress_callback((idx + len(gallery)) * 100 / num_iterations) + + return ConverterReturn(annotations, None, content_errors) + + def read_db(self): + data = loadmat(str(self.split_file))['dbStruct'] + db_image = [f[0] for f in data['dbImageFns']] + utm_db = np.array(data['utmDb']).T + + q_image = [f[0] for f in data['qImageFns']] + utm_q = np.array(data['utmQ']).T + return q_image, utm_q, db_image, utm_db diff --git a/tools/accuracy_checker/accuracy_checker/config/config_reader.py b/tools/accuracy_checker/accuracy_checker/config/config_reader.py index 9f4c6d03704..69a9ea42ccb 100644 --- a/tools/accuracy_checker/accuracy_checker/config/config_reader.py +++ b/tools/accuracy_checker/accuracy_checker/config/config_reader.py @@ -332,15 +332,12 @@ def process_modules(config, entries_paths): def _provide_cmd_arguments(arguments, config, mode): profile_dataset = 'profile' in arguments and arguments.profile profile_report_type = arguments.profile_report_type if 'profile_report_type' in arguments else 'csv' - def _add_subset_specific_arg(dataset_entry): - if 'shuffle' in arguments and arguments.shuffle is not None: - dataset_entry['shuffle'] = arguments.shuffle - - if 'subsample_size' in arguments and arguments.subsample_size is not None: - dataset_entry['subsample_size'] = arguments.subsample_size def merge_models(config, arguments, update_launcher_entry): def provide_models(launchers): + if input_precisions: + for launcher in launchers: + launcher['_input_precision'] = input_precisions if 'models' not in arguments or not arguments.models: return launchers model_paths = arguments.models @@ -358,13 +355,15 @@ def provide_models(launchers): updated_launchers.append(copy_launcher) return updated_launchers + input_precisions = arguments.input_precision if 'input_precision' in arguments else None + for model in config['models']: for launcher_entry in model['launchers']: merge_dlsdk_launcher_args(arguments, launcher_entry, update_launcher_entry) model['launchers'] = provide_models(model['launchers']) for dataset_entry in model['datasets']: - _add_subset_specific_arg(dataset_entry) + _add_subset_specific_arg(dataset_entry, arguments) if 'ie_preprocessing' in arguments and arguments.ie_preprocessing: dataset_entry['_ie_preprocessing'] = arguments.ie_preprocessing @@ -390,7 +389,7 @@ def merge_modules(config, arguments, update_launcher_entry): if 'datasets' not in module_config: continue for dataset in module_config['datasets']: - _add_subset_specific_arg(dataset) + _add_subset_specific_arg(dataset, arguments) dataset['_profile'] = profile_dataset dataset['_report_type'] = profile_report_type @@ -850,3 +849,11 @@ def _async_evaluation_args(launcher_entry): launcher_entry['affinity_map'] = arguments.affinity_map return launcher_entry + + +def _add_subset_specific_arg(dataset_entry, arguments): + if 'shuffle' in arguments and arguments.shuffle is not None: + dataset_entry['shuffle'] = arguments.shuffle + + if 'subsample_size' in arguments and arguments.subsample_size is not None: + dataset_entry['subsample_size'] = arguments.subsample_size diff --git a/tools/accuracy_checker/accuracy_checker/dataset.py b/tools/accuracy_checker/accuracy_checker/dataset.py index b9d17bc9635..a581ae019eb 100644 --- a/tools/accuracy_checker/accuracy_checker/dataset.py +++ b/tools/accuracy_checker/accuracy_checker/dataset.py @@ -31,7 +31,9 @@ BoolField ) from .utils import JSONDecoderWithAutoConversion, read_json, get_path, contains_all, set_image_metadata, OrderedSet -from .representation import BaseRepresentation, ReIdentificationClassificationAnnotation, ReIdentificationAnnotation +from .representation import ( + BaseRepresentation, ReIdentificationClassificationAnnotation, ReIdentificationAnnotation +) from .data_readers import DataReaderField, REQUIRES_ANNOTATIONS from .logging import print_info @@ -194,9 +196,7 @@ def make_subset(self, ids=None, start=0, step=1, end=None, accept_pairs=False): self.subset = ids if not pairwise_subset else self._make_subset_pairwise(ids, accept_pairs) def _make_subset_pairwise(self, ids, add_pairs=False): - subsample_set = OrderedSet() - pairs_set = OrderedSet() - if isinstance(self._annotation[0], ReIdentificationClassificationAnnotation): + def reid_pairwise_subset(pairs_set, subsample_set, ids): identifier_to_index = {annotation.identifier: index for index, annotation in enumerate(self._annotation)} for idx in ids: subsample_set.add(idx) @@ -209,7 +209,9 @@ def _make_subset_pairwise(self, ids, add_pairs=False): identifier_to_index[pair_identifier] for pair_identifier in current_annotation.positive_pairs ] pairs_set |= negative_pairs - else: + return pairs_set, subsample_set + + def reid_subset(pairs_set, subsample_set, ids): for idx in ids: subsample_set.add(idx) selected_annotation = self._annotation[idx] @@ -225,7 +227,18 @@ def _make_subset_pairwise(self, ids, add_pairs=False): if annotation.person_id == selected_annotation.person_id and not annotation.query ] pairs_set |= OrderedSet(gallery_for_person) + return pairs_set, subsample_set + realisation = [ + (ReIdentificationClassificationAnnotation, reid_pairwise_subset), + (ReIdentificationAnnotation, reid_subset) + ] + subsample_set = OrderedSet() + pairs_set = OrderedSet() + for (dtype, func) in realisation: + if isinstance(self._annotation[0], dtype): + pairs_set, subsample_set = func(pairs_set, subsample_set, ids) + break if add_pairs: subsample_set |= pairs_set diff --git a/tools/accuracy_checker/accuracy_checker/evaluators/custom_evaluators/README.md b/tools/accuracy_checker/accuracy_checker/evaluators/custom_evaluators/README.md index 82b10c12db6..1cd8358a901 100644 --- a/tools/accuracy_checker/accuracy_checker/evaluators/custom_evaluators/README.md +++ b/tools/accuracy_checker/accuracy_checker/evaluators/custom_evaluators/README.md @@ -23,19 +23,23 @@ Optionally you can provide `module_config` section which contains config for cus ## Examples * **Sequential Action Recognition Evaluator** demonstrates how to run Action Recognition models with encoder + decoder architecture. - Evaluator code. - Configuration file example: action-recognition-0001. + Evaluator code. + Configuration file example: action-recognition-0001. * **MTCNN Evaluator** shows how to run MTCNN model. - Evaluator code. - Configuration file example: mtcnn. + Evaluator code. + Configuration file example: mtcnn. * **Text Spotting Evaluator** demonstrates how to evaluate the `text-spotting-0002` model via Accuracy Checker. - Evaluator code. - Configuration file example: text-spotting-0002. + Evaluator code. + Configuration file example: text-spotting-0002. * **Automatic Speech Recognition Evaluator** shows how to evaluate speech recognition pipeline (encoder + decoder). -Evaluator code. -* **Im2latex formula recognition** demonstrates how to run encoder-decoder model for extractring latex formula from image - Evaluator code - Configuration file example: im2latex-medium-0002 + Evaluator code. + +* **Im2latex formula recognition** demonstrates how to run encoder-decoder model for extractring latex formula from image. + Evaluator code. + Configuration file example: im2latex-medium-0002. + +* **I3D Evaluator** demonstrates how to evaluate two-stream I3D model (RGB + Flow). + Evaluator code. diff --git a/tools/accuracy_checker/accuracy_checker/evaluators/custom_evaluators/i3d_evaluator.py b/tools/accuracy_checker/accuracy_checker/evaluators/custom_evaluators/i3d_evaluator.py new file mode 100644 index 00000000000..a6ad046c2f3 --- /dev/null +++ b/tools/accuracy_checker/accuracy_checker/evaluators/custom_evaluators/i3d_evaluator.py @@ -0,0 +1,413 @@ +""" +Copyright (c) 2018-2020 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +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. +""" + +from pathlib import Path +from collections import OrderedDict +import warnings +import numpy as np + +from ..base_evaluator import BaseEvaluator +from ..quantization_model_evaluator import create_dataset_attributes +from ...adapters import create_adapter +from ...config import ConfigError +from ...launcher import create_launcher +from ...data_readers import create_reader +from ...utils import extract_image_representations, contains_all, get_path +from ...progress_reporters import ProgressReporter +from ...logging import print_info +from ...preprocessor import Crop, Resize + + +class I3DEvaluator(BaseEvaluator): + def __init__(self, dataset_config, launcher, adapter, rgb_model, flow_model): + self.dataset_config = dataset_config + self.preprocessor = None + self.dataset = None + self.postprocessor = None + self.metric_executor = None + self.launcher = launcher + self.adapter = adapter + self.rgb_model = rgb_model + self.flow_model = flow_model + self._metrics_results = [] + + @classmethod + def from_configs(cls, config, delayed_model_loading=False): + dataset_config = config['datasets'] + launcher_settings = config['launchers'][0] + supported_frameworks = ['dlsdk'] + if not launcher_settings['framework'] in supported_frameworks: + raise ConfigError('{} framework not supported'.format(launcher_settings['framework'])) + if 'device' not in launcher_settings: + launcher_settings['device'] = 'CPU' + launcher = create_launcher(launcher_settings, delayed_model_loading=True) + adapter = create_adapter(launcher_settings['adapter']) + network_info = config.get('network_info', {}) + data_source = dataset_config[0].get('data_source', None) + if not delayed_model_loading: + flow_network = network_info.get('flow', {}) + rgb_network = network_info.get('rgb', {}) + model_args = config.get('_models', []) + models_is_blob = config.get('_model_is_blob') + if 'model' not in flow_network and model_args: + flow_network['model'] = model_args[0] + flow_network['_model_is_blob'] = models_is_blob + if 'model' not in rgb_network and model_args: + rgb_network['model'] = model_args[1 if len(model_args) > 1 else 0] + rgb_network['_model_is_blob'] = models_is_blob + network_info.update({ + 'flow': flow_network, + 'rgb': rgb_network + }) + if not contains_all(network_info, ['flow', 'rgb']): + raise ConfigError('configuration for flow/rgb does not exist') + + flow_model = I3DFlowModel( + network_info.get('flow', {}), launcher, data_source, delayed_model_loading + ) + rgb_model = I3DRGBModel( + network_info.get('rgb', {}), launcher, data_source, delayed_model_loading + ) + if rgb_model.output_blob != flow_model.output_blob: + warnings.warn("Outputs for rgb and flow models have different names. " + "rgb model's output name: {}. flow model's output name: {}. Output name of rgb model " + "will be used in combined output".format(rgb_model.output_blob, flow_model.output_blob)) + adapter.output_blob = rgb_model.output_blob + return cls(dataset_config, launcher, adapter, rgb_model, flow_model) + + @staticmethod + def get_dataset_info(dataset): + annotation = dataset.annotation_reader.annotation + identifiers = dataset.annotation_reader.identifiers + + return annotation, identifiers + + @staticmethod + def combine_predictions(output_rgb, output_flow): + output = {} + for key_rgb, key_flow in zip(output_rgb.keys(), output_flow.keys()): + data_rgb = np.asarray(output_rgb[key_rgb]) + data_flow = np.asarray(output_flow[key_flow]) + + if data_rgb.shape != data_flow.shape: + raise ValueError("Сalculation of combined output is not possible. Outputs for rgb and flow models have " + "different shapes. rgb model's output shape: {}. " + "flow model's output shape: {}.".format(data_rgb.shape, data_flow.shape)) + + result_data = (data_rgb + data_flow) / 2 + output[key_rgb] = result_data + + return output + + def process_dataset( + self, subset=None, + num_images=None, + check_progress=False, + dataset_tag='', + allow_pairwise_subset=False, + **kwargs): + + if self.dataset is None or (dataset_tag and self.dataset.tag != dataset_tag): + self.select_dataset(dataset_tag) + self._create_subset(subset, num_images, allow_pairwise_subset) + + self._annotations, self._predictions = [], [] + + if 'progress_reporter' in kwargs: + _progress_reporter = kwargs['progress_reporter'] + _progress_reporter.reset(self.dataset.size) + else: + _progress_reporter = None if not check_progress else self._create_progress_reporter( + check_progress, self.dataset.size + ) + + compute_intermediate_metric_res = kwargs.get('intermediate_metrics_results', False) + if compute_intermediate_metric_res: + metric_interval = kwargs.get('metrics_interval', 1000) + ignore_results_formatting = kwargs.get('ignore_results_formatting', False) + + annotation, identifiers = self.get_dataset_info(self.dataset) + for batch_id, (batch_annotation, batch_identifiers) in enumerate(zip(annotation, identifiers)): + batch_inputs_images = self.rgb_model.prepare_data(batch_identifiers) + batch_inputs_flow = self.flow_model.prepare_data(batch_identifiers) + + extr_batch_inputs_images, _ = extract_image_representations([batch_inputs_images]) + extr_batch_inputs_flow, _ = extract_image_representations([batch_inputs_flow]) + + batch_raw_prediction_rgb = self.rgb_model.predict(extr_batch_inputs_images) + batch_raw_prediction_flow = self.flow_model.predict(extr_batch_inputs_flow) + batch_raw_out = self.combine_predictions(batch_raw_prediction_rgb, batch_raw_prediction_flow) + + batch_prediction = self.adapter.process([batch_raw_out], identifiers, [{}]) + + if self.metric_executor.need_store_predictions: + self._annotations.extend([batch_annotation]) + self._predictions.extend(batch_prediction) + + if _progress_reporter: + _progress_reporter.update(batch_id, len(batch_prediction)) + if compute_intermediate_metric_res and _progress_reporter.current % metric_interval == 0: + self.compute_metrics( + print_results=True, ignore_results_formatting=ignore_results_formatting + ) + + if _progress_reporter: + _progress_reporter.finish() + + def compute_metrics(self, print_results=True, ignore_results_formatting=False): + if self._metrics_results: + del self._metrics_results + self._metrics_results = [] + + for result_presenter, evaluated_metric in self.metric_executor.iterate_metrics( + self._annotations, self._predictions + ): + self._metrics_results.append(evaluated_metric) + if print_results: + result_presenter.write_result(evaluated_metric, ignore_results_formatting) + + return self._metrics_results + + def print_metrics_results(self, ignore_results_formatting=False): + if not self._metrics_results: + self.compute_metrics(True, ignore_results_formatting) + return + result_presenters = self.metric_executor.get_metric_presenters() + for presenter, metric_result in zip(result_presenters, self._metrics_results): + presenter.write_results(metric_result, ignore_results_formatting) + + def extract_metrics_results(self, print_results=True, ignore_results_formatting=False): + if not self._metrics_results: + self.compute_metrics(False, ignore_results_formatting) + + result_presenters = self.metric_executor.get_metric_presenters() + extracted_results, extracted_meta = [], [] + for presenter, metric_result in zip(result_presenters, self._metrics_results): + result, metadata = presenter.extract_result(metric_result) + if isinstance(result, list): + extracted_results.extend(result) + extracted_meta.extend(metadata) + else: + extracted_results.append(result) + extracted_meta.append(metadata) + if print_results: + presenter.write_result(metric_result, ignore_results_formatting) + + return extracted_results, extracted_meta + + def release(self): + self.rgb_model.release() + self.flow_model.release() + self.launcher.release() + + def reset(self): + if self.metric_executor: + self.metric_executor.reset() + if hasattr(self, '_annotations'): + del self._annotations + del self._predictions + del self._metrics_results + self._annotations = [] + self._predictions = [] + self._metrics_results = [] + if self.dataset: + self.dataset.reset(self.postprocessor.has_processors) + + @staticmethod + def get_processing_info(config): + module_specific_params = config.get('module_config') + model_name = config['name'] + dataset_config = module_specific_params['datasets'][0] + launcher_config = module_specific_params['launchers'][0] + return ( + model_name, launcher_config['framework'], launcher_config['device'], launcher_config.get('tags'), + dataset_config['name'] + ) + + def select_dataset(self, dataset_tag): + if self.dataset is not None and isinstance(self.dataset_config, list): + return + dataset_attributes = create_dataset_attributes(self.dataset_config, dataset_tag) + self.dataset, self.metric_executor, self.preprocessor, self.postprocessor = dataset_attributes + + @staticmethod + def _create_progress_reporter(check_progress, dataset_size): + pr_kwargs = {} + if isinstance(check_progress, int) and not isinstance(check_progress, bool): + pr_kwargs = {"print_interval": check_progress} + + return ProgressReporter.provide('print', dataset_size, **pr_kwargs) + + def _create_subset(self, subset=None, num_images=None, allow_pairwise=False): + if self.dataset.batch is None: + self.dataset.batch = 1 + if subset is not None: + self.dataset.make_subset(ids=subset, accept_pairs=allow_pairwise) + elif num_images is not None: + self.dataset.make_subset(end=num_images, accept_pairs=allow_pairwise) + + +class BaseModel: + def __init__(self, network_info, launcher, data_source, delayed_model_loading=False): + self.input_blob = None + self.output_blob = None + self.with_prefix = False + reader_config = network_info.get('reader', {}) + source_prefix = reader_config.get('source_prefix', '') + reader_config.update({ + 'data_source': data_source / source_prefix + }) + self.reader = create_reader(reader_config) + if not delayed_model_loading: + self.load_model(network_info, launcher, log=True) + + @staticmethod + def auto_model_search(network_info, net_type): + model = Path(network_info['model']) + is_blob = network_info.get('_model_is_blob') + if model.is_dir(): + if is_blob: + model_list = list(model.glob('*.blob')) + else: + model_list = list(model.glob('*.xml')) + if not model_list and is_blob is None: + model_list = list(model.glob('*.blob')) + if not model_list: + raise ConfigError('Suitable model not found') + if len(model_list) > 1: + raise ConfigError('Several suitable models found') + model = model_list[0] + print_info('{} - Found model: {}'.format(net_type, model)) + if model.suffix == '.blob': + return model, None + weights = get_path(network_info.get('weights', model.parent / model.name.replace('xml', 'bin'))) + print_info('{} - Found weights: {}'.format(net_type, weights)) + + return model, weights + + def predict(self, input_data): + return self.exec_network.infer(inputs=input_data[0]) + + def release(self): + del self.network + del self.exec_network + + def load_model(self, network_info, launcher, log=False): + model, weights = self.auto_model_search(network_info, self.net_type) + if weights: + self.network = launcher.read_network(str(model), str(weights)) + self.network.batch_size = 1 + self.exec_network = launcher.ie_core.load_network(self.network, launcher.device) + else: + self.network = None + launcher.ie_core.import_network(str(model)) + self.set_input_and_output() + if log: + self.print_input_output_info() + + def set_input_and_output(self): + has_info = hasattr(self.exec_network, 'input_info') + input_info = self.exec_network.input_info if has_info else self.exec_network.inputs + input_blob = next(iter(input_info)) + with_prefix = input_blob.startswith('{}_'.format(self.net_type)) + if self.input_blob is None or with_prefix != self.with_prefix: + if self.input_blob is None: + output_blob = next(iter(self.exec_network.outputs)) + else: + output_blob = ( + '_'.join([self.net_type, self.output_blob]) + if with_prefix else self.output_blob.split('{}_'.format(self.net_type))[-1] + ) + self.input_blob = input_blob + self.output_blob = output_blob + self.with_prefix = with_prefix + + def print_input_output_info(self): + print_info('{} - Input info:'.format(self.net_type)) + has_info = hasattr(self.network if self.network is not None else self.exec_network, 'input_info') + if self.network: + if has_info: + network_inputs = OrderedDict( + [(name, data.input_data) for name, data in self.network.input_info.items()] + ) + else: + network_inputs = self.network.inputs + network_outputs = self.network.outputs + else: + if has_info: + network_inputs = OrderedDict([ + (name, data.input_data) for name, data in self.exec_network.input_info.items() + ]) + else: + network_inputs = self.exec_network.inputs + network_outputs = self.exec_network.outputs + for name, input_info in network_inputs.items(): + print_info('\tLayer name: {}'.format(name)) + print_info('\tprecision: {}'.format(input_info.precision)) + print_info('\tshape {}\n'.format(input_info.shape)) + print_info('{} - Output info'.format(self.net_type)) + for name, output_info in network_outputs.items(): + print_info('\tLayer name: {}'.format(name)) + print_info('\tprecision: {}'.format(output_info.precision)) + print_info('\tshape: {}\n'.format(output_info.shape)) + + def fit_to_input(self, input_data): + has_info = hasattr(self.exec_network, 'input_info') + input_info = ( + self.exec_network.input_info[self.input_blob].input_data + if has_info else self.exec_network.inputs[self.input_blob] + ) + input_data = np.array(input_data) + input_data = np.transpose(input_data, (3, 0, 1, 2)) + input_data = np.reshape(input_data, input_info.shape) + return {self.input_blob: input_data} + + def prepare_data(self, data): + pass + + +class I3DRGBModel(BaseModel): + def __init__(self, network_info, launcher, data_source, delayed_model_loading=False): + self.net_type = 'rgb' + super().__init__(network_info, launcher, data_source, delayed_model_loading) + + def prepare_data(self, data): + image_data = data[0] + prepared_data = self.reader(image_data) + prepared_data = self.preprocessing(prepared_data) + prepared_data.data = self.fit_to_input(prepared_data.data) + return prepared_data + + @staticmethod + def preprocessing(image): + resizer_config = {'type': 'resize', 'size': 256, 'aspect_ratio_scale': 'fit_to_window'} + resizer = Resize(resizer_config) + image = resizer.process(image) + for i, frame in enumerate(image.data): + image.data[i] = Crop.process_data(frame, 224, 224, None, False, True, {}) + return image + + +class I3DFlowModel(BaseModel): + def __init__(self, network_info, launcher, data_source, delayed_model_loading=False): + self.net_type = 'flow' + super().__init__(network_info, launcher, data_source, delayed_model_loading) + + def prepare_data(self, data): + numpy_data = data[1] + prepared_data = self.reader(numpy_data) + prepared_data.data = self.fit_to_input(prepared_data.data) + return prepared_data diff --git a/tools/accuracy_checker/accuracy_checker/evaluators/model_evaluator.py b/tools/accuracy_checker/accuracy_checker/evaluators/model_evaluator.py index e82e639e21b..ccd7e8b9899 100644 --- a/tools/accuracy_checker/accuracy_checker/evaluators/model_evaluator.py +++ b/tools/accuracy_checker/accuracy_checker/evaluators/model_evaluator.py @@ -79,18 +79,23 @@ def from_configs(cls, model_config): dataset_config.get('preprocessing'), dataset_name, dataset.metadata, enable_ie_preprocessing=enable_ie_preprocessing ) + input_precision = launcher_config.get('_input_precision', []) if enable_ie_preprocessing: launcher_kwargs['preprocessor'] = preprocessor if launcher_config['framework'] == 'dummy' and launcher_config.get('provide_identifiers', False): launcher_kwargs = {'identifiers': dataset.identifiers} + if input_precision: + launcher_kwargs['postpone_inputs_configuration'] = True launcher = create_launcher(launcher_config, model_name, **launcher_kwargs) async_mode = launcher.async_mode if hasattr(launcher, 'async_mode') else False config_adapter = launcher_config.get('adapter') adapter = None if not config_adapter else create_adapter(config_adapter, launcher, dataset) input_feeder = InputFeeder( launcher.config.get('inputs', []), launcher.inputs, launcher.fit_to_input, launcher.default_layout, - launcher_config['framework'] == 'dummy' + launcher_config['framework'] == 'dummy', input_precision ) + if input_precision: + launcher.update_input_configuration(input_feeder.inputs_config) preprocessor.input_shapes = launcher.inputs_info_for_meta() postprocessor = PostprocessingExecutor(dataset_config.get('postprocessing'), dataset_name, dataset.metadata) metric_dispatcher = MetricsExecutor(dataset_config.get('metrics', []), dataset) diff --git a/tools/accuracy_checker/accuracy_checker/launcher/dlsdk_launcher.py b/tools/accuracy_checker/accuracy_checker/launcher/dlsdk_launcher.py index 8f2b38a4d49..2b82ed5067f 100644 --- a/tools/accuracy_checker/accuracy_checker/launcher/dlsdk_launcher.py +++ b/tools/accuracy_checker/accuracy_checker/launcher/dlsdk_launcher.py @@ -63,6 +63,7 @@ Blob, TensorDesc = None, None +# pylint:disable=R0904 class DLSDKLauncher(Launcher): """ Class for infer model using DLSDK framework. @@ -124,7 +125,9 @@ def parameters(cls): return parameters - def __init__(self, config_entry, model_name='', delayed_model_loading=False, preprocessor=None): + def __init__( + self, config_entry, model_name='', delayed_model_loading=False, + preprocessor=None, postpone_inputs_configuration=False): super().__init__(config_entry, model_name=model_name) self._set_variable = False @@ -142,12 +145,14 @@ def __init__(self, config_entry, model_name='', delayed_model_loading=False, pre self._prepare_bitstream_firmware(self.config) self._prepare_ie() self._delayed_model_loading = delayed_model_loading + self._postpone_input_configuration = postpone_inputs_configuration self._preprocess_info = {} self._preprocess_steps = [] self.disable_resize_to_input = False self._do_reshape = False self._use_set_blob = False self._output_layouts = dict() + self.preprocessor = preprocessor if not delayed_model_loading: if dlsdk_launcher_config.need_conversion: @@ -779,14 +784,29 @@ def load_network(self, network=None, log=False, preprocessing=None): self._create_network() else: self.network = network + if not self._postpone_input_configuration: + self._set_precision() + if log: + self._print_input_output_info() + if preprocessing: + self._set_preprocess(preprocessing) + + if self.network and not preprocessing: + self.exec_network = self.ie_core.load_network( + self.network, self._device, num_requests=self.num_requests + ) + + def update_input_configuration(self, input_config): + self.config['inputs'] = input_config self._set_precision() - if log: - self._print_input_output_info() - if preprocessing: - self._set_preprocess(preprocessing) + self._print_input_output_info() + if self.preprocessor: + self._set_preprocess(self.preprocessor) if self.network: - self.exec_network = self.ie_core.load_network(self.network, self._device, num_requests=self.num_requests) + self.exec_network = self.ie_core.load_network( + self.network, self._device, num_requests=self.num_requests + ) def load_ir(self, xml_path, bin_path, log=False): self._model = xml_path @@ -866,11 +886,6 @@ def _set_precision(self): self.network.inputs[input_config['name']].precision = input_config['precision'] else: self.network.input_info[input_config['name']].precision = input_config['precision'] - else: - if not has_info: - self.exec_network.inputs[input_config['name']].precision = input_config['precision'] - else: - self.exec_network.input_info[input_config['name']].precision = input_config['precision'] def _configure_lstm_inputs(self): lstm_mapping = {} diff --git a/tools/accuracy_checker/accuracy_checker/launcher/dlsdk_launcher_readme.md b/tools/accuracy_checker/accuracy_checker/launcher/dlsdk_launcher_readme.md index 30c94b7b397..702fca5b3a5 100644 --- a/tools/accuracy_checker/accuracy_checker/launcher/dlsdk_launcher_readme.md +++ b/tools/accuracy_checker/accuracy_checker/launcher/dlsdk_launcher_readme.md @@ -54,7 +54,7 @@ Each supported device has own set of supported configuration parameters which ca CPU: ENFORCE_BF16: "NO" ``` -Device config example can be found here +Device config example can be found here Beside that, you can launch model in `async_mode`, enable this option and optionally provide the number of infer requests (`num_requests`), which will be used in evaluation process. By default, if `num_requests` not provided or used value `AUTO`, automatic number request assignment for specific device will be performed For multi device configuration async mode used always. You can provide number requests for each device as part device specification: `MULTI:device_1(num_req_1),device_2(num_req_2)` or in `num_requests` config section (for this case comma-separated list of integer numbers or one value if number requests for all devices equal can be used). diff --git a/tools/accuracy_checker/accuracy_checker/launcher/input_feeder.py b/tools/accuracy_checker/accuracy_checker/launcher/input_feeder.py index c98aff7e01a..e78753f96df 100644 --- a/tools/accuracy_checker/accuracy_checker/launcher/input_feeder.py +++ b/tools/accuracy_checker/accuracy_checker/launcher/input_feeder.py @@ -15,6 +15,7 @@ """ import re +from collections import defaultdict import numpy as np from ..config import ConfigError @@ -59,7 +60,10 @@ class InputFeeder: - def __init__(self, inputs_config, network_inputs, prepare_input_data=None, default_layout='NCHW', dummy=False): + def __init__( + self, inputs_config, network_inputs, prepare_input_data=None, default_layout='NCHW', dummy=False, + input_precisions_list=None + ): def fit_to_input(data, input_layer_name, layout, precision): if len(np.shape(data)) == 4: data = np.transpose(data, layout) @@ -71,14 +75,14 @@ def fit_to_input(data, input_layer_name, layout, precision): self.network_inputs = network_inputs or [] self.default_layout = default_layout self.dummy = dummy - self.configure(inputs_config) + self.configure(inputs_config, input_precisions_list) - def configure(self, inputs_config): + def configure(self, inputs_config, precisions_list): if not self.dummy: - parsing_results = self._parse_inputs_config(inputs_config, self.default_layout) + parsing_results = self._parse_inputs_config(inputs_config, self.default_layout, precisions_list) self.const_inputs, self.non_constant_inputs, self.inputs_mapping = parsing_results[:3] self.image_info_inputs, self.orig_image_info_inputs, self.lstm_inputs = parsing_results[3:6] - self.layouts_mapping, self.precision_mapping = parsing_results[6:] + self.layouts_mapping, self.precision_mapping, self.inputs_config = parsing_results[6:] if not self.non_constant_inputs: raise ConfigError('Network should contain at least one layer for setting variable data.') @@ -162,16 +166,8 @@ def fill_inputs(self, data_representation_batch): infer_inputs.update(self.const_inputs) return inputs - def _parse_inputs_config(self, inputs_entry, default_layout='NCHW'): - def get_layer_precision(input_config, input_name): - if 'precision' not in input_config: - return None - input_precision = PRECISION_TO_DTYPE.get(input_config['precision']) - if input_precision is None: - raise ConfigError("unsupported precision {} for layer {}".format(input_config['precision'], input_name)) - precisions[input_name] = input_precision - return input_precision - + def _parse_inputs_config(self, inputs_entry, default_layout='NCHW', precisions_list=None): + precision_info = self.validate_input_precision(precisions_list) constant_inputs = {} non_constant_inputs_mapping = {} config_non_constant_inputs = [] @@ -188,17 +184,17 @@ def get_layer_precision(input_config, input_name): if input_['type'] == 'IMAGE_INFO': image_info_inputs.append(name) - get_layer_precision(input_, name) + self.get_layer_precision(input_, name, precision_info, precisions) continue if input_['type'] == 'ORIG_IMAGE_INFO': orig_image_info_inputs.append(name) - get_layer_precision(input_, name) + self.get_layer_precision(input_, name, precision_info, precisions) continue if input_['type'] == 'LSTM_INPUT': lstm_inputs.append(name) - get_layer_precision(input_, name) + self.get_layer_precision(input_, name, precision_info, precisions) continue value = input_.get('value') @@ -206,7 +202,7 @@ def get_layer_precision(input_config, input_name): if input_['type'] == 'CONST_INPUT': if isinstance(value, list): value = np.array(value) - precision = get_layer_precision(input_, name) + precision = self.get_layer_precision(input_, name, precision_info, precisions) value = value.astype(precision) if precision is not None else value constant_inputs[name] = value else: @@ -216,7 +212,7 @@ def get_layer_precision(input_config, input_name): non_constant_inputs_mapping[name] = value layout = input_.get('layout', default_layout) layouts[name] = LAYER_LAYOUT_TO_IMAGE_LAYOUT[layout] - get_layer_precision(input_, name) + self.get_layer_precision(input_, name, precision_info, precisions) all_config_inputs = ( config_non_constant_inputs + list(constant_inputs.keys()) + @@ -226,6 +222,10 @@ def get_layer_precision(input_config, input_name): if config_non_constant_inputs and not_config_inputs: raise ConfigError('input value for {} are not presented in config.'.format(','.join(not_config_inputs))) non_constant_inputs = not_config_inputs + config_non_constant_inputs + if not_config_inputs and (precision_info or isinstance(precision_info, defaultdict)): + inputs_entry = self.provide_input_config_for_not_config( + inputs_entry, precision_info, not_config_inputs, precisions + ) return ( constant_inputs, @@ -235,7 +235,8 @@ def get_layer_precision(input_config, input_name): orig_image_info_inputs, lstm_inputs, layouts, - precisions + precisions, + inputs_entry ) def _transform_batch(self, batch_data, meta): @@ -283,5 +284,47 @@ def separate_data(data, num_splits): return [batch_data] + def validate_input_precision(self, precisions_list): + if not precisions_list: + return {} + if len(precisions_list) == 1 and len(precisions_list[0].rsplit(':', 1)) == 1: + return defaultdict(lambda: precisions_list[0]) + precision_dict = {} + for input_c in precisions_list: + precision_for_layer = input_c.rsplit(':', 1) + if len(precision_for_layer) == 1: + raise ConfigError( + 'invalid value for input precision {}. Please specify :'.format(input_c) + ) + layer_name, precision_ = precision_for_layer + if layer_name not in self.network_inputs: + raise ConfigError("precision specified for unknown layer: {}".format(layer_name)) + precision_dict[layer_name] = precision_ + return precision_dict + + @staticmethod + def get_layer_precision(input_config, input_name, precision_info, precisions): + precision = ( + precision_info.get(input_name) if not isinstance(precision_info, defaultdict) + else precision_info[input_name] + ) + if precision is not None: + input_config['precision'] = precision + if 'precision' not in input_config: + return None + input_precision = PRECISION_TO_DTYPE.get(input_config['precision']) + if input_precision is None: + raise ConfigError("unsupported precision {} for layer {}".format(input_config['precision'], input_name)) + precisions[input_name] = input_precision + return input_precision + + def provide_input_config_for_not_config(self, inputs_entry, precision_info, not_config_inputs, precisions): + for input_name in not_config_inputs: + input_config = {'name': input_name, 'type': 'INPUT'} + precision = self.get_layer_precision(input_config, input_name, precision_info, precisions) + if precision is not None: + inputs_entry.append(input_config) + return inputs_entry + def release(self): del self.network_inputs diff --git a/tools/accuracy_checker/accuracy_checker/launcher/launcher.py b/tools/accuracy_checker/accuracy_checker/launcher/launcher.py index 85c87281c87..a531fe41572 100644 --- a/tools/accuracy_checker/accuracy_checker/launcher/launcher.py +++ b/tools/accuracy_checker/accuracy_checker/launcher/launcher.py @@ -96,6 +96,9 @@ def parameters(cls): ), '_list_lstm_inputs': ListField( allow_empty=True, optional=True, default=[], description="List of lstm inputs." + ), + '_input_precision': ListField( + allow_empty=True, optional=True, default=[], description='Input precision list from command line.' ) } @@ -153,6 +156,9 @@ def inputs_info_for_meta(self): if layer_name not in self.const_inputs + self.image_info_inputs } + def update_input_configuration(self, input_config): + self.config['inputs'] = input_config + @property def name(self): return self.__provider__ diff --git a/tools/accuracy_checker/accuracy_checker/main.py b/tools/accuracy_checker/accuracy_checker/main.py index 65714bdb1af..72203165c72 100644 --- a/tools/accuracy_checker/accuracy_checker/main.py +++ b/tools/accuracy_checker/accuracy_checker/main.py @@ -271,6 +271,12 @@ def build_arguments_parser(): parser.add_argument('--profile_report_type', required=False, choices=['csv', 'json'], default='csv') parser.add_argument('--intermediate_metrics_results', required=False, default=False, type=cast_to_bool) parser.add_argument('--metrics_interval', required=False, default=1000, type=int) + parser.add_argument( + '--input_precision', required=False, nargs='+', + help='space-separated list of precisions for network inputs. ' + 'Providing several values required : format. ' + 'If single value without layer_name provided, then it will be applayed to all input layers.' + ) return parser @@ -290,7 +296,6 @@ def main(): evaluator_kwargs['metrics_interval'] = args.metrics_interval evaluator_kwargs['ignore_result_formatting'] = args.ignore_result_formatting - config, mode = ConfigReader.merge(args) evaluator_class = EVALUATION_MODE.get(mode) if not evaluator_class: diff --git a/tools/accuracy_checker/accuracy_checker/metrics/README.md b/tools/accuracy_checker/accuracy_checker/metrics/README.md index 6fcc835447d..20eeaba579b 100644 --- a/tools/accuracy_checker/accuracy_checker/metrics/README.md +++ b/tools/accuracy_checker/accuracy_checker/metrics/README.md @@ -82,6 +82,9 @@ More detailed information about calculation segmentation metrics you can find [h * `min_score` - min score for determining that objects are different. You can provide value or use `train_median` value which will be calculated if annotations has training subset. * `pairwise_accuracy_subsets` - object reidentification pairwise accuracy with division dataset on test and train subsets for calculation mean score. Supported representations: `ReIdentificationClassificationAnnotation`, `ReIdentificationPrediction`. * `subset_number` - number of subsets for separating. +* `localization_recall` - recall metric used for evaluation place recognition task. Supported representations: `PlaceRecognitionAnnotation`, `ReidentificationPrediction`. + * `top_k` - number of k highest ranked samples to consider when matching. + * `distance_threshold` - distance threshold for search positive matching pairs between query and gallery (Optional, default 25). * `mae` - [Mean Absolute Error](https://en.wikipedia.org/wiki/Mean_absolute_error). Supported representations: `RegressionAnnotation`, `RegressionPrediction`, `FeatureRegressionAnnotation`, `DepthEstimationAnnotation`, `DepthEstimationPrediction`. * `mae_on_intervals` - Mean Absolute Error estimated magnitude for specific value range. Supported representations: `RegressionAnnotation`, `RegressionPrediction`. * `intervals` - comma-separated list of interval boundaries. diff --git a/tools/accuracy_checker/accuracy_checker/metrics/__init__.py b/tools/accuracy_checker/accuracy_checker/metrics/__init__.py index 81d7c18f644..f8b8d35170c 100644 --- a/tools/accuracy_checker/accuracy_checker/metrics/__init__.py +++ b/tools/accuracy_checker/accuracy_checker/metrics/__init__.py @@ -38,7 +38,8 @@ PairwiseAccuracy, PairwiseAccuracySubsets, FaceRecognitionTAFAPairMetric, - NormalizedEmbeddingAccuracy + NormalizedEmbeddingAccuracy, + LocalizationRecall ) from .semantic_segmentation import SegmentationAccuracy, SegmentationIOU, SegmentationMeanAccuracy, SegmentationFWAcc from .character_recognition import CharacterRecognitionAccuracy, LabelLevelRecognitionAccuracy @@ -123,6 +124,7 @@ 'PairwiseAccuracySubsets', 'FaceRecognitionTAFAPairMetric', 'NormalizedEmbeddingAccuracy', + 'LocalizationRecall', 'SegmentationAccuracy', 'SegmentationIOU', diff --git a/tools/accuracy_checker/accuracy_checker/metrics/classification.py b/tools/accuracy_checker/accuracy_checker/metrics/classification.py index 9641c89a9b6..cc074755e40 100644 --- a/tools/accuracy_checker/accuracy_checker/metrics/classification.py +++ b/tools/accuracy_checker/accuracy_checker/metrics/classification.py @@ -201,7 +201,10 @@ def __init__(self, *args, **kwargs): self.previous_video_label = None def update(self, annotation, prediction): - video_id = annotation.identifier.video + if isinstance(annotation.identifier, list): + video_id = annotation.identifier[0].video + else: + video_id = annotation.identifier.video if self.previous_video_id is not None and video_id != self.previous_video_id: video_top_label = np.argmax(self.video_avg_prob.evaluate()) diff --git a/tools/accuracy_checker/accuracy_checker/metrics/reid.py b/tools/accuracy_checker/accuracy_checker/metrics/reid.py index adf9cd939a2..a701c7c2a0d 100644 --- a/tools/accuracy_checker/accuracy_checker/metrics/reid.py +++ b/tools/accuracy_checker/accuracy_checker/metrics/reid.py @@ -21,6 +21,7 @@ from ..representation import ( ReIdentificationClassificationAnnotation, ReIdentificationAnnotation, + PlaceRecognitionAnnotation, ReIdentificationPrediction ) from ..config import BaseField, BoolField, NumberField @@ -588,3 +589,49 @@ def _average_precision(y_true_, y_score_): return auc(recall, precision) return _average_binary_score(_average_precision, y_true, y_score) + + +class LocalizationRecall(FullDatasetEvaluationMetric): + __provider__ = 'localization_recall' + annotation_types = (PlaceRecognitionAnnotation, ) + prediction_types = (ReIdentificationPrediction, ) + + @classmethod + def parameters(cls): + params = super().parameters() + params.update({ + 'top_k': NumberField(optional=True, value_type=int, min_value=1, default=1), + 'distance_threshold': NumberField(optional=True, default=25) + }) + return params + + def configure(self): + self.top_k = self.get_value_from_config('top_k') + self.distance_threshold = self.get_value_from_config('distance_threshold') + + def evaluate(self, annotations, predictions): + gallery_embeddings = extract_embeddings(annotations, predictions, query=False) + query_embeddings = extract_embeddings(annotations, predictions, query=True) + query_ann = [ann for ann in annotations if ann.query] + gallery_ann = [ann for ann in annotations if not ann.query] + query_len = np.shape(query_embeddings)[0] + not_empty = np.size(gallery_embeddings) > 0 and np.size(query_embeddings) > 0 + if not not_empty: + warnings.warn('No gallery or query embeddings for evaluation') + return 0 + l2_distance = ( + np.sum(query_embeddings ** 2, axis=1, keepdims=True) + + np.sum(gallery_embeddings ** 2, axis=1) + - 2 * np.dot(query_embeddings, gallery_embeddings.transpose()) + ) + correct_at_n = 0 + for i, q in enumerate(query_ann): + indices = np.argsort(l2_distance[i, :])[:self.top_k] + for ind in indices: + g_loc = gallery_ann[ind].coords + q_loc = q.coords + dist = np.linalg.norm(q_loc - g_loc) + if dist < self.distance_threshold: + correct_at_n += 1 + recall = correct_at_n / query_len + return recall diff --git a/tools/accuracy_checker/accuracy_checker/representation/__init__.py b/tools/accuracy_checker/accuracy_checker/representation/__init__.py index acabb655621..e4e1fee8580 100644 --- a/tools/accuracy_checker/accuracy_checker/representation/__init__.py +++ b/tools/accuracy_checker/accuracy_checker/representation/__init__.py @@ -33,6 +33,7 @@ from .reid_representation import ( ReIdentificationAnnotation, ReIdentificationClassificationAnnotation, + PlaceRecognitionAnnotation, ReIdentificationPrediction ) from .segmentation_representation import ( @@ -108,6 +109,7 @@ 'ReIdentificationAnnotation', 'ReIdentificationClassificationAnnotation', + 'PlaceRecognitionAnnotation', 'ReIdentificationPrediction', 'SegmentationRepresentation', diff --git a/tools/accuracy_checker/accuracy_checker/representation/reid_representation.py b/tools/accuracy_checker/accuracy_checker/representation/reid_representation.py index b53d968c122..20e0d03a0e9 100644 --- a/tools/accuracy_checker/accuracy_checker/representation/reid_representation.py +++ b/tools/accuracy_checker/accuracy_checker/representation/reid_representation.py @@ -29,6 +29,13 @@ def __init__(self, identifier, camera_id, person_id, query): self.query = query +class PlaceRecognitionAnnotation(ReIdentification): + def __init__(self, identifier, coords, query): + super().__init__(identifier) + self.coords = coords + self.query = query + + class ReIdentificationClassificationAnnotation(ReIdentification): def __init__(self, identifier, positive_pairs=None, negative_pairs=None): super().__init__(identifier) diff --git a/tools/accuracy_checker/configs/fcrn-dp-nyu-depth-v2-tf.yml b/tools/accuracy_checker/configs/fcrn-dp-nyu-depth-v2-tf.yml new file mode 120000 index 00000000000..6879bca328e --- /dev/null +++ b/tools/accuracy_checker/configs/fcrn-dp-nyu-depth-v2-tf.yml @@ -0,0 +1 @@ +../../../models/public/fcrn-dp-nyu-depth-v2-tf/accuracy-check.yml \ No newline at end of file diff --git a/tools/accuracy_checker/configs/shufflenet-v2-x1.0.yml b/tools/accuracy_checker/configs/shufflenet-v2-x1.0.yml new file mode 120000 index 00000000000..ddf47eeff6a --- /dev/null +++ b/tools/accuracy_checker/configs/shufflenet-v2-x1.0.yml @@ -0,0 +1 @@ +../../../models/public/shufflenet-v2-x1.0/accuracy-check.yml \ No newline at end of file diff --git a/tools/accuracy_checker/dataset_definitions.yml b/tools/accuracy_checker/dataset_definitions.yml index de3e9177fba..6c6ceafcdb5 100644 --- a/tools/accuracy_checker/dataset_definitions.yml +++ b/tools/accuracy_checker/dataset_definitions.yml @@ -958,6 +958,15 @@ datasets: eos_index: 1 sequence_len: 192 + - name: NYU_Depth_V2 + data_source: nyudepthv2/val/converted/images + additional_data_source: nyudepthv2/val/converted/depth + annotation_conversion: + converter: nyu_depth_v2 + images_dir: nyudepthv2/val/converted/images + depth_map_dir: nyudepthv2/val/converted/depth + data_dir: nyudepthv2/val/official + - name: SCUT_EPT data_source: SCUT_EPT/test annotation_conversion: diff --git a/tools/accuracy_checker/requirements-test.in b/tools/accuracy_checker/requirements-test.in index 3639a4c9681..30fd626e684 100644 --- a/tools/accuracy_checker/requirements-test.in +++ b/tools/accuracy_checker/requirements-test.in @@ -4,7 +4,5 @@ pytest-mock~=2.0 # pytest depends on atomicwrites, but only on Windows. # This means that if we use pip-compile on Linux, the resulting requirements.txt # will not include atomicwrites and thus will not work on Windows. -# And we _can't_ use pip-compile on Windows, because sentencepiece does not have -# Python 3.5 Windows wheels on PyPI. # So as a workaround, make the atomicwrites dependency unconditional. atomicwrites diff --git a/tools/accuracy_checker/sample/README.md b/tools/accuracy_checker/sample/README.md index 860c319099b..2f3afc82dcc 100644 --- a/tools/accuracy_checker/sample/README.md +++ b/tools/accuracy_checker/sample/README.md @@ -40,7 +40,7 @@ Now try edit config, to run SampLeNet on other device or framework (e.g. Caffe, ### Additional useful resources -* config() for running SampleNet via [OpenCV launcher](../accuracy_checker/launcher/opencv_launcher_readme.md) -* config for running SampleNet using compiled executable network blob. +* config() for running SampleNet via [OpenCV launcher](../accuracy_checker/launcher/opencv_launcher_readme.md) +* config for running SampleNet using compiled executable network blob. >**NOTE**: Not all Inference Engine plugins support compiled network blob execution. diff --git a/tools/accuracy_checker/setup.cfg b/tools/accuracy_checker/setup.cfg index ad131b321c4..fb1fdd64d06 100644 --- a/tools/accuracy_checker/setup.cfg +++ b/tools/accuracy_checker/setup.cfg @@ -6,3 +6,4 @@ ignore = F401 line_length = 120 use_parentheses = True known_third_party = openvino.inference_engine,caffe,cv2,mxnet,tensorflow,torch +extension-pkg-whitelist = kenlm diff --git a/tools/accuracy_checker/setup.py b/tools/accuracy_checker/setup.py index eb5730db72e..2e40c1dea31 100644 --- a/tools/accuracy_checker/setup.py +++ b/tools/accuracy_checker/setup.py @@ -114,7 +114,7 @@ def prepare_requirements(): "convert_annotation=accuracy_checker.annotation_converters.convert:main", ]}, zip_safe=False, - python_requires='>=3.5', + python_requires='>=3.6', install_requires=requirements if not is_arm else '', tests_require=[read("requirements-test.in")], cmdclass={'test': PyTest, 'install_core': CoreInstall} diff --git a/tools/accuracy_checker/tests/test_input_feeder.py b/tools/accuracy_checker/tests/test_input_feeder.py index aa7ff8ac444..df7b9327c91 100644 --- a/tools/accuracy_checker/tests/test_input_feeder.py +++ b/tools/accuracy_checker/tests/test_input_feeder.py @@ -27,10 +27,12 @@ class InputInfo_test: layout = '' precision = '' shape = [] - def __init__(self, layout = '', precision = '', shape = []): + + def __init__(self, layout='', precision='', shape=None): self.layout = layout self.precision = precision - self.shape = shape + self.shape = shape or [] + class TestInputFeeder: def test_create_input_feeder_without_inputs_raise_config_error(self): @@ -91,6 +93,78 @@ def test_create_input_feeder_not_all_non_constant_inputs_in_config_raise_config_ {'0': (1, 3, 10, 10), '1': (1, 3, 10, 10)} ) + def test_create_input_feeder_with_precision_info_as_single_element(self): + input_feeder = InputFeeder( + [{'name': 'const_data', 'type': 'CONST_INPUT', 'value': [[1, 2, 3, 4]], 'precision': 'FP32'}], + {'data': (1, 3, 10, 10), 'const_data': (1, 4)}, input_precisions_list=['U8'] + ) + assert 'const_data' in input_feeder.precision_mapping + assert input_feeder.precision_mapping['const_data'] == np.uint8 + assert input_feeder.const_inputs['const_data'].dtype == np.uint8 + assert 'data' in input_feeder.precision_mapping + assert input_feeder.precision_mapping['data'] == np.uint8 + assert len(input_feeder.inputs_config) == 2 + assert input_feeder.inputs_config[0]['name'] == 'const_data' and input_feeder.inputs_config[0]['precision'] == 'U8' + assert input_feeder.inputs_config[1]['name'] == 'data' and input_feeder.inputs_config[1]['precision'] == 'U8' + + def test_create_input_feeder_with_precision_info_for_specific_layer(self): + input_feeder = InputFeeder( + [{'name': 'const_data', 'type': 'CONST_INPUT', 'value': [[1, 2, 3, 4]], 'precision': 'FP32'}], + {'data': (1, 3, 10, 10), 'const_data': (1, 4)}, input_precisions_list=['data:U8'] + ) + assert 'const_data' in input_feeder.precision_mapping + assert input_feeder.precision_mapping['const_data'] == np.float32 + assert input_feeder.const_inputs['const_data'].dtype == np.float32 + assert len(input_feeder.inputs_config) == 2 + assert input_feeder.inputs_config[0]['name'] == 'const_data' and input_feeder.inputs_config[0]['precision'] == 'FP32' + assert input_feeder.inputs_config[1]['name'] == 'data' and input_feeder.inputs_config[1]['precision'] == 'U8' + + def test_create_input_feeder_with_wrong_precision_info_raises_config_error(self): + with pytest.raises(ConfigError): + InputFeeder( + [{'name': 'const_data', 'type': 'CONST_INPUT', 'value': [[1, 2, 3, 4]], 'precision': 'FP32'}], + {'data': (1, 3, 10, 10), 'const_data': (1, 4)}, input_precisions_list=['data:8U'] + ) + + def test_create_input_feeder_with_wrong_input_name_in_precision_info_raises_config_error(self): + with pytest.raises(ConfigError): + InputFeeder( + [{'name': 'const_data', 'type': 'CONST_INPUT', 'value': [[1, 2, 3, 4]], 'precision': 'FP32'}], + {'data': (1, 3, 10, 10), 'const_data': (1, 4)}, input_precisions_list=['unknown:U8'] + ) + + def test_create_input_feeder_with_several_precision_info_in_wrong_format_raises_config_error(self): + with pytest.raises(ConfigError): + InputFeeder( + [{'name': 'const_data', 'type': 'CONST_INPUT', 'value': [[1, 2, 3, 4]], 'precision': 'FP32'}], + {'data': (1, 3, 10, 10), 'const_data': (1, 4)}, input_precisions_list=['U8', 'FP16'] + ) + + def test_create_input_feeder_with_several_precision_info(self): + input_feeder = InputFeeder( + [{'name': 'const_data', 'type': 'CONST_INPUT', 'value': [[1, 2, 3, 4]], 'precision': 'FP32'}], + {'data': (1, 3, 10, 10), 'const_data': (1, 4)}, input_precisions_list=['data:U8', 'const_data:FP16'] + ) + assert 'const_data' in input_feeder.precision_mapping + assert input_feeder.precision_mapping['const_data'] == np.float16 + assert input_feeder.const_inputs['const_data'].dtype == np.float16 + assert len(input_feeder.inputs_config) == 2 + assert input_feeder.inputs_config[0]['name'] == 'const_data' and input_feeder.inputs_config[0]['precision'] == 'FP16' + + assert input_feeder.inputs_config[1]['name'] == 'data' and input_feeder.inputs_config[1]['precision'] == 'U8' + + def test_create_input_feeder_without_config_inputs_and_wint_input_precision(self): + input_feeder = InputFeeder( + [], + {'data': (1, 3, 10, 10)}, input_precisions_list=['U8'] + ) + assert 'data' in input_feeder.precision_mapping + assert input_feeder.precision_mapping['data'] == np.uint8 + assert len(input_feeder.inputs_config) == 1 + + assert input_feeder.inputs_config[0]['name'] == 'data' and input_feeder.inputs_config[0]['precision'] == 'U8' + + def test_fill_non_constant_input_with_one_input_without_specific_mapping_batch_1(self): input_feeder = InputFeeder([], { 'input': InputInfo_test(shape=(1, 3, 10, 10)) }) result = input_feeder.fill_non_constant_inputs([DataRepresentation(np.zeros((10, 10, 3)), identifier='0')])[0] diff --git a/tools/downloader/README.md b/tools/downloader/README.md index 1c2015571e4..f66f698af03 100644 --- a/tools/downloader/README.md +++ b/tools/downloader/README.md @@ -22,7 +22,7 @@ future releases. ## Prerequisites -1. Install Python (version 3.5.2 or higher) +1. Install Python (version 3.6 or higher) 2. Install the tools' dependencies with the following command: ```sh @@ -45,20 +45,6 @@ For models from Caffe2: python3 -mpip install --user -r ./requirements-caffe2.in ``` -When running the model downloader with Python 3.5.x on macOS, you may encounter -an error similar to the following: - -> requests.exceptions.SSLError: [...] (Caused by SSLError(SSLError(1, '[SSL: TLSV1_ALERT_PROTOCOL_VERSION] -tlsv1 alert protocol version (\_ssl.c:719)'),)) - -You can work around this by installing additional packages: - -```sh -python3 -mpip install --user 'requests[security]' -``` - -Alternatively, upgrade to Python 3.6 or a later version. - ## Model downloader usage The basic usage is to run the script like this: @@ -308,7 +294,7 @@ the script. Before you run the model quantizer, you must prepare a directory with the datasets required for the quantization process. This directory will be referred to as `` below. You can find more detailed information -about dataset preparation in the Dataset Preparation Guide. +about dataset preparation in the Dataset Preparation Guide. The basic usage is to run the script like this: diff --git a/tools/downloader/converter.py b/tools/downloader/converter.py index 7664205e693..a00959eeb82 100755 --- a/tools/downloader/converter.py +++ b/tools/downloader/converter.py @@ -25,6 +25,25 @@ import common +def run_pre_convert(reporter, model, output_dir, args): + script = common.MODEL_ROOT / model.subdirectory / 'pre-convert.py' + if not script.exists(): + return True + + reporter.print_section_heading('{}Running pre-convert script for {}', + '(DRY RUN) ' if args.dry_run else '', model.name) + + cmd = [str(args.python), '--', str(script), '--', + str(args.download_dir / model.subdirectory), str(output_dir / model.subdirectory)] + + reporter.print('Pre-convert command: {}', common.command_string(cmd)) + reporter.print(flush=True) + + success = True if args.dry_run else reporter.job_context.subprocess(cmd) + reporter.print() + + return success + def convert_to_onnx(reporter, model, output_dir, args): reporter.print_section_heading('{}Converting {} to ONNX', '(DRY RUN) ' if args.dry_run else '', model.name) @@ -119,6 +138,11 @@ def convert(reporter, model): reporter.print() return True + (output_dir / model.subdirectory).mkdir(parents=True, exist_ok=True) + + if not run_pre_convert(reporter, model, output_dir, args): + return False + model_format = model.framework if model.conversion_to_onnx_args: diff --git a/tools/downloader/requirements-caffe2.in b/tools/downloader/requirements-caffe2.in index 1b368b2a9df..5f1ceb698af 100644 --- a/tools/downloader/requirements-caffe2.in +++ b/tools/downloader/requirements-caffe2.in @@ -1,5 +1,3 @@ future onnx - -# fix version in order to be compatible with requirements-pytorch.in -torch<1.5 +torch diff --git a/tools/downloader/requirements-pytorch.in b/tools/downloader/requirements-pytorch.in index 76db2a223f1..2131c0ce87f 100644 --- a/tools/downloader/requirements-pytorch.in +++ b/tools/downloader/requirements-pytorch.in @@ -1,6 +1,4 @@ onnx scipy # via torchvision - -# can't use higher versions because of https://github.com/pytorch/vision/issues/2132 -torch==1.4.* -torchvision==0.5.* +torch>=1.4 +torchvision