Compare commits
65 Commits
2022.2.0.d
...
dev-cpu/20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f39925343 | ||
|
|
997337c33d | ||
|
|
595523e6d3 | ||
|
|
0b21f70339 | ||
|
|
bb429a855a | ||
|
|
ff38537aea | ||
|
|
d570dc4e16 | ||
|
|
0f23ee9ad6 | ||
|
|
9f5e3c50b9 | ||
|
|
fa38c36b2f | ||
|
|
c533aa6b8b | ||
|
|
5b6827649c | ||
|
|
f037208b3f | ||
|
|
a1ccf115df | ||
|
|
8b7f7d6391 | ||
|
|
6a8b37fe4f | ||
|
|
f326f0b824 | ||
|
|
ecdda2c909 | ||
|
|
c9304c5c7f | ||
|
|
04ba093dca | ||
|
|
d81896502f | ||
|
|
26a20e5875 | ||
|
|
d7d4097418 | ||
|
|
91ec6b0806 | ||
|
|
841b2dc47a | ||
|
|
b53bc6bac5 | ||
|
|
f5af87f810 | ||
|
|
c4021f8e6e | ||
|
|
a1f21f3797 | ||
|
|
b08bf8a9de | ||
|
|
cecd11457e | ||
|
|
d9d934bf86 | ||
|
|
c302bc94da | ||
|
|
c20d762af8 | ||
|
|
f5ea549d97 | ||
|
|
b2ba3d5055 | ||
|
|
a9104e1a88 | ||
|
|
fbf241d9d8 | ||
|
|
63b283fe88 | ||
|
|
167f74a7bc | ||
|
|
36be40c7e9 | ||
|
|
543963bf8d | ||
|
|
901210fa6c | ||
|
|
eb87aacc49 | ||
|
|
a56e1a9c4b | ||
|
|
11238a504c | ||
|
|
6955c389d6 | ||
|
|
9e9e3dd01b | ||
|
|
3bfc042a35 | ||
|
|
4696b9e58a | ||
|
|
e17179d795 | ||
|
|
bacc15c275 | ||
|
|
04fabe7b20 | ||
|
|
bd09a6a218 | ||
|
|
21f3555f59 | ||
|
|
eae4782284 | ||
|
|
af4731a1f1 | ||
|
|
cd4150c8ef | ||
|
|
5e1a5aef3e | ||
|
|
8ee5514629 | ||
|
|
7e4539f6df | ||
|
|
3bebf4a76d | ||
|
|
d5e16f7844 | ||
|
|
838f71eb9a | ||
|
|
81b1fbd5c1 |
@@ -13,7 +13,7 @@ resources:
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/openvino_contrib
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
jobs:
|
||||
- job: android_arm64
|
||||
@@ -110,11 +110,11 @@ jobs:
|
||||
-DANDROID_ABI=$(ANDROID_ABI_CONFIG)
|
||||
-DANDROID_STL=c++_shared
|
||||
-DANDROID_PLATFORM=$(ANDROID_SDK_VERSION)
|
||||
-DENABLE_OPENCV=OFF
|
||||
-DENABLE_TESTS=ON
|
||||
-DENABLE_SAMPLES=ON
|
||||
-DENABLE_INTEL_MYRIAD=OFF
|
||||
-DBUILD_java_api=ON
|
||||
-DBUILD_cuda_plugin=OFF
|
||||
-DTHREADING=SEQ
|
||||
-DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
|
||||
@@ -13,13 +13,13 @@ resources:
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/openvino_contrib
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
- repository: testdata
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/testdata
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
jobs:
|
||||
- job: Lin
|
||||
@@ -161,7 +161,6 @@ jobs:
|
||||
-DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache
|
||||
-DBUILD_cuda_plugin=OFF
|
||||
$(REPO_DIR)
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
|
||||
@@ -215,6 +214,7 @@ jobs:
|
||||
set -e
|
||||
mkdir -p $(INSTALL_DIR)/opencv/
|
||||
cmake -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake
|
||||
cp -R $(REPO_DIR)/temp/opencv_4.5.2_ubuntu20/opencv/* $(INSTALL_DIR)/opencv/
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'Install tests'
|
||||
|
||||
@@ -255,7 +255,7 @@ jobs:
|
||||
- script: |
|
||||
export DATA_PATH=$(MODELS_PATH)
|
||||
export MODELS_PATH=$(MODELS_PATH)
|
||||
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_TEST_DIR)/pyopenvino $(PYTHON_STATIC_ARGS) --junitxml=TEST-Pyngraph.xml --ignore=$(INSTALL_TEST_DIR)/pyopenvino/tests/test_utils/test_utils.py --ignore=$(INSTALL_TEST_DIR)/pyopenvino/tests/test_onnx/test_zoo_models.py --ignore=$(INSTALL_TEST_DIR)/pyopenvino/tests/test_onnx/test_backend.py -v
|
||||
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_TEST_DIR)/pyopenvino $(PYTHON_STATIC_ARGS) --junitxml=TEST-Pyngraph.xml --ignore=$(INSTALL_TEST_DIR)/pyopenvino/tests/test_utils/test_utils.py --ignore=$(INSTALL_TEST_DIR)/pyopenvino/tests/test_onnx/test_zoo_models.py --ignore=$(INSTALL_TEST_DIR)/pyopenvino/tests/test_onnx/test_backend.py
|
||||
displayName: 'Python API 2.0 Tests'
|
||||
continueOnError: false
|
||||
|
||||
@@ -270,20 +270,10 @@ jobs:
|
||||
displayName: 'OV Core UT'
|
||||
continueOnError: false
|
||||
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/onnx_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:TEST-ONNXImportUT.xml
|
||||
workingDirectory: $(INSTALL_TEST_DIR)
|
||||
displayName: 'ONNX Frontend UT'
|
||||
continueOnError: false
|
||||
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/paddle_tests --gtest_print_time=1 --gtest_output=xml:TEST-Paddle.xml
|
||||
displayName: 'Paddle Frontend UT'
|
||||
continueOnError: false
|
||||
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/onnx_frontend_tests --gtest_print_time=1 --gtest_output=xml:TEST-Paddle.xml
|
||||
workingDirectory: $(INSTALL_TEST_DIR)
|
||||
displayName: 'ONNX Frontend UT'
|
||||
continueOnError: false
|
||||
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/tensorflow_tests --gtest_print_time=1 --gtest_output=xml:TEST-Tensorflow.xml
|
||||
displayName: 'Tensorflow Frontend UT'
|
||||
continueOnError: false
|
||||
@@ -332,7 +322,7 @@ jobs:
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/cpuFuncTests --gtest_filter=*smoke* --gtest_print_time=1 --gtest_output=xml:TEST-cpuFuncTests.xml
|
||||
displayName: 'CPU FuncTests'
|
||||
continueOnError: false
|
||||
condition: and(succeeded(), eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'OFF'))
|
||||
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'OFF')
|
||||
|
||||
- script: |
|
||||
export DATA_PATH=$(MODELS_PATH)
|
||||
|
||||
@@ -13,7 +13,7 @@ resources:
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/openvino_contrib
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
jobs:
|
||||
- job: linux_arm64
|
||||
@@ -127,6 +127,7 @@ jobs:
|
||||
-GNinja
|
||||
-DVERBOSE_BUILD=ON
|
||||
-DOpenCV_DIR=$(INSTALL_OPENCV)/cmake
|
||||
-DENABLE_OPENCV=OFF
|
||||
-DPYTHON_INCLUDE_DIRS=$(INSTALL_PYTHON)/include/python3.8
|
||||
-DPYTHON_LIBRARY=$(INSTALL_PYTHON)/lib/libpython3.8.so
|
||||
-DENABLE_PYTHON=ON
|
||||
@@ -142,7 +143,6 @@ jobs:
|
||||
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
|
||||
-DENABLE_SAMPLES=ON
|
||||
-DBUILD_java_api=OFF
|
||||
-DBUILD_cuda_plugin=OFF
|
||||
-DENABLE_INTEL_MYRIAD=OFF
|
||||
-DTHREADING=SEQ
|
||||
-DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules
|
||||
|
||||
@@ -21,6 +21,7 @@ jobs:
|
||||
VSTS_HTTP_TIMEOUT: 200
|
||||
BUILD_TYPE: Release
|
||||
REPO_DIR: $(Build.Repository.LocalPath)
|
||||
OPENVINO_CONTRIB_REPO_DIR: $(REPO_DIR)/../openvino_contrib
|
||||
MODELS_PATH: $(REPO_DIR)/../testdata
|
||||
WORK_DIR: $(Pipeline.Workspace)/_w
|
||||
BUILD_DIR: $(WORK_DIR)/build
|
||||
|
||||
@@ -4,7 +4,7 @@ resources:
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/openvino_contrib
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
jobs:
|
||||
- job: Lin
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# type: github
|
||||
# endpoint: openvinotoolkit
|
||||
# name: openvinotoolkit/testdata
|
||||
# ref: releases/2022/2
|
||||
# ref: master
|
||||
|
||||
jobs:
|
||||
- job: Lin_lohika
|
||||
|
||||
@@ -95,6 +95,7 @@ jobs:
|
||||
-DPYTHON_EXECUTABLE=/usr/bin/python3.8
|
||||
-DENABLE_INTEL_MYRIAD_COMMON=OFF
|
||||
-DENABLE_INTEL_GNA=OFF
|
||||
-DENABLE_OPENCV=OFF
|
||||
-DENABLE_CPPLINT=OFF
|
||||
-DENABLE_TESTS=OFF
|
||||
-DENABLE_INTEL_CPU=ON
|
||||
|
||||
@@ -13,13 +13,13 @@ resources:
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/openvino_contrib
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
- repository: testdata
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/testdata
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
jobs:
|
||||
- job: Mac
|
||||
@@ -101,7 +101,7 @@ jobs:
|
||||
export PATH="/usr/local/opt/cython/bin:$PATH"
|
||||
export CC=gcc
|
||||
export CXX=g++
|
||||
cmake -GNinja -DVERBOSE_BUILD=ON -DENABLE_REQUIREMENTS_INSTALL=OFF -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DENABLE_TESTS=OFF -DENABLE_STRICT_DEPENDENCIES=OFF -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DBUILD_cuda_plugin=OFF $(REPO_DIR)
|
||||
cmake -GNinja -DVERBOSE_BUILD=ON -DENABLE_REQUIREMENTS_INSTALL=OFF -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DENABLE_TESTS=OFF -DENABLE_STRICT_DEPENDENCIES=OFF -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache $(REPO_DIR)
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'CMake'
|
||||
|
||||
@@ -145,24 +145,19 @@ jobs:
|
||||
set -e
|
||||
mkdir -p $(INSTALL_DIR)/opencv/
|
||||
cmake -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake
|
||||
cp -R $(REPO_DIR)/temp/opencv_4.5.2_osx/opencv/* $(INSTALL_DIR)/opencv/
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'Install tests'
|
||||
|
||||
- script: ls -alR $(INSTALL_DIR)
|
||||
displayName: 'List install files'
|
||||
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/ov_core_unit_tests --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-NGraphUT.xml
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/ov_core_unit_tests --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU*:IE_CPU.onnx_model_sigmoid:IE_CPU/GRUSequenceOp.onnx_model_gru* --gtest_output=xml:TEST-NGraphUT.xml
|
||||
workingDirectory: $(INSTALL_TEST_DIR)
|
||||
displayName: 'OV Core UT'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/onnx_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU*:IE_CPU.onnx_model_sigmoid:IE_CPU/GRUSequenceOp.onnx_model_gru* --gtest_output=xml:TEST-ONNXImportUT.xml
|
||||
workingDirectory: $(INSTALL_TEST_DIR)
|
||||
displayName: 'ONNX Frontend UT'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
|
||||
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/InferenceEngineUnitTests --gtest_print_time=1 --gtest_filter=-MKLDNNGraphStructureTests.TestNoRedundantReordersBeforeDWConvolution:TestConvolution/MKLDNNGraphConvolutionTests.TestsConvolution/0:TestConvolutionDefaultPrimitivesPriority/MKLDNNGraphConvolutionTests.TestsConvolution/0 --gtest_output=xml:TEST-InferenceEngineUnitTests.xml
|
||||
displayName: 'IE UT old'
|
||||
continueOnError: false
|
||||
|
||||
@@ -13,13 +13,13 @@ resources:
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/openvino_contrib
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
- repository: testdata
|
||||
type: github
|
||||
endpoint: openvinotoolkit
|
||||
name: openvinotoolkit/testdata
|
||||
ref: releases/2022/2
|
||||
ref: master
|
||||
|
||||
jobs:
|
||||
- job: Win
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
maxParallel: 2
|
||||
|
||||
# About 150% of total time
|
||||
timeoutInMinutes: 270 #Temporary change
|
||||
timeoutInMinutes: 180
|
||||
|
||||
pool:
|
||||
name: WIN_VMSS_VENV_D8S_WU2
|
||||
@@ -135,7 +135,7 @@ jobs:
|
||||
|
||||
- script: |
|
||||
set PATH=$(WORK_DIR)\ninja-win;%PATH%
|
||||
call "$(MSVS_VARS_PATH)" && $(CMAKE_CMD) -G "Ninja Multi-Config" -DENABLE_WHEEL=ON -DENABLE_ONEDNN_FOR_GPU=$(CMAKE_BUILD_SHARED_LIBS) -DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_REQUIREMENTS_INSTALL=OFF -DENABLE_FASTER_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE="C:\hostedtoolcache\windows\Python\3.7.6\x64\python.exe" -DPYTHON_INCLUDE_DIR="C:\hostedtoolcache\windows\Python\3.7.6\x64\include" -DPYTHON_LIBRARY="C:\hostedtoolcache\windows\Python\3.7.6\x64\libs\python37.lib" -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DBUILD_cuda_plugin=OFF $(REPO_DIR)
|
||||
call "$(MSVS_VARS_PATH)" && $(CMAKE_CMD) -G "Ninja Multi-Config" -DENABLE_WHEEL=ON -DENABLE_ONEDNN_FOR_GPU=$(CMAKE_BUILD_SHARED_LIBS) -DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_REQUIREMENTS_INSTALL=OFF -DENABLE_FASTER_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE="C:\hostedtoolcache\windows\Python\3.7.6\x64\python.exe" -DPYTHON_INCLUDE_DIR="C:\hostedtoolcache\windows\Python\3.7.6\x64\include" -DPYTHON_LIBRARY="C:\hostedtoolcache\windows\Python\3.7.6\x64\libs\python37.lib" -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR)
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'CMake'
|
||||
|
||||
@@ -195,7 +195,7 @@ jobs:
|
||||
displayName: 'Samples Smoke Tests'
|
||||
continueOnError: false
|
||||
|
||||
- script: $(CMAKE_CMD) -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake
|
||||
- script: $(CMAKE_CMD) -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) -DCOMPONENT=tests -P cmake_install.cmake && xcopy $(REPO_DIR)\temp\opencv_4.5.2\opencv\* $(INSTALL_DIR)\opencv\ /e /h /y
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'Install tests'
|
||||
|
||||
@@ -211,20 +211,10 @@ jobs:
|
||||
displayName: 'OV Core UT'
|
||||
continueOnError: false
|
||||
|
||||
- script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\onnx_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:TEST-ONNXImportUT.xml
|
||||
workingDirectory: $(INSTALL_TEST_DIR)
|
||||
displayName: 'ONNX Frontend UT'
|
||||
continueOnError: false
|
||||
|
||||
- script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\paddle_tests --gtest_print_time=1 --gtest_output=xml:TEST-Paddle.xml
|
||||
displayName: 'Paddle Frontend UT'
|
||||
continueOnError: false
|
||||
|
||||
- script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\onnx_frontend_tests --gtest_print_time=1 --gtest_output=xml:TEST-ONNX.xml
|
||||
workingDirectory: $(INSTALL_TEST_DIR)
|
||||
displayName: 'ONNX Frontend UT'
|
||||
continueOnError: false
|
||||
|
||||
- script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\tensorflow_tests --gtest_print_time=1 --gtest_output=xml:TEST-Tensorflow.xml
|
||||
displayName: 'Tensorflow Frontend UT'
|
||||
continueOnError: false
|
||||
@@ -276,7 +266,7 @@ jobs:
|
||||
- script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\cpuFuncTests --gtest_filter=*smoke* --gtest_output=xml:TEST-cpuFuncTests.xml
|
||||
displayName: 'CPU FuncTests'
|
||||
continueOnError: false
|
||||
condition: and(succeeded(), eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'OFF'))
|
||||
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'OFF')
|
||||
|
||||
- script: |
|
||||
set DATA_PATH=$(MODELS_PATH)
|
||||
|
||||
@@ -21,6 +21,7 @@ jobs:
|
||||
VSTS_HTTP_TIMEOUT: 200
|
||||
BUILD_TYPE: Release
|
||||
REPO_DIR: $(Build.Repository.LocalPath)
|
||||
OPENVINO_CONTRIB_REPO_DIR: $(REPO_DIR)\..\openvino_contrib
|
||||
MODELS_PATH: $(REPO_DIR)\..\testdata
|
||||
WORK_DIR: $(Pipeline.Workspace)\_w
|
||||
BUILD_DIR: $(WORK_DIR)\build
|
||||
|
||||
@@ -59,6 +59,7 @@ RUN cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DENABLE_INTEL_MYRIAD_COMMON=OFF \
|
||||
-DENABLE_INTEL_GNA=OFF \
|
||||
-DENABLE_OPENCV=OFF \
|
||||
-DENABLE_CPPLINT=OFF \
|
||||
-DENABLE_NCC_STYLE=OFF \
|
||||
-DENABLE_TESTS=OFF \
|
||||
|
||||
10
.github/workflows/build_doc.yml
vendored
10
.github/workflows/build_doc.yml
vendored
@@ -4,7 +4,7 @@ on: [push, pull_request]
|
||||
jobs:
|
||||
Build_Doc:
|
||||
if: github.repository == 'openvinotoolkit/openvino'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Clone OpenVINO
|
||||
uses: actions/checkout@v2
|
||||
@@ -17,11 +17,11 @@ jobs:
|
||||
set -e
|
||||
# install doc dependencies
|
||||
sudo apt update
|
||||
sudo apt --assume-yes install libusb-1.0-0-dev graphviz texlive liblua5.2-0
|
||||
sudo apt --assume-yes install libusb-1.0-0-dev graphviz texlive
|
||||
cd docs
|
||||
python3 -m pip install -r requirements.txt --user
|
||||
python -m pip install -r requirements.txt --user
|
||||
cd openvino_sphinx_theme
|
||||
python3 setup.py install --user
|
||||
python setup.py install --user
|
||||
cd ../..
|
||||
# install doxyrest
|
||||
wget https://github.com/vovkos/doxyrest/releases/download/doxyrest-2.1.3/doxyrest-2.1.3-linux-amd64.tar.xz
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DENABLE_DOCS=ON -DENABLE_PYTHON=ON -DCMAKE_BUILD_TYPE=Release ..
|
||||
cmake -DENABLE_DOCS=ON -DENABLE_PYTHON=ON -DNGRAPH_PYTHON_BUILD_ENABLE=ON -DCMAKE_BUILD_TYPE=Release ..
|
||||
|
||||
- name: Build doc
|
||||
run: |
|
||||
|
||||
2
.github/workflows/check_pr_commits.yml
vendored
2
.github/workflows/check_pr_commits.yml
vendored
@@ -3,7 +3,7 @@ on: [pull_request]
|
||||
|
||||
jobs:
|
||||
Checks:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Clone OpenVINO
|
||||
uses: actions/checkout@v2
|
||||
|
||||
8
.github/workflows/code_style.yml
vendored
8
.github/workflows/code_style.yml
vendored
@@ -48,7 +48,7 @@ jobs:
|
||||
path: build/code_style_diff.diff
|
||||
|
||||
ShellCheck:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
working-directory: build
|
||||
|
||||
NamingConventionCheck:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
@@ -82,8 +82,8 @@ jobs:
|
||||
- name: Install Clang dependency
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt --assume-yes remove clang-7 clang-8 clang-9 clang-10 clang-11 clang-12 clang-13
|
||||
sudo apt --assume-yes install libclang-14-dev
|
||||
sudo apt --assume-yes remove clang-7 clang-8 clang-9 clang-10 clang-11
|
||||
sudo apt --assume-yes install libclang-12-dev
|
||||
|
||||
- name: Install Python-based dependencies
|
||||
run: python3 -m pip install -r cmake/developer_package/ncc_naming_style/requirements_dev.txt
|
||||
|
||||
2
.github/workflows/files_size.yml
vendored
2
.github/workflows/files_size.yml
vendored
@@ -3,7 +3,7 @@ on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
Check_Files_Size:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
|
||||
2
.github/workflows/mo.yml
vendored
2
.github/workflows/mo.yml
vendored
@@ -9,7 +9,7 @@ on:
|
||||
|
||||
jobs:
|
||||
Pylint-UT:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
|
||||
2
.github/workflows/py_checks.yml
vendored
2
.github/workflows/py_checks.yml
vendored
@@ -12,7 +12,7 @@ on:
|
||||
- 'samples/python/**'
|
||||
jobs:
|
||||
linters:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- name: Code checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,8 +1,5 @@
|
||||
# build/artifact dirs
|
||||
_*
|
||||
[Bb]uild*/
|
||||
cmake-build*
|
||||
|
||||
# but ensure we don't skip __init__.py and __main__.py
|
||||
!__init__.py
|
||||
!__main__.py
|
||||
@@ -12,10 +9,12 @@ cmake-build*
|
||||
# developer tools
|
||||
*.idea
|
||||
.vscode
|
||||
cmake-build-*
|
||||
.DS_Store
|
||||
**/tags
|
||||
compile_commands.json
|
||||
bin/
|
||||
build/
|
||||
.local_vimrc
|
||||
.gdb_history
|
||||
.vimspector.json
|
||||
@@ -35,13 +34,14 @@ docs/IE_PLUGIN_DG/html/
|
||||
*.pydevproject
|
||||
*.settings
|
||||
*/gen/
|
||||
__pycache__
|
||||
*.swp
|
||||
/config.xml
|
||||
|
||||
# Python-specific
|
||||
*.?env*
|
||||
*.env3
|
||||
*.pyc
|
||||
__pycache__
|
||||
|
||||
# Tests-specific
|
||||
*.coverage
|
||||
*htmlcov
|
||||
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
||||
[submodule "src/plugins/intel_cpu/thirdparty/onednn"]
|
||||
path = src/plugins/intel_cpu/thirdparty/onednn
|
||||
url = https://github.com/openvinotoolkit/oneDNN.git
|
||||
url = https://github.com/luo-cheng2021/oneDNN.git
|
||||
ignore = dirty
|
||||
[submodule "thirdparty/xbyak"]
|
||||
path = thirdparty/xbyak
|
||||
|
||||
@@ -17,10 +17,6 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "CMake build type" FORCE)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
add_compile_options(-fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv)
|
||||
endif()
|
||||
|
||||
find_package(IEDevScripts REQUIRED
|
||||
PATHS "${OpenVINO_SOURCE_DIR}/cmake/developer_package"
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
|
||||
@@ -30,7 +30,7 @@ Jenkinsfile @openvinotoolkit/openvino-admins
|
||||
# IE Core:
|
||||
/inference-engine/ @openvinotoolkit/openvino-ie-maintainers
|
||||
/src/bindings/python/ @openvinotoolkit/openvino-ie-python-api-maintainers
|
||||
/src/common/transformations/ @openvinotoolkit/openvino-ie-transformations-maintainers
|
||||
/src/common/transformations/ @GlebKazantaev @ilyachur
|
||||
/src/common/legacy/ @openvinotoolkit/openvino-ngraph-maintainers
|
||||
/src/common/ @openvinotoolkit/openvino-ie-maintainers
|
||||
/src/core/ @openvinotoolkit/openvino-ngraph-maintainers
|
||||
|
||||
@@ -161,10 +161,10 @@ The list of OpenVINO tutorials:
|
||||
|
||||
## System requirements
|
||||
|
||||
The full information about system requirements depends on platform and is available on dedicated pages:
|
||||
- [Linux](https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_linux_header.html)
|
||||
- [Windows](https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_windows_header.html)
|
||||
- [macOS](https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_macos_header.html)
|
||||
The full information about system requirements depends on platform and available in section `System requirement` on dedicated pages:
|
||||
- [Linux](https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_linux.html)
|
||||
- [Windows](https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_windows.html)
|
||||
- [macOS](https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_macos.html)
|
||||
- [Raspbian](https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_raspbian.html)
|
||||
|
||||
## How to build
|
||||
|
||||
@@ -84,11 +84,6 @@ ie_coverage_extract(INPUT "openvino" OUTPUT "core"
|
||||
ie_coverage_genhtml(INFO_FILE "core"
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "openvino_all"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/src/*" "${OV_COVERAGE_BASE_DIRECTORY}/docs/template_plugin/*")
|
||||
ie_coverage_genhtml(INFO_FILE "openvino_all"
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
if(ENABLE_OV_ONNX_FRONTEND)
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "onnx"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/src/frontends/onnx/*"
|
||||
|
||||
@@ -151,9 +151,6 @@ function(ov_download_tbb)
|
||||
if(EXISTS "${TBBROOT}/lib/cmake/TBB/TBBConfig.cmake")
|
||||
# oneTBB case
|
||||
update_deps_cache(TBB_DIR "${TBBROOT}/lib/cmake/TBB" "Path to TBB cmake folder")
|
||||
elseif(EXISTS "${TBBROOT}/lib/cmake/tbb/TBBConfig.cmake")
|
||||
# oneTBB release package version less than 2021.6.0
|
||||
update_deps_cache(TBB_DIR "${TBBROOT}/lib/cmake/tbb" "Path to TBB cmake folder")
|
||||
elseif(EXISTS "${TBBROOT}/lib64/cmake/TBB/TBBConfig.cmake")
|
||||
# 64-bits oneTBB case
|
||||
update_deps_cache(TBB_DIR "${TBBROOT}/lib64/cmake/TBB" "Path to TBB cmake folder")
|
||||
|
||||
@@ -28,6 +28,7 @@ if(ENABLE_CLANG_FORMAT AND NOT TARGET clang_format_check_all)
|
||||
add_custom_target(clang_format_fix_all)
|
||||
set_target_properties(clang_format_check_all clang_format_fix_all
|
||||
PROPERTIES FOLDER clang_format)
|
||||
set(CLANG_FORMAT_ALL_OUTPUT_FILES "" CACHE INTERNAL "All clang-format output files")
|
||||
endif()
|
||||
|
||||
function(add_clang_format_target TARGET_NAME)
|
||||
@@ -87,10 +88,14 @@ function(add_clang_format_target TARGET_NAME)
|
||||
"[clang-format] ${source_file}"
|
||||
VERBATIM)
|
||||
|
||||
list(APPEND all_input_sources "${source_file}")
|
||||
list(APPEND all_output_files "${output_file}")
|
||||
endforeach()
|
||||
|
||||
set(CLANG_FORMAT_ALL_OUTPUT_FILES
|
||||
${CLANG_FORMAT_ALL_OUTPUT_FILES} ${all_output_files}
|
||||
CACHE INTERNAL
|
||||
"All clang-format output files")
|
||||
|
||||
add_custom_target(${TARGET_NAME}
|
||||
DEPENDS ${all_output_files}
|
||||
COMMENT "[clang-format] ${TARGET_NAME}")
|
||||
@@ -99,11 +104,11 @@ function(add_clang_format_target TARGET_NAME)
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "CLANG_FORMAT=${CLANG_FORMAT}"
|
||||
-D "INPUT_FILES=${all_input_sources}"
|
||||
-D "INPUT_FILES=${CLANG_FORMAT_FOR_SOURCES}"
|
||||
-D "EXCLUDE_PATTERNS=${CLANG_FORMAT_EXCLUDE_PATTERNS}"
|
||||
-P "${IEDevScripts_DIR}/clang_format/clang_format_fix.cmake"
|
||||
DEPENDS
|
||||
"${all_input_sources}"
|
||||
"${CLANG_FORMAT_FOR_SOURCES}"
|
||||
"${IEDevScripts_DIR}/clang_format/clang_format_fix.cmake"
|
||||
COMMENT
|
||||
"[clang-format] ${TARGET_NAME}_fix"
|
||||
|
||||
@@ -9,46 +9,26 @@ endif()
|
||||
set(ncc_style_dir "${IEDevScripts_DIR}/ncc_naming_style")
|
||||
set(ncc_style_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/ncc_naming_style")
|
||||
|
||||
# find python3
|
||||
# try to find_package(Clang QUIET)
|
||||
# ClangConfig.cmake contains bug that if libclang-XX-dev is not
|
||||
# installed, then find_package fails with errors even in QUIET mode
|
||||
configure_file("${ncc_style_dir}/try_find_clang.cmake"
|
||||
"${ncc_style_bin_dir}/source/CMakeLists.txt" COPYONLY)
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -S "${ncc_style_bin_dir}/source"
|
||||
-B "${ncc_style_bin_dir}/build"
|
||||
RESULT_VARIABLE clang_find_result
|
||||
OUTPUT_VARIABLE output_var
|
||||
ERROR_VARIABLE error_var)
|
||||
|
||||
find_package(PythonInterp 3 QUIET)
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
message(WARNING "Python3 interpreter was not found (required for ncc naming style check)")
|
||||
if(NOT clang_find_result EQUAL "0")
|
||||
message(WARNING "Please, install clang-[N] libclang-[N]-dev package (required for ncc naming style check)")
|
||||
message(WARNING "find_package(Clang) output: ${output_var}")
|
||||
message(WARNING "find_package(Clang) error: ${error_var}")
|
||||
set(ENABLE_NCC_STYLE OFF)
|
||||
endif()
|
||||
|
||||
if(PYTHON_VERSION_MINOR EQUAL 6)
|
||||
set(clang_version 10)
|
||||
elseif(PYTHON_VERSION_MINOR EQUAL 8)
|
||||
set(clang_version 12)
|
||||
elseif(PYTHON_VERSION_MINOR EQUAL 9)
|
||||
set(clang_version 12)
|
||||
elseif(PYTHON_VERSION_MINOR EQUAL 10)
|
||||
set(clang_version 14)
|
||||
endif()
|
||||
|
||||
|
||||
if(ENABLE_NCC_STYLE)
|
||||
# try to find_package(Clang QUIET)
|
||||
# ClangConfig.cmake contains bug that if libclang-XX-dev is not
|
||||
# installed, then find_package fails with errors even in QUIET mode
|
||||
configure_file("${ncc_style_dir}/try_find_clang.cmake"
|
||||
"${ncc_style_bin_dir}/source/CMakeLists.txt" COPYONLY)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -S "${ncc_style_bin_dir}/source"
|
||||
-B "${ncc_style_bin_dir}/build"
|
||||
RESULT_VARIABLE clang_find_result
|
||||
OUTPUT_VARIABLE output_var
|
||||
ERROR_VARIABLE error_var)
|
||||
|
||||
if(NOT clang_find_result EQUAL "0")
|
||||
message(WARNING "Please, install `apt-get install clang-${clang_version} libclang-${clang_version}-dev` package (required for ncc naming style check)")
|
||||
message(TRACE "find_package(Clang) output: ${output_var}")
|
||||
message(TRACE "find_package(Clang) error: ${error_var}")
|
||||
set(ENABLE_NCC_STYLE OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Since we were able to find_package(Clang) in a separate process
|
||||
# let's try to find in current process
|
||||
if(ENABLE_NCC_STYLE)
|
||||
@@ -57,11 +37,19 @@ if(ENABLE_NCC_STYLE)
|
||||
get_target_property(libclang_location libclang LOCATION)
|
||||
message(STATUS "Found libclang: ${libclang_location}")
|
||||
else()
|
||||
message(WARNING "libclang-${clang_version} is not found (required for ncc naming style check)")
|
||||
message(WARNING "libclang is not found (required for ncc naming style check)")
|
||||
set(ENABLE_NCC_STYLE OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# find python3
|
||||
|
||||
find_package(PythonInterp 3 QUIET)
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
message(WARNING "Python3 interpreter was not found (required for ncc naming style check)")
|
||||
set(ENABLE_NCC_STYLE OFF)
|
||||
endif()
|
||||
|
||||
# check python requirements_dev.txt
|
||||
|
||||
set(ncc_script_py "${ncc_style_dir}/ncc/ncc.py")
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
clang==10.0.1; python_version == '3.6'
|
||||
clang==12.0.1; python_version == '3.8'
|
||||
clang==12.0.1; python_version == '3.9'
|
||||
clang==14.0; python_version == '3.10'
|
||||
clang==11.0
|
||||
pyyaml
|
||||
@@ -6,17 +6,6 @@ include(CMakeParseArguments)
|
||||
|
||||
find_host_program(shellcheck_PROGRAM NAMES shellcheck DOC "Path to shellcheck tool")
|
||||
|
||||
if(shellcheck_PROGRAM)
|
||||
execute_process(COMMAND "${shellcheck_PROGRAM}" --version
|
||||
RESULT_VARIABLE shellcheck_EXIT_CODE
|
||||
OUTPUT_VARIABLE shellcheck_VERSION_STRING)
|
||||
if(shellcheck_EXIT_CODE EQUAL 0)
|
||||
if(shellcheck_VERSION_STRING MATCHES "version: ([0-9]+)\.([0-9]+).([0-9]+)")
|
||||
set(shellcheck_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" CACHE STRING "shellcheck version")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
function(ie_shellcheck_process)
|
||||
if(NOT shellcheck_PROGRAM)
|
||||
message(WARNING "shellcheck tool is not found")
|
||||
@@ -44,7 +33,7 @@ function(ie_shellcheck_process)
|
||||
set(output_file "${output_file}.txt")
|
||||
get_filename_component(script_name "${script}" NAME)
|
||||
|
||||
add_custom_command(OUTPUT ${output_file}
|
||||
add_custom_command(OUTPUT ${output_file}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D IE_SHELLCHECK_PROGRAM=${shellcheck_PROGRAM}
|
||||
-D IE_SHELL_SCRIPT=${script}
|
||||
|
||||
@@ -126,7 +126,7 @@ ie_dependent_option (ENABLE_FUNCTIONAL_TESTS "functional tests" ON "ENABLE_TESTS
|
||||
|
||||
ie_dependent_option (ENABLE_SAMPLES "console samples are part of inference engine package" ON "NOT MINGW" OFF)
|
||||
|
||||
ie_option (ENABLE_OPENCV "enables OpenCV" OFF)
|
||||
ie_option (ENABLE_OPENCV "enables OpenCV" ON)
|
||||
|
||||
ie_option (ENABLE_V7_SERIALIZE "enables serialization to IR v7" OFF)
|
||||
|
||||
@@ -136,7 +136,16 @@ ie_dependent_option(ENABLE_TBB_RELEASE_ONLY "Only Release TBB libraries are link
|
||||
|
||||
ie_dependent_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" OFF "BUILD_SHARED_LIBS" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_SYSTEM_TBB "use the system version of TBB" OFF "THREADING MATCHES TBB;LINUX" OFF)
|
||||
get_linux_name(LINUX_OS_NAME)
|
||||
if(LINUX_OS_NAME MATCHES "^Ubuntu [0-9]+\.[0-9]+$" AND NOT DEFINED ENV{TBBROOT})
|
||||
# Debian packages are enabled on Ubuntu systems
|
||||
# so, system TBB can be tried for usage
|
||||
set(ENABLE_SYSTEM_TBB_DEFAULT ON)
|
||||
else()
|
||||
set(ENABLE_SYSTEM_TBB_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
ie_dependent_option (ENABLE_SYSTEM_TBB "use the system version of TBB" ${ENABLE_SYSTEM_TBB_DEFAULT} "THREADING MATCHES TBB;LINUX" OFF)
|
||||
|
||||
ie_option (ENABLE_DEBUG_CAPS "enable OpenVINO debug capabilities at runtime" OFF)
|
||||
|
||||
|
||||
@@ -150,23 +150,13 @@ if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND NOT TBB_FOUND
|
||||
set(enable_system_tbb "@ENABLE_SYSTEM_TBB@")
|
||||
if(NOT enable_system_tbb)
|
||||
set_and_check(_tbb_dir "@PACKAGE_IE_TBB_DIR@")
|
||||
|
||||
# see https://stackoverflow.com/questions/28070810/cmake-generate-error-on-windows-as-it-uses-as-escape-seq
|
||||
if(DEFINED ENV{TBBROOT})
|
||||
file(TO_CMAKE_PATH $ENV{TBBROOT} ENV_TBBROOT)
|
||||
endif()
|
||||
if(DEFINED ENV{TBB_DIR})
|
||||
file(TO_CMAKE_PATH $ENV{TBB_DIR} ENV_TBB_DIR)
|
||||
endif()
|
||||
|
||||
set(find_package_tbb_extra_args
|
||||
CONFIG
|
||||
PATHS
|
||||
# oneTBB case exposed via export TBBROOT=<custom TBB root>
|
||||
"${ENV_TBBROOT}/lib64/cmake/TBB"
|
||||
"${ENV_TBBROOT}/lib/cmake/TBB"
|
||||
"${ENV_TBBROOT}/lib/cmake/tbb"
|
||||
"${ENV_TBB_DIR}"
|
||||
"$ENV{TBBROOT}/lib64/cmake/TBB"
|
||||
"$ENV{TBBROOT}/lib/cmake/TBB"
|
||||
# "$ENV{TBB_DIR}"
|
||||
# for custom TBB exposed via cmake -DTBBROOT=<custom TBB root>
|
||||
"${TBBROOT}/cmake"
|
||||
# _tbb_dir points to TBB_DIR (custom | temp | system) used to build OpenVINO
|
||||
|
||||
@@ -108,7 +108,7 @@ if(ENABLE_TESTS)
|
||||
|
||||
message(STATUS "pip version is ${pip3_version}")
|
||||
set(args --quiet)
|
||||
if(pip3_version VERSION_GREATER 20.2.2 AND pip3_version VERSION_LESS 20.3.0)
|
||||
if(pip3_version VERSION_GREATER 20.2.2)
|
||||
list(APPEND args --use-feature=2020-resolver)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# Introduction to OpenVINO™ Deployment {#openvino_docs_deployment_guide_introduction}
|
||||
|
||||
|
||||
Once you have a model that meets both OpenVINO™ and your requirements, you can choose among several ways of deploying it with your application:
|
||||
* [Run inference and develop your app with OpenVINO™ Runtime](../OV_Runtime_UG/openvino_intro.md).
|
||||
* [Deploy your application locally](../OV_Runtime_UG/deployment/deployment_intro.md).
|
||||
* [Deploy your model online with the OpenVINO Model Server](@ref ovms_what_is_openvino_model_server).
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
# OpenVINO™ Deep Learning Workbench Overview {#workbench_docs_Workbench_DG_Introduction}
|
||||
|
||||
@sphinxdirective
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:hidden:
|
||||
|
||||
workbench_docs_Workbench_DG_Install
|
||||
workbench_docs_Workbench_DG_Work_with_Models_and_Sample_Datasets
|
||||
Tutorials <workbench_docs_Workbench_DG_Tutorials>
|
||||
User Guide <workbench_docs_Workbench_DG_User_Guide>
|
||||
workbench_docs_Workbench_DG_Troubleshooting
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
|
||||
|
||||
|
||||
Deep Learning Workbench (DL Workbench) is an official OpenVINO™ graphical interface designed to make the production of pretrained deep learning Computer Vision and Natural Language Processing models significantly easier.
|
||||
|
||||
Minimize the inference-to-deployment workflow timing for neural models right in your browser: import a model, analyze its performance and accuracy, visualize the outputs, optimize and make the final model deployment-ready in a matter of minutes. DL Workbench takes you through the full OpenVINO™ workflow, providing the opportunity to learn about various toolkit components.
|
||||
|
||||

|
||||
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
.. link-button:: workbench_docs_Workbench_DG_Start_DL_Workbench_in_DevCloud
|
||||
:type: ref
|
||||
:text: Run DL Workbench in Intel® DevCloud
|
||||
:classes: btn-primary btn-block
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
DL Workbench enables you to get a detailed performance assessment, explore inference configurations, and obtain an optimized model ready to be deployed on various Intel® configurations, such as client and server CPU, Intel® Processor Graphics (GPU), Intel® Movidius™ Neural Compute Stick 2 (NCS 2), and Intel® Vision Accelerator Design with Intel® Movidius™ VPUs.
|
||||
|
||||
DL Workbench also provides the [JupyterLab environment](https://docs.openvino.ai/latest/workbench_docs_Workbench_DG_Jupyter_Notebooks.html#doxid-workbench-docs-workbench-d-g-jupyter-notebooks) that helps you quick start with OpenVINO™ API and command-line interface (CLI). Follow the full OpenVINO workflow created for your model and learn about different toolkit components.
|
||||
|
||||
|
||||
## Video
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
.. list-table::
|
||||
|
||||
* - .. raw:: html
|
||||
|
||||
<iframe allowfullscreen mozallowfullscreen msallowfullscreen oallowfullscreen webkitallowfullscreen height="315" width="560"
|
||||
src="https://www.youtube.com/embed/on8xSSTKCt8">
|
||||
</iframe>
|
||||
* - **DL Workbench Introduction**. Duration: 1:31
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
|
||||
## User Goals
|
||||
|
||||
DL Workbench helps achieve your goals depending on the stage of your deep learning journey.
|
||||
|
||||
If you are a beginner in the deep learning field, the DL Workbench provides you with
|
||||
learning opportunities:
|
||||
* Learn what neural networks are, how they work, and how to examine their architectures.
|
||||
* Learn the basics of neural network analysis and optimization before production.
|
||||
* Get familiar with the OpenVINO™ ecosystem and its main components without installing it on your system.
|
||||
|
||||
If you have enough experience with neural networks, DL Workbench provides you with a
|
||||
convenient web interface to optimize your model and prepare it for production:
|
||||
* Measure and interpret model performance.
|
||||
* Tune the model for enhanced performance.
|
||||
* Analyze the quality of your model and visualize output.
|
||||
|
||||
## General Workflow
|
||||
|
||||
The diagram below illustrates the typical DL Workbench workflow. Click to see the full-size image:
|
||||
|
||||

|
||||
|
||||
Get a quick overview of the workflow in the DL Workbench User Interface:
|
||||
|
||||

|
||||
|
||||
## OpenVINO™ Toolkit Components
|
||||
|
||||
The intuitive web-based interface of the DL Workbench enables you to easily use various
|
||||
OpenVINO™ toolkit components:
|
||||
|
||||
Component | Description
|
||||
|------------------|------------------|
|
||||
| [Open Model Zoo](https://docs.openvinotoolkit.org/latest/omz_tools_downloader.html)| Get access to the collection of high-quality pre-trained deep learning [public](https://docs.openvinotoolkit.org/latest/omz_models_group_public.html) and [Intel-trained](https://docs.openvinotoolkit.org/latest/omz_models_group_intel.html) models trained to resolve a variety of different tasks.
|
||||
| [Model Optimizer](https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html) |Optimize and transform models trained in supported frameworks to the IR format. <br>Supported frameworks include TensorFlow\*, Caffe\*, Kaldi\*, MXNet\*, and ONNX\* format.
|
||||
| [Benchmark Tool](https://docs.openvinotoolkit.org/latest/openvino_inference_engine_tools_benchmark_tool_README.html)| Estimate deep learning model inference performance on supported devices.
|
||||
| [Accuracy Checker](https://docs.openvinotoolkit.org/latest/omz_tools_accuracy_checker.html)| Evaluate the accuracy of a model by collecting one or several metric values.
|
||||
| [Post-Training Optimization Tool](https://docs.openvinotoolkit.org/latest/pot_README.html)| Optimize pretrained models with lowering the precision of a model from floating-point precision(FP32 or FP16) to integer precision (INT8), without the need to retrain or fine-tune models. |
|
||||
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
.. link-button:: workbench_docs_Workbench_DG_Start_DL_Workbench_in_DevCloud
|
||||
:type: ref
|
||||
:text: Run DL Workbench in Intel® DevCloud
|
||||
:classes: btn-outline-primary
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
## Contact Us
|
||||
|
||||
* [DL Workbench GitHub Repository](https://github.com/openvinotoolkit/workbench)
|
||||
|
||||
* [DL Workbench on Intel Community Forum](https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/bd-p/distribution-openvino-toolkit)
|
||||
|
||||
* [DL Workbench Gitter Chat](https://gitter.im/dl-workbench/general?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&content=body)
|
||||
@@ -1,12 +0,0 @@
|
||||
# Introduction to Model Processing {#openvino_docs_model_processing_introduction}
|
||||
|
||||
Every deep learning workflow begins with obtaining a model. You can choose to prepare a custom one, use a ready-made solution and adjust it to your needs, or even download and run a pre-trained network from an online database, such as OpenVINO's [Open Model Zoo](../model_zoo.md).
|
||||
|
||||
This section describes how to obtain and prepare your model for work with OpenVINO to get the best inference results:
|
||||
* [Browse a database of models for use in your projects](../model_zoo.md).
|
||||
* [Convert different model formats to the OpenVINO IR format](../MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md).
|
||||
* [Automate model-related tasks with Model Downloader and additional OMZ Tools](https://docs.openvino.ai/latest/omz_tools_downloader.html).
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
# OpenVINO™ Ecosystem Overview {#openvino_ecosystem}
|
||||
|
||||
|
||||
OpenVINO™ is not just one tool. It is an expansive ecosystem of utilities, providing a comprehensive workflow for deep learning solution development. Learn more about each of them to reach the full potential of OpenVINO™ Toolkit.
|
||||
|
||||
### OpenVINO™ Model Server (OVMS)
|
||||
OpenVINO Model Server is a scalable, high-performance solution for serving deep learning models optimized for Intel® architectures. The server uses Inference Engine libraries as a backend and exposes gRPC and HTTP/REST interfaces for inference that are fully compatible with TensorFlow Serving.
|
||||
|
||||
More resources:
|
||||
* [OpenVINO documentation](https://docs.openvino.ai/latest/openvino_docs_ovms.html)
|
||||
* [Docker Hub](https://hub.docker.com/r/openvino/model_server)
|
||||
* [GitHub](https://github.com/openvinotoolkit/model_server)
|
||||
* [Red Hat Ecosystem Catalog](https://catalog.redhat.com/software/container-stacks/detail/60649e41ccfb383fe395a167)
|
||||
|
||||
### Neural Network Compression Framework (NNCF)
|
||||
A suite of advanced algorithms for Neural Network inference optimization with minimal accuracy drop. NNCF applies quantization, filter pruning, binarization and sparsity algorithms to PyTorch and TensorFlow models during training.
|
||||
|
||||
More resources:
|
||||
* [Documentation](@ref docs_nncf_introduction)
|
||||
* [GitHub](https://github.com/openvinotoolkit/nncf)
|
||||
* [PyPI](https://pypi.org/project/nncf/)
|
||||
|
||||
### OpenVINO™ Security Add-on
|
||||
A solution for Model Developers and Independent Software Vendors to use secure packaging and secure model execution.
|
||||
|
||||
More resources:
|
||||
* [documentation](https://docs.openvino.ai/latest/ovsa_get_started.html)
|
||||
* [GitHub]https://github.com/openvinotoolkit/security_addon)
|
||||
|
||||
|
||||
### OpenVINO™ integration with TensorFlow (OVTF)
|
||||
A solution empowering TensorFlow developers with OpenVINO's optimization capabilities. With just two lines of code in your application, you can offload inference to OpenVINO, while keeping the TensorFlow API.
|
||||
|
||||
More resources:
|
||||
* [documentation](https://github.com/openvinotoolkit/openvino_tensorflow)
|
||||
* [PyPI](https://pypi.org/project/openvino-tensorflow/)
|
||||
* [GitHub](https://github.com/openvinotoolkit/openvino_tensorflow)
|
||||
|
||||
### DL Streamer
|
||||
A streaming media analytics framework, based on the GStreamer multimedia framework, for creating complex media analytics pipelines.
|
||||
|
||||
More resources:
|
||||
* [documentation on GitHub](https://openvinotoolkit.github.io/dlstreamer_gst/)
|
||||
* [installation Guide on GitHub](https://github.com/openvinotoolkit/dlstreamer_gst/wiki/Install-Guide)
|
||||
|
||||
### DL Workbench
|
||||
A web-based tool for deploying deep learning models. Built on the core of OpenVINO and equipped with a graphics user interface, DL Workbench is a great way to explore the possibilities of the OpenVINO workflow, import, analyze, optimize, and build your pre-trained models. You can do all that by visiting [Intel® DevCloud for the Edge](https://software.intel.com/content/www/us/en/develop/tools/devcloud.html) and launching DL Workbench on-line.
|
||||
|
||||
More resources:
|
||||
* [documentation](dl_workbench_overview.md)
|
||||
* [Docker Hub](https://hub.docker.com/r/openvino/workbench)
|
||||
* [PyPI](https://pypi.org/project/openvino-workbench/)
|
||||
|
||||
### OpenVINO™ Training Extensions (OTE)
|
||||
A convenient environment to train Deep Learning models and convert them using the OpenVINO™ toolkit for optimized inference.
|
||||
|
||||
More resources:
|
||||
* [GitHub](https://github.com/openvinotoolkit/training_extensions)
|
||||
|
||||
### Computer Vision Annotation Tool (CVAT)
|
||||
An online, interactive video and image annotation tool for computer vision purposes.
|
||||
|
||||
More resources:
|
||||
* [documentation on GitHub](https://openvinotoolkit.github.io/cvat/docs/)
|
||||
* [web application](https://cvat.org/)
|
||||
* [Docker Hub](https://hub.docker.com/r/openvino/cvat_server)
|
||||
* [GitHub](https://github.com/openvinotoolkit/cvat)
|
||||
|
||||
### Dataset Management Framework (Datumaro)
|
||||
A framework and CLI tool to build, transform, and analyze datasets.
|
||||
|
||||
More resources:
|
||||
* [documentation on GitHub](https://openvinotoolkit.github.io/datumaro/docs/)
|
||||
* [PyPI](https://pypi.org/project/datumaro/)
|
||||
* [GitHub](https://github.com/openvinotoolkit/datumaro)
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
# OpenVINO™ integration with TensorFlow {#ovtf_integration}
|
||||
|
||||
**OpenVINO™ integration with TensorFlow** is a solution for TensorFlow developers who want to get started with OpenVINO™ in their inferencing applications. By adding just two lines of code you can now take advantage of OpenVINO™ toolkit optimizations with TensorFlow inference applications across a range of Intel® computation devices.
|
||||
|
||||
This is all you need:
|
||||
```bash
|
||||
import openvino_tensorflow
|
||||
openvino_tensorflow.set_backend('<backend_name>')
|
||||
```
|
||||
|
||||
**OpenVINO™ integration with TensorFlow** accelerates inference across many AI models on a variety of Intel® technologies, such as:
|
||||
- Intel® CPUs
|
||||
- Intel® integrated GPUs
|
||||
- Intel® Movidius™ Vision Processing Units - referred to as VPU
|
||||
- Intel® Vision Accelerator Design with 8 Intel Movidius™ MyriadX VPUs - referred to as VAD-M or HDDL
|
||||
|
||||
> **NOTE**: For maximum performance, efficiency, tooling customization, and hardware control, we recommend developers to adopt native OpenVINO™ solutions.
|
||||
To find out more about the product itself, as well as learn how to use it in your project, check its dedicated [GitHub repository](https://github.com/openvinotoolkit/openvino_tensorflow/tree/master/docs).
|
||||
|
||||
|
||||
To see what you can do with **OpenVINO™ integration with TensorFlow**, explore the demos located in the [examples folder](https://github.com/openvinotoolkit/openvino_tensorflow/tree/master/examples) in our GitHub repository.
|
||||
|
||||
Sample tutorials are also hosted on [Intel® DevCloud](https://www.intel.com/content/www/us/en/developer/tools/devcloud/edge/build/ovtfoverview.html). The demo applications are implemented using Jupyter Notebooks. You can interactively execute them on Intel® DevCloud nodes, compare the results of **OpenVINO™ integration with TensorFlow**, native TensorFlow, and OpenVINO™.
|
||||
|
||||
## License
|
||||
**OpenVINO™ integration with TensorFlow** is licensed under [Apache License Version 2.0](https://github.com/openvinotoolkit/openvino_tensorflow/blob/master/LICENSE).
|
||||
By contributing to the project, you agree to the license and copyright terms therein
|
||||
and release your contribution under these terms.
|
||||
|
||||
## Support
|
||||
|
||||
Submit your questions, feature requests and bug reports via [GitHub issues](https://github.com/openvinotoolkit/openvino_tensorflow/issues).
|
||||
|
||||
## How to Contribute
|
||||
|
||||
We welcome community contributions to **OpenVINO™ integration with TensorFlow**. If you have an idea for improvement:
|
||||
|
||||
* Share your proposal via [GitHub issues](https://github.com/openvinotoolkit/openvino_tensorflow/issues).
|
||||
* Submit a [pull request](https://github.com/openvinotoolkit/openvino_tensorflow/pulls).
|
||||
|
||||
We will review your contribution as soon as possible. If any additional fixes or modifications are necessary, we will guide you and provide feedback. Before you make your contribution, make sure you can build **OpenVINO™ integration with TensorFlow** and run all the examples with your fix/patch. If you want to introduce a large feature, create test cases for your feature. Upon our verification of your pull request, we will merge it to the repository provided that the pull request has met the above mentioned requirements and proved acceptable.
|
||||
|
||||
---
|
||||
\* Other names and brands may be claimed as the property of others.
|
||||
@@ -9,13 +9,13 @@
|
||||
openvino_docs_Extensibility_UG_add_openvino_ops
|
||||
openvino_docs_Extensibility_UG_Frontend_Extensions
|
||||
openvino_docs_Extensibility_UG_GPU
|
||||
openvino_docs_Extensibility_UG_VPU_Kernel
|
||||
openvino_docs_IE_DG_Extensibility_DG_VPU_Kernel
|
||||
openvino_docs_MO_DG_prepare_model_customize_model_optimizer_Customize_Model_Optimizer
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
The Intel® Distribution of OpenVINO™ toolkit supports neural network models trained with various frameworks, including
|
||||
TensorFlow, PyTorch, ONNX, PaddlePaddle, Apache MXNet, Caffe, and Kaldi. The list of supported operations is different for
|
||||
TensorFlow, PyTorch, ONNX, PaddlePaddle, MXNet, Caffe, and Kaldi. The list of supported operations is different for
|
||||
each of the supported frameworks. To see the operations supported by your framework, refer to
|
||||
[Supported Framework Operations](../MO_DG/prepare_model/Supported_Frameworks_Layers.md).
|
||||
|
||||
@@ -52,7 +52,7 @@ Depending on model format used for import, mapping of custom operation is implem
|
||||
|
||||
2. If model is represented in TensorFlow, Caffe, Kaldi or MXNet formats, then [Model Optimizer Extensions](../MO_DG/prepare_model/customize_model_optimizer/Customize_Model_Optimizer.md) should be used. This approach is available for model conversion in Model Optimizer only.
|
||||
|
||||
Existing of two approaches simultaneously is explained by two different types of frontends used for model conversion in OpenVINO: new frontends (ONNX, PaddlePaddle) and legacy frontends (TensorFlow, Caffe, Kaldi and Apache MXNet). Model Optimizer can use both front-ends in contrast to the direct import of model with `read_model` method which can use new frontends only. Follow one of the appropriate guides referenced above to implement mappings depending on framework frontend.
|
||||
Existing of two approaches simultaneously is explained by two different types of frontends used for model conversion in OpenVINO: new frontends (ONNX, PaddlePaddle) and legacy frontends (TensorFlow, Caffe, Kaldi and MXNet). Model Optimizer can use both front-ends in contrast to the direct import of model with `read_model` method which can use new frontends only. Follow one of the appropriate guides referenced above to implement mappings depending on framework frontend.
|
||||
|
||||
If you are implementing extensions for ONNX or PaddlePaddle new frontends and plan to use Model Optimizer `--extension` option for model conversion, then the extensions should be
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# How to Implement Custom Layers for VPU (Intel® Neural Compute Stick 2) {#openvino_docs_Extensibility_UG_VPU_Kernel}
|
||||
# How to Implement Custom Layers for VPU (Intel® Neural Compute Stick 2) {#openvino_docs_IE_DG_Extensibility_DG_VPU_Kernel}
|
||||
|
||||
To enable operations not supported by OpenVINO™ out of the box, you need a custom extension for Model Optimizer, a custom nGraph operation set, and a custom kernel for the device you will target. This page describes custom kernel support for one the VPU, the Intel® Neural Compute Stick 2 device, which uses the MYRIAD device plugin.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Converting Models with Model Optimizer {#openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide}
|
||||
# Convert model with Model Optimizer {#openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide}
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
:hidden:
|
||||
|
||||
openvino_docs_MO_DG_prepare_model_convert_model_Converting_Model
|
||||
openvino_docs_MO_DG_prepare_model_Model_Optimization_Techniques
|
||||
openvino_docs_MO_DG_prepare_model_convert_model_Cutting_Model
|
||||
openvino_docs_MO_DG_Additional_Optimization_Use_Cases
|
||||
openvino_docs_MO_DG_FP16_Compression
|
||||
@@ -25,49 +24,54 @@
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
## Introduction
|
||||
|
||||
Model Optimizer is a cross-platform command-line tool that facilitates the transition between training and deployment environments, performs static model analysis, and adjusts deep learning models for optimal execution on end-point target devices.
|
||||
|
||||
To use it, you need a pre-trained deep learning model in one of the supported formats: TensorFlow, PyTorch, PaddlePaddle, MXNet, Caffe, Kaldi, or ONNX. Model Optimizer converts the model to the OpenVINO Intermediate Representation format (IR), which you can infer later with [OpenVINO™ Runtime](../OV_Runtime_UG/openvino_intro.md).
|
||||
Using Model Optimizer tool assumes you already have a deep learning model trained using one of the supported frameworks: TensorFlow, PyTorch, PaddlePaddle, MXNet, Caffe, Kaldi, or represented in ONNX* format. Model Optimizer produces an Intermediate Representation (IR) of the model, which can be inferred with [OpenVINO™ Runtime](../OV_Runtime_UG/openvino_intro.md).
|
||||
|
||||
Note that Model Optimizer does not infer models.
|
||||
> **NOTE**: Model Optimizer does not infer models. Model Optimizer is an offline tool that converts a model into IR and optimizes before the inference takes place.
|
||||
|
||||
The figure below illustrates the typical workflow for deploying a trained deep learning model:
|
||||
The scheme below illustrates the typical workflow for deploying a trained deep learning model:
|
||||
|
||||

|
||||
|
||||
where IR is a pair of files describing the model:
|
||||
The IR is a pair of files describing the model:
|
||||
|
||||
* <code>.xml</code> - Describes the network topology.
|
||||
* <code>.xml</code> - Describes the network topology
|
||||
|
||||
* <code>.bin</code> - Contains the weights and biases binary data.
|
||||
|
||||
The generated IR can be additionally optimized for inference by [Post-training optimization](../../tools/pot/docs/Introduction.md)
|
||||
> **NOTE**: The generated IR can be additionally optimized for inference by [Post-training optimization](../../tools/pot/docs/Introduction.md)
|
||||
> that applies post-training quantization methods.
|
||||
|
||||
> **TIP**: You can also work with Model Optimizer in OpenVINO™ [Deep Learning Workbench (DL Workbench)](https://docs.openvino.ai/latest/workbench_docs_Workbench_DG_Introduction.html), which is a web-based tool with GUI for optimizing, fine-tuning, analyzing, visualizing, and comparing performance of deep learning models.
|
||||
> **TIP**: You also can work with the Model Optimizer inside the OpenVINO™ [Deep Learning Workbench](https://docs.openvino.ai/latest/workbench_docs_Workbench_DG_Introduction.html) (DL Workbench).
|
||||
> [DL Workbench](https://docs.openvino.ai/latest/workbench_docs_Workbench_DG_Introduction.html) is a web-based graphical environment that enables you to optimize, fine-tune, analyze, visualize, and compare performance of deep learning models.
|
||||
|
||||
## How to Run Model Optimizer
|
||||
## Run Model Optimizer
|
||||
|
||||
To convert a model to IR, you can run Model Optimizer by using the following command:
|
||||
To convert the model to IR, run Model Optimizer:
|
||||
|
||||
```sh
|
||||
mo --input_model INPUT_MODEL
|
||||
```
|
||||
|
||||
If the out-of-the-box conversion (only the `--input_model` parameter is specified) is not successful, use the parameters mentioned below to override input shapes and cut the model:
|
||||
If out-of-the-box conversion (only the `--input_model` parameter is specified) is not succeed,
|
||||
try to use parameters for overriding input shapes and cutting the model, mentioned below.
|
||||
|
||||
- Model Optimizer provides two parameters to override original input shapes for model conversion: `--input` and `--input_shape`.
|
||||
For more information about these parameters, refer to the [Setting Input Shapes](prepare_model/convert_model/Converting_Model.md) guide.
|
||||
To override original input shapes for model conversion, Model Optimizer provides two parameters: `--input` and `--input_shape`.
|
||||
For more information about these parameters, refer to [Setting Input Shapes](prepare_model/convert_model/Converting_Model.md).
|
||||
|
||||
- To cut off unwanted parts of a model (such as unsupported operations and training sub-graphs),
|
||||
use the `--input` and `--output` parameters to define new inputs and outputs of the converted model.
|
||||
For a more detailed description, refer to the [Cutting Off Parts of a Model](prepare_model/convert_model/Cutting_Model.md) guide.
|
||||
To cut off unwanted parts of a model, such as unsupported operations and training sub-graphs,
|
||||
the `--input` and `--output` parameters can be used, defining new inputs and outputs of the converted model.
|
||||
For a more detailed description, refer to [Cutting Off Parts of a Model](prepare_model/convert_model/Cutting_Model.md).
|
||||
|
||||
You can also insert additional input pre-processing sub-graphs into the converted model by using
|
||||
Also, you can insert additional input pre-processing sub-graphs into the converted model using
|
||||
the `--mean_values`, `scales_values`, `--layout`, and other parameters described
|
||||
in the [Embedding Preprocessing Computation](prepare_model/Additional_Optimizations.md) article.
|
||||
in [Embedding Preprocessing Computation](prepare_model/Additional_Optimizations.md).
|
||||
|
||||
The `--data_type` compression parameter in Model Optimizer allows generating IR of the `FP16` data type. For more details, refer to the [Compression of a Model to FP16](prepare_model/FP16_Compression.md) guide.
|
||||
Model Optimizer's compression parameter `--data_type` allows to generate IR of the `FP16` data type. For more details,
|
||||
please refer to [Compression of a Model to FP16](prepare_model/FP16_Compression.md).
|
||||
|
||||
To get the full list of conversion parameters available in Model Optimizer, run the following command:
|
||||
|
||||
@@ -77,51 +81,54 @@ mo --help
|
||||
|
||||
## Examples of CLI Commands
|
||||
|
||||
Below is a list of separate examples for different frameworks and Model Optimizer parameters:
|
||||
Below is a list of separate examples for different frameworks and Model Optimizer parameters.
|
||||
|
||||
1. Launch Model Optimizer for a TensorFlow MobileNet model in the binary protobuf format:
|
||||
1. Launch Model Optimizer for a TensorFlow MobileNet model in the binary protobuf format.
|
||||
```sh
|
||||
mo --input_model MobileNet.pb
|
||||
```
|
||||
Launch Model Optimizer for a TensorFlow BERT model in the SavedModel format with three inputs. Specify input shapes explicitly
|
||||
where the batch size and the sequence length equal 2 and 30 respectively:
|
||||
Launch Model Optimizer for a TensorFlow BERT model in the SavedModel format, with three inputs. Explicitly specify input shapes
|
||||
where the batch size and the sequence length equal 2 and 30 respectively.
|
||||
```sh
|
||||
mo --saved_model_dir BERT --input mask,word_ids,type_ids --input_shape [2,30],[2,30],[2,30]
|
||||
```
|
||||
For more information, refer to the [Converting a TensorFlow Model](prepare_model/convert_model/Convert_Model_From_TensorFlow.md) guide.
|
||||
For more information on TensorFlow model conversion,
|
||||
refer to [Converting a TensorFlow Model](prepare_model/convert_model/Convert_Model_From_TensorFlow.md).
|
||||
|
||||
2. Launch Model Optimizer for an ONNX OCR model and specify new output explicitly:
|
||||
2. Launch Model Optimizer for an ONNX OCR model and explicitly specify new output.
|
||||
```sh
|
||||
mo --input_model ocr.onnx --output probabilities
|
||||
```
|
||||
For more information, refer to the [Converting an ONNX Model (prepare_model/convert_model/Convert_Model_From_ONNX.md) guide.
|
||||
For more information on ONNX model conversion,
|
||||
please refer to [Converting an ONNX Model](prepare_model/convert_model/Convert_Model_From_ONNX.md).
|
||||
Note that PyTorch models must be exported to the ONNX format before its conversion into IR.
|
||||
More details can be found in [Converting a PyTorch Model](prepare_model/convert_model/Convert_Model_From_PyTorch.md).
|
||||
|
||||
> **NOTE**: PyTorch models must be exported to the ONNX format before conversion into IR. More information can be found in [Converting a PyTorch Model](prepare_model/convert_model/Convert_Model_From_PyTorch.md).
|
||||
|
||||
3. Launch Model Optimizer for a PaddlePaddle UNet model and apply mean-scale normalization to the input:
|
||||
3. Launch Model Optimizer for a PaddlePaddle UNet model and apply mean-scale normalization to the input.
|
||||
```sh
|
||||
mo --input_model unet.pdmodel --mean_values [123,117,104] --scale 255
|
||||
```
|
||||
For more information, refer to the [Converting a PaddlePaddle Model](prepare_model/convert_model/Convert_Model_From_Paddle.md) guide.
|
||||
For more information on PaddlePaddle model conversion, please refer to
|
||||
[Converting a PaddlePaddle Model](prepare_model/convert_model/Convert_Model_From_Paddle.md).
|
||||
|
||||
4. Launch Model Optimizer for an Apache MXNet SSD Inception V3 model and specify first-channel layout for the input:
|
||||
4. Launch Model Optimizer for an MXNet SSD Inception V3 model and specify first-channel layout for the input.
|
||||
```sh
|
||||
mo --input_model ssd_inception_v3-0000.params --layout NCHW
|
||||
```
|
||||
For more information, refer to the [Converting an Apache MXNet Model](prepare_model/convert_model/Convert_Model_From_MxNet.md) guide.
|
||||
For more information on MXNet models conversion, please refer to [Converting an MXNet Model](prepare_model/convert_model/Convert_Model_From_MxNet.md).
|
||||
|
||||
5. Launch Model Optimizer for a Caffe AlexNet model with input channels in the RGB format which needs to be reversed:
|
||||
5. Launch Model Optimizer for a Caffe AlexNet model with input channels in the RGB format, which needs to be reversed.
|
||||
```sh
|
||||
mo --input_model alexnet.caffemodel --reverse_input_channels
|
||||
```
|
||||
For more information, refer to the [Converting a Caffe Model](prepare_model/convert_model/Convert_Model_From_Caffe.md) guide.
|
||||
For more information on Caffe model conversion, please refer to [Converting a Caffe Model](prepare_model/convert_model/Convert_Model_From_Caffe.md).
|
||||
|
||||
6. Launch Model Optimizer for a Kaldi LibriSpeech nnet2 model:
|
||||
6. Launch Model Optimizer for a Kaldi LibriSpeech nnet2 model.
|
||||
```sh
|
||||
mo --input_model librispeech_nnet2.mdl --input_shape [1,140]
|
||||
```
|
||||
For more information, refer to the [Converting a Kaldi Model](prepare_model/convert_model/Convert_Model_From_Kaldi.md) guide.
|
||||
For more information on Kaldi model conversion,
|
||||
refer to [Converting a Kaldi Model](prepare_model/convert_model/Convert_Model_From_Kaldi.md).
|
||||
|
||||
- To get conversion recipes for specific TensorFlow, ONNX, PyTorch, Apache MXNet, and Kaldi models,
|
||||
refer to the [Model Conversion Tutorials](prepare_model/convert_model/Convert_Model_Tutorials.md).
|
||||
- For more information about IR, see [Deep Learning Network Intermediate Representation and Operation Sets in OpenVINO™](IR_and_opsets.md).
|
||||
To get conversion recipes for specific TensorFlow, ONNX, PyTorch, MXNet, and Kaldi models,
|
||||
refer to [Model Conversion Tutorials](prepare_model/convert_model/Convert_Model_Tutorials.md).
|
||||
|
||||
@@ -1,44 +1,46 @@
|
||||
# Deep Learning Network Intermediate Representation and Operation Sets in OpenVINO™ {#openvino_docs_MO_DG_IR_and_opsets}
|
||||
|
||||
This article provides essential information on the format used for representation of deep learning models in OpenVINO toolkit and supported operation sets.
|
||||
This document provides essential information on the format used for representation of deep learning models in OpenVINO™ toolkit and supported operation sets.
|
||||
|
||||
## Overview of Artificial Neural Networks Representation
|
||||
|
||||
This paragraph provides an overview of how a deep learning network is represented in various deep learning frameworks.
|
||||
|
||||
A deep learning network is usually represented as a directed graph describing the flow of data from the network input data to the inference results.
|
||||
Input data can be in the form of images, video, audio, or preprocessed information representing objects from the target area of interest.
|
||||
Input data can be represented as a photograph, video, audio information or some preprocessed data that represent object from the target area of interest in a convenient way.
|
||||
|
||||
Here is an illustration of a small graph representing a model that consists of a single Convolutional layer and activation function:
|
||||
|
||||

|
||||
|
||||
Vertices in the graph represent layers or operation instances such as convolution, pooling, and element-wise operations with tensors.
|
||||
The terms of "layer" and "operation" are used interchangeably within OpenVINO documentation and define how input data is processed to produce output data for a node in a graph.
|
||||
Vertices in the graph represent layers or operation instances, like convolution, pooling or element-wise operations with tensors.
|
||||
Layer and operation terms are used interchangeably along the OpenVINO™ documentation and define how input data is processed to produce output data for a node in a graph.
|
||||
An operation node in a graph may consume data at one or multiple input ports.
|
||||
For example, an element-wise addition operation has two input ports which accept tensors that are to be summed.
|
||||
Some operations do not have any input ports, for example the `Const` operation, which knows the data to be produced without any input.
|
||||
An edge between operations represents data flow or data dependency implied from one operation node to another.
|
||||
For example, element-wise addition operation has two input ports which accepts tensors that are added together.
|
||||
Some operations don't have any input ports, for example Const operation which knowns the data to be produced without any input.
|
||||
An edge between operations represent data flow or data dependency implied from one operation node to another operation node.
|
||||
|
||||
Each operation produces data on one or multiple output ports. For example, convolution produces output tensor with activations at a single output port. Split operation usually has multiple output ports, each producing part of an input tensor.
|
||||
Each operation produces data on one or multiple output ports. For example, convolution produces output tensor with activations at a single output port. Split operation usually has multiple output ports each producing part of an input tensor.
|
||||
|
||||
Depending on a deep learning framework, the graph can also contain extra nodes that explicitly represent tensors between operations.
|
||||
In such representations, operation nodes are not connected to each other directly. They are rather using data nodes as intermediate stops for data flow.
|
||||
In such representations, operation nodes are not connected directly to each other, rather using data nodes as intermediate stops for data flow.
|
||||
If data nodes are not used, the produced data is associated with an output port of a corresponding operation node that produces the data.
|
||||
|
||||
A set of various operations used in a network is usually fixed for each deep learning framework.
|
||||
It determines expressiveness and level of representation available in that framework.
|
||||
Sometimes, a network that can be represented in one framework is hard or impossible to be represented in another one or should use significantly different graph, because operation sets used in those two frameworks do not match.
|
||||
It may happen that a network that can be represented in one framework is hard or impossible to be represented in another one or should use significantly different graph because operation sets used in those two frameworks do not match.
|
||||
|
||||
## Intermediate Representation Used in OpenVINO
|
||||
## Intermediate Representation Used in OpenVINO™
|
||||
|
||||
OpenVINO toolkit introduces its own format of graph representation and its own operation set.
|
||||
OpenVINO™ toolkit introduces its own format of graph representation and its own operation set.
|
||||
A graph is represented with two files: an XML file and a binary file.
|
||||
This representation is commonly referred to as the *Intermediate Representation* or *IR*.
|
||||
|
||||
The XML file describes a network topology using a `<layer>` tag for an operation node and an `<edge>` tag for a data-flow connection.
|
||||
Each operation has a fixed number of attributes that define operation flavor used for a node.
|
||||
For example, the `Convolution` operation has such attributes as `dilation`, `stride`, `pads_begin`, and `pads_end`.
|
||||
For example, `Convolution` operation has such attributes as `dilation`, `stride`, `pads_begin` and `pads_end`.
|
||||
|
||||
The XML file does not have big constant values like convolution weights.
|
||||
The XML file doesn't have big constant values, like convolution weights.
|
||||
Instead, it refers to a part of the accompanying binary file that stores such values in a binary format.
|
||||
|
||||
Here is an example of a small IR XML file that corresponds to a graph from the previous section:
|
||||
@@ -149,48 +151,48 @@ Here is an example of a small IR XML file that corresponds to a graph from the p
|
||||
</net>
|
||||
```
|
||||
|
||||
The IR does not use explicit data nodes described in the previous section.
|
||||
The IR doesn't use explicit data nodes described in the previous section.
|
||||
In contrast, properties of data such as tensor dimensions and their data types are described as properties of input and output ports of operations.
|
||||
|
||||
## Operation Sets
|
||||
## Operation Set
|
||||
|
||||
Operations in OpenVINO Operation Sets are selected based on capabilities of supported deep learning frameworks and hardware capabilities of the target inference device.
|
||||
Operations in the OpenVINO™ Operation Set are selected based on capabilities of supported deep learning frameworks and hardware capabilities of the target inference device.
|
||||
It consists of several groups of operations:
|
||||
|
||||
* Conventional deep learning layers such as `Convolution`, `MaxPool`, and `MatMul` (also known as `FullyConnected`).
|
||||
* Conventional deep learning layers like Convolution, MaxPool, MatMul (also known as FullyConnected).
|
||||
|
||||
* Various activation functions such as `ReLU`, `Tanh`, and `PReLU`.
|
||||
* Various activation functions, e.g. ReLU, Tanh, PReLU.
|
||||
|
||||
* Generic element-wise arithmetic tensor operations such as `Add`, `Subtract`, and `Multiply`.
|
||||
* Generic element-wise arithmetic tensor operations like Add, Subtract, Multiply.
|
||||
|
||||
* Comparison operations that compare two numeric tensors and produce boolean tensors, for example, `Less`, `Equeal`, `Greater`.
|
||||
* Comparison operations that compare two numeric tensors and produce boolean tensors, for example Less, Equeal, Greater.
|
||||
|
||||
* Logical operations that are dealing with boolean tensors, for example, `And`, `Xor`, `Not`.
|
||||
* Logical operations that are dealing with boolean tensors, like And, Xor, Not.
|
||||
|
||||
* Data movement operations which are dealing with parts of tensors, for example, `Concat`, `Split`, `StridedSlice`, `Select`.
|
||||
* Data movement operations which are dealing with parts of tensors: Concat, Split, StridedSlice, Select.
|
||||
|
||||
* Specialized operations that implement complex algorithms dedicated for models of specific type, for example, `DetectionOutput`, `RegionYolo`, `PriorBox`.
|
||||
* Specialized operations that implement complex algorithms dedicated for models of specific type: DetectionOutput, RegionYolo, PriorBox.
|
||||
|
||||
For more information, refer to the complete description of the supported operation sets in the [Available Operation Sets](../ops/opset.md) article.
|
||||
Refer to the complete description of the supported operation sets in the [Available Operation Sets](../ops/opset.md) document.
|
||||
|
||||
## IR Versions vs Operation Set Versions
|
||||
|
||||
The expressiveness of operations in OpenVINO is highly dependent on the supported frameworks and target hardware capabilities.
|
||||
The expressiveness of operations in OpenVINO™ is highly dependent on the supported frameworks and target hardware capabilities.
|
||||
As the frameworks and hardware capabilities grow over time, the operation set is constantly evolving to support new models.
|
||||
To maintain backward compatibility and growing demands, both IR format and operation set have versioning.
|
||||
|
||||
Version of IR specifies the rules which are used to read the XML and binary files that represent a model. It defines an XML schema and compatible operation set that can be used to describe operations.
|
||||
|
||||
Historically, there are two major IR version epochs:
|
||||
Historically, there are two major IR version epochs.
|
||||
|
||||
1. The older one includes IR versions from version 1 to version 7 without versioning of the operation set. During that epoch, the operation set has been growing evolutionally accumulating more layer types and extending existing layer semantics. Changing of the operation set for those versions meant increasing of IR version.
|
||||
|
||||
2. OpenVINO 2020.1 is the starting point of the next epoch. With IR version 10 introduced in OpenVINO 2020.1, the versioning of the operation set is tracked separately from the IR versioning. Also, the operation set was significantly reworked as the result of nGraph integration to the OpenVINO.
|
||||
2. OpenVINO™ 2020.1 is the starting point of the next epoch. With IR version 10 introduced in OpenVINO™ 2020.1, the versioning of the operation set is tracked separately from the IR versioning. Also, the operation set was significantly reworked as the result of nGraph integration to the OpenVINO.
|
||||
|
||||
The first supported operation set in the new epoch is `opset1`.
|
||||
The number after `opset` is going to be increased each time new operations are added or old operations deleted at the release cadence.
|
||||
The number after `opset` is going to be increased each time when new operations are added or old operations deleted at the release cadence.
|
||||
|
||||
The operations from the new epoch cover more TensorFlow and ONNX operators in a form that is closer to the original operation semantics from the frameworks in comparison to the operation set used in former versions of IR (7 and lower).
|
||||
The operations from the new epoch cover more TensorFlow* and ONNX* operators in a form that is closer to the original operation semantics from the frameworks in comparison to the operation set used in former versions of IR (7 and lower).
|
||||
|
||||
The name of the opset is specified for each operation in IR.
|
||||
The IR version is specified once per whole IR.
|
||||
@@ -213,30 +215,31 @@ Here is an example from the IR snippet:
|
||||
...
|
||||
```
|
||||
|
||||
The `type="Parameter"` and `version="opset1"` attributes in the example above mean "use that version of the `Parameter` operation that is included in the `opset1` operation set. "
|
||||
The attributes `type="Parameter"` and `version="opset1"` in the example above mean "use that version of operation `Parameter` that is included into the operation set `opset1`".
|
||||
|
||||
When a new operation set is introduced, most of the operations remain unchanged and are just aliased from the previous operation set within a new one.
|
||||
The goal of operation set version evolution is to add new operations, and probably change small fractions of existing operations (fixing bugs and extending semantics).
|
||||
However, such changes affect only new versions of operations from a new operation set, while old operations are used by specifying an appropriate `version`.
|
||||
When an old `version` is specified, the behavior will be kept unchanged from that specified version to provide backward compatibility with older IRs.
|
||||
When a new operation set is introduced, the significant part of the operations remains unchanged and it is just aliased from the previous operation set within a new one.
|
||||
The goal of operation set versions evolution is adding new operations, and probably changing of small fraction of existing operations (fixing bugs and extending semantics).
|
||||
However such changes affect only new versions of operations from a new operation set, while old operations are used by specifying an appropriate `version`.
|
||||
When the old `version` is specified, the behavior is kept unchanged from that specified version to provide the backward compatibility with older IRs.
|
||||
|
||||
A single `xml` file with IR may contain operations from different opsets.
|
||||
An operation that is included in several opsets may be referred to with `version` which points to any opset that includes that operation.
|
||||
For example, the same `Convolution` can be used with `version="opset1"` and `version="opset2"` because both opsets have the same `Convolution` operations.
|
||||
An operation that is included into several opsets may be referred to with `version` which points to any opset that includes that operation.
|
||||
For example, the same `Convolution` can be used with `version="opset1"` and `version="opset2"` because both opsets have the same operations `Convolution`.
|
||||
|
||||
## How to Read Opset Specification
|
||||
## How to Read the Specification
|
||||
|
||||
In the [Available Operation Sets](../ops/opset.md) there are opsets and there are operations.
|
||||
Each opset specification has a list of links to operations descriptions that are included into that specific opset.
|
||||
Two or more opsets may refer to the same operation.
|
||||
That means an operation is kept unchanged from one operation set to another.
|
||||
|
||||
The description of each operation has a `Versioned name` field.
|
||||
For example, the `ReLU` entry point in [`opset1`](../ops/opset1.md) refers to [`ReLU-1`](../ops/activation/ReLU_1.md) as the versioned name.
|
||||
Meanwhile, `ReLU` in `opset2` refers to the same `ReLU-1` and both `ReLU` operations are the same operation and it has a single [description](../ops/activation/ReLU_1.md), which means that `opset1` and `opset2` share the same operation `ReLU`.
|
||||
Each operation description has a field `Versioned name`.
|
||||
For example, `ReLU` entry point in [`opset1`](../ops/opset1.md) refers to [`ReLU-1`](../ops/activation/ReLU_1.md) as the versioned name.
|
||||
And `ReLU` in `opset2` refers to the same `ReLU-1` and both `ReLU` operations are the same operation and it has a single [description](../ops/activation/ReLU_1.md).
|
||||
So `opset1` and `opset2` share the same operation `ReLU`.
|
||||
|
||||
To differentiate versions of the same operation type such as `ReLU`, the `-N` suffix is used in a versioned name of the operation.
|
||||
The `N` suffix usually refers to the first occurrence of `opsetN` where this version of the operation is introduced.
|
||||
There is no guarantee that new operations will be named according to that rule. The naming convention might be changed, but not for old operations which are frozen completely.
|
||||
To differentiate versions of the same operation type, like `ReLU`, the suffix `-N` is used in a versioned name of the operation.
|
||||
`N` usually refers to the first `opsetN` where this version of the operation is introduced.
|
||||
It is not guaranteed that new operations will be named according to that rule, the naming convention might be changed, but not for old operations which are frozen completely.
|
||||
|
||||
|
||||
|
||||
@@ -2,101 +2,100 @@
|
||||
|
||||
Input data for inference can be different from the training dataset and requires additional preprocessing before inference.
|
||||
To accelerate the whole pipeline including preprocessing and inference, Model Optimizer provides special parameters such as `--mean_values`,
|
||||
`--scale_values`, `--reverse_input_channels`, and `--layout`. Based on these parameters, Model Optimizer generates IR with additionally
|
||||
inserted sub-graph that performs the defined preprocessing. This preprocessing block can perform mean-scale normalization of input data,
|
||||
reverting data along channel dimension, and changing the data layout. For more details about these parameters, refer to the paragraphs below.
|
||||
The same functionality is also available in runtime, please refer to [Overview of Preprocessing API](../../OV_Runtime_UG/preprocessing_overview.md)
|
||||
for more information.
|
||||
|
||||
`--scale_values`, `--reverse_input_channels`, and `--layout`. Based on these parameters, Model Optimizer generates OpenVINO IR with additionally
|
||||
inserted sub-graphs to perform the defined preprocessing. This preprocessing block can perform mean-scale normalization of input data,
|
||||
reverting data along channel dimension, and changing the data layout.
|
||||
See the following sections for details on the parameters, or the [Overview of Preprocessing API](../../OV_Runtime_UG/preprocessing_overview.md) for the same functionality in OpenVINO Runtime.
|
||||
## When to Specify Layout
|
||||
|
||||
## Specifying Layout
|
||||
|
||||
You may need to set input layouts, as it is required by some preprocessing, for example, setting a batch, applying mean or scales, and reversing input channels (BGR<->RGB).
|
||||
|
||||
Layout defines the meaning of dimensions in shape and can be specified for both inputs and outputs. Some preprocessing requires to set input layouts, for example, setting a batch, applying mean or scales, and reversing input channels (BGR<->RGB).
|
||||
You may need to set input layouts, as it is required by some preprocessing, for example, setting a batch,
|
||||
applying mean or scales, and reversing input channels (BGR<->RGB).
|
||||
|
||||
Layout defines the meaning of dimensions in shape and can be specified for both inputs and outputs.
|
||||
For the layout syntax, check the [Layout API overview](../../OV_Runtime_UG/layout_overview.md).
|
||||
To specify the layout, you can use the `--layout` option followed by the layout value.
|
||||
To specify the layout, you can use `--layout` option followed by the layout value.
|
||||
|
||||
For example, the following command specifies the `NHWC` layout for a Tensorflow `nasnet_large` model that was exported to the ONNX format:
|
||||
For example, for Tensorflow\* `nasnet_large` model that was exported to ONNX format and thus has input with `NHWC` layout:
|
||||
|
||||
```
|
||||
mo --input_model tf_nasnet_large.onnx --layout nhwc
|
||||
```
|
||||
|
||||
Additionally, if a model has more than one input or needs both input and output layouts specified, you need to provide the name of each input or output to apply the layout.
|
||||
Additionally, if a model has more than one input or needs both input and output layouts specified,
|
||||
you need to provide the name of each input or output to which you apply the layout.
|
||||
|
||||
For example, the following command specifies the layout for an ONNX `Yolo v3 Tiny` model with its first input `input_1` in `NCHW` layout and second input `image_shape` having two dimensions: batch and size of the image expressed as the `N?` layout:
|
||||
For example, for ONNX\* `Yolo v3 Tiny` model that has first input `input_1` in `NCHW` layout and second input `image_shape`
|
||||
with 2 dimensions: batch and size of the image which can be expressed as `N?` layout:
|
||||
|
||||
```
|
||||
mo --input_model yolov3-tiny.onnx --layout input_1(nchw),image_shape(n?)
|
||||
```
|
||||
|
||||
## Changing Model Layout
|
||||
## How to Change Layout of a Model Inputs and Outputs
|
||||
|
||||
Changing the model layout may be necessary if it differs from the one presented by input data.
|
||||
Use either `--layout` or `--source_layout` with `--target_layout` to change the layout.
|
||||
To change the layout, you can use either `--layout` or `--source_layout` with `--target_layout`.
|
||||
|
||||
For example, for the same `nasnet_large` model mentioned previously, you can use the following commands to provide data in the `NCHW` layout:
|
||||
For example, for the same `nasnet_large` that were mentioned previously we may want to provide data in `NCHW` layout:
|
||||
|
||||
```
|
||||
mo --input_model tf_nasnet_large.onnx --source_layout nhwc --target_layout nchw
|
||||
mo --input_model tf_nasnet_large.onnx --layout "nhwc->nchw"
|
||||
```
|
||||
|
||||
Again, if a model has more than one input or needs both input and output layouts specified, you need to provide the name of each input or output to apply the layout.
|
||||
Again, if a model has more than one input or needs both input and output layouts specified, you need to provide the name of each input or output to which you apply the layout.
|
||||
|
||||
For example, to provide data in the `NHWC` layout for the `Yolo v3 Tiny` model mentioned earlier, use the following commands:
|
||||
For example, to provide data in the `NHWC` layout for the `Yolo v3 Tiny` model mentioned earlier:
|
||||
|
||||
```
|
||||
mo --input_model yolov3-tiny.onnx --source_layout "input_1(nchw),image_shape(n?)" --target_layout "input_1(nhwc)"
|
||||
mo --input_model yolov3-tiny.onnx --layout "input_1(nchw->nhwc),image_shape(n?)"
|
||||
```
|
||||
|
||||
## Specifying Mean and Scale Values
|
||||
Neural network models are usually trained with the normalized input data. This means that the input data values are converted to be in a specific range,
|
||||
for example, `[0, 1]` or `[-1, 1]`. Sometimes, the mean values (mean images) are subtracted from the input data values as part of the preprocessing.
|
||||
## When to Specify Mean and Scale Values
|
||||
Usually neural network models are trained with the normalized input data. This means that the input data values are converted to be in a specific range,
|
||||
for example, `[0, 1]` or `[-1, 1]`. Sometimes the mean values (mean images) are subtracted from the input data values as part of the pre-processing.
|
||||
There are two cases of how the input data pre-processing is implemented.
|
||||
* The input pre-processing operations are a part of a model. In this case, the application does not pre-process the input data as a separate step: everything is embedded into the model itself.
|
||||
* The input pre-processing operations are not a part of a model and the pre-processing is performed within the application which feeds the model with input data.
|
||||
|
||||
There are two cases of how the input data preprocessing is implemented.
|
||||
* The input preprocessing operations are a part of a model.
|
||||
|
||||
In this case, the application does not perform a separate preprocessing step: everything is embedded into the model itself. Model Optimizer will generate the OpenVINO IR format with required preprocessing operations, and no `mean` and `scale` parameters are required.
|
||||
* The input preprocessing operations are not a part of a model and the preprocessing is performed within the application which feeds the model with input data.
|
||||
|
||||
In this case, information about mean/scale values should be provided to Model Optimizer to embed it to the generated OpenVINO IR format.
|
||||
In the first case, the Model Optimizer generates the IR with required pre-processing operations and no `mean` and `scale` parameters are required.
|
||||
|
||||
In the second case, information about mean/scale values should be provided to the Model Optimizer to embed it to the generated IR.
|
||||
Model Optimizer provides command-line parameters to specify the values: `--mean_values`, `--scale_values`, `--scale`.
|
||||
Using these parameters, Model Optimizer embeds the corresponding preprocessing block for mean-value normalization of the input data
|
||||
and optimizes this block so that the preprocessing takes negligible time for inference.
|
||||
|
||||
For example, the following command runs Model Optimizer for the PaddlePaddle UNet model and applies mean-scale normalization to the input data:
|
||||
For example, run the Model Optimizer for the PaddlePaddle* UNet model and apply mean-scale normalization to the input data.
|
||||
|
||||
```sh
|
||||
mo --input_model unet.pdmodel --mean_values [123,117,104] --scale 255
|
||||
```
|
||||
|
||||
## Reversing Input Channels <a name="when_to_reverse_input_channels"></a>
|
||||
Sometimes, input images for your application can be of the RGB (or BGR) format and the model is trained on images of the BGR (or RGB) format,
|
||||
which is in the opposite order of color channels. In this case, it is important to preprocess the input images by reverting the color channels before inference.
|
||||
## When to Reverse Input Channels <a name="when_to_reverse_input_channels"></a>
|
||||
Sometimes input images for your application can be of the RGB (BGR) format and the model is trained on images of the BGR (RGB) format,
|
||||
the opposite color channel order. In this case, it is important to preprocess the input images by reverting the color channels before inference.
|
||||
To embed this preprocessing step into IR, Model Optimizer provides the `--reverse_input_channels` command-line parameter to shuffle the color channels.
|
||||
|
||||
To embed this preprocessing step into OpenVINO IR, Model Optimizer provides the `--reverse_input_channels` command-line parameter to shuffle the color channels.
|
||||
|
||||
The `--reverse_input_channels` parameter can be used to preprocess the model input in the following cases:
|
||||
The `--reverse_input_channels` parameter applies to an input of the model in two cases.
|
||||
* Only one dimension in the input shape has a size equal to 3.
|
||||
* One dimension has an undefined size and is marked as `C` channel using `layout` parameters.
|
||||
|
||||
Using the `--reverse_input_channels` parameter, Model Optimizer embeds the corresponding preprocessing block for reverting
|
||||
the input data along channel dimension and optimizes this block so that the preprocessing takes only negligible time for inference.
|
||||
the input data along channel dimension and optimizes this block so that the preprocessing takes negligible time for inference.
|
||||
|
||||
For example, the following command launches Model Optimizer for the TensorFlow AlexNet model and embeds the `reverse_input_channel` preprocessing block into OpenVINO IR:
|
||||
For example, launch the Model Optimizer for the TensorFlow* AlexNet model and embed `reverse_input_channel` preprocessing block into IR.
|
||||
|
||||
```sh
|
||||
mo --input_model alexnet.pb --reverse_input_channels
|
||||
```
|
||||
|
||||
> **NOTE**: If both mean and scale values are specified, the mean is subtracted first and then the scale is applied regardless of the order of options
|
||||
in the command-line. Input values are *divided* by the scale value(s). If the `--reverse_input_channels` option is also used, `reverse_input_channels`
|
||||
in the command line. Input values are *divided* by the scale value(s). If also `--reverse_input_channels` option is used, the `reverse_input_channels`
|
||||
will be applied first, then `mean` and after that `scale`. The data flow in the model looks as follows:
|
||||
`Parameter -> ReverseInputChannels -> Mean apply-> Scale apply -> the original body of the model`.
|
||||
|
||||
## Additional Resources
|
||||
## See Also
|
||||
* [Overview of Preprocessing API](../../OV_Runtime_UG/preprocessing_overview.md)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Compressing a Model to FP16 {#openvino_docs_MO_DG_FP16_Compression}
|
||||
# Compression of a Model to FP16 {#openvino_docs_MO_DG_FP16_Compression}
|
||||
|
||||
Model Optimizer can convert all floating-point weights to `FP16` data type. The resulting IR is called
|
||||
compressed `FP16` model.
|
||||
@@ -10,12 +10,11 @@ To compress the model, use the `--data_type` option:
|
||||
```
|
||||
|
||||
> **NOTE**: Using `--data_type FP32` will give no result and will not force `FP32`
|
||||
> precision in the model. If the model was `FP16`, it will have `FP16` precision in IR as well.
|
||||
> precision in the model. If the model was `FP16` it will have `FP16` precision in IR as well.
|
||||
|
||||
The resulting model will occupy about twice as less space in the file system, but it may have some accuracy drop.
|
||||
The resulting model will occupy about half of the previous space in the file system, but lose some of its accuracy.
|
||||
For most models, the accuracy drop is negligible.
|
||||
For details on how plugins handle compressed `FP16` models, see [Working with devices](../../OV_Runtime_UG/supported_plugins/Device_Plugins.md).
|
||||
The resulting model will occupy about twice as less space in the file system, but it may have some accuracy drop,
|
||||
although for the majority of models accuracy degradation is negligible. For details on how plugins handle
|
||||
compressed `FP16` models refer to [Working with devices](../../OV_Runtime_UG/supported_plugins/Device_Plugins.md) page.
|
||||
|
||||
> **NOTE**: `FP16` compression is sometimes used as the initial step for `INT8` quantization.
|
||||
> Refer to the [Post-training optimization](../../../tools/pot/docs/Introduction.md) guide for more information about that.
|
||||
> **NOTE**: `FP16` compression is sometimes used as initial step for `INT8` quantization, please refer to
|
||||
> [Post-training optimization](../../../tools/pot/docs/Introduction.md) for more information about that.
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
# Getting Performance Numbers {#openvino_docs_MO_DG_Getting_Performance_Numbers}
|
||||
|
||||
This guide introduces things to notice and how to use the benchmark_app to get performance numbers. It also explains how the performance numbers are reflected through internal inference performance counters and execution graphs. In the last section, it includes information on using ITT and Intel® VTune™ Profiler to get performance insights.
|
||||
|
||||
## Tip 1: Select Proper Set of Operations to Measure
|
||||
## Tip 1. Measure the Proper Set of Operations
|
||||
|
||||
When evaluating the performance of a model with OpenVINO Runtime, it is required to measure proper set of operations. Remember the following tips:
|
||||
- Avoid including one-time costs such as model loading.
|
||||
When evaluating performance of your model with the OpenVINO Runtime, you must measure the proper set of operations. To do so, consider the following tips:
|
||||
|
||||
- Track operations that occur outside OpenVINO Runtime (such as video decoding) separately.
|
||||
- Avoid including one-time costs like model loading.
|
||||
|
||||
> **NOTE**: Some image pre-processing can be baked into OpenVINO IR and accelerated accordingly. For more information, refer to [Embedding the Pre-processing](Additional_Optimizations.md) and [General Runtime Optimizations](../../optimization_guide/dldt_deployment_optimization_common).
|
||||
- Track separately the operations that happen outside the OpenVINO Runtime, like video decoding.
|
||||
|
||||
## Tip 2: Try to Get Credible Data
|
||||
> **NOTE**: Some image pre-processing can be baked into the IR and accelerated accordingly. For more information, refer to [Embedding the Preprocessing](Additional_Optimizations.md). Also consider [Runtime Optimizations of the Preprocessing](../../optimization_guide/dldt_deployment_optimization_common).
|
||||
|
||||
Performance conclusions should be build upon reproducible data. As for the performance measurements, they should be done with a large number of invocations of the same routine. Since the first iteration is almost always significantly slower than the subsequent ones, an aggregated value can be used for the execution time for final projections:
|
||||
## Tip 2. Getting Credible Performance Numbers
|
||||
|
||||
You need to build your performance conclusions on reproducible data. Do the performance measurements with a large number of invocations of the same routine. Since the first iteration is almost always significantly slower than the subsequent ones, you can use an aggregated value for the execution time for final projections:
|
||||
|
||||
- If the warm-up run does not help or execution time still varies, you can try running a large number of iterations and then average or find a mean of the results.
|
||||
- If the time values range too much, consider geomean.
|
||||
- Be aware of the throttling and other power oddities. A device can exist in one of several different power states. When optimizing your model, consider fixing the device frequency for better performance data reproducibility. However, the end-to-end (application) benchmarking should also be performed under real operational conditions.
|
||||
- For time values that range too much, consider geomean.
|
||||
- Beware of the throttling and other power oddities. A device can exist in one of several different power states. When optimizing your model, for better performance data reproducibility consider fixing the device frequency. However the end to end (application) benchmarking should be also performed under real operational conditions.
|
||||
|
||||
## Using benchmark_app to Measure Reference Performance Numbers
|
||||
## Tip 3. Measure Reference Performance Numbers with OpenVINO's benchmark_app
|
||||
|
||||
To get performance numbers, use the dedicated [OpenVINO Benchmark app](../../../samples/cpp/benchmark_app/README.md) sample, which is the most-recommended solution to produce performance reference.
|
||||
It includes a lot of device-specific knobs, but the primary usage is as simple as in the following command to measure the performance of the model on GPU:
|
||||
To get performance numbers, use the dedicated [Benchmark App](../../../samples/cpp/benchmark_app/README.md) sample which is the best way to produce the performance reference.
|
||||
It has a lot of device-specific knobs, but the primary usage is as simple as:
|
||||
```bash
|
||||
$ ./benchmark_app –d GPU –m <model> -i <input>
|
||||
```
|
||||
@@ -33,28 +33,28 @@ $ ./benchmark_app –d CPU –m <model> -i <input>
|
||||
```
|
||||
to execute on the CPU instead.
|
||||
|
||||
Each of the [OpenVINO supported devices](../../OV_Runtime_UG/supported_plugins/Supported_Devices.md) offers performance settings that contain command-line equivalents in the [Benchmark app](../../../samples/cpp/benchmark_app/README.md).
|
||||
While these settings provide really low-level control and allow leveraging the optimal model performance on the _specific_ device, it is recommended to always start the performance evaluation with the [OpenVINO High-Level Performance Hints](../../OV_Runtime_UG/performance_hints.md) first:
|
||||
Each of the [OpenVINO supported devices](../../OV_Runtime_UG/supported_plugins/Supported_Devices.md) offers performance settings that have command-line equivalents in the [Benchmark App](../../../samples/cpp/benchmark_app/README.md).
|
||||
While these settings provide really low-level control and allow to leverage the optimal model performance on the _specific_ device, we suggest always starting the performance evaluation with the [OpenVINO High-Level Performance Hints](../../OV_Runtime_UG/performance_hints.md) first:
|
||||
- benchmark_app **-hint tput** -d 'device' -m 'path to your model'
|
||||
- benchmark_app **-hint latency** -d 'device' -m 'path to your model'
|
||||
|
||||
## Notes for Comparing Performance with Native/Framework Code
|
||||
## Comparing Performance with Native/Framework Code
|
||||
|
||||
When comparing the OpenVINO Runtime performance with the framework or another reference code, make sure that both versions are as similar as possible:
|
||||
|
||||
- Wrap the exact inference execution (refer to the [Benchmark app](../../../samples/cpp/benchmark_app/README.md) for examples).
|
||||
- Wrap exactly the inference execution (refer to the [Benchmark App](../../../samples/cpp/benchmark_app/README.md) for examples).
|
||||
- Do not include model loading time.
|
||||
- Ensure that the inputs are identical for OpenVINO Runtime and the framework. For example, watch out for random values that can be used to populate the inputs.
|
||||
- In situations when any user-side pre-processing should be tracked separately, consider [image pre-processing and conversion](../../OV_Runtime_UG/preprocessing_overview.md).
|
||||
- When applicable, leverage the [Dynamic Shapes support](../../OV_Runtime_UG/ov_dynamic_shapes.md).
|
||||
- Ensure the inputs are identical for the OpenVINO Runtime and the framework. For example, beware of random values that can be used to populate the inputs.
|
||||
- Consider [Image Pre-processing and Conversion](../../OV_Runtime_UG/preprocessing_overview.md), while any user-side pre-processing should be tracked separately.
|
||||
- When applicable, leverage the [Dynamic Shapes support](../../OV_Runtime_UG/ov_dynamic_shapes.md)
|
||||
- If possible, demand the same accuracy. For example, TensorFlow allows `FP16` execution, so when comparing to that, make sure to test the OpenVINO Runtime with the `FP16` as well.
|
||||
|
||||
## Data from Internal Inference Performance Counters and Execution Graphs <a name="performance-counters"></a>
|
||||
More detailed insights into inference performance breakdown can be achieved with device-specific performance counters and/or execution graphs.
|
||||
Both [C++](../../../samples/cpp/benchmark_app/README.md) and [Python](../../../tools/benchmark_tool/README.md) versions of the `benchmark_app` support a `-pc` command-line parameter that outputs internal execution breakdown.
|
||||
## Internal Inference Performance Counters and Execution Graphs <a name="performance-counters"></a>
|
||||
Further, finer-grained insights into inference performance breakdown can be achieved with device-specific performance counters and/or execution graphs.
|
||||
Both [C++](../../../samples/cpp/benchmark_app/README.md) and [Python](../../../tools/benchmark_tool/README.md) versions of the `benchmark_app` supports a `-pc` command-line parameter that outputs internal execution breakdown.
|
||||
|
||||
For example, the table shown below is the part of performance counters for quantized [TensorFlow implementation of ResNet-50](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/resnet-50-tf) model inference on [CPU Plugin](../../OV_Runtime_UG/supported_plugins/CPU.md).
|
||||
Keep in mind that since the device is CPU, the `realTime` wall clock and the `cpu` time layers are the same. Information about layer precision is also stored in the performance counters.
|
||||
For example, below is the part of performance counters for quantized [TensorFlow* implementation of ResNet-50](https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/public/resnet-50-tf) model inference on [CPU Plugin](../../OV_Runtime_UG/supported_plugins/CPU.md).
|
||||
Notice that since the device is CPU, the layers wall clock `realTime` and the `cpu` time are the same. Information about layer precision is also stored in the performance counters.
|
||||
|
||||
| layerName | execStatus | layerType | execType | realTime (ms) | cpuTime (ms) |
|
||||
| --------------------------------------------------------- | ---------- | ------------ | -------------------- | ------------- | ------------ |
|
||||
@@ -68,23 +68,22 @@ Keep in mind that since the device is CPU, the `realTime` wall clock and the `cp
|
||||
| resnet\_model/add\_5/fq\_input\_1 | NOT\_RUN | FakeQuantize | undef | 0 | 0 |
|
||||
|
||||
|
||||
The `exeStatus` column of the table includes the following possible values:
|
||||
- `EXECUTED` - the layer was executed by standalone primitive.
|
||||
- `NOT_RUN` - the layer was not executed by standalone primitive or was fused with another operation and executed in another layer primitive.
|
||||
The `exeStatus` column of the table includes possible values:
|
||||
- `EXECUTED` - layer was executed by standalone primitive,
|
||||
- `NOT_RUN` - layer was not executed by standalone primitive or was fused with another operation and executed in another layer primitive.
|
||||
|
||||
The `execType` column of the table includes inference primitives with specific suffixes. The layers could have the following marks:
|
||||
* The `I8` suffix is for layers that had 8-bit data type input and were computed in 8-bit precision.
|
||||
* The `FP32` suffix is for layers computed in 32-bit precision.
|
||||
The `execType` column of the table includes inference primitives with specific suffixes. The layers have the following marks:
|
||||
* Suffix `I8` for layers that had 8-bit data type input and were computed in 8-bit precision
|
||||
* Suffix `FP32` for layers computed in 32-bit precision
|
||||
|
||||
All `Convolution` layers are executed in `int8` precision. The rest of the layers are fused into Convolutions using post-operation optimization, as described in [CPU Device](../../OV_Runtime_UG/supported_plugins/CPU.md).
|
||||
This contains layer names (as seen in OpenVINO IR), type of the layer, and execution statistics.
|
||||
All `Convolution` layers are executed in int8 precision. Rest layers are fused into Convolutions using post operations optimization technique, which is described in [Internal CPU Plugin Optimizations](../../OV_Runtime_UG/supported_plugins/CPU.md).
|
||||
This contains layers name (as seen in IR), layers type and execution statistics.
|
||||
|
||||
Both `benchmark_app` versions also support the `exec_graph_path` command-line option. It requires OpenVINO to output the same execution statistics per layer, but in the form of plugin-specific [Netron-viewable](https://netron.app/) graph to the specified file.
|
||||
Both benchmark_app versions also support "exec_graph_path" command-line option governing the OpenVINO to output the same per-layer execution statistics, but in the form of the plugin-specific [Netron-viewable](https://netron.app/) graph to the specified file.
|
||||
|
||||
Especially when performance-debugging the [latency](../../optimization_guide/dldt_deployment_optimization_latency.md), note that the counters do not reflect the time spent in the `plugin/device/driver/etc` queues. If the sum of the counters is too different from the latency of an inference request, consider testing with less inference requests. For example, running single [OpenVINO stream](../../optimization_guide/dldt_deployment_optimization_tput.md) with multiple requests would produce nearly identical counters as running a single inference request, while the actual latency can be quite different.
|
||||
Notice that on some devices, the execution graphs/counters may be pretty intrusive overhead-wise.
|
||||
Also, especially when performance-debugging the [latency case](../../optimization_guide/dldt_deployment_optimization_latency.md) notice that the counters do not reflect the time spent in the plugin/device/driver/etc queues. If the sum of the counters is too different from the latency of an inference request, consider testing with less inference requests. For example running single [OpenVINO stream](../../optimization_guide/dldt_deployment_optimization_tput.md) with multiple requests would produce nearly identical counters as running single inference request, yet the actual latency can be quite different.
|
||||
|
||||
Lastly, the performance statistics with both performance counters and execution graphs are averaged, so such data for the [inputs of dynamic shapes](../../OV_Runtime_UG/ov_dynamic_shapes.md) should be measured carefully, preferably by isolating the specific shape and executing multiple times in a loop, to gather the reliable data.
|
||||
Finally, the performance statistics with both performance counters and execution graphs is averaged, so such a data for the [dynamically-shaped inputs](../../OV_Runtime_UG/ov_dynamic_shapes.md) should be measured carefully (ideally by isolating the specific shape and executing multiple times in a loop, to gather the reliable data).
|
||||
|
||||
## Using ITT to Get Performance Insights
|
||||
|
||||
In general, OpenVINO and its individual plugins are heavily instrumented with Intel® Instrumentation and Tracing Technology (ITT). Therefore, you can also compile OpenVINO from the source code with ITT enabled and use tools like [Intel® VTune™ Profiler](https://software.intel.com/en-us/vtune) to get detailed inference performance breakdown and additional insights in the application-level performance on the timeline view.
|
||||
OpenVINO in general and individual plugins are heavily instrumented with Intel® instrumentation and tracing technology (ITT), so another option is to compile the OpenVINO from the source code with the ITT enabled and using tools like [Intel® VTune™ Profiler](https://software.intel.com/en-us/vtune) to get detailed inference performance breakdown and additional insights in the application-level performance on the timeline view.
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
# Model Optimization Techniques {#openvino_docs_MO_DG_prepare_model_Model_Optimization_Techniques}
|
||||
|
||||
Optimization offers methods to accelerate inference with the convolution neural networks (CNN) that do not require model retraining.
|
||||
|
||||
* * *
|
||||
|
||||
## Linear Operations Fusing
|
||||
|
||||
Many convolution neural networks includes `BatchNormalization` and `ScaleShift` layers (for example, Resnet\*, Inception\*) that can be presented as a sequence of linear operations: additions and multiplications. For example ScaleShift layer can be presented as Mul → Add sequence. These layers can be fused into previous `Convolution` or `FullyConnected` layers, except when Convolution comes after an Add operation (due to Convolution paddings).
|
||||
|
||||
### Usage
|
||||
|
||||
In the Model Optimizer, this optimization is turned on by default. To disable it, you can pass `--disable_fusing` parameter to the Model Optimizer.
|
||||
|
||||
### Optimization Description
|
||||
|
||||
This optimization method consists of three stages:
|
||||
|
||||
1. `BatchNormalization` and `ScaleShift` decomposition: in this stage, `BatchNormalization` layer is decomposed to `Mul → Add → Mul → Add` sequence, and `ScaleShift` layer is decomposed to `Mul → Add` layers sequence.
|
||||
|
||||
2. Linear operations merge: in this stage, the `Mul` and `Add` operations are merged into a single `Mul → Add` instance.
|
||||
For example, if there is a `BatchNormalization → ScaleShift` sequence in the topology, it is replaced with `Mul → Add` in the first stage. In the next stage, the latter is replaced with a `ScaleShift` layer if there is no available `Convolution` or `FullyConnected` layer to fuse into next.
|
||||
3. Linear operations fusion: in this stage, the tool fuses `Mul` and `Add` operations to `Convolution` or `FullyConnected` layers. Note that it searches for `Convolution` and `FullyConnected` layers both backward and forward in the graph (except for `Add` operation that cannot be fused to `Convolution` layer in forward direction).
|
||||
|
||||
### Usage Examples
|
||||
|
||||
The picture below shows the depicted part of Caffe Resnet269 topology where `BatchNorm` and `ScaleShift` layers will be fused to `Convolution` layers.
|
||||
|
||||

|
||||
|
||||
* * *
|
||||
|
||||
## ResNet optimization (stride optimization)
|
||||
|
||||
ResNet optimization is a specific optimization that applies to Caffe ResNet topologies such as ResNet50, ResNet101, ResNet152 and to ResNet-based topologies. This optimization is turned on by default, and can be disabled with the `--disable_resnet_optimization` key.
|
||||
|
||||
### Optimization Description
|
||||
|
||||
In the picture below, you can see the original and optimized parts of a Caffe ResNet50 model. The main idea of this optimization is to move the stride that is greater than 1 from Convolution layers with the kernel size = 1 to upper Convolution layers. In addition, the Model Optimizer adds a Pooling layer to align the input shape for a Eltwise layer, if it was changed during the optimization.
|
||||
|
||||

|
||||
|
||||
In this example, the stride from the `res3a_branch1` and `res3a_branch2a` Convolution layers moves to the `res2c_branch2b` Convolution layer. In addition, to align the input shape for `res2c` Eltwise, the optimization inserts the Pooling layer with kernel size = 1 and stride = 2.
|
||||
|
||||
* * *
|
||||
|
||||
## Grouped Convolution Fusing
|
||||
|
||||
Grouped convolution fusing is a specific optimization that applies for TensorFlow topologies. The main idea of this optimization is to combine convolutions results for the `Split` outputs and then recombine them using `Concat` operation in the same order as they were out from `Split`.
|
||||
|
||||

|
||||
|
||||
* * *
|
||||
|
||||
## Disabling Fusing
|
||||
|
||||
Model Optimizer allows to disable optimizations for specified nodes via `--finegrain_fusing <node_name1>,<node_name2>,...` (regex is also supported). Using this key, you mark nodes that will noy be touched by any optimizations.
|
||||
|
||||
### Examples of usage
|
||||
|
||||
On the picture below you can see two visualized Intermediate Representations (IR) of TensorFlow InceptionV4 topology.
|
||||
The first one is original IR that will be produced by the Model Optimizer.
|
||||
The second one will be produced by the Model Optimizer with key `--finegrain_fusing InceptionV4/InceptionV4/Conv2d_1a_3x3/Conv2D`, where you can see that `Convolution` was not fused with `Mul1_3752` and `Mul1_4061/Fused_Mul_5096/FusedScaleShift_5987` operations.
|
||||
|
||||

|
||||
@@ -4,25 +4,25 @@ If your question is not covered by the topics below, use the [OpenVINO™ Su
|
||||
|
||||
#### 1. What does the message "[ ERROR ]: Current caffe.proto does not contain field" mean? <a name="question-1"></a>
|
||||
|
||||
Internally, Model Optimizer uses a protobuf library to parse and load Caffe models. This library requires a file grammar and a generated parser. For a Caffe fallback, Model Optimizer uses a Caffe-generated parser for a Caffe-specific `.proto` file (which is usually located in the `src/caffe/proto` directory). Make sure that you install exactly the same version of Caffe (with Python interface) as that was used to create the model.
|
||||
Internally, the Model Optimizer uses a protobuf library to parse and load Caffe\* models. This library requires a file grammar and a generated parser. For a Caffe fallback, the Model Optimizer uses a Caffe-generated parser for a Caffe-specific `.proto` file (which is usually located in the `src/caffe/proto` directory). So, if you have Caffe installed on your machine with Python* interface available, make sure that this is exactly the version of Caffe that was used to create the model.
|
||||
|
||||
If you just want to experiment with Model Optimizer and test a Python extension for working with your custom
|
||||
If you just want to experiment with the Model Optimizer and test a Python extension for working with your custom
|
||||
layers without building Caffe, add the layer description to the `caffe.proto` file and generate a parser for it.
|
||||
|
||||
For example, to add the description of the `CustomReshape` layer, which is an artificial layer not present in any `caffe.proto` files:
|
||||
|
||||
1. Add the following lines to the `caffe.proto` file:
|
||||
1. Add the following lines to of the `caffe.proto` file:
|
||||
```shell
|
||||
package mo_caffe; // To avoid conflict with Caffe system, it is highly recommended to specify different package name.
|
||||
package mo_caffe; // to avoid conflict with system Caffe* it is highly recommended to specify different package name
|
||||
...
|
||||
message LayerParameter {
|
||||
// Other layers parameters description.
|
||||
// other layers parameters description
|
||||
...
|
||||
optional CustomReshapeParameter custom_reshape_param = 546; // 546 - ID is any number not present in caffe.proto.
|
||||
optional CustomReshapeParameter custom_reshape_param = 546; // 546 - ID is any number not present in caffe.proto
|
||||
}
|
||||
// The lines from here to the end of the file are describing contents of this parameter.
|
||||
// these lines to end of the file - describing contents of this parameter
|
||||
message CustomReshapeParameter {
|
||||
optional BlobShape shape = 1; // Just use the same parameter type as some other Caffe layers.
|
||||
optional BlobShape shape = 1; // we just use the same parameter type as some other Caffe layers
|
||||
}
|
||||
```
|
||||
|
||||
@@ -31,15 +31,15 @@ For example, to add the description of the `CustomReshape` layer, which is an ar
|
||||
cd <SITE_PACKAGES_WITH_INSTALLED_OPENVINO>/openvino/tools/mo/front/caffe/proto
|
||||
python3 generate_caffe_pb2.py --input_proto <PATH_TO_CUSTOM_CAFFE>/src/caffe/proto/caffe.proto
|
||||
```
|
||||
where `PATH_TO_CUSTOM_CAFFE` is the path to the root directory of custom Caffe.
|
||||
where `PATH_TO_CUSTOM_CAFFE` is the path to the root directory of custom Caffe\*.
|
||||
|
||||
3. Now, Model Optimizer is able to load the model into memory and start working with your extensions if there are any.
|
||||
3. Now, the Model Optimizer is able to load the model into memory and start working with your extensions if there are any.
|
||||
|
||||
However, since your model has custom layers, you must register them as custom. To learn more about it, refer to [Custom Layers in Model Optimizer](customize_model_optimizer/Customize_Model_Optimizer.md).
|
||||
However, because your model has custom layers, you must register your custom layers as custom. To learn more about it, refer to the section [Custom Layers in Model Optimizer](customize_model_optimizer/Customize_Model_Optimizer.md).
|
||||
|
||||
#### 2. How do I create a bare caffemodel, if I have only prototxt? <a name="question-2"></a>
|
||||
|
||||
You need the Caffe Python interface. In this case, do the following:
|
||||
You need the Caffe\* Python\* interface. In this case, do the following:
|
||||
```shell
|
||||
python3
|
||||
import caffe
|
||||
@@ -48,25 +48,25 @@ net.save('<PATH_TO_PROTOTXT>/my_net.caffemodel')
|
||||
```
|
||||
#### 3. What does the message "[ ERROR ]: Unable to create ports for node with id" mean? <a name="question-3"></a>
|
||||
|
||||
Most likely, Model Optimizer does not know how to infer output shapes of some layers in the given topology.
|
||||
To lessen the scope, compile the list of layers that are custom for Model Optimizer: present in the topology,
|
||||
absent in the [list of supported layers](Supported_Frameworks_Layers.md) for the target framework. Then, refer to available options in the corresponding section in the [Custom Layers in Model Optimizer](customize_model_optimizer/Customize_Model_Optimizer.md) page.
|
||||
Most likely, the Model Optimizer does not know how to infer output shapes of some layers in the given topology.
|
||||
To lessen the scope, compile the list of layers that are custom for the Model Optimizer: present in the topology,
|
||||
absent in [list of supported layers](Supported_Frameworks_Layers.md) for the target framework. Then refer to available options in the corresponding section in [Custom Layers in Model Optimizer](customize_model_optimizer/Customize_Model_Optimizer.md).
|
||||
|
||||
#### 4. What does the message "Input image of shape is larger than mean image from file" mean? <a name="question-4"></a>
|
||||
|
||||
Your model input shapes must be smaller than or equal to the shapes of the mean image file you provide. The idea behind the mean file is to subtract its values from the input image in an element-wise manner. When the mean file is smaller than the input image, there are not enough values to perform element-wise subtraction. Also, make sure you use the mean file that was used during the network training phase. Note that the mean file is dependent on dataset.
|
||||
Your model input shapes must be smaller than or equal to the shapes of the mean image file you provide. The idea behind the mean file is to subtract its values from the input image in an element-wise manner. When the mean file is smaller than the input image, there are not enough values to perform element-wise subtraction. Also, make sure that you use the mean file that was used during the network training phase. Note that the mean file is dataset dependent.
|
||||
|
||||
#### 5. What does the message "Mean file is empty" mean? <a name="question-5"></a>
|
||||
|
||||
Most likely, the mean file specified with the `--mean_file` flag is empty while Model Optimizer is launched. Make sure that this is exactly the required mean file and try to regenerate it from the given dataset if possible.
|
||||
Most likely, the mean file that you have is specified with `--mean_file` flag, while launching the Model Optimizer is empty. Make sure that this is exactly the required mean file and try to regenerate it from the given dataset if possible.
|
||||
|
||||
#### 6. What does the message "Probably mean file has incorrect format" mean? <a name="question-6"></a>
|
||||
|
||||
The mean file that you provide for Model Optimizer must be in the `.binaryproto` format. You can try to check the content, using recommendations from the BVLC Caffe ([#290](https://github.com/BVLC/caffe/issues/290)).
|
||||
The mean file that you provide for the Model Optimizer must be in a `.binaryproto` format. You can try to check the content using recommendations from the BVLC Caffe\* ([#290](https://github.com/BVLC/caffe/issues/290)).
|
||||
|
||||
#### 7. What does the message "Invalid proto file: there is neither 'layer' nor 'layers' top-level messages" mean? <a name="question-7"></a>
|
||||
|
||||
The structure of any Caffe topology is described in the `caffe.proto` file of any Caffe version. For example, the following `.proto` file in Model Optimizer is used by default: `mo/front/caffe/proto/my_caffe.proto`, with the structure:
|
||||
The structure of any Caffe\* topology is described in the `caffe.proto` file of any Caffe version. For example, in the Model Optimizer, you can find the following proto file, used by default: `mo/front/caffe/proto/my_caffe.proto`. There you can find the structure:
|
||||
```
|
||||
message NetParameter {
|
||||
// ... some other parameters
|
||||
@@ -81,7 +81,7 @@ This means that any topology should contain layers as top-level structures in `p
|
||||
|
||||
#### 8. What does the message "Old-style inputs (via 'input_dims') are not supported. Please specify inputs via 'input_shape'" mean? <a name="question-8"></a>
|
||||
|
||||
The structure of any Caffe topology is described in the `caffe.proto` file for any Caffe version. For example, the following `.proto` file in Model Optimizer is used by default: `mo/front/caffe/proto/my_caffe.proto`, with the structure:
|
||||
The structure of any Caffe\* topology is described in the `caffe.proto` file for any Caffe version. For example, in the Model Optimizer you can find the following `.proto` file, used by default: `mo/front/caffe/proto/my_caffe.proto`. There you can find the structure:
|
||||
```sh
|
||||
message NetParameter {
|
||||
|
||||
@@ -98,7 +98,7 @@ message NetParameter {
|
||||
// ... other parameters
|
||||
}
|
||||
```
|
||||
Therefore, the input layer of the provided model must be specified in one of the following styles:
|
||||
So, the input layer of the provided model must be specified in one of the following styles:
|
||||
|
||||
*
|
||||
```sh
|
||||
@@ -154,43 +154,43 @@ input_dim: 3
|
||||
input_dim: 500
|
||||
```
|
||||
|
||||
However, if your model contains more than one input, Model Optimizer is able to convert the model with inputs specified in one of the first three forms in the above list. The 4th form is not supported for multi-input topologies.
|
||||
However, if your model contains more than one input, the Model Optimizer is able to convert the model with inputs specified in a form of 1, 2, 3 of the list above. The last form is not supported for multi-input topologies.
|
||||
|
||||
#### 9. What does the message "Mean file for topologies with multiple inputs is not supported" mean? <a name="question-9"></a>
|
||||
|
||||
Model Optimizer does not support mean file processing for topologies with more than one input. In this case, you need to perform preprocessing of the inputs for a generated Intermediate Representation in OpenVINO Runtime to perform subtraction for every input of your multi-input model. See the [Overview of Preprocessing](../../OV_Runtime_UG/preprocessing_overview.md) for details.
|
||||
Model Optimizer does not support mean file processing for topologies with more than one input. In this case, you need to perform preprocessing of the inputs for a generated Intermediate Representation in the OpenVINO Runtime to perform subtraction for every input of your multi-input model, see [Overview of Preprocessing](../../OV_Runtime_UG/preprocessing_overview.md) for details.
|
||||
|
||||
#### 10. What does the message "Cannot load or process mean file: value error" mean? <a name="question-10"></a>
|
||||
|
||||
There are multiple reasons why Model Optimizer does not accept the mean file. See FAQs [#4](#question-4), [#5](#question-5), and [#6](#question-6).
|
||||
There are multiple reasons why the Model Optimizer does not accept the mean file. See FAQs [#4](#question-4), [#5](#question-5), and [#6](#question-6).
|
||||
|
||||
#### 11. What does the message "Invalid prototxt file: value error" mean? <a name="question-11"></a>
|
||||
|
||||
There are multiple reasons why Model Optimizer does not accept a Caffe topology. See FAQs [#7](#question-7) and [#20](#question-20).
|
||||
There are multiple reasons why the Model Optimizer does not accept a Caffe* topology. See FAQs [#7](#question-7) and [#20](#question-20).
|
||||
|
||||
#### 12. What does the message "Error happened while constructing caffe.Net in the Caffe fallback function" mean? <a name="question-12"></a>
|
||||
|
||||
Model Optimizer tried to infer a specified layer via the Caffe framework. However, it cannot construct a net using the Caffe Python interface. Make sure that your `caffemodel` and `prototxt` files are correct. To ensure that the problem is not in the `prototxt` file, see FAQ [#2](#question-2).
|
||||
Model Optimizer tried to infer a specified layer via the Caffe\* framework, however it cannot construct a net using the Caffe Python* interface. Make sure that your `caffemodel` and `prototxt` files are correct. To prove that the problem is not in the `prototxt` file, see FAQ [#2](#question-2).
|
||||
|
||||
#### 13. What does the message "Cannot infer shapes due to exception in Caffe" mean? <a name="question-13"></a>
|
||||
|
||||
Model Optimizer tried to infer a custom layer via the Caffe framework, but the model could not be inferred using Caffe. This might happen if you try to convert the model with some noise weights and biases, which conflict with layers that have dynamic shapes. You should write your own extension for every custom layer your topology might have. For more details, refer to the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) page.
|
||||
Model Optimizer tried to infer a custom layer via the Caffe\* framework, but an error occurred, meaning that the model could not be inferred using Caffe. This might happen if you try to convert the model with some noise weights and biases that result in problems with layers that have dynamic shapes. You should write your own extension for every custom layer you topology might have. For more details, refer to [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md).
|
||||
|
||||
#### 14. What does the message "Cannot infer shape for node {} because there is no Caffe available. Please register python infer function for op or use Caffe for shape inference" mean? <a name="question-14"></a>
|
||||
|
||||
Your model contains a custom layer and you have correctly registered it with the `CustomLayersMapping.xml` file. These steps are required to offload shape inference of the custom layer with the help of the system Caffe. However, Model Optimizer could not import a Caffe package. Make sure that you have built Caffe with a `pycaffe` target and added it to the `PYTHONPATH` environment variable. At the same time, it is highly recommended to avoid dependency on Caffe and write your own Model Optimizer extension for your custom layer. For more information, refer to FAQ [#44](#question-44).
|
||||
Your model contains a custom layer and you have correctly registered it with the `CustomLayersMapping.xml` file. These steps are required to offload shape inference of the custom layer with the help of the system Caffe\*. However, the Model Optimizer could not import a Caffe package. Make sure that you have built Caffe with a `pycaffe` target and added it into the `PYTHONPATH` environment variable. At the same time, it is highly recommend to avoid dependency on Caffe and write your own Model Optimizer extension for your custom layer. For more information, refer to the FAQ [#45](#question-45).
|
||||
|
||||
#### 15. What does the message "Framework name can not be deduced from the given options. Use --framework to choose one of Caffe, TensorFlow, MXNet" mean? <a name="question-15"></a>
|
||||
|
||||
You have run Model Optimizer without a flag `--framework caffe|tf|mxnet`. Model Optimizer tries to deduce the framework by the extension of input model file (`.pb` for TensorFlow, `.caffemodel` for Caffe, `.params` for Apache MXNet). Your input model might have a different extension and you need to explicitly set the source framework. For example, use `--framework caffe`.
|
||||
You have run the Model Optimizer without a flag `--framework caffe|tf|mxnet`. Model Optimizer tries to deduce the framework by the input model file extension (`.pb` for TensorFlow\*, `.caffemodel` for Caffe\*, `.params` for MXNet\*). Your input model might have a different extension and you need to explicitly set the source framework. For example, use `--framework caffe`.
|
||||
|
||||
#### 16. What does the message "Input shape is required to convert MXNet model. Please provide it with --input_shape" mean? <a name="question-16"></a>
|
||||
|
||||
Input shape was not provided. That is mandatory for converting an MXNet model to the OpenVINO Intermediate Representation, because MXNet models do not contain information about input shapes. Use the `--input_shape` flag to specify it. For more information about using the `--input_shape`, refer to FAQ [#56](#question-56).
|
||||
Input shape was not provided. That is mandatory for converting an MXNet\* model to the Intermediate Representation, because MXNet models do not contain information about input shapes. Please, use the `--input_shape` flag to specify it. For more information about using the `--input_shape`, refer to the FAQ [#57](#question-57).
|
||||
|
||||
#### 17. What does the message "Both --mean_file and mean_values are specified. Specify either mean file or mean values" mean? <a name="question-17"></a>
|
||||
|
||||
The `--mean_file` and `--mean_values` options are two ways of specifying preprocessing for the input. However, they cannot be used together, as it would mean double subtraction and lead to ambiguity. Choose one of these options and pass it with the corresponding CLI option.
|
||||
`--mean_file` and `--mean_values` are two ways of specifying preprocessing for the input. However, they cannot be used together, as it would mean double subtraction and lead to ambiguity. Choose one of these options and pass it using the corresponding CLI option.
|
||||
|
||||
#### 18. What does the message "Negative value specified for --mean_file_offsets option. Please specify positive integer values in format '(x,y)'" mean? <a name="question-18"></a>
|
||||
|
||||
@@ -198,157 +198,157 @@ You might have specified negative values with `--mean_file_offsets`. Only positi
|
||||
|
||||
#### 19. What does the message "Both --scale and --scale_values are defined. Specify either scale factor or scale values per input channels" mean? <a name="question-19"></a>
|
||||
|
||||
The `--scale` option sets a scaling factor for all channels, while `--scale_values` sets a scaling factor per each channel. Using both of them simultaneously produces ambiguity, so you must use only one of them. For more information, refer to the **Using Framework-Agnostic Conversion Parameters** section: for <a href="ConvertFromCaffe.html#using-framework-agnostic-conv-param">Converting a Caffe Model</a>, <a href="ConvertFromTensorFlow.html#using-framework-agnostic-conv-param">Converting a TensorFlow Model</a>, <a href="ConvertFromMXNet.html#using-framework-agnostic-conv-param">Converting an MXNet Model</a>.
|
||||
`--scale` sets a scaling factor for all channels. `--scale_values` sets a scaling factor per each channel. Using both of them simultaneously produces ambiguity, so you must use only one of them. For more information, refer to the Using Framework-Agnostic Conversion Parameters: for <a href="ConvertFromCaffe.html#using-framework-agnostic-conv-param">Converting a Caffe* Model</a>, <a href="ConvertFromTensorFlow.html#using-framework-agnostic-conv-param">Converting a TensorFlow* Model</a>, <a href="ConvertFromMXNet.html#using-framework-agnostic-conv-param">Converting an MXNet* Model</a>.
|
||||
|
||||
#### 20. What does the message "Cannot find prototxt file: for Caffe please specify --input_proto - a protobuf file that stores topology and --input_model that stores pre-trained weights" mean? <a name="question-20"></a>
|
||||
|
||||
Model Optimizer cannot find a `.prototxt` file for a specified model. By default, it must be located in the same directory as the input model with the same name (except extension). If any of these conditions is not satisfied, use `--input_proto` to specify the path to the `.prototxt` file.
|
||||
|
||||
#### 21. What does the message "Failed to create directory .. . Permission denied!" mean? <a name="question-21"></a>
|
||||
#### 22. What does the message "Failed to create directory .. . Permission denied!" mean? <a name="question-22"></a>
|
||||
|
||||
Model Optimizer cannot create a directory specified via `--output_dir`. Make sure that you have enough permissions to create the specified directory.
|
||||
|
||||
#### 22. What does the message "Discovered data node without inputs and value" mean? <a name="question-22"></a>
|
||||
#### 23. What does the message "Discovered data node without inputs and value" mean? <a name="question-23"></a>
|
||||
|
||||
One of the layers in the specified topology might not have inputs or values. Make sure that the provided `caffemodel` and `protobuf` files are correct.
|
||||
One of the layers in the specified topology might not have inputs or values. Please make sure that the provided `caffemodel` and `protobuf` files are correct.
|
||||
|
||||
#### 23. What does the message "Part of the nodes was not translated to IE. Stopped" mean? <a name="question-23"></a>
|
||||
#### 24. What does the message "Part of the nodes was not translated to IE. Stopped" mean? <a name="question-24"></a>
|
||||
|
||||
Some of the operations are not supported by OpenVINO Runtime and cannot be translated to OpenVINO Intermediate Representation. You can extend Model Optimizer by allowing generation of new types of operations and implement these operations in the dedicated OpenVINO plugins. For more information, refer to the [OpenVINO Extensibility Mechanism](../../Extensibility_UG/Intro.md) guide.
|
||||
Some of the operations are not supported by the OpenVINO Runtime and cannot be translated to an Intermediate Representation. You can extend the Model Optimizer by allowing generation of new types of operations and implement these operations in the dedicated OpenVINO plugins. For more information, refer to the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md)
|
||||
|
||||
#### 24. What does the message "While creating an edge from .. to .. : node name is undefined in the graph. Check correctness of the input model" mean? <a name="question-24"></a>
|
||||
#### 25. What does the message "While creating an edge from .. to .. : node name is undefined in the graph. Check correctness of the input model" mean? <a name="question-25"></a>
|
||||
|
||||
Model Optimizer cannot build a graph based on a specified model. Most likely, it is incorrect.
|
||||
|
||||
#### 25. What does the message "Node does not exist in the graph" mean? <a name="question-25"></a>
|
||||
#### 26. What does the message "Node does not exist in the graph" mean? <a name="question-26"></a>
|
||||
|
||||
You might have specified an output node via the `--output` flag that does not exist in a provided model. Make sure that the specified output is correct and this node exists in the current model.
|
||||
|
||||
#### 26. What does the message "--input parameter was provided. Other inputs are needed for output computation. Provide more inputs or choose another place to cut the net" mean? <a name="question-26"></a>
|
||||
#### 27. What does the message "--input parameter was provided. Other inputs are needed for output computation. Provide more inputs or choose another place to cut the net" mean? <a name="question-27"></a>
|
||||
|
||||
Most likely, Model Optimizer tried to cut the model by a specified input. However, other inputs are needed.
|
||||
Most likely, the Model Optimizer tried to cut the model by a specified input. However, other inputs are needed.
|
||||
|
||||
#### 27. What does the message "Placeholder node does not have an input port, but input port was provided" mean? <a name="question-27"></a>
|
||||
#### 28. What does the message "Placeholder node does not have an input port, but input port was provided" mean? <a name="question-28"></a>
|
||||
|
||||
You might have specified a placeholder node with an input node, while the placeholder node does not have it in the model.
|
||||
You might have specified a placeholder node with an input node, while the placeholder node does not have it the model.
|
||||
|
||||
#### 28. What does the message "Port index is out of number of available input ports for node" mean? <a name="question-28"></a>
|
||||
#### 29. What does the message "Port index is out of number of available input ports for node" mean? <a name="question-29"></a>
|
||||
|
||||
This error occurs when an incorrect input port is specified with the `--input` command line argument. When using `--input`, you may optionally specify an input port in the form: `X:node_name`, where `X` is an integer index of the input port starting from 0 and `node_name` is the name of a node in the model. This error occurs when the specified input port `X` is not in the range 0..(n-1), where n is the number of input ports for the node. Specify a correct port index, or do not use it if it is not needed.
|
||||
This error occurs when an incorrect input port is specified with the `--input` command line argument. When using `--input`, you can optionally specify an input port in the form: `X:node_name`, where `X` is an integer index of the input port starting from 0 and `node_name` is the name of a node in the model. This error occurs when the specified input port `X` is not in the range 0..(n-1), where n is the number of input ports for the node. Please, specify a correct port index, or do not use it if it is not needed.
|
||||
|
||||
#### 29. What does the message "Node has more than 1 input and input shapes were provided. Try not to provide input shapes or specify input port with PORT:NODE notation, where PORT is an integer" mean? <a name="question-29"></a>
|
||||
#### 30. What does the message "Node has more than 1 input and input shapes were provided. Try not to provide input shapes or specify input port with PORT:NODE notation, where PORT is an integer" mean? <a name="question-30"></a>
|
||||
|
||||
This error occurs when an incorrect combination of the `--input` and `--input_shape` command line options is used. Using both `--input` and `--input_shape` is valid only if `--input` points to the `Placeholder` node, a node with one input port or `--input` has the form `PORT:NODE`, where `PORT` is an integer port index of input for node `NODE`. Otherwise, the combination of `--input` and `--input_shape` is incorrect.
|
||||
|
||||
#### 30. What does the message "Input port > 0 in --input is not supported if --input_shape is not provided. Node: NAME_OF_THE_NODE. Omit port index and all input ports will be replaced by placeholders. Or provide --input_shape" mean? <a name="question-30"></a>
|
||||
#### 31. What does the message "Input port > 0 in --input is not supported if --input_shape is not provided. Node: NAME_OF_THE_NODE. Omit port index and all input ports will be replaced by placeholders. Or provide --input_shape" mean? <a name="question-31"></a>
|
||||
|
||||
When using the `PORT:NODE` notation for the `--input` command line argument and `PORT` > 0, you should specify `--input_shape` for this input. This is a limitation of the current Model Optimizer implementation.
|
||||
|
||||
**NOTE**: It is no longer relevant message since the limitation on input port index for model truncation has been resolved.
|
||||
|
||||
#### 31. What does the message "No or multiple placeholders in the model, but only one shape is provided, cannot set it" mean? <a name="question-31"></a>
|
||||
#### 32. What does the message "No or multiple placeholders in the model, but only one shape is provided, cannot set it" mean? <a name="question-32"></a>
|
||||
|
||||
You might have provided only one shape for the placeholder, while there are none or multiple inputs in the model. Make sure that you have provided the correct data for placeholder nodes.
|
||||
Looks like you have provided only one shape for the placeholder, however there are no or multiple inputs in the model. Please, make sure that you have provided correct data for placeholder nodes.
|
||||
|
||||
#### 32. What does the message "The amount of input nodes for port is not equal to 1" mean? <a name="question-32"></a>
|
||||
#### 33. What does the message "The amount of input nodes for port is not equal to 1" mean? <a name="question-33"></a>
|
||||
|
||||
This error occurs when the `SubgraphMatch.single_input_node` function is used for an input port that supplies more than one node in a sub-graph. The `single_input_node` function can be used only for ports that has a single consumer inside the matching sub-graph. When multiple nodes are connected to the port, use the `input_nodes` function or `node_by_pattern` function instead of `single_input_node`. For more details, refer to the **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) guide.
|
||||
This error occurs when the `SubgraphMatch.single_input_node` function is used for an input port that supplies more than one node in a sub-graph. The `single_input_node` function can be used only for ports that has a single consumer inside the matching sub-graph. When multiple nodes are connected to the port, use the `input_nodes` function or `node_by_pattern` function instead of `single_input_node`. Please, refer to **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) documentation for more details.
|
||||
|
||||
#### 33. What does the message "Output node for port has already been specified" mean? <a name="question-33"></a>
|
||||
#### 34. What does the message "Output node for port has already been specified" mean? <a name="question-34"></a>
|
||||
|
||||
This error occurs when the `SubgraphMatch._add_output_node` function is called manually from user's extension code. This is an internal function, and you should not call it directly.
|
||||
|
||||
#### 34. What does the message "Unsupported match kind.... Match kinds "points" or "scope" are supported only" mean? <a name="question-34"></a>
|
||||
#### 35. What does the message "Unsupported match kind.... Match kinds "points" or "scope" are supported only" mean? <a name="question-35"></a>
|
||||
|
||||
While using configuration file to implement a TensorFlow front replacement extension, an incorrect match kind was used. Only `points` or `scope` match kinds are supported. For more details, refer to the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) guide.
|
||||
While using configuration file to implement a TensorFlow\* front replacement extension, an incorrect match kind was used. Only `points` or `scope` match kinds are supported. Please refer to [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) for more details.
|
||||
|
||||
#### 35. What does the message "Cannot write an event file for the TensorBoard to directory" mean? <a name="question-35"></a>
|
||||
#### 36. What does the message "Cannot write an event file for the TensorBoard to directory" mean? <a name="question-36"></a>
|
||||
|
||||
Model Optimizer tried to write an event file in the specified directory but failed to do that. That could happen when the specified directory does not exist or you do not have permissions to write in it.
|
||||
Model Optimizer tried to write an event file in the specified directory but failed to do that. That could happen because the specified directory does not exist or you do not have enough permissions to write in it.
|
||||
|
||||
#### 36. What does the message "There is no registered 'infer' function for node with op = .. . Please implement this function in the extensions" mean? <a name="question-36"></a>
|
||||
#### 37. What does the message "There is no registered 'infer' function for node with op = .. . Please implement this function in the extensions" mean? <a name="question-37"></a>
|
||||
|
||||
Most likely, you tried to extend Model Optimizer with a new primitive, but you did not specify an infer function. For more information on extensions, see the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md) guide.
|
||||
Most likely, you tried to extend Model Optimizer with a new primitive, but did not specify an infer function. For more information on extensions, see [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md).
|
||||
|
||||
#### 37. What does the message "Stopped shape/value propagation at node" mean? <a name="question-37"></a>
|
||||
#### 38. What does the message "Stopped shape/value propagation at node" mean? <a name="question-38"></a>
|
||||
|
||||
Model Optimizer cannot infer shapes or values for the specified node. It can happen because of the following reasons: a bug exists in the custom shape infer function, the node inputs have incorrect values/shapes, or the input shapes are incorrect.
|
||||
Model Optimizer cannot infer shapes or values for the specified node. It can happen because of a bug in the custom shape infer function, because the node inputs have incorrect values/shapes, or because the input shapes are incorrect.
|
||||
|
||||
#### 38. What does the message "The input with shape .. does not have the batch dimension" mean? <a name="question-38"></a>
|
||||
#### 39. What does the message "The input with shape .. does not have the batch dimension" mean? <a name="question-39"></a>
|
||||
|
||||
Batch dimension is the first dimension in the shape and it should be equal to 1 or undefined. In your case, it is not either equal to 1 or undefined, which is why the `-b` shortcut produces undefined and unspecified behavior. To resolve the issue, specify full shapes for each input with the `--input_shape` option. Run Model Optimizer with the `--help` option to learn more about the notation for input shapes.
|
||||
Batch dimension is the first dimension in the shape and it should be equal to 1 or undefined. In your case, it is not equal to either 1 or undefined, which is why the `-b` shortcut produces undefined and unspecified behavior. To resolve the issue, specify full shapes for each input with the `--input_shape` option. Run Model Optimizer with the `--help` option to learn more about the notation for input shapes.
|
||||
|
||||
#### 39. What does the message "Not all output shapes were inferred or fully defined for node" mean? <a name="question-39"></a>
|
||||
#### 40. What does the message "Not all output shapes were inferred or fully defined for node" mean? <a name="question-40"></a>
|
||||
|
||||
Most likely, the shape is not defined (partially or fully) for the specified node. You can use `--input_shape` with positive integers to override model input shapes.
|
||||
|
||||
#### 40. What does the message "Shape for tensor is not defined. Can not proceed" mean? <a name="question-40"></a>
|
||||
#### 41. What does the message "Shape for tensor is not defined. Can not proceed" mean? <a name="question-41"></a>
|
||||
|
||||
This error occurs when the `--input` command-line option is used to cut a model and `--input_shape` is not used to override shapes for a node, so a shape for the node cannot be inferred by Model Optimizer. You need to help Model Optimizer by specifying shapes with `--input_shape` for each node specified with the `--input` command-line option.
|
||||
This error occurs when the `--input` command line option is used to cut a model and `--input_shape` is not used to override shapes for a node and a shape for the node cannot be inferred by Model Optimizer. You need to help Model Optimizer and specify shapes with `--input_shape` for each node that is specified with the `--input` command line option.
|
||||
|
||||
#### 41. What does the message "Module TensorFlow was not found. Please install TensorFlow 1.2 or higher" mean? <a name="question-41"></a>
|
||||
#### 42. What does the message "Module TensorFlow was not found. Please install TensorFlow 1.2 or higher" mean? <a name="question-42"></a>
|
||||
|
||||
To convert TensorFlow models with Model Optimizer, TensorFlow 1.2 or newer must be installed. For more information on prerequisites, see the [Configuring Model Optimizer](../Deep_Learning_Model_Optimizer_DevGuide.md) guide.
|
||||
To convert TensorFlow\* models with Model Optimizer, TensorFlow 1.2 or newer must be installed. For more information on prerequisites, see [Configuring the Model Optimizer](../Deep_Learning_Model_Optimizer_DevGuide.md).
|
||||
|
||||
#### 42. What does the message "Cannot read the model file: it is incorrect TensorFlow model file or missing" mean? <a name="question-42"></a>
|
||||
#### 43. What does the message "Cannot read the model file: it is incorrect TensorFlow model file or missing" mean? <a name="question-43"></a>
|
||||
|
||||
The model file should contain a frozen TensorFlow graph in the text or binary format. Make sure that `--input_model_is_text` is provided for a model in the text format. By default, a model is interpreted as binary file.
|
||||
The model file should contain a frozen TensorFlow\* graph in the text or binary format. Make sure that `--input_model_is_text` is provided for a model in the text format. By default, a model is interpreted as binary file.
|
||||
|
||||
#### 43. What does the message "Cannot pre-process TensorFlow graph after reading from model file. File is corrupt or has unsupported format" mean? <a name="question-43"></a>
|
||||
#### 44. What does the message "Cannot pre-process TensorFlow graph after reading from model file. File is corrupt or has unsupported format" mean? <a name="question-44"></a>
|
||||
|
||||
Most likely, there is a problem with the specified file for the model. The file exists, but it has an invalid format or is corrupted.
|
||||
Most likely, there is a problem with the specified file for model. The file exists, but it has bad formatting or is corrupted.
|
||||
|
||||
#### 44. What does the message "Found custom layer. Model Optimizer does not support this layer. Please, register it in CustomLayersMapping.xml or implement extension" mean? <a name="question-44"></a>
|
||||
#### 45. What does the message "Found custom layer. Model Optimizer does not support this layer. Please, register it in CustomLayersMapping.xml or implement extension" mean? <a name="question-45"></a>
|
||||
|
||||
This means that the layer `{layer_name}` is not supported in Model Optimizer. You will find a list of all unsupported layers in the corresponding section. You should implement the extensions for this layer. See [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md) for more information.
|
||||
This means that the layer `{layer_name}` is not supported in the Model Optimizer. You can find a list of all unsupported layers in the corresponding section. You should implement the extensions for this layer ([OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md)).
|
||||
|
||||
#### 45. What does the message "Custom replacement configuration file does not exist" mean? <a name="question-45"></a>
|
||||
#### 46. What does the message "Custom replacement configuration file does not exist" mean? <a name="question-46"></a>
|
||||
|
||||
A path to the custom replacement configuration file was provided with the `--transformations_config` flag, but the file could not be found. Make sure the specified path is correct and the file exists.
|
||||
Path to the custom replacement configuration file was provided with the `--transformations_config` flag, but the file could not be found. Please, make sure that the specified path is correct and the file exists.
|
||||
|
||||
#### 46. What does the message "Extractors collection have case insensitive duplicates" mean? <a name="question-46"></a>
|
||||
#### 47. What does the message "Extractors collection have case insensitive duplicates" mean? <a name="question-47"></a>
|
||||
|
||||
When extending Model Optimizer with new primitives, keep in mind that their names are case-insensitive. Most likely, another operation with the same name is already defined. For more information, see the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md) guide.
|
||||
When extending Model Optimizer with new primitives keep in mind that their names are case insensitive. Most likely, another operation with the same name is already defined. For more information, see [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md).
|
||||
|
||||
#### 47. What does the message "Input model name is not in an expected format, cannot extract iteration number" mean? <a name="question-47"></a>
|
||||
#### 48. What does the message "Input model name is not in an expected format, cannot extract iteration number" mean? <a name="question-48"></a>
|
||||
|
||||
Model Optimizer cannot load an MXNet model in the specified file format. Make sure you use the `.json` or `.param` format.
|
||||
Model Optimizer can not load an MXNet\* model in the specified file format. Please, use the `.json` or `.param` format.
|
||||
|
||||
#### 48. What does the message "Cannot convert type of placeholder because not all of its outputs are 'Cast' to float operations" mean? <a name="question-48"></a>
|
||||
#### 49. What does the message "Cannot convert type of placeholder because not all of its outputs are 'Cast' to float operations" mean? <a name="question-49"></a>
|
||||
|
||||
There are models where `Placeholder` has the UINT8 type and the first operation after it is 'Cast', which casts the input to FP32. Model Optimizer detected that the `Placeholder` has the UINT8 type, but the next operation is not 'Cast' to float. Model Optimizer does not support such a case. Make sure you change the model to have `Placeholder` for FP32.
|
||||
There are models where `Placeholder` has the UINT8 type and the first operation after it is 'Cast', which casts the input to FP32. Model Optimizer detected that the `Placeholder` has the UINT8 type, but the next operation is not 'Cast' to float. Model Optimizer does not support such a case. Please, change the model to have placeholder FP32 data type.
|
||||
|
||||
#### 49. What does the message "Data type is unsupported" mean? <a name="question-49"></a>
|
||||
#### 50. What does the message "Data type is unsupported" mean? <a name="question-50"></a>
|
||||
|
||||
Model Optimizer cannot convert the model to the specified data type. Currently, FP16 and FP32 are supported. Make sure you specify the data type with the `--data_type` flag. The available values are: FP16, FP32, half, float.
|
||||
Model Optimizer cannot convert the model to the specified data type. Currently, FP16 and FP32 are supported. Please, specify the data type with the `--data_type` flag. The available values are: FP16, FP32, half, float.
|
||||
|
||||
#### 50. What does the message "No node with name ..." mean? <a name="question-50"></a>
|
||||
#### 51. What does the message "No node with name ..." mean? <a name="question-51"></a>
|
||||
|
||||
Model Optimizer tried to access a node that does not exist. This could happen if you have incorrectly specified placeholder, input or output node name.
|
||||
|
||||
#### 51. What does the message "Module MXNet was not found. Please install MXNet 1.0.0" mean? <a name="question-51"></a>
|
||||
#### 52. What does the message "Module mxnet was not found. Please install MXNet 1.0.0" mean? <a name="question-52"></a>
|
||||
|
||||
To convert MXNet models with Model Optimizer, Apache MXNet 1.0.0 must be installed. For more information about prerequisites, see the[Configuring Model Optimizer](../Deep_Learning_Model_Optimizer_DevGuide.md) guide.
|
||||
To convert MXNet\* models with Model Optimizer, MXNet 1.0.0 must be installed. For more information about prerequisites, see [Configuring the Model Optimizer](../Deep_Learning_Model_Optimizer_DevGuide.md).
|
||||
|
||||
#### 52. What does the message "The following error happened while loading MXNet model .." mean? <a name="question-52"></a>
|
||||
#### 53. What does the message "The following error happened while loading MXNet model .." mean? <a name="question-53"></a>
|
||||
|
||||
Most likely, there is a problem with loading of the MXNet model. Make sure the specified path is correct, the model exists and is not corrupted, and you have sufficient permissions to work with it.
|
||||
Most likely, there is a problem with loading of the MXNet\* model. Please, make sure that the specified path is correct, the model exists, it is not corrupted, and you have sufficient permissions to work with it.
|
||||
|
||||
#### 53. What does the message "The following error happened while processing input shapes: .." mean? <a name="question-53"></a>
|
||||
#### 54. What does the message "The following error happened while processing input shapes: .." mean? <a name="question-54"></a>
|
||||
|
||||
Make sure inputs are defined and have correct shapes. You can use `--input_shape` with positive integers to override model input shapes.
|
||||
Please, make sure that inputs are defined and have correct shapes. You can use `--input_shape` with positive integers to override model input shapes.
|
||||
|
||||
#### 54. What does the message "Attempt to register of custom name for the second time as class. Note that custom names are case-insensitive" mean? <a name="question-54"></a>
|
||||
#### 55. What does the message "Attempt to register of custom name for the second time as class. Note that custom names are case-insensitive" mean? <a name="question-55"></a>
|
||||
|
||||
When extending Model Optimizer with new primitives, keep in mind that their names are case-insensitive. Most likely, another operation with the same name is already defined. For more information, see the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md) guide.
|
||||
When extending Model Optimizer with new primitives keep in mind that their names are case insensitive. Most likely, another operation with the same name is already defined. For more information, see [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md).
|
||||
|
||||
#### 55. What does the message "Both --input_shape and --batch were provided. Please, provide only one of them" mean? <a name="question-55"></a>
|
||||
#### 56. What does the message "Both --input_shape and --batch were provided. Please, provide only one of them" mean? <a name="question-56"></a>
|
||||
|
||||
Specifying the batch and the input shapes at the same time is not supported. You must specify a desired batch as the first value of the input shape.
|
||||
You cannot specify the batch and the input shape at the same time. You should specify a desired batch as the first value of the input shape.
|
||||
|
||||
#### 56. What does the message "Input shape .. cannot be parsed" mean? <a name="question-56"></a>
|
||||
#### 57. What does the message "Input shape .. cannot be parsed" mean? <a name="question-57"></a>
|
||||
|
||||
The specified input shape cannot be parsed. Define it in one of the following ways:
|
||||
The specified input shape cannot be parsed. Please, define it in one of the following ways:
|
||||
|
||||
*
|
||||
```shell
|
||||
@@ -365,141 +365,141 @@ The specified input shape cannot be parsed. Define it in one of the following wa
|
||||
|
||||
Keep in mind that there is no space between and inside the brackets for input shapes.
|
||||
|
||||
#### 57. What does the message "Please provide input layer names for input layer shapes" mean? <a name="question-57"></a>
|
||||
#### 58. What does the message "Please provide input layer names for input layer shapes" mean? <a name="question-58"></a>
|
||||
|
||||
When specifying input shapes for several layers, you must provide names for inputs, whose shapes will be overwritten. For usage examples, see the [Converting a Caffe Model](convert_model/Convert_Model_From_Caffe.md). Additional information for `--input_shape` is in FAQ [#56](#question-56).
|
||||
When specifying input shapes for several layers, you must provide names for inputs, whose shapes will be overwritten. For usage examples, see [Converting a Caffe* Model](convert_model/Convert_Model_From_Caffe.md. Additional information for `--input_shape` is in FAQ [#57](#question-57).
|
||||
|
||||
#### 58. What does the message "Values cannot be parsed" mean? <a name="question-58"></a>
|
||||
#### 59. What does the message "Values cannot be parsed" mean? <a name="question-59"></a>
|
||||
|
||||
Mean values for the given parameter cannot be parsed. It should be a string with a list of mean values. For example, in '(1,2,3)', 1 stands for the RED channel, 2 for the GREEN channel, 3 for the BLUE channel.
|
||||
|
||||
#### 59. What does the message ".. channels are expected for given values" mean? <a name="question-59"></a>
|
||||
#### 60. What does the message ".. channels are expected for given values" mean? <a name="question-60"></a>
|
||||
|
||||
The number of channels and the number of given values for mean values do not match. The shape should be defined as '(R,G,B)' or '[R,G,B]'. The shape should not contain undefined dimensions (? or -1). The order of values is as follows: (value for a RED channel, value for a GREEN channel, value for a BLUE channel).
|
||||
|
||||
#### 60. What does the message "You should specify input for each mean value" mean? <a name="question-60"></a>
|
||||
#### 61. What does the message "You should specify input for each mean value" mean? <a name="question-61"></a>
|
||||
|
||||
Most likely, you didn't specify inputs using `--mean_values`. Specify inputs with the `--input` flag. For usage examples, refer to the FAQ [#62](#question-62).
|
||||
Most likely, you have not specified inputs using `--mean_values`. Please, specify inputs with the `--input` flag. For usage examples, please, refer to FAQ [#63](#question-63).
|
||||
|
||||
#### 61. What does the message "You should specify input for each scale value" mean? <a name="question-61"></a>
|
||||
#### 62. What does the message "You should specify input for each scale value" mean? <a name="question-62"></a>
|
||||
|
||||
Most likely, you didn't specify inputs using `--scale_values`. Specify inputs with the `--input` flag. For usage examples, refer to the FAQ [#63](#question-63).
|
||||
Most likely, you have not specified inputs using `--scale_values`. Please, specify inputs with the `--input` flag. For usage examples, please, refer to FAQ [#64](#question-64).
|
||||
|
||||
#### 62. What does the message "Number of inputs and mean values does not match" mean? <a name="question-62"></a>
|
||||
#### 63. What does the message "Number of inputs and mean values does not match" mean? <a name="question-63"></a>
|
||||
|
||||
The number of specified mean values and the number of inputs must be equal. For a usage example, refer to the [Converting a Caffe Model](convert_model/Convert_Model_From_Caffe.md) guide.
|
||||
The number of specified mean values and the number of inputs must be equal. Please, refer to [Converting a Caffe* Model](convert_model/Convert_Model_From_Caffe.md) for a usage example.
|
||||
|
||||
#### 63. What does the message "Number of inputs and scale values does not match" mean? <a name="question-63"></a>
|
||||
#### 64. What does the message "Number of inputs and scale values does not match" mean? <a name="question-64"></a>
|
||||
|
||||
The number of specified scale values and the number of inputs must be equal. For a usage example, refer to the [Converting a Caffe Model](convert_model/Convert_Model_From_Caffe.md) guide.
|
||||
The number of specified scale values and the number of inputs must be equal. Please, refer to [Converting a Caffe* Model](convert_model/Convert_Model_From_Caffe.md) for a usage example.
|
||||
|
||||
#### 64. What does the message "No class registered for match kind ... Supported match kinds are .. " mean? <a name="question-64"></a>
|
||||
#### 65. What does the message "No class registered for match kind ... Supported match kinds are .. " mean? <a name="question-65"></a>
|
||||
|
||||
A replacement defined in the configuration file for sub-graph replacement, using node names patterns or start/end nodes, has the `match_kind` attribute. The attribute may have only one of the values: `scope` or `points`. If a different value is provided, this error is displayed.
|
||||
A replacement defined in the configuration file for sub-graph replacement using node names patterns or start/end nodes has the `match_kind` attribute. The attribute may have only one of the values: `scope` or `points`. If a different value is provided, this error is displayed.
|
||||
|
||||
#### 65. What does the message "No instance(s) is(are) defined for the custom replacement" mean? <a name="question-65"></a>
|
||||
#### 66. What does the message "No instance(s) is(are) defined for the custom replacement" mean? <a name="question-66"></a>
|
||||
|
||||
A replacement defined in the configuration file for sub-graph replacement, using node names patterns or start/end nodes, has the `instances` attribute. This attribute is mandatory. This error will occur if the attribute is missing. For more details, refer to the **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) guide.
|
||||
A replacement defined in the configuration file for sub-graph replacement using node names patterns or start/end nodes has the `instances` attribute. This attribute is mandatory, and it causes this error if it is missing. Refer to documentation with a description of the sub-graph replacement feature.
|
||||
|
||||
#### 66. What does the message "The instance must be a single dictionary for the custom replacement with id .." mean? <a name="question-66"></a>
|
||||
#### 67. What does the message "The instance must be a single dictionary for the custom replacement with id .." mean? <a name="question-67"></a>
|
||||
|
||||
A replacement defined in the configuration file for sub-graph replacement, using start/end nodes, has the `instances` attribute. For this type of replacement, the instance must be defined with a dictionary with two keys `start_points` and `end_points`. Values for these keys are lists with the start and end node names, respectively. For more details, refer to the **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) guide.
|
||||
A replacement defined in the configuration file for sub-graph replacement using start/end nodes has the `instances` attribute. For this type of replacement, the instance must be defined with a dictionary with two keys `start_points` and `end_points`. Values for these keys are lists with the start and end node names, respectively. Refer to documentation with a description of the sub-graph replacement feature.
|
||||
|
||||
#### 67. What does the message "No instances are defined for replacement with id .. " mean? <a name="question-67"></a>
|
||||
#### 68. What does the message "No instances are defined for replacement with id .. " mean? <a name="question-68"></a>
|
||||
|
||||
A replacement for the specified id is not defined in the configuration file. For more information, refer to the FAQ [#65](#question-65).
|
||||
A replacement for the specified id is not defined in the configuration file. Please, refer to FAQ [#66](#question-66) for more information.
|
||||
|
||||
#### 68. What does the message "Custom replacements configuration file .. does not exist" mean? <a name="question-68"></a>
|
||||
#### 69. What does the message "Custom replacements configuration file .. does not exist" mean? <a name="question-69"></a>
|
||||
|
||||
The path to a custom replacement configuration file was provided with the `--transformations_config` flag, but it cannot be found. Make sure the specified path is correct and the file exists.
|
||||
Path to a custom replacement configuration file was provided with the `--transformations_config` flag, but it cannot be found. Please, make sure that the specified path is correct and the file exists.
|
||||
|
||||
#### 69. What does the message "Failed to parse custom replacements configuration file .." mean? <a name="question-69"></a>
|
||||
#### 70. What does the message "Failed to parse custom replacements configuration file .." mean? <a name="question-70"></a>
|
||||
|
||||
The file for custom replacement configuration provided with the `--transformations_config` flag cannot be parsed. In particular, it should have a valid JSON structure. For more details, refer to the [JSON Schema Reference](https://spacetelescope.github.io/understanding-json-schema/reference/index.html) page.
|
||||
The file for custom replacement configuration provided with the `--transformations_config` flag cannot be parsed. In particular, it should have a valid JSON structure. For more details, refer to [JSON Schema Reference](https://spacetelescope.github.io/understanding-json-schema/reference/index.html).
|
||||
|
||||
#### 70. What does the message "One of the custom replacements in the configuration file .. does not contain attribute 'id'" mean? <a name="question-70"></a>
|
||||
#### 71. What does the message "One of the custom replacements in the configuration file .. does not contain attribute 'id'" mean? <a name="question-71"></a>
|
||||
|
||||
Every custom replacement should declare a set of mandatory attributes and their values. For more details, refer to FAQ [#71](#question-71).
|
||||
Every custom replacement should declare a set of mandatory attributes and their values. For more details, refer to FAQ [#72](#question-72).
|
||||
|
||||
#### 71. What does the message "File .. validation failed" mean? <a name="question-71"></a>
|
||||
#### 72. What does the message "File .. validation failed" mean? <a name="question-72"></a>
|
||||
|
||||
The file for custom replacement configuration provided with the `--transformations_config` flag cannot pass validation. Make sure you have specified `id`, `instances`, and `match_kind` for all the patterns.
|
||||
The file for custom replacement configuration provided with the `--transformations_config` flag cannot pass validation. Make sure that you have specified `id`, `instances` and `match_kind` for all the patterns.
|
||||
|
||||
#### 72. What does the message "Cannot update the file .. because it is broken" mean? <a name="question-72"></a>
|
||||
#### 73. What does the message "Cannot update the file .. because it is broken" mean? <a name="question-73"></a>
|
||||
|
||||
The custom replacement configuration file provided with the `--tensorflow_custom_operations_config_update` cannot be parsed. Make sure that the file is correct and refer to FAQ [#68](#question-68), [#69](#question-69), [#70](#question-70), and [#71](#question-71).
|
||||
The custom replacement configuration file provided with the `--tensorflow_custom_operations_config_update` cannot be parsed. Please, make sure that the file is correct and refer to FAQs [#69](#question-69), [#70](#question-70), [#71](#question-71), and [#72](#question-72).
|
||||
|
||||
#### 73. What does the message "End node .. is not reachable from start nodes: .." mean? <a name="question-73"></a>
|
||||
#### 74. What does the message "End node .. is not reachable from start nodes: .." mean? <a name="question-74"></a>
|
||||
|
||||
This error occurs when you try to make a sub-graph match. It is detected that between the start and end nodes that were specified as inputs/outputs for the subgraph to find, there are nodes marked as outputs but there is no path from them to the input nodes. Make sure the subgraph you want to match does actually contain all the specified output nodes.
|
||||
This error occurs when you try to make a sub-graph match. It is detected that between the start and end nodes that were specified as inputs/outputs of the subgraph to find, there are nodes that are marked as outputs but there is no path from them to the input nodes. Make sure that the subgraph you want to match does actually contain all the specified output nodes.
|
||||
|
||||
#### 74. What does the message "Sub-graph contains network input node .." mean? <a name="question-74"></a>
|
||||
#### 75. What does the message "Sub-graph contains network input node .." mean? <a name="question-75"></a>
|
||||
|
||||
The start or end node for the sub-graph replacement using start/end nodes is specified incorrectly. Model Optimizer finds internal nodes of the sub-graph strictly "between" the start and end nodes, and then adds all input nodes to the sub-graph (and the inputs of their inputs, etc.) for these "internal" nodes. This error reports that Model Optimizer reached input node during this phase. This means that the start/end points are specified incorrectly in the configuration file. For more details, refer to the **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) guide.
|
||||
Start or end node for the sub-graph replacement using start/end nodes is specified incorrectly. Model Optimizer finds internal nodes of the sub-graph strictly "between" the start and end nodes. Then it adds all input nodes to the sub-graph (and inputs of their inputs and so on) for these "internal" nodes. The error reports, that the Model Optimizer reached input node during this phase. This means that the start/end points are specified incorrectly in the configuration file. Refer to documentation with a description of the sub-graph replacement feature.
|
||||
|
||||
#### 75. What does the message "... elements of ... were clipped to infinity while converting a blob for node [...] to ..." mean? <a name="question-75"></a>
|
||||
#### 76. What does the message "... elements of ... were clipped to infinity while converting a blob for node [...] to ..." mean? <a name="question-76"></a>
|
||||
|
||||
This message may appear when the `--data_type=FP16` command-line option is used. This option implies conversion of all the blobs in the node to FP16. If a value in a blob is out of the range of valid FP16 values, the value is converted to positive or negative infinity. It may lead to incorrect results of inference or may not be a problem, depending on the model. The number of such elements and the total number of elements in the blob is printed out together with the name of the node, where this blob is used.
|
||||
This message may appear when the `--data_type=FP16` command line option is used. This option implies conversion of all the blobs in the node to FP16. If a value in a blob is out of the range of valid FP16 values, the value is converted to positive or negative infinity. It may lead to incorrect results of inference or may not be a problem, depending on the model. The number of such elements and the total number of elements in the blob is printed out together with the name of the node, where this blob is used.
|
||||
|
||||
#### 76. What does the message "... elements of ... were clipped to zero while converting a blob for node [...] to ..." mean? <a name="question-76"></a>
|
||||
#### 77. What does the message "... elements of ... were clipped to zero while converting a blob for node [...] to ..." mean? <a name="question-77"></a>
|
||||
|
||||
This message may appear when the `--data_type=FP16` command-line option is used. This option implies conversion of all blobs in the mode to FP16. If a value in the blob is so close to zero that it cannot be represented as a valid FP16 value, it is converted to a true zero FP16 value. Depending on the model, it may lead to incorrect results of inference or may not be a problem. The number of such elements and the total number of elements in the blob are printed out together with a name of the node, where this blob is used.
|
||||
This message may appear when the `--data_type=FP16` command line option is used. This option implies conversion of all blobs in the mode to FP16. If a value in the blob is so close to zero that it cannot be represented as a valid FP16 value, it is converted to a true zero FP16 value. Depending on the model, it may lead to incorrect results of inference or may not be a problem. The number of such elements and the total number of elements in the blob are printed out together with a name of the node, where this blob is used.
|
||||
|
||||
#### 77. What does the message "The amount of nodes matched pattern ... is not equal to 1" mean? <a name="question-77"></a>
|
||||
#### 78. What does the message "The amount of nodes matched pattern ... is not equal to 1" mean? <a name="question-78"></a>
|
||||
|
||||
This error occurs when the `SubgraphMatch.node_by_pattern` function is used with a pattern that does not uniquely identify a single node in a sub-graph. Try to extend the pattern string to make unambiguous match to a single sub-graph node. For more details, refer to the **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) guide.
|
||||
This error occurs when the `SubgraphMatch.node_by_pattern` function is used with a pattern that does not uniquely identify a single node in a sub-graph. Try to extend the pattern string to make unambiguous match to a single sub-graph node. For more details, refer to **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](customize_model_optimizer/Customize_Model_Optimizer.md) documentation.
|
||||
|
||||
#### 78. What does the message "The topology contains no "input" layers" mean? <a name="question-78"></a>
|
||||
#### 79. What does the message "The topology contains no "input" layers" mean? <a name="question-79"></a>
|
||||
|
||||
Your Caffe topology `.prototxt` file is intended for training. Model Optimizer expects a deployment-ready `.prototxt` file. To fix the problem, prepare a deployment-ready `.prototxt` file. Preparation of a deploy-ready topology usually results in removing `data` layer(s), adding `input` layer(s), and removing loss layer(s).
|
||||
Your Caffe\* topology `.prototxt` file is intended for training. Model Optimizer expects a deployment-ready `.prototxt` file. To fix the problem, prepare a deployment-ready `.prototxt` file. Usually, preparation of a deploy-ready topology results in removing `data` layer(s), adding `input` layer(s), and removing loss layer(s).
|
||||
|
||||
#### 79. What does the message "Warning: please expect that Model Optimizer conversion might be slow" mean? <a name="question-79"></a>
|
||||
#### 80. What does the message "Warning: please expect that Model Optimizer conversion might be slow" mean? <a name="question-80"></a>
|
||||
|
||||
You are using an unsupported Python version. Use only versions 3.4 - 3.6 for the C++ `protobuf` implementation that is supplied with OpenVINO toolkit. You can still boost the conversion speed by building the protobuf library from sources. For complete instructions about building `protobuf` from sources, see the appropriate section in the[Converting a Model to Intermediate Representation](../Deep_Learning_Model_Optimizer_DevGuide.md) guide.
|
||||
You are using an unsupported Python\* version. Use only versions 3.4 - 3.6 for the C++ `protobuf` implementation that is supplied with the OpenVINO Toolkit. You can still boost conversion speed by building protobuf library from sources. For complete instructions about building `protobuf` from sources, see the appropriate section in [Converting a Model to Intermediate Representation](../Deep_Learning_Model_Optimizer_DevGuide.md).
|
||||
|
||||
#### 80. What does the message "Arguments --nd_prefix_name, --pretrained_model_name and --input_symbol should be provided. Please provide all or do not use any." mean? <a name="question-80"></a>
|
||||
#### 81. What does the message "Arguments --nd_prefix_name, --pretrained_model_name and --input_symbol should be provided. Please provide all or do not use any." mean? <a name="question-81"></a>
|
||||
|
||||
This error occurs if you did not provide the `--nd_prefix_name`, `--pretrained_model_name`, and `--input_symbol` parameters.
|
||||
Model Optimizer requires both `.params` and `.nd` model files to merge into the result file (`.params`).
|
||||
Topology description (`.json` file) should be prepared (merged) in advance and provided with the `--input_symbol` parameter.
|
||||
This error occurs if you do not provide `--nd_prefix_name`, `--pretrained_model_name` and `--input_symbol` parameters.
|
||||
Model Optimizer requires both `.params` and `.nd` model files to merge into the result file (`.params`). Topology
|
||||
description (`.json` file) should be prepared (merged) in advance and provided with `--input_symbol` parameter.
|
||||
|
||||
If you add additional layers and weights that are in `.nd` files to your model, Model Optimizer can build a model
|
||||
If you add to your model additional layers and weights that are in `.nd` files, the Model Optimizer can build a model
|
||||
from one `.params` file and two additional `.nd` files (`*_args.nd`, `*_auxs.nd`).
|
||||
To do that, provide both CLI options or do not pass them if you want to convert an MXNet model without additional weights.
|
||||
For more information, refer to the [Converting an MXNet Model](convert_model/Convert_Model_From_MxNet.md) guide.
|
||||
For more information, refer to [Converting a MXNet* Model](convert_model/Convert_Model_From_MxNet.md).
|
||||
|
||||
#### 81. What does the message "You should specify input for mean/scale values" mean? <a name="question-81"></a>
|
||||
#### 82. What does the message "You should specify input for mean/scale values" mean? <a name="question-82"></a>
|
||||
|
||||
When the model has multiple inputs and you want to provide mean/scale values, you need to pass those values for each input. More specifically, the number of passed values should be the same as the number of inputs of the model.
|
||||
For more information, refer to the [Converting a Model to Intermediate Representation](convert_model/Converting_Model.md) guide.
|
||||
In case when the model has multiple inputs and you want to provide mean/scale values, you need to pass those values for each input. More specifically, a number of passed values should be the same as the number of inputs of the model.
|
||||
For more information, refer to [Converting a Model to Intermediate Representation](convert_model/Converting_Model.md).
|
||||
|
||||
#### 82. What does the message "Input with name ... not found!" mean? <a name="question-82"></a>
|
||||
#### 83. What does the message "Input with name ... not found!" mean? <a name="question-83"></a>
|
||||
|
||||
When you passed the mean/scale values and specify names of input layers of the model, you might have used the name that does not correspond to any input layer. Make sure that you list only names of the input layers of your model when passing values with the `--input` option.
|
||||
For more information, refer to the [Converting a Model to Intermediate Representation](convert_model/Converting_Model.md) guide.
|
||||
When you passed the mean/scale values and specify names of input layers of the model, you might have used the name that does not correspond to any input layer. Make sure that by passing values with `--input` option, you list only names of the input layers of your model.
|
||||
For more information, refer to the [Converting a Model to Intermediate Representation](convert_model/Converting_Model.md).
|
||||
|
||||
#### 83. What does the message "Specified input json ... does not exist" mean? <a name="question-83"></a>
|
||||
#### 84. What does the message "Specified input json ... does not exist" mean? <a name="question-84"></a>
|
||||
|
||||
Most likely, `.json` file does not exist or has a name that does not match the notation of Apache MXNet. Make sure the file exists and has a correct name.
|
||||
For more information, refer to the [Converting an MXNet Model](convert_model/Convert_Model_From_MxNet.md) guide.
|
||||
Most likely, `.json` file does not exist or has a name that does not match the notation of MXNet. Make sure that the file exists and it has a correct name.
|
||||
For more information, refer to [Converting a MXNet\* Model](convert_model/Convert_Model_From_MxNet.md).
|
||||
|
||||
#### 84. What does the message "Unsupported Input model file type ... Model Optimizer support only .params and .nd files format" mean? <a name="question-84"></a>
|
||||
#### 85. What does the message "Unsupported Input model file type ... Model Optimizer support only .params and .nd files format" mean? <a name="question-85"></a>
|
||||
|
||||
Model Optimizer for Apache MXNet supports only `.params` and `.nd` files formats. Most likely, you specified an unsupported file format in `--input_model`.
|
||||
For more information, refer to [Converting an MXNet Model](convert_model/Convert_Model_From_MxNet.md).
|
||||
Model Optimizer for MXNet supports only `.params` and `.nd` files formats. Most likely, you specified some unsupported file format in `--input_model`.
|
||||
For more information, refer to [Converting a MXNet* Model](convert_model/Convert_Model_From_MxNet.md).
|
||||
|
||||
#### 85. What does the message "Operation ... not supported. Please register it as custom op" mean? <a name="question-85"></a>
|
||||
#### 86. What does the message "Operation ... not supported. Please register it as custom op" mean? <a name="question-86"></a>
|
||||
|
||||
Model Optimizer tried to load the model that contains some unsupported operations.
|
||||
If you want to convert model that contains unsupported operations, you need to prepare extension for all such operations.
|
||||
For more information, refer to the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md) guide.
|
||||
If you want to convert model that contains unsupported operations you need to prepare extension for all such operations.
|
||||
For more information, refer to [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md).
|
||||
|
||||
#### 86. What does the message "Can not register Op ... Please, call function 'register_caffe_python_extractor' with parameter 'name'" mean? <a name="question-86"></a>
|
||||
#### 87. What does the message "Can not register Op ... Please, call function 'register_caffe_python_extractor' with parameter 'name'" mean? <a name="question-87"></a>
|
||||
|
||||
This error appears if the class of implementation of `Op` for Python Caffe layer could not be used by Model Optimizer. Python layers should be handled differently comparing to ordinary Caffe layers.
|
||||
This error appears if the class of implementation of op for Python Caffe layer could not be used by Model Optimizer. Python layers should be handled differently compared to ordinary Caffe layers.
|
||||
|
||||
In particular, you need to call the function `register_caffe_python_extractor` and pass `name` as the second argument of the function.
|
||||
The name should be the compilation of the layer name with the module name separated by a dot.
|
||||
The name should be the compilation of the layer name and the module name separated by a dot.
|
||||
|
||||
For example, your topology contains this layer with type `Python`:
|
||||
|
||||
@@ -516,7 +516,7 @@ layer {
|
||||
}
|
||||
```
|
||||
|
||||
The first step is to implement an extension for this layer in Model Optimizer as an ancestor of `Op` class:
|
||||
What you do first is implementing an extension for this layer in the Model Optimizer as an ancestor of `Op` class.
|
||||
```
|
||||
class ProposalPythonExampleOp(Op):
|
||||
op = 'Proposal'
|
||||
@@ -534,48 +534,48 @@ register_caffe_python_extractor(ProposalPythonExampleOp, 'rpn.proposal_layer.Pro
|
||||
Op.excluded_classes.append(ProposalPythonExampleOp)
|
||||
```
|
||||
|
||||
Note that the first call <code>register_caffe_python_extractor(ProposalPythonExampleOp, 'rpn.proposal_layer.ProposalLayer')</code> registers an extension of the layer in Model Optimizer, which will be found by the specific name (mandatory to join module name and layer name): <code>rpn.proposal_layer.ProposalLayer</code>.
|
||||
Note that the first call <code>register_caffe_python_extractor(ProposalPythonExampleOp, 'rpn.proposal_layer.ProposalLayer')</code> registers extension of the layer in the Model Optimizer that will be found by the specific name (mandatory to join module name and layer name): <code>rpn.proposal_layer.ProposalLayer</code>.
|
||||
|
||||
The second call prevents Model Optimizer from using this extension as if it is an extension for
|
||||
a layer with type `Proposal`. Otherwise, this layer can be chosen as an implementation of extension that can lead to potential issues.
|
||||
For more information, refer to the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md) guide.
|
||||
For more information, refer to the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md).
|
||||
|
||||
#### 87. What does the message "Model Optimizer is unable to calculate output shape of Memory node .." mean? <a name="question-87"></a>
|
||||
#### 88. What does the message "Model Optimizer is unable to calculate output shape of Memory node .." mean? <a name="question-88"></a>
|
||||
|
||||
Model Optimizer supports only `Memory` layers, in which `input_memory` goes before `ScaleShift` or the `FullyConnected` layer.
|
||||
This error message means that in your model the layer after input memory is not of the `ScaleShift` or `FullyConnected` type.
|
||||
Model Optimizer supports only `Memory` layers, in which `input_memory` goes before `ScaleShift` or `FullyConnected` layer.
|
||||
This error message means that in your model the layer after input memory is not of type `ScaleShift` or `FullyConnected`.
|
||||
This is a known limitation.
|
||||
|
||||
#### 88. What do the messages "File ... does not appear to be a Kaldi file (magic number does not match)", "Kaldi model should start with <Nnet> tag" mean? <a name="question-88"></a>
|
||||
#### 89. What do the messages "File ... does not appear to be a Kaldi file (magic number does not match)", "Kaldi model should start with <Nnet> tag" mean? <a name="question-89"></a>
|
||||
|
||||
These error messages mean that Model Optimizer does not support your Kaldi model, because the `checksum` of the model is not
|
||||
16896 (the model should start with this number), or the model file does not contain the `<Net>` tag as a starting one.
|
||||
Make sure that you provide a path to a true Kaldi model and try again.
|
||||
These error messages mean that the Model Optimizer does not support your Kaldi\* model, because check sum of the model is not
|
||||
16896 (the model should start with this number) or model file does not contain tag `<Net>` as a starting one.
|
||||
Double check that you provide a path to a true Kaldi model and try again.
|
||||
|
||||
#### 89. What do the messages "Expect counts file to be one-line file." or "Expect counts file to contain list of integers" mean? <a name="question-89"></a>
|
||||
#### 90. What do the messages "Expect counts file to be one-line file." or "Expect counts file to contain list of integers" mean? <a name="question-90"></a>
|
||||
|
||||
These messages mean that the file counts you passed contain not one line. The count file should start with
|
||||
`[` and end with `]`, and integer values should be separated by spaces between those brackets.
|
||||
These messages mean that you passed the file counts containing not one line. The count file should start with
|
||||
`[` and end with `]`, and integer values should be separated by space between those signs.
|
||||
|
||||
#### 90. What does the message "Model Optimizer is not able to read Kaldi model .." mean? <a name="question-90"></a>
|
||||
#### 91. What does the message "Model Optimizer is not able to read Kaldi model .." mean? <a name="question-91"></a>
|
||||
|
||||
There are multiple reasons why Model Optimizer does not accept a Kaldi topology, including:
|
||||
the file is not available or does not exist. Refer to FAQ [#88](#question-88).
|
||||
There are multiple reasons why the Model Optimizer does not accept a Kaldi topology:
|
||||
file is not available or does not exist. Refer to FAQ [#89](#question-89).
|
||||
|
||||
#### 91. What does the message "Model Optimizer is not able to read counts file .." mean? <a name="question-91"></a>
|
||||
#### 92. What does the message "Model Optimizer is not able to read counts file .." mean? <a name="question-92"></a>
|
||||
|
||||
There are multiple reasons why Model Optimizer does not accept a counts file, including:
|
||||
the file is not available or does not exist. Refer to FAQ [#89](#question-89).
|
||||
There are multiple reasons why the Model Optimizer does not accept a counts file:
|
||||
file is not available or does not exist. Also refer to FAQ [#90](#question-90).
|
||||
|
||||
#### 92. What does the message "For legacy MXNet models Model Optimizer does not support conversion of old MXNet models (trained with 1.0.0 version of MXNet and lower) with custom layers." mean? <a name="question-92"></a>
|
||||
#### 93. What does the message "For legacy MXNet models Model Optimizer does not support conversion of old MXNet models (trained with 1.0.0 version of MXNet and lower) with custom layers." mean? <a name="question-93"></a>
|
||||
|
||||
This message means that if you have a model with custom layers and its JSON file has been generated with Apache MXNet version
|
||||
lower than 1.0.0, Model Optimizer does not support such topologies. If you want to convert it, you have to rebuild
|
||||
MXNet with unsupported layers or generate a new JSON file with Apache MXNet version 1.0.0 or higher. You also need to implement
|
||||
OpenVINO extension to use custom layers.
|
||||
For more information, refer to the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md) guide.
|
||||
This message means that if you have model with custom layers and its json file has been generated with MXNet version
|
||||
lower than 1.0.0, Model Optimizer does not support such topologies. If you want to convert it you have to rebuild
|
||||
MXNet with unsupported layers or generate new json with MXNet version 1.0.0 and higher. Also you need to implement
|
||||
OpenVINO extension for used custom layers.
|
||||
For more information, refer to the [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md).
|
||||
|
||||
#### 93. What does the message "Graph contains a cycle. Can not proceed .." mean? <a name="question-93"></a>
|
||||
#### 97. What does the message "Graph contains a cycle. Can not proceed .." mean? <a name="question-97"></a>
|
||||
|
||||
Model Optimizer supports only straightforward models without cycles.
|
||||
|
||||
@@ -586,56 +586,56 @@ For Tensorflow:
|
||||
|
||||
For all frameworks:
|
||||
1. [Replace cycle containing Sub-graph in Model Optimizer](customize_model_optimizer/Customize_Model_Optimizer.md)
|
||||
2. See [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md)
|
||||
2. [OpenVINO™ Extensibility Mechanism](../../Extensibility_UG/Intro.md)
|
||||
|
||||
or
|
||||
* Edit the model in its original framework to exclude cycle.
|
||||
* Edit model in original framework to exclude cycle.
|
||||
|
||||
#### 94. What does the message "Can not transpose attribute '..' with value .. for node '..' .." mean? <a name="question-94"></a>
|
||||
#### 98. What does the message "Can not transpose attribute '..' with value .. for node '..' .." mean? <a name="question-98"></a>
|
||||
|
||||
This message means that the model is not supported. It may be caused by using shapes larger than 4-D.
|
||||
This message means that model is not supported. It may be caused by using shapes larger than 4-D.
|
||||
There are two ways to avoid such message:
|
||||
|
||||
* [Cut off parts of the model](convert_model/Cutting_Model.md).
|
||||
* Edit the network in its original framework to exclude such layers.
|
||||
1. [Cutting Off Parts of a Model](convert_model/Cutting_Model.md)
|
||||
2. Edit network in original framework to exclude such layers.
|
||||
|
||||
#### 95. What does the message "Expected token `</ParallelComponent>`, has `...`" mean? <a name="question-95"></a>
|
||||
#### 99. What does the message "Expected token `</ParallelComponent>`, has `...`" mean? <a name="question-99"></a>
|
||||
|
||||
This error messages mean that Model Optimizer does not support your Kaldi model, because the Net contains `ParallelComponent` that does not end with the `</ParallelComponent>` tag.
|
||||
Make sure that you provide a path to a true Kaldi model and try again.
|
||||
This error messages mean that Model Optimizer does not support your Kaldi model, because the Net contains `ParallelComponent` that does not end by tag `</ParallelComponent>`.
|
||||
Double check that you provide a path to a true Kaldi model and try again.
|
||||
|
||||
#### 96. What does the message "Interp layer shape inference function may be wrong, please, try to update layer shape inference function in the file (extensions/ops/interp.op at the line ...)." mean? <a name="question-96"></a>
|
||||
#### 100. What does the message "Interp layer shape inference function may be wrong, please, try to update layer shape inference function in the file (extensions/ops/interp.op at the line ...)." mean? <a name="question-100"></a>
|
||||
|
||||
There are many flavors of Caffe framework, and most layers in them are implemented identically.
|
||||
However, there are exceptions. For example, the output value of layer Interp is calculated differently in Deeplab-Caffe and classic Caffe. Therefore, if your model contains layer Interp and the conversion of your model has failed, modify the `interp_infer` function in the `extensions/ops/interp.op` file according to the comments in the file.
|
||||
But there are exceptions. For example, output value of layer Interp is calculated differently in Deeplab-Caffe and classic Caffe. So if your model contain layer Interp and converting of your model has failed, please modify the 'interp_infer' function in the file extensions/ops/interp.op according to the comments of the file.
|
||||
|
||||
#### 97. What does the message "Mean/scale values should ..." mean? <a name="question-97"></a>
|
||||
#### 101. What does the message "Mean/scale values should ..." mean? <a name="question-101"></a>
|
||||
|
||||
It means that your mean/scale values have a wrong format. Specify mean/scale values in the form of `layer_name(val1,val2,val3)`.
|
||||
You need to specify values for each input of the model. For more information, refer to the [Converting a Model to Intermediate Representation](convert_model/Converting_Model.md) guide.
|
||||
It means that your mean/scale values have wrong format. Specify mean/scale values using the form `layer_name(val1,val2,val3)`.
|
||||
You need to specify values for each input of the model. For more information, refer to [Converting a Model to Intermediate Representation](convert_model/Converting_Model.md).
|
||||
|
||||
#### 98. What does the message "Operation _contrib_box_nms is not supported ..." mean? <a name="question-98"></a>
|
||||
#### 102. What does the message "Operation _contrib_box_nms is not supported ..." mean? <a name="question-102"></a>
|
||||
|
||||
It means that you are trying to convert a topology contains the `_contrib_box_nms` operation which is not supported directly. However, the sub-graph of operations including `_contrib_box_nms` could be replaced with the DetectionOutput layer if your topology is one of the `gluoncv` topologies. Specify the `--enable_ssd_gluoncv` command-line parameter for Model Optimizer to enable this transformation.
|
||||
It means that you trying to convert the topology which contains '_contrib_box_nms' operation which is not supported directly. However the sub-graph of operations including the '_contrib_box_nms' could be replaced with DetectionOutput layer if your topology is one of the gluoncv topologies. Specify '--enable_ssd_gluoncv' command line parameter for the Model Optimizer to enable this transformation.
|
||||
|
||||
#### 99. What does the message "ModelOptimizer is not able to parse *.caffemodel" mean? <a name="question-99"></a>
|
||||
#### 103. What does the message "ModelOptimizer is not able to parse *.caffemodel" mean? <a name="question-103"></a>
|
||||
|
||||
If a `*.caffemodel` file exists and is correct, the error occurred possibly because of the use of Python protobuf implementation. In some cases, error messages may appear during model parsing, for example: "`utf-8` codec can't decode byte 0xe0 in position 4: invalid continuation byte in field: mo_caffe.SpatialTransformerParameter.transform_type". You can either use Python 3.6/3.7 or build the `cpp` implementation of `protobuf` yourself for your version of Python. For the complete instructions about building `protobuf` from sources, see the appropriate section in the [Converting Models with Model Optimizer](../Deep_Learning_Model_Optimizer_DevGuide.md) guide.
|
||||
If a '*.caffemodel' file exists and it is correct, the error possibly occured due to the use of Python protobuf implementation. In some cases, it shows error message during model parsing, for example: "'utf-8' codec can't decode byte 0xe0 in position 4: invalid continuation byte in field: mo_caffe.SpatialTransformerParameter.transform_type". You can either use Python 3.6/3.7 or build 'cpp' implementation of protobuf yourself for your version of Python. For the complete instructions about building `protobuf` from sources, see the appropriate section in [Converting a Model to Intermediate Representation](../Deep_Learning_Model_Optimizer_DevGuide.md).
|
||||
|
||||
#### 100. What does the message "SyntaxError: 'yield' inside list comprehension" during MxNet model conversion mean? <a name="question-100"></a>
|
||||
#### 104. What does the message "SyntaxError: 'yield' inside list comprehension" during MxNet\* model conversion mean? <a name="question-104"></a>
|
||||
|
||||
The issue "SyntaxError: `yield` inside list comprehension" might occur during converting MXNet models (`mobilefacedet-v1-mxnet`, `brain-tumor-segmentation-0001`) on Windows platform with Python 3.8 environment. This issue is caused by the API changes for `yield expression` in Python 3.8.
|
||||
The issue "SyntaxError: 'yield' inside list comprehension" might occur during converting MXNet\* models (mobilefacedet-v1-mxnet, brain-tumor-segmentation-0001) on Windows* platform with Python* 3.8 environment. This issue is caused by API changes for `yield expression` in Python 3.8.
|
||||
The following workarounds are suggested to resolve this issue:
|
||||
1. Use Python 3.6/3.7 to convert MXNet models on Windows
|
||||
2. Update Apache MXNet by using `pip install mxnet==1.7.0.post2`
|
||||
Note that it might have conflicts with previously installed PyPI dependencies.
|
||||
1. Use Python 3.6/3.7 to convert MXNet\* models on Windows
|
||||
2. Update MXNet: pip install mxnet=1.7.0.post2
|
||||
Note that you might have conflicts between previously installed PyPI dependencies.
|
||||
|
||||
#### 101. What does the message "The IR preparation was executed by the legacy MO path. ..." mean? <a name="question-101"></a>
|
||||
#### 105. What does the message "The IR preparation was executed by the legacy MO path. ..." mean? <a name="question-105"></a>
|
||||
|
||||
For the models in ONNX format, there are two available paths of IR conversion.
|
||||
The old one is handled by the old Python implementation, while the new one uses new C++ frontends.
|
||||
For the models in ONNX* format, there are two available paths of IR conversion.
|
||||
The old one is handled by the old Python* implementation, while the new one uses new C++ frontends.
|
||||
Starting from the 2022.1 version, the default IR conversion path for ONNX models is processed using the new ONNX frontend.
|
||||
Certain features, such as `--extensions` and `--transformations_config`, are not yet fully supported on the new frontends.
|
||||
The new frontends support only paths to shared libraries (.dll and .so) for `--extensions`. They support JSON configurations with defined library fields for `--transformations_config`.
|
||||
Inputs freezing (enabled by `--freeze_placeholder_with_value` or `--input` arguments) is not supported by the new frontends.
|
||||
The IR conversion falls back to the old path if a user does not select any expected path of conversion explicitly (with `--use_new_frontend` or `--use_legacy_frontend` MO arguments) and unsupported pre-defined scenario is detected on the new frontend path.
|
||||
For `--extensions`, the new frontends support only paths to shared libraries (.dll and .so). For `--transformations_config`, they support JSON configurations with defined library fields.
|
||||
Inputs freezing (enabled by `--freeze_placeholder_with_value` or `--input` arguments) is not supported on the new frontends.
|
||||
The IR conversion falls back to the old path if a user does not select any expected path of conversion explicitly (by `--use_new_frontend` or `--use_legacy_frontend` MO arguments) and unsupported pre-defined scenario is detected on the new frontend path.
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# Supported Framework Layers {#openvino_docs_MO_DG_prepare_model_Supported_Frameworks_Layers}
|
||||
|
||||
|
||||
In this article, you can find lists of supported framework layers, divided by frameworks.
|
||||
|
||||
## Caffe Supported Layers
|
||||
|
||||
|
||||
@@ -19,7 +16,7 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
| Crop | |
|
||||
| Deconvolution | |
|
||||
| DetectionOutput | |
|
||||
| Dropout | Not needed for inference. |
|
||||
| Dropout | Not needed for inference |
|
||||
| Eltwise | |
|
||||
| Flatten | |
|
||||
| GlobalInput | |
|
||||
@@ -27,7 +24,7 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
| Input | |
|
||||
| LRN | |
|
||||
| Normalize | |
|
||||
| Python | Supported only for the Python Proposal operation. |
|
||||
| Python | Supported only for the Python Proposal operation |
|
||||
| Permute | |
|
||||
| Pooling | |
|
||||
| Power | |
|
||||
@@ -50,10 +47,10 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
| Tile | |
|
||||
|
||||
|
||||
## Apache MXNet Supported Symbols
|
||||
## MXNet Supported Symbols
|
||||
|
||||
|
||||
| Symbol Name in Apache MXNet| Limitations|
|
||||
| Symbol Name in MXNet| Limitations|
|
||||
| :----------| :----------|
|
||||
| _Plus | |
|
||||
| _contrib_arange_like | |
|
||||
@@ -61,7 +58,7 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
| _contrib_DeformableConvolution | |
|
||||
| _contrib_DeformablePSROIPooling | |
|
||||
| _contrib_div_sqrt_dim | |
|
||||
| _contrib_MultiBoxDetection | `force_suppress` = 1 is not supported, non-default variances are not supported. |
|
||||
| _contrib_MultiBoxDetection | "force_suppress" = 1 is not supported, non-default variances are not supported |
|
||||
| _contrib_MultiBoxPrior | |
|
||||
| _contrib_Proposal | |
|
||||
| _copy | Not needed for inference |
|
||||
@@ -73,7 +70,7 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
| _random_uniform | Operation provides sequence from uniform distribution, but exact values won't match. |
|
||||
| _rnn_param_concat | |
|
||||
| _arange | |
|
||||
| _contrib_AdaptiveAvgPooling2D | Converted to the Average Pooling with fixed paddings. |
|
||||
| _contrib_AdaptiveAvgPooling2D | Converted to the Average Pooling with fixed paddings |
|
||||
| _maximum | |
|
||||
| _minimum | |
|
||||
| _np_roll | |
|
||||
@@ -99,8 +96,8 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
| greater_scalar | |
|
||||
| max | |
|
||||
| minus_scalar | |
|
||||
| null | Not needed for inference. |
|
||||
| LayerNorm | `output_mean_var` = True is not supported. |
|
||||
| null | Not needed for inference |
|
||||
| LayerNorm | "output_mean_var" = True is not supported |
|
||||
| repeat | |
|
||||
| rnn | |
|
||||
| rnn_param_concat | |
|
||||
@@ -117,24 +114,24 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
| tile | |
|
||||
| transpose | |
|
||||
| zeros | |
|
||||
| Activation | Supported `act_type` = `relu`, `sigmoid`, `softrelu` or `tanh`. |
|
||||
| Activation | supported "act_type" = "relu", "sigmoid", "softrelu" or "tanh" |
|
||||
| BatchNorm | |
|
||||
| Concat | |
|
||||
| Convolution | |
|
||||
| Crop | `center_crop` = 1 is not supported. |
|
||||
| Custom | See [Custom Layers in Model Optimizer].(customize_model_optimizer/Customize_Model_Optimizer.md) |
|
||||
| Crop | "center_crop" = 1 is not supported |
|
||||
| Custom | [Custom Layers in Model Optimizer](customize_model_optimizer/Customize_Model_Optimizer.md) |
|
||||
| Deconvolution | |
|
||||
| DeformableConvolution | |
|
||||
| DeformablePSROIPooling | |
|
||||
| Dropout | Not needed for inference. |
|
||||
| Dropout | Not needed for inference |
|
||||
| ElementWiseSum | |
|
||||
| Embedding | |
|
||||
| Flatten | |
|
||||
| FullyConnected | |
|
||||
| InstanceNorm | |
|
||||
| L2Normalization | Only 4D input is supported. |
|
||||
| L2Normalization | only 4D input is supported |
|
||||
| LRN | |
|
||||
| LeakyReLU | Supported `act_type` = `prelu`, `elu`, `leaky`, `gelu`. |
|
||||
| LeakyReLU | supported "act_type" = "prelu", "elu", "leaky", "gelu" |
|
||||
| ones_like | |
|
||||
| Pad | |
|
||||
| Pooling | |
|
||||
@@ -145,7 +142,7 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
| SoftmaxActivation | |
|
||||
| SoftmaxOutput | |
|
||||
| SoftSign | |
|
||||
| Take | The attribute `mode` is not supported. |
|
||||
| Take | The attribute 'mode' is not supported |
|
||||
| Tile | |
|
||||
| UpSampling | |
|
||||
| Where | |
|
||||
@@ -154,7 +151,7 @@ In this article, you can find lists of supported framework layers, divided by fr
|
||||
|
||||
## TensorFlow Supported Operations
|
||||
|
||||
Some of TensorFlow operations do not match any OpenVINO operations. Yet, they are still supported by Model Optimizer and can be used on constant propagation path. These layers are labeled with `Constant propagation` in the table below:
|
||||
Some TensorFlow operations do not match to any OpenVINO operation, but are still supported by the Model Optimizer and can be used on constant propagation path. These layers are labeled 'Constant propagation' in the table.
|
||||
|
||||
|
||||
| Operation Name in TensorFlow | Limitations|
|
||||
@@ -168,19 +165,19 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| ArgMax | |
|
||||
| ArgMin | |
|
||||
| Asinh | |
|
||||
| Assert | Not needed for inference. |
|
||||
| Assign | Not needed for inference. |
|
||||
| AssignSub | Not needed for inference. |
|
||||
| Assert | Not needed for inference |
|
||||
| Assign | Not needed for inference |
|
||||
| AssignSub | Not needed for inference |
|
||||
| Atanh | |
|
||||
| AvgPool | |
|
||||
| AvgPoolV2 | Supported only for constant-foldable `kernel_size` and strides inputs. |
|
||||
| AvgPoolV2 | Supported only for constant-foldable kernel_size and strides inputs |
|
||||
| AvgPool3D | |
|
||||
| BatchMatMul | |
|
||||
| BatchMatMulV2 | |
|
||||
| BatchToSpaceND | |
|
||||
| BiasAdd | |
|
||||
| BlockLSTM | |
|
||||
| Bucketize | CPU only. |
|
||||
| Bucketize | CPU only |
|
||||
| BroadcastTo | |
|
||||
| Cast | |
|
||||
| Ceil | |
|
||||
@@ -194,30 +191,30 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| Conv3DBackpropInputV2 | |
|
||||
| Cos | |
|
||||
| Cosh | |
|
||||
| CropAndResize | `method` = `bilinear` only. |
|
||||
| CTCGreedyDecoder | Supported only with decoded indices output in a dense format. |
|
||||
| CTCLoss | Supported only with decoded indices input in a dense format. |
|
||||
| CropAndResize | "method" = "bilinear" only |
|
||||
| CTCGreedyDecoder | Supported only with decoded indices output in a dense format |
|
||||
| CTCLoss | Supported only with decoded indices input in a dense format |
|
||||
| CumSum | |
|
||||
| DepthToSpace| |
|
||||
| DepthwiseConv2dNative| |
|
||||
| Einsum | Supported only with equation that does not contain repeated labels within a subscript. |
|
||||
| Einsum | Supported only with equation that does not contain repeated labels within a subscript |
|
||||
| Elu | |
|
||||
| EmptyTensorList | Supported only when it is part of a sub-graph of the special form. |
|
||||
| Enter | Supported only when it is fused to the TensorIterator layer. |
|
||||
| EmptyTensorList | Supported only when it is part of a sub-graph of the special form |
|
||||
| Enter | Supported only when it is fused to the TensorIterator layer |
|
||||
| Equal | |
|
||||
| Erf | |
|
||||
| Exit | Supported only when it is fused to the TensorIterator layer. |
|
||||
| Exit | Supported only when it is fused to the TensorIterator layer |
|
||||
| Exp | |
|
||||
| ExpandDims | |
|
||||
| ExperimentalSparseWeightedSum | CPU only. |
|
||||
| ExperimentalSparseWeightedSum | CPU only |
|
||||
| ExtractImagePatches | |
|
||||
| EuclideanNorm | |
|
||||
| FakeQuantWithMinMaxVars | |
|
||||
| FakeQuantWithMinMaxVarsPerChannel | |
|
||||
| FFT | Supported only when it is part of a sub-graph of the special form. |
|
||||
| FFT2D | Supported only when it is part of a sub-graph of the special form. |
|
||||
| FFT3D | Supported only when it is part of a sub-graph of the special form. |
|
||||
| FIFOQueueV2 | Supported only when it is part of a sub-graph of the special form. |
|
||||
| FFT | Supported only when it is part of a sub-graph of the special form |
|
||||
| FFT2D | Supported only when it is part of a sub-graph of the special form |
|
||||
| FFT3D | Supported only when it is part of a sub-graph of the special form |
|
||||
| FIFOQueueV2 | Supported only when it is part of a sub-graph of the special form |
|
||||
| Fill | |
|
||||
| Floor | |
|
||||
| FloorDiv | |
|
||||
@@ -231,12 +228,12 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| GatherV2 | |
|
||||
| Greater | |
|
||||
| GreaterEqual | |
|
||||
| Identity | Not needed for shape inference. |
|
||||
| Identity | Not needed for shape inference |
|
||||
| IdentityN | |
|
||||
| IFFT | Supported only when it is part of a sub-graph of the special form. |
|
||||
| IFFT2D | Supported only when it is part of a sub-graph of the special form. |
|
||||
| IFFT3D | Supported only when it is part of a sub-graph of the special form. |
|
||||
| IteratorGetNext | Supported only when it is part of a sub-graph of the special form. |
|
||||
| IFFT | Supported only when it is part of a sub-graph of the special form |
|
||||
| IFFT2D | Supported only when it is part of a sub-graph of the special form |
|
||||
| IFFT3D | Supported only when it is part of a sub-graph of the special form |
|
||||
| IteratorGetNext | Supported only when it is part of a sub-graph of the special form |
|
||||
| LRN | |
|
||||
| LeakyRelu | |
|
||||
| Less | |
|
||||
@@ -247,23 +244,23 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| LogicalOr | |
|
||||
| LogicalNot | |
|
||||
| LogSoftmax | |
|
||||
| LookupTableInsertV2 | Supported only when it is part of a sub-graph of the special form. |
|
||||
| LoopCond | Supported only when it is fused to the TensorIterator layer. |
|
||||
| LookupTableInsertV2 | Supported only when it is part of a sub-graph of the special form |
|
||||
| LoopCond | Supported only when it is fused to the TensorIterator layer |
|
||||
| MatMul | |
|
||||
| Max | |
|
||||
| MaxPool | |
|
||||
| MaxPoolV2 | Supported only for constant-foldable `kernel_size` and strides inputs. |
|
||||
| MaxPoolV2 | Supported only for constant-foldable kernel_size and strides inputs |
|
||||
| MaxPool3D | |
|
||||
| Maximum | |
|
||||
| Mean | |
|
||||
| Merge | Supported only when it is fused to the TensorIterator layer. |
|
||||
| Merge | Supported only when it is fused to the TensorIterator layer |
|
||||
| Min | |
|
||||
| Minimum | |
|
||||
| MirrorPad | |
|
||||
| Mod | |
|
||||
| Mul | |
|
||||
| Neg | |
|
||||
| NextIteration | Supported only when it is fused to the TensorIterator layer. |
|
||||
| NextIteration | Supported only when it is fused to the TensorIterator layer |
|
||||
| NonMaxSuppressionV2 | |
|
||||
| NonMaxSuppressionV3 | |
|
||||
| NonMaxSuppressionV4 | |
|
||||
@@ -277,9 +274,9 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| Placeholder | |
|
||||
| PlaceholderWithDefault | |
|
||||
| Prod | |
|
||||
| QueueDequeue | Supported only when it is part of a sub-graph of the special form. |
|
||||
| QueueDequeueUpToV2 | Supported only when it is part of a sub-graph of the special form. |
|
||||
| QueueDequeueV2 | Supported only when it is part of a sub-graph of the special form. |
|
||||
| QueueDequeue | Supported only when it is part of a sub-graph of the special form |
|
||||
| QueueDequeueUpToV2 | Supported only when it is part of a sub-graph of the special form |
|
||||
| QueueDequeueV2 | Supported only when it is part of a sub-graph of the special form |
|
||||
| RandomUniform | |
|
||||
| RandomUniformInt | |
|
||||
| Range | |
|
||||
@@ -293,7 +290,7 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| ResizeNearestNeighbor | |
|
||||
| ResourceGather| |
|
||||
| ReverseSequence | |
|
||||
| ReverseV2 | Supported only when it can be converted to the ReverseSequence operation. |
|
||||
| ReverseV2 | Supported only when it can be converted to the ReverseSequence operation |
|
||||
| Roll | |
|
||||
| Round | |
|
||||
| Pow | |
|
||||
@@ -312,10 +309,10 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| Softsign | |
|
||||
| SpaceToBatchND | |
|
||||
| SpaceToDepth | |
|
||||
| SparseFillEmptyRows | Supported only when it is part of a sub-graph of the special form. |
|
||||
| SparseReshape | Supported only when it is part of a sub-graph of the special form. |
|
||||
| SparseSegmentSum | Supported only when it is part of a sub-graph of the special form. |
|
||||
| SparseSegmentMean | Supported only when it is part of a sub-graph of the special form. |
|
||||
| SparseFillEmptyRows | Supported only when it is part of a sub-graph of the special form |
|
||||
| SparseReshape | Supported only when it is part of a sub-graph of the special form |
|
||||
| SparseSegmentSum | Supported only when it is part of a sub-graph of the special form |
|
||||
| SparseSegmentMean | Supported only when it is part of a sub-graph of the special form |
|
||||
| SparseToDense | CPU only |
|
||||
| Split | |
|
||||
| SplitV | |
|
||||
@@ -323,31 +320,31 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| Square | |
|
||||
| SquaredDifference | |
|
||||
| Square| |
|
||||
| Squeeze | Cases in which squeeze axis is not specified are not supported. |
|
||||
| Squeeze | The case when squeeze axis is not specified is not supported |
|
||||
| StatelessWhile | |
|
||||
| StopGradient | Not needed for shape inference. |
|
||||
| StridedSlice | Supported only for constant-foldable `begin`, `end`, and `strides` inputs. |
|
||||
| StopGradient | Not needed for shape inference |
|
||||
| StridedSlice | Supported only for constant-foldable begin, end, and strides inputs |
|
||||
| Sub | |
|
||||
| Sum | |
|
||||
| Swish | |
|
||||
| swish_f32 | |
|
||||
| Switch | Control flow propagation. |
|
||||
| Switch | Control flow propagation |
|
||||
| Tan | |
|
||||
| Tanh | |
|
||||
| TensorArrayGatherV3 | Supported only when it is fused to the TensorIterator layer. |
|
||||
| TensorArrayReadV3 | Supported only when it is fused to the TensorIterator layer. |
|
||||
| TensorArrayScatterV3 | Supported only when it is fused to the TensorIterator layer. |
|
||||
| TensorArraySizeV3 | Supported only when it is fused to the TensorIterator layer. |
|
||||
| TensorArrayV3 | Supported only when it is fused to the TensorIterator layer. |
|
||||
| TensorArrayWriteV3 | Supported only when it is fused to the TensorIterator layer. |
|
||||
| TensorListPushBack | Supported only when it is part of a sub-graph of the special form. |
|
||||
| TensorArrayGatherV3 | Supported only when it is fused to the TensorIterator layer |
|
||||
| TensorArrayReadV3 | Supported only when it is fused to the TensorIterator layer |
|
||||
| TensorArrayScatterV3 | Supported only when it is fused to the TensorIterator layer |
|
||||
| TensorArraySizeV3 | Supported only when it is fused to the TensorIterator layer |
|
||||
| TensorArrayV3 | Supported only when it is fused to the TensorIterator layer |
|
||||
| TensorArrayWriteV3 | Supported only when it is fused to the TensorIterator layer |
|
||||
| TensorListPushBack | Supported only when it is part of a sub-graph of the special form |
|
||||
| Tile | |
|
||||
| TopkV2 | |
|
||||
| Transpose | |
|
||||
| Unpack | |
|
||||
| Variable | |
|
||||
| VariableV2 | |
|
||||
| Where | Supported only when it is part of a sub-graph of the special form. |
|
||||
| Where | Supported only when it is part of a sub-graph of the special form |
|
||||
| ZerosLike | |
|
||||
|
||||
|
||||
@@ -369,7 +366,7 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| Bidirectional | |
|
||||
| Concatenate | |
|
||||
| Conv1D | |
|
||||
| Conv1DTranspose | Not supported if `dilation` is not equal to 1. |
|
||||
| Conv1DTranspose | Not supported if dilation is not equal to 1 |
|
||||
| Conv2D | |
|
||||
| Conv2DTranspose | |
|
||||
| Conv3D | |
|
||||
@@ -378,7 +375,7 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| Cropping2D | |
|
||||
| Cropping3D | |
|
||||
| Dense | |
|
||||
| DenseFeatures | Not supported for categorical and crossed features. |
|
||||
| DenseFeatures | Not supported for categorical and crossed features |
|
||||
| DepthwiseConv2D | |
|
||||
| Dot | |
|
||||
| Dropout | |
|
||||
@@ -410,7 +407,7 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| Multiply | |
|
||||
| PReLU | |
|
||||
| Permute | |
|
||||
| RNN | Not supported for some custom cells. |
|
||||
| RNN | Not supported for some custom cells |
|
||||
| ReLU | |
|
||||
| RepeatVector | |
|
||||
| Reshape | |
|
||||
@@ -445,7 +442,7 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| affinetransform | |
|
||||
| backproptruncationcomponent | |
|
||||
| batchnormcomponent | |
|
||||
| clipgradientcomponent | Not needed for inference. |
|
||||
| clipgradientcomponent | Not needed for inference |
|
||||
| concat | |
|
||||
| convolutional1dcomponent | |
|
||||
| convolutionalcomponent | |
|
||||
@@ -455,7 +452,7 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| fixedaffinecomponent | |
|
||||
| fixedbiascomponent | |
|
||||
| fixedscalecomponent | |
|
||||
| generaldropoutcomponent| Not needed for inference. |
|
||||
| generaldropoutcomponent| Not needed for inference |
|
||||
| linearcomponent | |
|
||||
| logsoftmaxcomponent | |
|
||||
| lstmnonlinearitycomponent | |
|
||||
@@ -464,7 +461,7 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| maxpoolingcomponent | |
|
||||
| naturalgradientaffinecomponent | |
|
||||
| naturalgradientperelementscalecomponent | |
|
||||
| noopcomponent | Not needed for inference. |
|
||||
| noopcomponent | Not needed for inference |
|
||||
| normalizecomponent | |
|
||||
| parallelcomponent | |
|
||||
| pnormcomponent | |
|
||||
@@ -474,7 +471,7 @@ Some of TensorFlow operations do not match any OpenVINO operations. Yet, they ar
|
||||
| sigmoidcomponent | |
|
||||
| softmax | |
|
||||
| softmaxComponent | |
|
||||
| specaugmenttimemaskcomponent | Not needed for inference. |
|
||||
| specaugmenttimemaskcomponent | Not needed for inference |
|
||||
| splicecomponent | |
|
||||
| tanhcomponent | |
|
||||
| tdnncomponent | |
|
||||
@@ -670,95 +667,68 @@ paddlepaddle>=2.1
|
||||
|
||||
| Operator Name in PaddlePaddle| Limitations|
|
||||
| :----------| :----------|
|
||||
| adpative_pool2d | The `NHWC` data_layout is not supported. |
|
||||
| arg_max | The `int32` output data_type is not supported. |
|
||||
| assign | |
|
||||
| adpative_pool2d | 'NHWC' data_layout is not supported |
|
||||
| arg_max | 'int32' output data_type is not supported |
|
||||
| assign_value | |
|
||||
| batch_norm | |
|
||||
| bilinear_interp | `NCW`, `NWC`, `NHWC`, `NCDHW`, `NDHWC` data_layout are not supported. |
|
||||
| bilinear_interp_v2 | `NCW`, `NWC`, `NHWC`, `NCDHW`, `NDHWC` data_layout are not supported. |
|
||||
| bilinear_interp | 'NCW' 'NWC' 'NHWC' 'NCDHW' 'NDHWC' data_layout are not supported |
|
||||
| bilinear_interp_v2 | 'NCW' 'NWC' 'NHWC' 'NCDHW' 'NDHWC' data_layout are not supported |
|
||||
| bmm | |
|
||||
| cast | |
|
||||
| clip | |
|
||||
| concat | |
|
||||
| conv2d | `NHWC` data_layout is not supported. |
|
||||
| conv2d | 'NHWC' data_layout is not supported |
|
||||
| depthwise_conv2d | 'NHWC' data_layout is not supported |
|
||||
| deformable_conv | |
|
||||
| depthwise_conv2d | `NHWC` data_layout is not supported. |
|
||||
| elementwise_add | |
|
||||
| elementwise_div | |
|
||||
| elementwise_max | |
|
||||
| elementwise_min | |
|
||||
| elementwise_mul | |
|
||||
| elementwise_not_equal | |
|
||||
| elementwise_pow | |
|
||||
| elementwise_sub | |
|
||||
| equal | |
|
||||
| exp | |
|
||||
| expand | |
|
||||
| expand_v2 | |
|
||||
| exp | |
|
||||
| fill_any_like | |
|
||||
| fill_constant | |
|
||||
| fill_constant_batch_size_like | |
|
||||
| fill_zeros_like | |
|
||||
| fill_constant | |
|
||||
| flatten_contiguous_range | |
|
||||
| floor | |
|
||||
| gather | |
|
||||
| gather_tree | |
|
||||
| gelu | |
|
||||
| generate_proposals_v2 | |
|
||||
| greater_equal | |
|
||||
| greater_than | |
|
||||
| hard_sigmoid | |
|
||||
| hard_swish | |
|
||||
| layer_norm | |
|
||||
| leaky_relu | |
|
||||
| less_than | |
|
||||
| log | |
|
||||
| logical_and | |
|
||||
| logical_not | |
|
||||
| logical_or | |
|
||||
| logical_xor | |
|
||||
| lookup_table_v2 | |
|
||||
| matmul | |
|
||||
| matmul_v2 | |
|
||||
| matrix_nms | Only supports IE CPU plugin with *"number of selected boxes"* static shape(e.g.: `min(min(num_boxes, nms_top_k) * num_classes_output, keep_top_k)`). |
|
||||
| matrix_nms | Only supports IE CPU plugin with 'number of selected boxes' static shape(e.g.: min(min(num_boxes, nms_top_k) * num_classes_output, keep_top_k)) |
|
||||
| max_pool2d_with_index | |
|
||||
| meshgrid | |
|
||||
| mul | |
|
||||
| multiclass_nms3 | Only supports IE CPU plugin with *"number of selected boxes"* static shape(e.g.: `min(min(num_boxes, nms_top_k) * num_classes_output, keep_top_k)`). |
|
||||
| nearest_interp | `NCW`, `NWC`, `NHWC`, `NCDHW`, `NDHWC` data_layout are not supported. |
|
||||
| nearest_interp_v2 | `NCW`, `NWC`, `NHWC`, `NCDHW`, `NDHWC` data_layout are not supported. |
|
||||
| pad3d | `Circular` mode is not supported. |
|
||||
| pool2d | `NHWC` data_layout is not supported. |
|
||||
| multiclass_nms3 | Only supports IE CPU plugin with 'number of selected boxes' static shape(e.g.: min(min(num_boxes, nms_top_k) * num_classes_output, keep_top_k)) |
|
||||
| nearest_interp | 'NCW' 'NWC' 'NHWC' 'NCDHW' 'NDHWC' data_layout are not supported |
|
||||
| nearest_interp_v2 | 'NCW' 'NWC' 'NHWC' 'NCDHW' 'NDHWC' data_layout are not supported |
|
||||
| pad3d | 'Circular' mode is not supported |
|
||||
| pow | |
|
||||
| pool2d | 'NHWC' data_layout is not supported |
|
||||
| prior_box | |
|
||||
| range | |
|
||||
| reduce_max | |
|
||||
| reduce_mean | |
|
||||
| reduce_min | |
|
||||
| reduce_prod | |
|
||||
| reduce_sum | |
|
||||
| relu | |
|
||||
| relu6 | |
|
||||
| reshape2 | |
|
||||
| rnn | `SimpleRNN` and `GRU` modes are not supported. |
|
||||
| roi_align | |
|
||||
| rnn | 'SimpleRNN' and 'GRU' modes are not supported |
|
||||
| scale | |
|
||||
| shape | |
|
||||
| sigmoid | |
|
||||
| slice | |
|
||||
| softmax | |
|
||||
| softplus | |
|
||||
| sigmoid | |
|
||||
| split | |
|
||||
| sqrt | |
|
||||
| squeeze2 | |
|
||||
| stack | |
|
||||
| strided_slice | |
|
||||
| swish | |
|
||||
| tanh | |
|
||||
| top_k | |
|
||||
| top_k_v2 | |
|
||||
| transpose2 | |
|
||||
| unsqueeze2 | |
|
||||
| where | |
|
||||
| yolo_box | |
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
# Converting a Caffe Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Caffe}
|
||||
# Converting a Caffe* Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Caffe}
|
||||
|
||||
<a name="Convert_From_Caffe"></a>To convert a Caffe model, run Model Optimizer with the path to the input model `.caffemodel` file:
|
||||
## Convert a Caffe* Model <a name="Convert_From_Caffe"></a>
|
||||
To convert a Caffe\* model, run Model Optimizer with the path to the input model `.caffemodel` file:
|
||||
|
||||
```sh
|
||||
mo --input_model <INPUT_MODEL>.caffemodel
|
||||
```
|
||||
|
||||
The following list provides the Caffe-specific parameters.
|
||||
The following list provides the Caffe\*-specific parameters.
|
||||
|
||||
```
|
||||
Caffe-specific parameters:
|
||||
Caffe*-specific parameters:
|
||||
--input_proto INPUT_PROTO, -d INPUT_PROTO
|
||||
Deploy-ready prototxt file that contains a topology
|
||||
structure and layer attributes
|
||||
@@ -44,16 +45,14 @@ Caffe-specific parameters:
|
||||
attributes without flattening nested parameters.
|
||||
```
|
||||
|
||||
### CLI Examples Using Caffe-Specific Parameters
|
||||
### Command-Line Interface (CLI) Examples Using Caffe\*-Specific Parameters
|
||||
|
||||
* Launching Model Optimizer for [bvlc_alexnet.caffemodel](https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet) with a specified `prototxt` file.
|
||||
This is needed when the name of the Caffe model and the `.prototxt` file are different or are placed in different directories. Otherwise, it is enough to provide only the path to the input `model.caffemodel` file.
|
||||
* Launching the Model Optimizer for the [bvlc_alexnet.caffemodel](https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet) with a specified `prototxt` file. This is needed when the name of the Caffe\* model and the `.prototxt` file are different or are placed in different directories. Otherwise, it is enough to provide only the path to the input `model.caffemodel` file.
|
||||
```sh
|
||||
mo --input_model bvlc_alexnet.caffemodel --input_proto bvlc_alexnet.prototxt
|
||||
```
|
||||
* Launching Model Optimizer for [bvlc_alexnet.caffemodel](https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet) with a specified `CustomLayersMapping` file.
|
||||
This is the legacy method of quickly enabling model conversion if your model has custom layers. This requires the Caffe system on the computer.
|
||||
The optional parameters without default values and not specified by the user in the `.prototxt` file are removed from the Intermediate Representation, and nested parameters are flattened:
|
||||
* Launching the Model Optimizer for the [bvlc_alexnet.caffemodel](https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet) with a specified `CustomLayersMapping` file. This is the legacy method of quickly enabling model conversion if your model has custom layers. This requires the Caffe\* system on the computer.
|
||||
Optional parameters without default values and not specified by the user in the `.prototxt` file are removed from the Intermediate Representation, and nested parameters are flattened:
|
||||
```sh
|
||||
mo --input_model bvlc_alexnet.caffemodel -k CustomLayersMapping.xml --disable_omitting_optional --enable_flattening_nested_params
|
||||
```
|
||||
@@ -83,22 +82,22 @@ The optional parameters without default values and not specified by the user in
|
||||
```
|
||||
## Custom Layer Definition
|
||||
|
||||
Internally, when you run Model Optimizer, it loads the model, goes through the topology, and tries to find each layer type in a list of known layers. Custom layers are layers that are not included in the list. If your topology contains such kind of layers, Model Optimizer classifies them as custom.
|
||||
Internally, when you run the Model Optimizer, it loads the model, goes through the topology, and tries to find each layer type in a list of known layers. Custom layers are layers that are not included in the list of known layers. If your topology contains any layers that are not in this list of known layers, the Model Optimizer classifies them as custom.
|
||||
|
||||
## Supported Caffe Layers
|
||||
For the list of supported standard layers, refer to the [Supported Framework Layers](../Supported_Frameworks_Layers.md) page.
|
||||
## Supported Caffe\* Layers
|
||||
Refer to [Supported Framework Layers](../Supported_Frameworks_Layers.md) for the list of supported standard layers.
|
||||
|
||||
## Frequently Asked Questions (FAQ)
|
||||
|
||||
Model Optimizer provides explanatory messages when it is unable to complete conversions due to typographical errors, incorrectly used options, or other issues. A message describes the potential cause of the problem and gives a link to [Model Optimizer FAQ](../Model_Optimizer_FAQ.md) which provides instructions on how to resolve most issues. The FAQ also includes links to relevant sections to help you understand what went wrong.
|
||||
The Model Optimizer provides explanatory messages if it is unable to run to completion due to issues like typographical errors, incorrectly used options, or other issues. The message describes the potential cause of the problem and gives a link to the [Model Optimizer FAQ](../Model_Optimizer_FAQ.md). The FAQ has instructions on how to resolve most issues. The FAQ also includes links to relevant sections in the Model Optimizer Developer Guide to help you understand what went wrong.
|
||||
|
||||
## Summary
|
||||
|
||||
In this document, you learned:
|
||||
|
||||
* Basic information about how the Model Optimizer works with Caffe models.
|
||||
* Which Caffe models are supported.
|
||||
* How to convert a trained Caffe model by using Model Optimizer with both framework-agnostic and Caffe-specific command-line options.
|
||||
* Basic information about how the Model Optimizer works with Caffe\* models
|
||||
* Which Caffe\* models are supported
|
||||
* How to convert a trained Caffe\* model using the Model Optimizer with both framework-agnostic and Caffe-specific command-line options
|
||||
|
||||
## See Also
|
||||
[Model Conversion Tutorials](Convert_Model_Tutorials.md)
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
# Converting a Kaldi Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Kaldi}
|
||||
# Converting a Kaldi* Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Kaldi}
|
||||
|
||||
> **NOTE**: Model Optimizer supports the [nnet1](http://kaldi-asr.org/doc/dnn1.html) and [nnet2](http://kaldi-asr.org/doc/dnn2.html) formats of Kaldi models. The support of the [nnet3](http://kaldi-asr.org/doc/dnn3.html) format is limited.
|
||||
|
||||
<a name="Convert_From_Kaldi"></a>To convert a Kaldi model, run Model Optimizer with the path to the input model `.nnet` or `.mdl` file:
|
||||
> **NOTE**: The Model Optimizer supports the [nnet1](http://kaldi-asr.org/doc/dnn1.html) and [nnet2](http://kaldi-asr.org/doc/dnn2.html) formats of Kaldi models. Support of the [nnet3](http://kaldi-asr.org/doc/dnn3.html) format is limited.
|
||||
|
||||
## Convert a Kaldi* Model <a name="Convert_From_Kaldi"></a>
|
||||
To convert a Kaldi\* model, run Model Optimizer with the path to the input model `.nnet` or `.mdl` file:
|
||||
|
||||
```sh
|
||||
mo --input_model <INPUT_MODEL>.nnet
|
||||
```
|
||||
|
||||
## Using Kaldi-Specific Conversion Parameters <a name="kaldi_specific_conversion_params"></a>
|
||||
### Using Kaldi\*-Specific Conversion Parameters <a name="kaldi_specific_conversion_params"></a>
|
||||
|
||||
The following list provides the Kaldi-specific parameters.
|
||||
The following list provides the Kaldi\*-specific parameters.
|
||||
|
||||
```sh
|
||||
Kaldi-specific parameters:
|
||||
@@ -20,14 +21,14 @@ Kaldi-specific parameters:
|
||||
--remove_memory Remove the Memory layer and add new inputs and outputs instead
|
||||
```
|
||||
|
||||
## Examples of CLI Commands
|
||||
### Examples of CLI Commands
|
||||
|
||||
* To launch Model Optimizer for the `wsj_dnn5b_smbr` model with the specified `.nnet` file:
|
||||
* To launch the Model Optimizer for the wsj_dnn5b_smbr model with the specified `.nnet` file:
|
||||
```sh
|
||||
mo --input_model wsj_dnn5b_smbr.nnet
|
||||
```
|
||||
|
||||
* To launch Model Optimizer for the `wsj_dnn5b_smbr` model with the existing file that contains counts for the last layer with biases:
|
||||
* To launch the Model Optimizer for the wsj_dnn5b_smbr model with existing file that contains counts for the last layer with biases:
|
||||
```sh
|
||||
mo --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts
|
||||
```
|
||||
@@ -43,7 +44,7 @@ Kaldi-specific parameters:
|
||||
\f$|C|\f$ - number of elements in the counts array;
|
||||
* The normalized counts are subtracted from biases of the last or next to last layer (if last layer is SoftMax).
|
||||
|
||||
> **NOTE**: Model Optimizer will show a warning if a model contains values of counts and the `--counts` option is not used.
|
||||
> **NOTE**: Model Optimizer will show warning if model contains counts values inside model and `--counts` option is not used.
|
||||
|
||||
* If you want to remove the last SoftMax layer in the topology, launch the Model Optimizer with the
|
||||
`--remove_output_softmax` flag:
|
||||
@@ -51,30 +52,28 @@ Kaldi-specific parameters:
|
||||
mo --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts --remove_output_softmax
|
||||
```
|
||||
|
||||
The Model Optimizer finds the last layer of the topology and removes this layer only if it is a SoftMax layer.
|
||||
The Model Optimizer finds the last layer of the topology and removes this layer only if it is a SoftMax layer.
|
||||
|
||||
> **NOTE**: Model Optimizer can remove SoftMax layer only if the topology has one output.
|
||||
> **NOTE**: Model Optimizer can remove SoftMax layer only if the topology has one output.
|
||||
|
||||
* You can use the *OpenVINO Speech Recognition* sample application for the sample inference of Kaldi models. This sample supports models with only one output. If your model has several outputs, specify the desired one with the `--output` option.
|
||||
> **NOTE**: For sample inference of Kaldi models, you can use the OpenVINO Speech Recognition sample application. The sample supports models with one output. If your model has several outputs, specify the desired one with the `--output` option.
|
||||
|
||||
## Converting a Model for Intel® Movidius™ Myriad™ VPU
|
||||
|
||||
If you want to convert a model for inference on Intel® Movidius™ Myriad™ VPU, use the `--remove_memory` option.
|
||||
It removes the Memory layers from the OpenVINO IR files. Additional inputs and outputs will appear in the IR files instead.
|
||||
Model Optimizer will output the mapping between inputs and outputs. For example:
|
||||
If you want to convert a model for inference on Intel® Movidius™ Myriad™, use the `--remove_memory` option.
|
||||
It removes Memory layers from the IR. Instead of it, additional inputs and outputs appear in the IR.
|
||||
The Model Optimizer outputs the mapping between inputs and outputs. For example:
|
||||
```sh
|
||||
[ WARNING ] Add input/output mapped Parameter_0_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out -> Result_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out
|
||||
[ WARNING ] Add input/output mapped Parameter_1_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out -> Result_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out
|
||||
[ WARNING ] Add input/output mapped Parameter_0_for_iteration_Offset_fastlstm3.c_trunc__3390 -> Result_for_iteration_Offset_fastlstm3.c_trunc__3390
|
||||
```
|
||||
Based on this mapping, link inputs and outputs in your application manually as follows:
|
||||
Based on this mapping, link inputs and outputs in your application manually as follows:
|
||||
|
||||
1. Initialize inputs from the mapping as zeros in the first frame of an utterance.
|
||||
2. Copy output blobs from the mapping to the corresponding inputs. For example, data from `Result_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out`
|
||||
must be copied to `Parameter_0_for_Offset_fastlstm2.r_trunc__2Offset_fastlstm2.r_trunc__2_out`.
|
||||
|
||||
## Supported Kaldi Layers
|
||||
For the list of supported standard layers, refer to the [Supported Framework Layers ](../Supported_Frameworks_Layers.md) page.
|
||||
## Supported Kaldi\* Layers
|
||||
Refer to [Supported Framework Layers ](../Supported_Frameworks_Layers.md) for the list of supported standard layers.
|
||||
|
||||
## See Also
|
||||
[Model Conversion Tutorials](Convert_Model_Tutorials.md)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
# Converting an MXNet Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_MxNet}
|
||||
# Converting an MXNet* Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_MxNet}
|
||||
|
||||
<a name="ConvertMxNet"></a>To convert an MXNet model, run Model Optimizer with the path to the *`.params`* file of the input model:
|
||||
## Convert an MXNet* Model <a name="ConvertMxNet"></a>
|
||||
To convert an MXNet\* model, run Model Optimizer with a path to the input model `.params` file:
|
||||
|
||||
```sh
|
||||
mo --input_model model-file-0000.params
|
||||
```
|
||||
|
||||
## Using MXNet-Specific Conversion Parameters <a name="mxnet_specific_conversion_params"></a>
|
||||
The following list provides the MXNet-specific parameters.
|
||||
### Using MXNet\*-Specific Conversion Parameters <a name="mxnet_specific_conversion_params"></a>
|
||||
The following list provides the MXNet\*-specific parameters.
|
||||
|
||||
```
|
||||
MXNet-specific parameters:
|
||||
@@ -22,36 +23,36 @@ MXNet-specific parameters:
|
||||
--save_params_from_nd
|
||||
Enable saving built parameters file from .nd files
|
||||
--legacy_mxnet_model
|
||||
Enable Apache MXNet loader to make a model compatible with the latest Apache MXNet version.
|
||||
Use only if your model was trained with Apache MXNet version lower than 1.0.0
|
||||
Enable MXNet loader to make a model compatible with the latest MXNet version.
|
||||
Use only if your model was trained with MXNet version lower than 1.0.0
|
||||
--enable_ssd_gluoncv
|
||||
Enable transformation for converting the gluoncv ssd topologies.
|
||||
Use only if your topology is one of ssd gluoncv topologies
|
||||
```
|
||||
|
||||
> **NOTE**: By default, Model Optimizer does not use the Apache MXNet loader. It transforms the topology to another format which is compatible with the latest
|
||||
> version of Apache MXNet. However, the Apache MXNet loader is required for models trained with lower version of Apache MXNet. If your model was trained with an Apache MXNet version lower than 1.0.0, specify the
|
||||
> `--legacy_mxnet_model` key to enable the Apache MXNet loader. Note that the loader does not support models with custom layers. In this case, you must manually
|
||||
> recompile Apache MXNet with custom layers and install it in your environment.
|
||||
> **NOTE**: By default, the Model Optimizer does not use the MXNet loader, as it transforms the topology to another format, which is compatible with the latest
|
||||
> version of MXNet, but it is required for models trained with lower version of MXNet. If your model was trained with MXNet version lower than 1.0.0, specify the
|
||||
> `--legacy_mxnet_model` key to enable the MXNet loader. However, the loader does not support models with custom layers. In this case, you must manually
|
||||
> recompile MXNet with custom layers and install it to your environment.
|
||||
|
||||
## Custom Layer Definition
|
||||
|
||||
Internally, when you run Model Optimizer, it loads the model, goes through the topology, and tries to find each layer type in a list of known layers. Custom layers are layers that are not included in the list. If your topology contains such kind of layers, Model Optimizer classifies them as custom.
|
||||
Internally, when you run the Model Optimizer, it loads the model, goes through the topology, and tries to find each layer type in a list of known layers. Custom layers are layers that are not included in the list of known layers. If your topology contains any layers that are not in this list of known layers, the Model Optimizer classifies them as custom.
|
||||
|
||||
## Supported MXNet Layers
|
||||
For the list of supported standard layers, refer to the [Supported Framework Layers](../Supported_Frameworks_Layers.md) page.
|
||||
## Supported MXNet\* Layers
|
||||
Refer to [Supported Framework Layers](../Supported_Frameworks_Layers.md) for the list of supported standard layers.
|
||||
|
||||
## Frequently Asked Questions (FAQ)
|
||||
|
||||
Model Optimizer provides explanatory messages when it is unable to complete conversions due to typographical errors, incorrectly used options, or other issues. A message describes the potential cause of the problem and gives a link to [Model Optimizer FAQ](../Model_Optimizer_FAQ.md) which provides instructions on how to resolve most issues. The FAQ also includes links to relevant sections to help you understand what went wrong.
|
||||
The Model Optimizer provides explanatory messages if it is unable to run to completion due to issues like typographical errors, incorrectly used options, or other issues. The message describes the potential cause of the problem and gives a link to the [Model Optimizer FAQ](../Model_Optimizer_FAQ.md). The FAQ has instructions on how to resolve most issues. The FAQ also includes links to relevant sections in the Model Optimizer Developer Guide to help you understand what went wrong.
|
||||
|
||||
## Summary
|
||||
|
||||
In this document, you learned:
|
||||
|
||||
* Basic information about how Model Optimizer works with MXNet models.
|
||||
* Which MXNet models are supported.
|
||||
* How to convert a trained MXNet model by using the Model Optimizer with both framework-agnostic and MXNet-specific command-line options.
|
||||
* Basic information about how the Model Optimizer works with MXNet\* models
|
||||
* Which MXNet\* models are supported
|
||||
* How to convert a trained MXNet\* model using the Model Optimizer with both framework-agnostic and MXNet-specific command-line options
|
||||
|
||||
## See Also
|
||||
[Model Conversion Tutorials](Convert_Model_Tutorials.md)
|
||||
|
||||
@@ -1,28 +1,21 @@
|
||||
# Converting an ONNX Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_ONNX}
|
||||
|
||||
## Introduction to ONNX
|
||||
[ONNX](https://github.com/onnx/onnx) is a representation format for deep learning models that allows AI developers to easily transfer models between different frameworks. It is hugely popular among deep learning tools, like PyTorch, Caffe2, Apache MXNet, Microsoft Cognitive Toolkit, and many others.
|
||||
|
||||
## Converting an ONNX Model <a name="Convert_From_ONNX"></a>
|
||||
|
||||
This page provides instructions on how to convert a model from the ONNX format to the OpenVINO IR format using Model Optimizer. To use Model Optimizer, install OpenVINO Development Tools by following the [installation instructions](https://docs.openvino.ai/latest/openvino_docs_install_guides_install_dev_tools.html).
|
||||
[ONNX*](https://github.com/onnx/onnx) is a representation format for deep learning models. ONNX allows AI developers easily transfer models between different frameworks that helps to choose the best combination for them. Today, PyTorch\*, Caffe2\*, Apache MXNet\*, Microsoft Cognitive Toolkit\* and other tools are developing ONNX support.
|
||||
|
||||
## Convert an ONNX* Model <a name="Convert_From_ONNX"></a>
|
||||
The Model Optimizer process assumes you have an ONNX model that was directly downloaded from a public repository or converted from any framework that supports exporting to the ONNX format.
|
||||
|
||||
To convert an ONNX model, run Model Optimizer with the path to the input model `.onnx` file:
|
||||
To convert an ONNX\* model, run Model Optimizer with the path to the input model `.onnx` file:
|
||||
|
||||
```sh
|
||||
mo --input_model <INPUT_MODEL>.onnx
|
||||
```
|
||||
|
||||
There are no ONNX specific parameters, so only framework-agnostic parameters are available to convert your model. For details, see the *General Conversion Parameters* section in the [Converting a Model to Intermediate Representation (IR)](Converting_Model.md) guide.
|
||||
There are no ONNX\* specific parameters, so only framework-agnostic parameters are available to convert your model. For details, see the General Conversion Parameters section on the [Converting a Model to Intermediate Representation (IR)](Converting_Model.md) page.
|
||||
|
||||
## Supported ONNX Layers
|
||||
For the list of supported standard layers, refer to the [Supported Framework Layers](../Supported_Frameworks_Layers.md) page.
|
||||
|
||||
## Additional Resources
|
||||
See the [Model Conversion Tutorials](Convert_Model_Tutorials.md) page for a set of tutorials providing step-by-step instructions for converting specific ONNX models. Here are some examples:
|
||||
* [Convert ONNX* Faster R-CNN Model](onnx_specific/Convert_Faster_RCNN.md)
|
||||
* [Convert ONNX* GPT-2 Model](onnx_specific/Convert_GPT2.md)
|
||||
* [Convert ONNX* Mask R-CNN Model](onnx_specific/Convert_Mask_RCNN.md)
|
||||
## Supported ONNX\* Layers
|
||||
Refer to [Supported Framework Layers](../Supported_Frameworks_Layers.md) for the list of supported standard layers.
|
||||
|
||||
## See Also
|
||||
[Model Conversion Tutorials](Convert_Model_Tutorials.md)
|
||||
|
||||
@@ -1,76 +1,25 @@
|
||||
# Converting a PaddlePaddle Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Paddle}
|
||||
# Converting a PaddlePaddle* Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Paddle}
|
||||
|
||||
To convert a PaddlePaddle model, use the `mo` script and specify the path to the input `.pdmodel` model file:
|
||||
## Convert a PaddlePaddle Model <a name="Convert_From_Paddle"></a>
|
||||
To convert a PaddlePaddle model, use the `mo` script and specify the path to the input model `.pdmodel` file:
|
||||
|
||||
```sh
|
||||
mo --input_model <INPUT_MODEL>.pdmodel
|
||||
```
|
||||
**For example,** this command converts a yolo v3 PaddlePaddle network to OpenVINO IR network:
|
||||
|
||||
### Example of Converting a PaddlePaddle Model
|
||||
Below is the example command to convert yolo v3 PaddlePaddle network to OpenVINO IR network with Model Optimizer.
|
||||
|
||||
```sh
|
||||
mo --input_model=yolov3.pdmodel --input=image,im_shape,scale_factor --input_shape=[1,3,608,608],[1,2],[1,2] --reverse_input_channels --output=save_infer_model/scale_0.tmp_1,save_infer_model/scale_1.tmp_1
|
||||
```
|
||||
|
||||
## Supported PaddlePaddle Layers
|
||||
For the list of supported standard layers, refer to the [Supported Framework Layers](../Supported_Frameworks_Layers.md) page.
|
||||
|
||||
## Officially Supported PaddlePaddle Models
|
||||
The following PaddlePaddle models have been officially validated and confirmed to work (as of OpenVINO 2022.1):
|
||||
|
||||
@sphinxdirective
|
||||
.. list-table::
|
||||
:widths: 20 25 55
|
||||
:header-rows: 1
|
||||
|
||||
* - Model Name
|
||||
- Model Type
|
||||
- Description
|
||||
* - ppocr-det
|
||||
- optical character recognition
|
||||
- Models are exported from `PaddleOCR <https://github.com/PaddlePaddle/PaddleOCR/tree/release/2.1/>`_. Refer to `READ.md <https://github.com/PaddlePaddle/PaddleOCR/tree/release/2.1/#pp-ocr-20-series-model-listupdate-on-dec-15>`_.
|
||||
* - ppocr-rec
|
||||
- optical character recognition
|
||||
- Models are exported from `PaddleOCR <https://github.com/PaddlePaddle/PaddleOCR/tree/release/2.1/>`_. Refer to `READ.md <https://github.com/PaddlePaddle/PaddleOCR/tree/release/2.1/#pp-ocr-20-series-model-listupdate-on-dec-15>`_.
|
||||
* - ResNet-50
|
||||
- classification
|
||||
- Models are exported from `PaddleClas <https://github.com/PaddlePaddle/PaddleClas/tree/release/2.1/>`_. Refer to `getting_started_en.md <https://github.com/PaddlePaddle/PaddleClas/blob/release/2.1/docs/en/tutorials/getting_started_en.md#4-use-the-inference-model-to-predict>`_.
|
||||
* - MobileNet v2
|
||||
- classification
|
||||
- Models are exported from `PaddleClas <https://github.com/PaddlePaddle/PaddleClas/tree/release/2.1/>`_. Refer to `getting_started_en.md <https://github.com/PaddlePaddle/PaddleClas/blob/release/2.1/docs/en/tutorials/getting_started_en.md#4-use-the-inference-model-to-predict>`_.
|
||||
* - MobileNet v3
|
||||
- classification
|
||||
- Models are exported from `PaddleClas <https://github.com/PaddlePaddle/PaddleClas/tree/release/2.1/)>`_. Refer to `getting_started_en.md <https://github.com/PaddlePaddle/PaddleClas/blob/release/2.1/docs/en/tutorials/getting_started_en.md#4-use-the-inference-model-to-predict>`_.
|
||||
* - BiSeNet v2
|
||||
- semantic segmentation
|
||||
- Models are exported from `PaddleSeg <https://github.com/PaddlePaddle/PaddleSeg/tree/release/2.1>`_. Refer to `model_export.md <https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.1/docs/model_export.md#>`_.
|
||||
* - DeepLab v3 plus
|
||||
- semantic segmentation
|
||||
- Models are exported from `PaddleSeg <https://github.com/PaddlePaddle/PaddleSeg/tree/release/2.1>`_. Refer to `model_export.md <https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.1/docs/model_export.md#>`_.
|
||||
* - Fast-SCNN
|
||||
- semantic segmentation
|
||||
- Models are exported from `PaddleSeg <https://github.com/PaddlePaddle/PaddleSeg/tree/release/2.1>`_. Refer to `model_export.md <https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.1/docs/model_export.md#>`_.
|
||||
* - OCRNET
|
||||
- semantic segmentation
|
||||
- Models are exported from `PaddleSeg <https://github.com/PaddlePaddle/PaddleSeg/tree/release/2.1>`_. Refer to `model_export.md <https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.1/docs/model_export.md#>`_.
|
||||
* - Yolo v3
|
||||
- detection
|
||||
- Models are exported from `PaddleDetection <https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.1>`_. Refer to `EXPORT_MODEL.md <https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/deploy/EXPORT_MODEL.md#>`_.
|
||||
* - ppyolo
|
||||
- detection
|
||||
- Models are exported from `PaddleDetection <https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.1>`_. Refer to `EXPORT_MODEL.md <https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.1/deploy/EXPORT_MODEL.md#>`_.
|
||||
* - MobileNetv3-SSD
|
||||
- detection
|
||||
- Models are exported from `PaddleDetection <https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.2>`_. Refer to `EXPORT_MODEL.md <https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.2/deploy/EXPORT_MODEL.md#>`_.
|
||||
* - U-Net
|
||||
- semantic segmentation
|
||||
- Models are exported from `PaddleSeg <https://github.com/PaddlePaddle/PaddleSeg/tree/release/2.3>`_. Refer to `model_export.md <https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.3/docs/model_export.md#>`_.
|
||||
* - BERT
|
||||
- language representation
|
||||
- Models are exported from `PaddleNLP <https://github.com/PaddlePaddle/PaddleNLP/tree/v2.1.1>`_. Refer to `README.md <https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/language_model/bert#readme>`_.
|
||||
@endsphinxdirective
|
||||
Refer to [Supported Framework Layers](../Supported_Frameworks_Layers.md) for the list of supported standard layers.
|
||||
|
||||
## Frequently Asked Questions (FAQ)
|
||||
When Model Optimizer is unable to run to completion due to typographical errors, incorrectly used options, or other issues, it provides explanatory messages. They describe the potential cause of the problem and give a link to the [Model Optimizer FAQ](../Model_Optimizer_FAQ.md), which provides instructions on how to resolve most issues. The FAQ also includes links to relevant sections in the Model Optimizer Developer Guide to help you understand what went wrong.
|
||||
|
||||
When Model Optimizer is unable to run to completion due to issues like typographical errors, incorrectly used options, etc., it provides explanatory messages. They describe the potential cause of the problem and give a link to the [Model Optimizer FAQ](../Model_Optimizer_FAQ.md), which provides instructions on how to resolve most issues. The FAQ also includes links to relevant sections in the Model Optimizer Developer Guide to help you understand what went wrong.
|
||||
|
||||
## See Also
|
||||
[Model Conversion Tutorials](Convert_Model_Tutorials.md)
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
# Converting a PyTorch Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_PyTorch}
|
||||
# Converting a PyTorch* Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_PyTorch}
|
||||
|
||||
The PyTorch framework is supported through export to the ONNX format. In order to optimize and deploy a model that was trained with it:
|
||||
## Typical Steps to Convert PyTorch Model <a name="typical-pytorch"></a>
|
||||
PyTorch* framework is supported through export to ONNX\* format. A summary of the steps for optimizing and deploying a model that was trained with the PyTorch\* framework:
|
||||
|
||||
1. [Export a PyTorch model to ONNX](#export-to-onnx).
|
||||
2. [Convert the ONNX model](Convert_Model_From_ONNX.md) to produce an optimized [Intermediate Representation](../../IR_and_opsets.md) of the model based on the trained network topology, weights, and biases values.
|
||||
1. [Export PyTorch model to ONNX\*](#export-to-onnx).
|
||||
2. [Convert an ONNX\* model](Convert_Model_From_ONNX.md) to produce an optimized [Intermediate Representation (IR)](../../IR_and_opsets.md) of the model based on the trained network topology, weights, and biases values.
|
||||
|
||||
## Exporting a PyTorch Model to ONNX Format <a name="export-to-onnx"></a>
|
||||
PyTorch models are defined in Python. To export them, use the `torch.onnx.export()` method. The code to
|
||||
evaluate or test the model is usually provided with its code and can be used for its initialization and export.
|
||||
The export to ONNX is crucial for this process, but it is covered by PyTorch framework, therefore, It will not be covered here in detail.
|
||||
For more information, refer to the [Exporting PyTorch models to ONNX format](https://pytorch.org/docs/stable/onnx.html) guide.
|
||||
## Export PyTorch\* Model to ONNX\* Format <a name="export-to-onnx"></a>
|
||||
PyTorch models are defined in a Python\* code, to export such models use `torch.onnx.export()` method. Usually code to
|
||||
evaluate or test the model is provided with the model code and can be used to initialize and export model.
|
||||
Only the basics will be covered here, the step to export to ONNX\* is crucial but it is covered by PyTorch\* framework.
|
||||
For more information, please refer to [Exporting PyTorch models to ONNX format](https://pytorch.org/docs/stable/onnx.html).
|
||||
|
||||
To export a PyTorch model, you need to obtain the model as an instance of `torch.nn.Module` class and call the `export` function.
|
||||
To export a PyTorch\* model you need to obtain the model as an instance of `torch.nn.Module` class and call the `export` function.
|
||||
|
||||
```python
|
||||
import torch
|
||||
@@ -28,9 +29,9 @@ torch.onnx.export(model, (dummy_input, ), 'model.onnx')
|
||||
|
||||
## Known Issues
|
||||
|
||||
* As of version 1.8.1, not all PyTorch operations can be exported to ONNX opset 9 which is used by default.
|
||||
* Not all PyTorch\* operations can be exported to ONNX\* opset 9 which is used by default, as of version 1.8.1.
|
||||
It is recommended to export models to opset 11 or higher when export to default opset 9 is not working. In that case, use `opset_version`
|
||||
option of the `torch.onnx.export`. For more information about ONNX opset, refer to the [Operator Schemas](https://github.com/onnx/onnx/blob/master/docs/Operators.md) page.
|
||||
option of the `torch.onnx.export`. For more information about ONNX* opset, refer to the [Operator Schemas](https://github.com/onnx/onnx/blob/master/docs/Operators.md).
|
||||
|
||||
## See Also
|
||||
[Model Conversion Tutorials](Convert_Model_Tutorials.md)
|
||||
|
||||
@@ -1,34 +1,30 @@
|
||||
# Converting a TensorFlow Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow}
|
||||
# Converting a TensorFlow* Model {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow}
|
||||
|
||||
This page provides general instructions on how to convert a model from a TensorFlow format to the OpenVINO IR format using Model Optimizer. The instructions are different depending on whether your model was created with TensorFlow v1.X or TensorFlow v2.X.
|
||||
## Convert TensorFlow 1 Models <a name="Convert_From_TF2X"></a>
|
||||
|
||||
To use Model Optimizer, install OpenVINO Development Tools by following the [installation instructions](../../../install_guides/installing-model-dev-tools.md).
|
||||
|
||||
## Converting TensorFlow 1 Models <a name="Convert_From_TF2X"></a>
|
||||
|
||||
### Converting Frozen Model Format <a name="Convert_From_TF"></a>
|
||||
To convert a TensorFlow model, use the *`mo`* script to simply convert a model with a path to the input model *`.pb`* file:
|
||||
### Convert Frozen Model Format <a name="Convert_From_TF"></a>
|
||||
To convert a TensorFlow model, use the `mo` script to simply convert a model with the path to the input model `.pb` file:
|
||||
|
||||
```sh
|
||||
mo --input_model <INPUT_MODEL>.pb
|
||||
```
|
||||
|
||||
### Converting Non-Frozen Model Formats <a name="loading-nonfrozen-models"></a>
|
||||
### Convert Non-Frozen Model Formats <a name="loading-nonfrozen-models"></a>
|
||||
There are three ways to store non-frozen TensorFlow models and convert them by Model Optimizer:
|
||||
|
||||
1. **Checkpoint**. In this case, a model consists of two files: `inference_graph.pb` (or `inference_graph.pbtxt`) and `checkpoint_file.ckpt`.
|
||||
If you do not have an inference graph file, refer to the [Freezing Custom Models in Python](#freeze-the-tensorflow-model) section.
|
||||
To convert the model with the inference graph in `.pb` format, run the `mo` script with a path to the checkpoint file:
|
||||
If you do not have an inference graph file, refer to [Freezing Custom Models in Python](#freeze-the-tensorflow-model).
|
||||
To convert the model with the inference graph in `.pb` format, run the `mo` script with the path to the checkpoint file to convert a model:
|
||||
```sh
|
||||
mo --input_model <INFERENCE_GRAPH>.pb --input_checkpoint <INPUT_CHECKPOINT>
|
||||
```
|
||||
To convert the model with the inference graph in `.pbtxt` format, run the `mo` script with a path to the checkpoint file:
|
||||
To convert the model with the inference graph in `.pbtxt` format, run the `mo` script with the path to the checkpoint file to convert a model:
|
||||
```sh
|
||||
mo --input_model <INFERENCE_GRAPH>.pbtxt --input_checkpoint <INPUT_CHECKPOINT> --input_model_is_text
|
||||
```
|
||||
|
||||
2. **MetaGraph**. In this case, a model consists of three or four files stored in the same directory: `model_name.meta`, `model_name.index`,
|
||||
`model_name.data-00000-of-00001` (the numbers may vary), and `checkpoint` (optional).
|
||||
`model_name.data-00000-of-00001` (digit part may vary), and `checkpoint` (optional).
|
||||
To convert such TensorFlow model, run the `mo` script with a path to the MetaGraph `.meta` file:
|
||||
```sh
|
||||
mo --input_meta_graph <INPUT_META_GRAPH>.meta
|
||||
@@ -46,10 +42,11 @@ If a model contains operations currently unsupported by OpenVINO, prune these op
|
||||
To determine custom input nodes, display a graph of the model in TensorBoard. To generate TensorBoard logs of the graph, use the `--tensorboard_logs` option.
|
||||
TensorFlow 2.x SavedModel format has a specific graph due to eager execution. In case of pruning, find custom input nodes in the `StatefulPartitionedCall/*` subgraph of TensorFlow 2.x SavedModel format.
|
||||
|
||||
### Freezing Custom Models in Python <a name="freeze-the-tensorflow-model"></a>
|
||||
When a network is defined in Python code, you have to create an inference graph file. Graphs are usually built in a form
|
||||
that allows model training. That means all trainable parameters are represented as variables in the graph.
|
||||
To be able to use such graph with Model Optimizer, it should be frozen and dumped to a file with the following code:
|
||||
### Freezing Custom Models in Python\* <a name="freeze-the-tensorflow-model"></a>
|
||||
When a network is defined in Python\* code, you have to create an inference graph file. Usually graphs are built in a form
|
||||
that allows model training. That means that all trainable parameters are represented as variables in the graph.
|
||||
To be able to use such graph with Model Optimizer such graph should be frozen.
|
||||
The graph is frozen and dumped to a file with the following code:
|
||||
|
||||
```python
|
||||
import tensorflow as tf
|
||||
@@ -60,18 +57,18 @@ graph_io.write_graph(frozen, './', 'inference_graph.pb', as_text=False)
|
||||
|
||||
Where:
|
||||
|
||||
* `sess` is the instance of the TensorFlow Session object where the network topology is defined.
|
||||
* `sess` is the instance of the TensorFlow\* Session object where the network topology is defined.
|
||||
* `["name_of_the_output_node"]` is the list of output node names in the graph; `frozen` graph will
|
||||
include only those nodes from the original `sess.graph_def` that are directly or indirectly used
|
||||
to compute given output nodes. The `'name_of_the_output_node'` is an example of a possible output
|
||||
to compute given output nodes. `'name_of_the_output_node'` here is an example of possible output
|
||||
node name. You should derive the names based on your own graph.
|
||||
* `./` is the directory where the inference graph file should be generated.
|
||||
* `inference_graph.pb` is the name of the generated inference graph file.
|
||||
* `as_text` specifies whether the generated file should be in human readable text format or binary.
|
||||
|
||||
## Converting TensorFlow 2 Models <a name="Convert_From_TF2X"></a>
|
||||
To convert TensorFlow 2 models, ensure that `openvino-dev[tensorflow2]` is installed via `pip`.
|
||||
TensorFlow 2.X officially supports two model formats: SavedModel and Keras H5 (or HDF5).
|
||||
## Convert TensorFlow 2 Models <a name="Convert_From_TF2X"></a>
|
||||
To convert TensorFlow* 2 models, ensure that `openvino-dev[tensorflow2]` is installed via `pip`.
|
||||
TensorFlow* 2.X officially supports two model formats: SavedModel and Keras H5 (or HDF5).
|
||||
Below are the instructions on how to convert each of them.
|
||||
|
||||
### SavedModel Format
|
||||
@@ -82,7 +79,7 @@ To convert such a model, run the `mo` script with a path to the SavedModel direc
|
||||
mo --saved_model_dir <SAVED_MODEL_DIRECTORY>
|
||||
```
|
||||
|
||||
TensorFlow 2 SavedModel format strictly requires the 2.x version of TensorFlow installed in the
|
||||
TensorFlow* 2 SavedModel format strictly requires the 2.x version of TensorFlow installed in the
|
||||
environment for conversion to the Intermediate Representation (IR).
|
||||
|
||||
If a model contains operations currently unsupported by OpenVINO™,
|
||||
@@ -92,11 +89,11 @@ options. To determine custom input nodes, visualize a model graph in the TensorB
|
||||
To generate TensorBoard logs of the graph, use the Model Optimizer `--tensorboard_logs` command-line
|
||||
option.
|
||||
|
||||
TensorFlow 2 SavedModel format has a specific graph structure due to eager execution. In case of
|
||||
TensorFlow* 2 SavedModel format has a specific graph structure due to eager execution. In case of
|
||||
pruning, find custom input nodes in the `StatefulPartitionedCall/*` subgraph.
|
||||
|
||||
### Keras H5
|
||||
If you have a model in the HDF5 format, load the model using TensorFlow 2 and serialize it in the
|
||||
If you have a model in the HDF5 format, load the model using TensorFlow* 2 and serialize it in the
|
||||
SavedModel format. Here is an example of how to do it:
|
||||
|
||||
```python
|
||||
@@ -117,9 +114,9 @@ tf.saved_model.save(model,'model')
|
||||
|
||||
Then follow the above instructions for the SavedModel format.
|
||||
|
||||
> **NOTE**: Do not use other hacks to resave TensorFlow 2 models into TensorFlow 1 formats.
|
||||
> **NOTE**: Do not use other hacks to resave TensorFlow* 2 models into TensorFlow* 1 formats.
|
||||
|
||||
## Command-Line Interface (CLI) Examples Using TensorFlow-Specific Parameters
|
||||
## Command-Line Interface (CLI) Examples Using TensorFlow\*-Specific Parameters
|
||||
* Launching the Model Optimizer for Inception V1 frozen model when model file is a plain text protobuf:
|
||||
|
||||
```sh
|
||||
@@ -132,30 +129,26 @@ Then follow the above instructions for the SavedModel format.
|
||||
mo --input_model inception_v1.pb -b 1 --tensorboard_logdir /tmp/log_dir
|
||||
```
|
||||
|
||||
* Launching the Model Optimizer for BERT model in the SavedModel format, with three inputs. Specify explicitly the input shapes
|
||||
* Launching the Model Optimizer for BERT model in the SavedModel format, with three inputs. Explicitly specify input shapes
|
||||
where the batch size and the sequence length equal 2 and 30 respectively.
|
||||
|
||||
```sh
|
||||
mo --saved_model_dir BERT --input mask,word_ids,type_ids --input_shape [2,30],[2,30],[2,30]
|
||||
```
|
||||
|
||||
## Supported TensorFlow and TensorFlow 2 Keras Layers
|
||||
For the list of supported standard layers, refer to the [Supported Framework Layers ](../Supported_Frameworks_Layers.md) page.
|
||||
## Supported TensorFlow\* and TensorFlow 2 Keras\* Layers
|
||||
Refer to [Supported Framework Layers ](../Supported_Frameworks_Layers.md) for the list of supported standard layers.
|
||||
|
||||
## Frequently Asked Questions (FAQ)
|
||||
The Model Optimizer provides explanatory messages if it is unable to run to completion due to typographical errors, incorrectly used options, or other issues. The message describes the potential cause of the problem and gives a link to the [Model Optimizer FAQ](../Model_Optimizer_FAQ.md). The FAQ provides instructions on how to resolve most issues. The FAQ also includes links to relevant sections in the Model Optimizer Developer Guide to help you understand what went wrong.
|
||||
The Model Optimizer provides explanatory messages if it is unable to run to completion due to issues like typographical errors, incorrectly used options, or other issues. The message describes the potential cause of the problem and gives a link to the [Model Optimizer FAQ](../Model_Optimizer_FAQ.md). The FAQ has instructions on how to resolve most issues. The FAQ also includes links to relevant sections in the Model Optimizer Developer Guide to help you understand what went wrong.
|
||||
|
||||
## Summary
|
||||
In this document, you learned:
|
||||
|
||||
* Basic information about how the Model Optimizer works with TensorFlow models.
|
||||
* Which TensorFlow models are supported.
|
||||
* How to freeze a TensorFlow model.
|
||||
* How to convert a trained TensorFlow model using the Model Optimizer with both framework-agnostic and TensorFlow-specific command-line options.
|
||||
|
||||
## Additional Resources
|
||||
For step-by-step instructions on how to convert specific TensorFlow models, see the [Model Conversion Tutorials](Convert_Model_Tutorials.md) page. Here are some examples:
|
||||
* [Convert TensorFlow EfficientDet Models](tf_specific/Convert_EfficientDet_Models.md)
|
||||
* [Convert TensorFlow FaceNet Models](tf_specific/Convert_FaceNet_From_Tensorflow.md)
|
||||
* [Convert TensorFlow Object Detection API Models](tf_specific/Convert_Object_Detection_API_Models.md)
|
||||
* Basic information about how the Model Optimizer works with TensorFlow models
|
||||
* Which TensorFlow models are supported
|
||||
* How to freeze a TensorFlow model
|
||||
* How to convert a trained TensorFlow model using the Model Optimizer with both framework-agnostic and TensorFlow-specific command-line options
|
||||
|
||||
## See Also
|
||||
[Model Conversion Tutorials](Convert_Model_Tutorials.md)
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
This section provides a set of tutorials that demonstrate conversion methods for specific TensorFlow, ONNX, PyTorch, MXNet, and Kaldi models, that unnecessarily cover your case.
|
||||
Before studying the tutorials, try to convert the model out-of-the-box by specifying only the `--input_model` parameter in the command line.
|
||||
This section provides you with a set of tutorials that demonstrate conversion steps for specific TensorFlow, ONNX, PyTorch, MXNet, and Kaldi models.
|
||||
It contains conversion recipes for concrete models, that unnecessarily cover your case.
|
||||
Try to convert the model out-of-the-box, meaning only the `--input_model` parameter is specified in the command line, before studying the tutorials.
|
||||
|
||||
You will find a collection of [Python tutorials](../../../tutorials.md) written for running on Jupyter notebooks that provide an introduction to the OpenVINO™ toolkit and explain how to use the Python API and tools for optimized deep learning inference.
|
||||
You can also find a collection of [Python tutorials](../../../tutorials.md) written for running on Jupyter* notebooks that provide an introduction to the OpenVINO™ toolkit and explain how to use the Python API and tools for optimized deep learning inference.
|
||||
|
||||
@@ -1,50 +1,51 @@
|
||||
# Setting Input Shapes {#openvino_docs_MO_DG_prepare_model_convert_model_Converting_Model}
|
||||
|
||||
With Model Optimizer you can increase your model's efficiency by providing an additional shape definition, with these two parameters: `--input_shape` and `--static_shape`.
|
||||
Paragraphs below provide details about specifying input shapes for model conversion.
|
||||
|
||||
@anchor when_to_specify_input_shapes
|
||||
## Specifying --input_shape Command-line Parameter
|
||||
## When to Specify --input_shape Command-line Parameter
|
||||
Model Optimizer supports conversion of models with dynamic input shapes that contain undefined dimensions.
|
||||
However, if the shape of data is not going to change from one inference request to another,
|
||||
However, if the shape of inference data is not going to change from one inference request to another,
|
||||
it is recommended to set up static shapes (when all dimensions are fully defined) for the inputs.
|
||||
Doing it at this stage, instead of during inference in runtime, can be beneficial in terms of performance and memory consumption.
|
||||
It can be beneficial from a performance perspective and memory consumption.
|
||||
To set up static shapes, Model Optimizer provides the `--input_shape` parameter.
|
||||
For more information on input shapes under runtime, refer to the [Changing input shapes](../../../OV_Runtime_UG/ShapeInference.md) guide.
|
||||
To learn more about dynamic shapes in runtime, refer to the [Dynamic Shapes](../../../OV_Runtime_UG/ov_dynamic_shapes.md) guide.
|
||||
This is an offline approach to set static shapes and it can save time and memory on runtime shape change.
|
||||
To learn more about runtime shape change please see a dedicated article about [reshape feature](../../../OV_Runtime_UG/ShapeInference.md).
|
||||
For more information about the dynamic shapes, refer to [Dynamic Shapes](../../../OV_Runtime_UG/ov_dynamic_shapes.md)
|
||||
|
||||
The OpenVINO Runtime API may present certain limitations in inferring models with undefined dimensions on some hardware. See the [Features support matrix](../../../OV_Runtime_UG/supported_plugins/Device_Plugins.md) for reference.
|
||||
In this case, the `--input_shape` parameter and the [reshape method](../../../OV_Runtime_UG/ShapeInference.md) can help to resolve undefined dimensions.
|
||||
OpenVINO Runtime API can have limitations to infer models with undefined dimensions on some hardware (see [Features support matrix](../../../OV_Runtime_UG/supported_plugins/Device_Plugins.md) for reference).
|
||||
In this case, the `--input_shape` parameter and the [reshape method](../../../OV_Runtime_UG/ShapeInference.md) can help resolving undefined dimensions.
|
||||
|
||||
Sometimes, Model Optimizer is unable to convert models out-of-the-box (only the `--input_model` parameter is specified).
|
||||
Sometimes Model Optimizer is unable to convert models out-of-the-box (only the `--input_model` parameter is specified).
|
||||
Such problem can relate to models with inputs of undefined ranks and a case of cutting off parts of a model.
|
||||
In this case, input shapes must be specified explicitly with the `--input_shape` parameter.
|
||||
In this case, user has to specify input shapes explicitly using `--input_shape` parameter.
|
||||
|
||||
For example, run Model Optimizer for the TensorFlow MobileNet model with the single input
|
||||
and specify the input shape of `[2,300,300,3]`:
|
||||
For example, run the Model Optimizer for the TensorFlow* MobileNet model with the single input
|
||||
and specify input shape `[2,300,300,3]`.
|
||||
|
||||
```sh
|
||||
mo --input_model MobileNet.pb --input_shape [2,300,300,3]
|
||||
```
|
||||
|
||||
If a model has multiple inputs, `--input_shape` must be used in conjunction with `--input` parameter.
|
||||
The `--input` parameter contains a list of input names, for which shapes in the same order are defined via `--input_shape`.
|
||||
For example, launch Model Optimizer for the ONNX OCR model with a pair of inputs `data` and `seq_len`
|
||||
and specify shapes `[3,150,200,1]` and `[3]` for them:
|
||||
The parameter `--input` contains a list of input names for which shapes in the same order are defined via `--input_shape`.
|
||||
For example, launch the Model Optimizer for the ONNX* OCR model with a pair of inputs `data` and `seq_len`
|
||||
and specify shapes `[3,150,200,1]` and `[3]` for them.
|
||||
|
||||
```sh
|
||||
mo --input_model ocr.onnx --input data,seq_len --input_shape [3,150,200,1],[3]
|
||||
```
|
||||
|
||||
Alternatively, specify input shapes, using the `--input` parameter as follows:
|
||||
The alternative way to specify input shapes is to use the `--input` parameter as follows:
|
||||
|
||||
```sh
|
||||
mo --input_model ocr.onnx --input data[3 150 200 1],seq_len[3]
|
||||
```
|
||||
|
||||
The `--input_shape` parameter allows overriding original input shapes to ones compatible with a given model.
|
||||
Dynamic shapes, i.e. with dynamic dimensions, can be replaced in the original model with static shapes for the converted model, and vice versa.
|
||||
The dynamic dimension can be marked in Model Optimizer command-line as `-1`* or *`?`.
|
||||
For example, launch Model Optimizer for the ONNX OCR model and specify dynamic batch dimension for inputs:
|
||||
The parameter `--input_shape` allows overriding original input shapes to the shapes compatible with a given model.
|
||||
Dynamic shapes, i.e. with dynamic dimensions, in the original model can be replaced with static shapes for the converted model, and vice versa.
|
||||
The dynamic dimension can be marked in Model Optimizer command-line as `-1` or `?`.
|
||||
For example, launch the Model Optimizer for the ONNX* OCR model and specify dynamic batch dimension for inputs.
|
||||
|
||||
```sh
|
||||
mo --input_model ocr.onnx --input data,seq_len --input_shape [-1,150,200,1],[-1]
|
||||
@@ -52,7 +53,7 @@ mo --input_model ocr.onnx --input data,seq_len --input_shape [-1,150,200,1],[-1]
|
||||
|
||||
To optimize memory consumption for models with undefined dimensions in run-time, Model Optimizer provides the capability to define boundaries of dimensions.
|
||||
The boundaries of undefined dimension can be specified with ellipsis.
|
||||
For example, launch Model Optimizer for the ONNX OCR model and specify a boundary for the batch dimension:
|
||||
For example, launch the Model Optimizer for the ONNX* OCR model and specify a boundary for the batch dimension.
|
||||
|
||||
```sh
|
||||
mo --input_model ocr.onnx --input data,seq_len --input_shape [1..3,150,200,1],[1..3]
|
||||
@@ -60,20 +61,20 @@ mo --input_model ocr.onnx --input data,seq_len --input_shape [1..3,150,200,1],[1
|
||||
|
||||
Practically, some models are not ready for input shapes change.
|
||||
In this case, a new input shape cannot be set via Model Optimizer.
|
||||
For more information about shape follow the [inference troubleshooting](@ref troubleshooting_reshape_errors) and [ways to relax shape inference flow](@ref how-to-fix-non-reshape-able-model) guides.
|
||||
Learn more about shape [inference troubleshooting](@ref troubleshooting_reshape_errors) and [ways to relax shape inference flow](@ref how-to-fix-non-reshape-able-model).
|
||||
|
||||
## Specifying --static_shape Command-line Parameter
|
||||
## When to Specify --static_shape Command-line Parameter
|
||||
Model Optimizer provides the `--static_shape` parameter that allows evaluating shapes of all operations in the model for fixed input shapes
|
||||
and folding shape computing sub-graphs into constants. The resulting IR may be more compact in size and the loading time for such IR may decrease.
|
||||
and to fold shape computing sub-graphs into constants. The resulting IR can be more compact in size and the loading time for such IR can be decreased.
|
||||
However, the resulting IR will not be reshape-able with the help of the [reshape method](../../../OV_Runtime_UG/ShapeInference.md) from OpenVINO Runtime API.
|
||||
It is worth noting that the `--input_shape` parameter does not affect reshapeability of the model.
|
||||
It is worth noting that the `--input_shape` parameter does not affect reshape-ability of the model.
|
||||
|
||||
For example, launch Model Optimizer for the ONNX OCR model using `--static_shape`:
|
||||
For example, launch the Model Optimizer for the ONNX* OCR model using `--static_shape`.
|
||||
|
||||
```sh
|
||||
mo --input_model ocr.onnx --input data[3 150 200 1],seq_len[3] --static_shape
|
||||
```
|
||||
|
||||
## Additional Resources
|
||||
* [Introduction to converting models with Model Optimizer](../../Deep_Learning_Model_Optimizer_DevGuide.md)
|
||||
## See Also
|
||||
* [Introduction](../../Deep_Learning_Model_Optimizer_DevGuide.md)
|
||||
* [Cutting Off Parts of a Model](Cutting_Model.md)
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# Cutting Off Parts of a Model {#openvino_docs_MO_DG_prepare_model_convert_model_Cutting_Model}
|
||||
|
||||
Sometimes, it is necessary to remove parts of a model when converting it to OpenVINO IR. This chapter describes how to do it, using Model Optimizer command-line options. Model cutting applies mostly to TensorFlow models, which is why TensorFlow will be used in this chapter's examples, but it may be also useful for other frameworks.
|
||||
Sometimes some parts of a model must be removed while the Model Optimizer is converting models to the Intermediate Representation. This chapter describes methods of doing cutting off parts of a model using Model Optimizer command-line options. Model cutting applies mostly to TensorFlow\* models, but is also useful for other frameworks. In this chapter, TensorFlow examples are used for illustration.
|
||||
|
||||
## Purpose of Model Cutting
|
||||
|
||||
The following examples are the situations when model cutting is useful or even required:
|
||||
|
||||
* A model has pre- or post-processing parts that cannot be translated to existing OpenVINO operations.
|
||||
* A model has a training part that is convenient to be kept in the model but not used during inference.
|
||||
* A model is too complex be converted at once, because it contains a lot of unsupported operations that cannot be easily implemented as custom layers.
|
||||
* A problem occurs with model conversion in Model Optimizer or inference in OpenVINO™ Runtime. To identify the issue, limit the conversion scope by iterative search for problematic areas in the model.
|
||||
* A single custom layer or a combination of custom layers is isolated for debugging purposes.
|
||||
* model has pre- or post-processing parts that cannot be translated to existing OpenVINO operations.
|
||||
* model has a training part that is convenient to be kept in the model, but not used during inference.
|
||||
* model is too complex (contains lots of unsupported operations that cannot be easily implemented as custom layers), so the complete model cannot be converted in one shot.
|
||||
* problem with model conversion in the Model Optimizer or inference in the OpenVINO Runtime occurred. To localize the issue, limit the scope for conversion by iteratively searching for problematic places in the model.
|
||||
* single custom layer or a combination of custom layers is isolated for debugging purposes.
|
||||
|
||||
## Command-Line Options
|
||||
|
||||
@@ -19,21 +19,21 @@ Model Optimizer provides command line options `--input` and `--output` to specif
|
||||
* `--input` option accepts a comma-separated list of layer names of the input model that should be treated as new entry points to the model.
|
||||
* `--output` option accepts a comma-separated list of layer names of the input model that should be treated as new exit points from the model.
|
||||
|
||||
The `--input` option is required for cases unrelated to model cutting. For example, when the model contains several inputs and `--input_shape` or `--mean_values` options are used, the `--input` option specifies the order of input nodes for correct mapping between multiple items provided in `--input_shape` and `--mean_values` and the inputs in the model.
|
||||
The `--input` option is required for cases unrelated to model cutting. For example, when the model contains several inputs and `--input_shape` or `--mean_values` options are used, you should use the `--input` option to specify the order of input nodes for correct mapping between multiple items provided in `--input_shape` and `--mean_values` and the inputs in the model. Details on these options are out of scope for this document, which focuses on model cutting.
|
||||
|
||||
Model cutting is illustrated with the Inception V1 model, found in the `models/research/slim` repository. To proceed with this chapter, make sure you do the necessary steps to [prepare the model for Model Optimizer](Converting_Model.md).
|
||||
Model cutting is illustrated with Inception V1. This model is in `models/research/slim` repository. [This section](Converting_Model.md) describes pre-work to prepare the model for the Model Optimizer to be ready to proceed with this chapter.
|
||||
|
||||
## Default Behavior without --input and --output
|
||||
|
||||
The input model is converted as a whole if neither `--input` nor `--output` command line options are used. All `Placeholder` operations in a TensorFlow graph are automatically identified as entry points. The `Input` layer type is generated for each of them. All nodes that have no consumers are automatically identified as exit points.
|
||||
The input model is converted as a whole if neither `--input` nor `--output` command line options are used. All `Placeholder` operations in a TensorFlow\* graph are automatically identified as entry points. The `Input` layer type is generated for each of them. All nodes that have no consumers are automatically identified as exit points.
|
||||
|
||||
For Inception_V1, there is one `Placeholder`: input. If the model is viewed in TensorBoard, the input operation is easy to find:
|
||||
For Inception_V1, there is one `Placeholder`: input. If the model is viewed in the TensorBoard\*, the input operation is easy to find:
|
||||
|
||||

|
||||
|
||||
`Reshape` is the only output operation, which is enclosed in a nested name scope of `InceptionV1/Logits/Predictions`, under the full name of `InceptionV1/Logits/Predictions/Reshape_1`.
|
||||
There is only one output operation, which enclosed in a nested name scope `InceptionV1/Logits/Predictions`, the `Reshape` operation has a full name `InceptionV1/Logits/Predictions/Reshape_1`.
|
||||
|
||||
In TensorBoard, along with some of its predecessors, it looks as follows:
|
||||
In the TensorBoard, it looks the following way together with some predecessors:
|
||||
|
||||

|
||||
|
||||
@@ -41,7 +41,7 @@ Convert this model and put the results in a writable output directory:
|
||||
```sh
|
||||
mo --input_model inception_v1.pb -b 1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
(The other examples on this page assume that you first go to the `model_optimizer` directory and add the `--output_dir` argument with a directory where you have read/write permissions.)
|
||||
(The other examples on this page assume that you first cd to the `model_optimizer` directory and add the `--output_dir` argument with a directory where you have write permissions.)
|
||||
|
||||
The output `.xml` file with an Intermediate Representation contains the `Input` layer among other layers in the model:
|
||||
```xml
|
||||
@@ -78,7 +78,7 @@ The last layer in the model is `InceptionV1/Logits/Predictions/Reshape_1`, which
|
||||
</output>
|
||||
</layer>
|
||||
```
|
||||
Due to automatic identification of inputs and outputs, providing the `--input` and `--output` options to convert the whole model is not required. The following commands are equivalent for the Inception V1 model:
|
||||
Due to automatic identification of inputs and outputs, you do not need to provide the `--input` and `--output` options to convert the whole model. The following commands are equivalent for the Inception V1 model:
|
||||
```sh
|
||||
mo --input_model inception_v1.pb -b 1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
|
||||
@@ -88,7 +88,7 @@ The Intermediate Representations are identical for both conversions. The same is
|
||||
|
||||
## Model Cutting
|
||||
|
||||
Now, consider how to cut some parts of the model off. This chapter describes the first convolution block `InceptionV1/InceptionV1/Conv2d_1a_7x7` of the Inception V1 model to illustrate cutting:
|
||||
Now consider how to cut some parts of the model off. This chapter uses the first convolution block `InceptionV1/InceptionV1/Conv2d_1a_7x7` of the Inception V1 model to illustrate cutting:
|
||||
|
||||

|
||||
|
||||
@@ -138,7 +138,7 @@ If you want to cut your model at the end, you have the following options:
|
||||
</edges>
|
||||
</net>
|
||||
```
|
||||
As shown in the TensorBoard picture, the original model has more nodes than its Intermediate Representation. Model Optimizer has fused batch normalization `InceptionV1/InceptionV1/Conv2d_1a_7x7/BatchNorm` with convolution `InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution`, which is why it is not present in the final model. This is not an effect of the `--output` option, it is the typical behavior of Model Optimizer for batch normalizations and convolutions. The effect of the `--output` is that the `ReLU` layer becomes the last one in the converted model.
|
||||
As you can see in the TensorBoard picture, the original model has more nodes than Intermediate Representation. Model Optimizer has fused batch normalization `InceptionV1/InceptionV1/Conv2d_1a_7x7/BatchNorm` to the convolution `InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution`, and it is not present in the final Intermediate Representation. This is not an effect of the `--output` option, it is usual behavior of the Model Optimizer for batch normalizations and convolutions. The effect of the `--output` is that the `ReLU` layer becomes the last one in the converted model.
|
||||
|
||||
2. The following command cuts the edge that comes from 0 output port of the `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` and the rest of the model, making this node the last one in the model:
|
||||
```sh
|
||||
@@ -182,7 +182,7 @@ If you want to cut your model at the end, you have the following options:
|
||||
</edges>
|
||||
</net>
|
||||
```
|
||||
This type of cutting is useful for cutting multiple output edges.
|
||||
This type of cutting is useful to cut edges in case of multiple output edges.
|
||||
|
||||
3. The following command cuts the edge that comes to 0 input port of the `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` and the rest of the model including `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu`, deleting this node and making the previous node `InceptionV1/InceptionV1/Conv2d_1a_7x7/Conv2D` the last in the model:
|
||||
```sh
|
||||
@@ -222,7 +222,7 @@ If you want to cut your model at the end, you have the following options:
|
||||
|
||||
If you want to go further and cut the beginning of the model, leaving only the `ReLU` layer, you have the following options:
|
||||
|
||||
1. Use the following command line, where `--input` and `--output` specify the same node in the graph:
|
||||
1. You can use the following command line, where `--input` and `--output` specify the same node in the graph:
|
||||
```sh
|
||||
mo --input_model=inception_v1.pb -b 1 --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --input InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
@@ -250,11 +250,11 @@ If you want to go further and cut the beginning of the model, leaving only the `
|
||||
</edges>
|
||||
</net>
|
||||
```
|
||||
`Input` layer is automatically created to feed the layer that is converted from the node specified in `--input`, which is `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` in this case. Model Optimizer does not replace the `ReLU` node by the `Input` layer. It produces such Intermediate Representation to make the node the first executable node in the final Intermediate Representation. Therefore, Model Optimizer creates enough `Inputs` to feed all input ports of the node that is passed in `--input`.<br>
|
||||
Even though `--input_shape` is not specified in the command line, the shapes for layers are inferred from the beginning of the original TensorFlow model to the point, at which the new input is defined. It has the same shape [1,64,112,112] as the model converted as a whole or without cutting off the beginning.
|
||||
`Input` layer is automatically created to feed the layer that is converted from the node specified in `--input`, which is `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` in this case. Model Optimizer does not replace the `ReLU` node by the `Input` layer, it produces such Intermediate Representation to make the node be the first executable node in the final Intermediate Representation. So the Model Optimizer creates enough `Inputs` to feed all input ports of the node that is passed in `--input`.<br>
|
||||
Even though `--input_shape` is not specified in the command line, the shapes for layers are inferred from the beginning of the original TensorFlow* model to the point at which the new input is defined. It has the same shape [1,64,112,112] as the model converted as a whole or without cutting off the beginning.
|
||||
|
||||
2. Cut the edge incoming to layer by port number. To specify the incoming port, use the following notation `--input=port:input_node`.
|
||||
To cut everything before `ReLU` layer, cut the edge incoming to port 0 of `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` node:
|
||||
2. You can cut edge incoming to layer by port number. To specify incoming port use notation `--input=port:input_node`.
|
||||
So, to cut everything before `ReLU` layer, cut edge incoming in port 0 of `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` node:
|
||||
```sh
|
||||
mo --input_model inception_v1.pb -b 1 --input 0:InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
@@ -282,11 +282,11 @@ To cut everything before `ReLU` layer, cut the edge incoming to port 0 of `Incep
|
||||
</edges>
|
||||
</net>
|
||||
```
|
||||
`Input` layer is automatically created to feed the layer that is converted from the node specified in `--input`, which is `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` in this case. Model Optimizer does not replace the `ReLU` node by the `Input` layer, it produces such Intermediate Representation to make the node be the first executable node in the final Intermediate Representation. Therefore, Model Optimizer creates enough `Inputs` to feed all input ports of the node that is passed in `--input`.<br>
|
||||
Even though `--input_shape` is not specified in the command line, the shapes for layers are inferred from the beginning of the original TensorFlow model to the point, at which the new input is defined. It has the same shape [1,64,112,112] as the model converted as a whole or without cutting off the beginning.
|
||||
`Input` layer is automatically created to feed the layer that is converted from the node specified in `--input`, which is `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` in this case. Model Optimizer does not replace the `ReLU` node by the `Input` layer, it produces such Intermediate Representation to make the node be the first executable node in the final Intermediate Representation. So the Model Optimizer creates enough `Inputs` to feed all input ports of the node that is passed in `--input`.<br>
|
||||
Even though `--input_shape` is not specified in the command line, the shapes for layers are inferred from the beginning of the original TensorFlow* model to the point at which the new input is defined. It has the same shape [1,64,112,112] as the model converted as a whole or without cutting off the beginning.
|
||||
|
||||
3. Cut edge outcoming from layer by port number. To specify the outcoming port, use the following notation `--input=input_node:port`.
|
||||
To cut everything before `ReLU` layer, cut edge from `InceptionV1/InceptionV1/Conv2d_1a_7x7/BatchNorm/batchnorm/add_1` node to `ReLU`:
|
||||
3. You can cut edge outcoming from layer by port number. To specify outcoming port use notation `--input=input_node:port`.
|
||||
So, to cut everything before `ReLU` layer, cut edge from `InceptionV1/InceptionV1/Conv2d_1a_7x7/BatchNorm/batchnorm/add_1` node to `ReLU`:
|
||||
```sh
|
||||
mo --input_model inception_v1.pb -b 1 --input InceptionV1/InceptionV1/Conv2d_1a_7x7/BatchNorm/batchnorm/add_1:0 --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
@@ -354,18 +354,18 @@ gives the following shapes in the `Input` and `ReLU` layers:
|
||||
</output>
|
||||
</layer>
|
||||
```
|
||||
An input shape [1,20,5,10] in the final Intermediate Representation differs from the shape [1,5,10,20] specified in the command line, because the original TensorFlow model uses NHWC layout, but the Intermediate Representation uses NCHW layout. Thus, usual NHWC to NCHW layout conversion occurred.
|
||||
An input shape [1,20,5,10] in the final Intermediate Representation differs from the shape [1,5,10,20] specified in the command line, because the original TensorFlow\* model uses NHWC layout, but the Intermediate Representation uses NCHW layout. So usual NHWC to NCHW layout conversion occurred.
|
||||
|
||||
When `--input_shape` is specified, shape inference inside Model Optimizer is not performed for the nodes in the beginning of the model that are not included in the translated region. It differs from the case when `--input_shape` is not specified as noted in the previous section, where the shape inference is still performed for such nodes to deduce shape for the layers that should fall into the final Intermediate Representation. Therefore, `--input_shape` should be used for a model with a complex graph with loops, which are not supported by Model Optimizer, to exclude such parts from the Model Optimizer shape inference process completely.
|
||||
When `--input_shape` is specified, shape inference inside the Model Optimizer is not performed for the nodes in the beginning of the model that are not included in the translated region. It differs from the case when `--input_shape` is not specified as noted in the previous section where the shape inference is still performed for such nodes to deduce shape for the layers that should fall into the final Intermediate Representation. So `--input_shape` should be used for a model with a complex graph with loops, which are not supported by the Model Optimizer, to exclude such parts from the Model Optimizer shape inference process completely.
|
||||
|
||||
## Inputs with Multiple Input Ports
|
||||
|
||||
There are operations that contain more than one input port. In the example considered here, the convolution `InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution` is such operation. When `--input_shape` is not provided, a new `Input` layer is created for each dynamic input port for the node. If a port is evaluated to a constant blob, this constant remains in the model and a corresponding input layer is not created. TensorFlow convolution used in this model contains two ports:
|
||||
There are operations that contain more than one input ports. In the example considered here, the convolution `InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution` is such operation. When `--input_shape` is not provided, a new `Input` layer is created for each dynamic input port for the node. If a port is evaluated to a constant blob, this constant remains in the model and a corresponding input layer is not created. TensorFlow convolution used in this model contains two ports:
|
||||
|
||||
* port 0: input tensor for convolution (dynamic)
|
||||
* port 1: convolution weights (constant)
|
||||
|
||||
Following this behavior, Model Optimizer creates an `Input` layer for port 0 only, leaving port 1 as a constant. Thus, the result of:
|
||||
Following this behavior, the Model Optimizer creates an `Input` layer for port 0 only, leaving port 1 as a constant. So the result of:
|
||||
|
||||
```sh
|
||||
mo --input_model inception_v1.pb -b 1 --input InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution --output_dir <OUTPUT_MODEL_DIR>
|
||||
@@ -377,13 +377,13 @@ Different behavior occurs when `--input_shape` is also used as an attempt to ove
|
||||
```sh
|
||||
mo --input_model inception_v1.pb--input=InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution --input_shape [1,224,224,3] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
An error occurs (for more information, see the [Model Optimizer FAQ](../Model_Optimizer_FAQ.md#FAQ30)):
|
||||
An error occurs (for more information, see <a href="MO_FAQ.html#FAQ30">FAQ #30</a>):
|
||||
```sh
|
||||
[ ERROR ] Node InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution has more than 1 input and input shapes were provided.
|
||||
Try not to provide input shapes or specify input port with PORT:NODE notation, where PORT is an integer.
|
||||
For more information, see FAQ #30
|
||||
```
|
||||
When `--input_shape` is specified and the node contains multiple input ports, you need to provide an input port index together with an input node name. The input port index is specified in front of the node name with ':' as a separator (`PORT:NODE`). In this case, the port index 0 of the node `InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution` should be specified as `0:InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution`.
|
||||
In this case, when `--input_shape` is specified and the node contains multiple input ports, you need to specify an input port index together with an input node name. The input port index is specified in front of the node name with ':' as a separator (`PORT:NODE`). In the considered case, the port index 0 of the node `InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution` should be specified as `0:InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution`.
|
||||
|
||||
The correct command line is:
|
||||
```sh
|
||||
|
||||
@@ -2,32 +2,32 @@
|
||||
|
||||
## Introduction
|
||||
|
||||
OpenVINO Runtime CPU and GPU devices can infer models in low precision.
|
||||
For more details, refer to the [Model Optimization Guide](@ref openvino_docs_model_optimization_guide).
|
||||
OpenVINO Runtime CPU and GPU devices can infer models in the low precision.
|
||||
For details, refer to [Model Optimization Guide](@ref openvino_docs_model_optimization_guide).
|
||||
|
||||
Intermediate Representation should be specifically formed to be suitable for low precision inference.
|
||||
Such a model is called a Low Precision IR and can be generated in two ways:
|
||||
- By [quantizing regular IR with the Post-Training Optimization tool](@ref pot_introduction)
|
||||
- Using Model Optimizer for a model pre-trained for Low Precision inference: TensorFlow pre-TFLite models (`.pb` model file with `FakeQuantize*` operations) and ONNX quantized models.
|
||||
Both TensorFlow and ONNX quantized models can be prepared by [Neural Network Compression Framework](https://github.com/openvinotoolkit/nncf/blob/develop/README.md).
|
||||
Intermediate Representation (IR) should be specifically formed to be suitable for low precision inference.
|
||||
Such an IR is called a Low Precision IR and you can generate it in two ways:
|
||||
- [Quantize regular IR with the Post-Training Optimization tool](@ref pot_introduction)
|
||||
- Use the Model Optimizer for a model pretrained for Low Precision inference: TensorFlow\* pre-TFLite models (`.pb` model file with `FakeQuantize*` operations) and ONNX\* quantized models.
|
||||
Both TensorFlow and ONNX quantized models could be prepared by [Neural Network Compression Framework](https://github.com/openvinotoolkit/nncf/blob/develop/README.md).
|
||||
|
||||
For an operation to be executed in INT8, it must have `FakeQuantize` operations as inputs.
|
||||
For more details, see the [specification of `FakeQuantize` operation](../../../ops/quantization/FakeQuantize_1.md).
|
||||
See the [specification of `FakeQuantize` operation](../../../ops/quantization/FakeQuantize_1.md) for details.
|
||||
|
||||
To execute the `Convolution` operation in INT8 on CPU, both data and weight inputs should have `FakeQuantize` as an input operation:
|
||||

|
||||
|
||||
Low precision IR is also suitable for FP32 and FP16 inference if a chosen plugin supports all operations of the IR. The only difference between a Low Precision IR and FP16 or FP32 IR is the existence of `FakeQuantize` in the Low Precision IR.
|
||||
Plugins that support Low Precision Inference recognize these sub-graphs and quantize them during inference.
|
||||
The ones that do not, execute all operations, including `FakeQuantize`, as is in the FP32 or FP16 precision.
|
||||
Low precision IR is also suitable for FP32 and FP16 inference if a chosen plugin supports all operations of the IR, because the only difference between a Low Precision IR and FP16 or FP32 IR is the existence of `FakeQuantize` in the Low Precision IR.
|
||||
Plugins with Low Precision Inference support recognize these sub-graphs and quantize them during the inference time.
|
||||
Plugins without Low Precision support execute all operations, including `FakeQuantize`, as is in the FP32 or FP16 precision.
|
||||
|
||||
Consequently, when `FakeQuantize` operations are present in an OpenVINO IR, it suggests to the inference device how to quantize particular operations in the model.
|
||||
If the device is capable, it accepts the suggestion and performs Low Precision Inference. If not, it executes the model in the floating-point precision.
|
||||
Accordingly, the presence of FakeQuantize operations in the IR is a recommendation for a plugin on how to quantize particular operations in the model.
|
||||
If capable, a plugin accepts the recommendation and performs Low Precision Inference, otherwise, the plugin ignores the recommendation and executes a model in the floating-point precision.
|
||||
|
||||
## Compressed Low Precision Weights
|
||||
|
||||
Weighted operations, such as `Convolution` and `MatMul`, store weights as the floating-point `Constant` in the graph followed by the `FakeQuantize` operation.
|
||||
The `Constant` followed by the `FakeQuantize` operation could be optimized memory-wise due to the `FakeQuantize` operation semantics.
|
||||
Weighted operations, like `Convolution`, `MatMul`, and others, store weights as floating-point `Constant` in the graph followed by the `FakeQuantize` operation.
|
||||
`Constant` followed by the `FakeQuantize` operation could be optimized memory-wise due to the `FakeQuantize` operation semantics.
|
||||
The resulting weights sub-graph stores weights in Low Precision `Constant`, which gets unpacked back to floating point with the `Convert` operation.
|
||||
Weights compression replaces `FakeQuantize` with optional `Subtract` and `Multiply` operation leaving output arithmetically the same and weights storing takes four times less memory.
|
||||
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
# Converting a Kaldi ASpIRE Chain Time Delay Neural Network (TDNN) Model {#openvino_docs_MO_DG_prepare_model_convert_model_kaldi_specific_Aspire_Tdnn_Model}
|
||||
# Convert Kaldi* ASpIRE Chain Time Delay Neural Network (TDNN) Model {#openvino_docs_MO_DG_prepare_model_convert_model_kaldi_specific_Aspire_Tdnn_Model}
|
||||
|
||||
At the beginning, you should [download a pre-trained model](https://kaldi-asr.org/models/1/0001_aspire_chain_model.tar.gz)
|
||||
for the ASpIRE Chain Time Delay Neural Network (TDNN) from the Kaldi project official website.
|
||||
You can [download a pre-trained model](https://kaldi-asr.org/models/1/0001_aspire_chain_model.tar.gz)
|
||||
for the ASpIRE Chain Time Delay Neural Network (TDNN) from the Kaldi* project official website.
|
||||
|
||||
## Converting an ASpIRE Chain TDNN Model to IR
|
||||
## Convert ASpIRE Chain TDNN Model to IR
|
||||
|
||||
Generate the Intermediate Representation of the model by running Model Optimizer with the following parameters:
|
||||
To generate the Intermediate Representation (IR) of the model, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
mo --input_model exp/chain/tdnn_7b/final.mdl --output output
|
||||
```
|
||||
|
||||
The IR will have two inputs: `input` for data, and `ivector` for ivectors.
|
||||
The IR will have two inputs: `input` for data and `ivector` for ivectors.
|
||||
|
||||
## Example: Running ASpIRE Chain TDNN Model with the Speech Recognition Sample
|
||||
## Example: Run ASpIRE Chain TDNN Model with the Speech Recognition Sample
|
||||
|
||||
> **NOTE**: Before you continue with this part of the article, get familiar with the [Speech Recognition sample](../../../../../samples/cpp/speech_sample/README.md).
|
||||
These instructions show how to run the converted model with the [Speech Recognition sample](../../../../../samples/cpp/speech_sample/README.md).
|
||||
In this example, the input data contains one utterance from one speaker.
|
||||
|
||||
In this example, the input data contains one utterance from one speaker.
|
||||
|
||||
To run the ASpIRE Chain TDNN Model with Speech Recognition sample, You need to prepare environment. Do it by following the steps below :
|
||||
To follow the steps described below, you must first do the following:
|
||||
1. Download a [Kaldi repository](https://github.com/kaldi-asr/kaldi).
|
||||
2. Build it by following instructions in `README.md` from the repository.
|
||||
2. Build it using instructions in `README.md` in the repository.
|
||||
3. Download the [model archive](https://kaldi-asr.org/models/1/0001_aspire_chain_model.tar.gz) from Kaldi website.
|
||||
4. Extract the downloaded model archive to the `egs/aspire/s5` folder of the Kaldi repository.
|
||||
|
||||
Once everything has been prepared, you can start a proper run:
|
||||
|
||||
To run the ASpIRE Chain TDNN Model with Speech Recognition sample:
|
||||
|
||||
1. Prepare the model for decoding. Refer to the `README.txt` file from the downloaded model archive for instructions.
|
||||
2. Convert data and ivectors to `.ark` format. Refer to the corresponding sections below for instructions.
|
||||
|
||||
### Preparing Data
|
||||
### Prepare Data
|
||||
|
||||
If you have a `.wav` data file, convert it to the `.ark` format using the following command:
|
||||
If you have a `.wav` data file, you can convert it to `.ark` format using the following command:
|
||||
```sh
|
||||
<path_to_kaldi_repo>/src/featbin/compute-mfcc-feats --config=<path_to_kaldi_repo>/egs/aspire/s5/conf/mfcc_hires.conf scp:./wav.scp ark,scp:feats.ark,feats.scp
|
||||
```
|
||||
Add the `feats.ark` absolute path to `feats.scp` to avoid errors in later commands.
|
||||
|
||||
### Preparing Ivectors
|
||||
### Prepare Ivectors
|
||||
|
||||
Prepare ivectors for the Speech Recognition sample:
|
||||
To prepare ivectors for the Speech Recognition sample, do the following:
|
||||
|
||||
1. Copy the `feats.scp` file to the `egs/aspire/s5/` directory of the built Kaldi repository and navigate there:
|
||||
```sh
|
||||
@@ -51,27 +51,29 @@ cd <path_to_kaldi_repo>/egs/aspire/s5/
|
||||
```sh
|
||||
./steps/online/nnet2/extract_ivectors_online.sh --nj 1 --ivector_period <max_frame_count_in_utterance> <data folder> exp/tdnn_7b_chain_online/ivector_extractor <ivector folder>
|
||||
```
|
||||
You can simplify the preparation of ivectors for the Speech Recognition sample. To do it, specify the maximum number of frames in utterances as a parameter for `--ivector_period`
|
||||
To simplify the preparation of ivectors for the Speech Recognition sample,
|
||||
specify the maximum number of frames in utterances as a parameter for `--ivector_period`
|
||||
to get only one ivector per utterance.
|
||||
|
||||
To get the maximum number of frames in utterances, use the following command line:
|
||||
To get the maximum number of frames in utterances, you can use the following command line:
|
||||
```sh
|
||||
../../../src/featbin/feat-to-len scp:feats.scp ark,t: | cut -d' ' -f 2 - | sort -rn | head -1
|
||||
```
|
||||
As a result, you will find the `ivector_online.1.ark` file in `<ivector folder>`.
|
||||
As a result, in `<ivector folder>`, you will find the `ivector_online.1.ark` file.
|
||||
|
||||
3. Go to the `<ivector folder>`:
|
||||
```sh
|
||||
cd <ivector folder>
|
||||
```
|
||||
|
||||
4. Convert the `ivector_online.1.ark` file to text format, using the `copy-feats` tool. Run the following command:
|
||||
4. Convert the `ivector_online.1.ark` file to text format using the `copy-feats` tool. Run the following command:
|
||||
```sh
|
||||
<path_to_kaldi_repo>/src/featbin/copy-feats --binary=False ark:ivector_online.1.ark ark,t:ivector_online.1.ark.txt
|
||||
```
|
||||
|
||||
5. For the Speech Recognition sample, the `.ark` file must contain an ivector
|
||||
for each frame. Copy the ivector `frame_count` times by running the below script in the Python command prompt:
|
||||
for each frame. You must copy the ivector `frame_count` times.
|
||||
To do this, you can run the following script in the Python* command prompt:
|
||||
```python
|
||||
import subprocess
|
||||
|
||||
@@ -99,12 +101,12 @@ length_file.close()
|
||||
<path_to_kaldi_repo>/src/featbin/copy-feats --binary=True ark,t:ivector_online_ie.ark.txt ark:ivector_online_ie.ark
|
||||
```
|
||||
|
||||
### Running the Speech Recognition Sample
|
||||
### Run the Speech Recognition Sample
|
||||
|
||||
Run the Speech Recognition sample with the created ivector `.ark` file:
|
||||
Run the Speech Recognition sample with the created ivector `.ark` file as follows:
|
||||
```sh
|
||||
speech_sample -i feats.ark,ivector_online_ie.ark -m final.xml -d CPU -o prediction.ark -cw_l 17 -cw_r 12
|
||||
```
|
||||
|
||||
Results can be decoded as described in "Use of Sample in Kaldi Speech Recognition Pipeline"
|
||||
in the [Speech Recognition Sample description](../../../../../samples/cpp/speech_sample/README.md) article.
|
||||
Results can be decoded as described in "Use of Sample in Kaldi* Speech Recognition Pipeline" chapter
|
||||
in [the Speech Recognition Sample description](../../../../../samples/cpp/speech_sample/README.md).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Converting MXNet GluonCV Models {#openvino_docs_MO_DG_prepare_model_convert_model_mxnet_specific_Convert_GluonCV_Models}
|
||||
# Convert MXNet GluonCV* Models {#openvino_docs_MO_DG_prepare_model_convert_model_mxnet_specific_Convert_GluonCV_Models}
|
||||
|
||||
This article provides the instructions and examples on how to use Model Optimizer to convert [GluonCV SSD and YOLO-v3 models](https://gluon-cv.mxnet.io/model_zoo/detection.html) to IR.
|
||||
This document provides the instructions and examples on how to use Model Optimizer to convert [GluonCV SSD and YOLO-v3 models](https://gluon-cv.mxnet.io/model_zoo/detection.html) to IR.
|
||||
|
||||
1. Choose the topology available from the [GluonCV Model Zoo](https://gluon-cv.mxnet.io/model_zoo/detection.html) and export to the MXNet format using the GluonCV API. For example, for the `ssd_512_mobilenet1.0` topology:
|
||||
```python
|
||||
@@ -10,7 +10,7 @@ net = model_zoo.get_model('ssd_512_mobilenet1.0_voc', pretrained=True)
|
||||
export_block('ssd_512_mobilenet1.0_voc', net, preprocess=True, layout='HWC')
|
||||
```
|
||||
As a result, you will get an MXNet model representation in `ssd_512_mobilenet1.0.params` and `ssd_512_mobilenet1.0.json` files generated in the current directory.
|
||||
2. Run the Model Optimizer tool, specifying the `--enable_ssd_gluoncv` option. Make sure the `--input_shape` parameter is set to the input shape layout of your model (NHWC or NCHW). The examples below illustrate running the Model Optimizer for the SSD and YOLO-v3 models trained with the NHWC layout and located in the `<model_directory>`:
|
||||
2. Run the Model Optimizer tool specifying the `--enable_ssd_gluoncv` option. Make sure the `--input_shape` parameter is set to the input shape layout of your model (NHWC or NCHW). The examples below illustrates running the Model Optimizer for the SSD and YOLO-v3 models trained with the NHWC layout and located in the `<model_directory>`:
|
||||
* **For GluonCV SSD topologies:**
|
||||
```sh
|
||||
mo --input_model <model_directory>/ssd_512_mobilenet1.0.params --enable_ssd_gluoncv --input_shape [1,512,512,3] --input data --output_dir <OUTPUT_MODEL_DIR>
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
# Converting an MXNet Style Transfer Model {#openvino_docs_MO_DG_prepare_model_convert_model_mxnet_specific_Convert_Style_Transfer_From_MXNet}
|
||||
# Convert MXNet Style Transfer Model {#openvino_docs_MO_DG_prepare_model_convert_model_mxnet_specific_Convert_Style_Transfer_From_MXNet}
|
||||
|
||||
This article provides instructions on how to generate a model for style transfer, using the public MXNet neural style transfer sample.
|
||||
The tutorial explains how to generate a model for style transfer using the public MXNet\* neural style transfer sample.
|
||||
To use the style transfer sample from OpenVINO™, follow the steps below as no public pre-trained style transfer model is provided with the OpenVINO toolkit.
|
||||
|
||||
**Step 1**: Download or clone the repository [Zhaw's Neural Style Transfer repository](https://github.com/zhaw/neural_style) with an MXNet neural style transfer sample.
|
||||
#### 1. Download or clone the repository with an MXNet neural style transfer sample: [Zhaw's Neural Style Transfer repository](https://github.com/zhaw/neural_style).
|
||||
|
||||
**Step 2**: Prepare the environment required to work with the cloned repository:
|
||||
|
||||
> **NOTE**: Python-tk installation is needed only for Linux. Python for Windows includes it by default.
|
||||
|
||||
1. Install packages dependency.<br>
|
||||
#### 2. Prepare the environment required to work with the cloned repository:
|
||||
1. Install packages dependency:<br>
|
||||
```sh
|
||||
sudo apt-get install python-tk
|
||||
```
|
||||
|
||||
2. Install Python requirements:
|
||||
Installing python-tk step is needed only for Linux, as it is included by default in Python\* for Windows\*.
|
||||
|
||||
2. Install Python\* requirements:
|
||||
```sh
|
||||
pip3 install --user mxnet
|
||||
pip3 install --user matplotlib
|
||||
pip3 install --user scikit-image
|
||||
```
|
||||
|
||||
**Step 3**: Download the pretrained [VGG19 model](https://github.com/dmlc/web-data/raw/master/mxnet/neural-style/model/vgg19.params) and save it to the root directory of the cloned repository. The sample expects the model `vgg19.params` file to be in that directory.<br>
|
||||
#### 3. Download the pre-trained [VGG19 model](https://github.com/dmlc/web-data/raw/master/mxnet/neural-style/model/vgg19.params) and save it to the root directory of the cloned repository because the sample expects the model `vgg19.params` file to be in that directory.<br>
|
||||
|
||||
**Step 4**: Modify source code files of style transfer sample from the cloned repository:<br>
|
||||
#### 4. Modify source code files of style transfer sample from cloned repository.<br>
|
||||
|
||||
1. Go to the `fast_mrf_cnn` subdirectory.
|
||||
```sh
|
||||
cd ./fast_mrf_cnn
|
||||
```
|
||||
|
||||
2. Open the `symbol.py` file and modify the `decoder_symbol()` function. You should see the following code there:
|
||||
2. Open the `symbol.py` file and modify the `decoder_symbol()` function. Replace.
|
||||
```py
|
||||
def decoder_symbol():
|
||||
data = mx.sym.Variable('data')
|
||||
data = mx.sym.Convolution(data=data, num_filter=256, kernel=(3,3), pad=(1,1), stride=(1, 1), name='deco_conv1')
|
||||
```
|
||||
Replace the code above with the following:<br>
|
||||
with the following code:<br>
|
||||
```py
|
||||
def decoder_symbol_with_vgg(vgg_symbol):
|
||||
data = mx.sym.Convolution(data=vgg_symbol, num_filter=256, kernel=(3,3), pad=(1,1), stride=(1, 1), name='deco_conv1')
|
||||
@@ -43,64 +43,64 @@ def decoder_symbol_with_vgg(vgg_symbol):
|
||||
|
||||
3. Save and close the `symbol.py` file.
|
||||
|
||||
4. Open and edit the `make_image.py` file. Go to the `__init__()` function in the `Maker` class:<br>
|
||||
4. Open and edit the `make_image.py` file:
|
||||
Modify the `__init__()` function in the `Maker` class. Replace:<br>
|
||||
```py
|
||||
decoder = symbol.decoder_symbol()
|
||||
```
|
||||
Modfiy it with the following code:<br>
|
||||
with the following code:<br>
|
||||
```py
|
||||
decoder = symbol.decoder_symbol_with_vgg(vgg_symbol)
|
||||
```
|
||||
|
||||
5. To join the pretrained weights with the decoder weights, make the following changes:
|
||||
After the code lines for loading the decoder weights:<br>
|
||||
```py
|
||||
args = mx.nd.load('%s_decoder_args.nd'%model_prefix)
|
||||
auxs = mx.nd.load('%s_decoder_auxs.nd'%model_prefix)
|
||||
```
|
||||
5. To join the pre-trained weights with the decoder weights, make the following changes:
|
||||
After the code lines for loading the decoder weights:<br>
|
||||
```py
|
||||
args = mx.nd.load('%s_decoder_args.nd'%model_prefix)
|
||||
auxs = mx.nd.load('%s_decoder_auxs.nd'%model_prefix)
|
||||
```
|
||||
add the following line:<br>
|
||||
```py
|
||||
arg_dict.update(args)
|
||||
```
|
||||
|
||||
Add the following line:<br>
|
||||
```py
|
||||
arg_dict.update(args)
|
||||
```
|
||||
|
||||
6. Use `arg_dict` instead of `args` as a parameter of the `decoder.bind()` function. Find the line below:<br>
|
||||
6. Use `arg_dict` instead of `args` as a parameter of the `decoder.bind()` function. Replace the line:<br>
|
||||
```py
|
||||
self.deco_executor = decoder.bind(ctx=mx.gpu(), args=args, aux_states=auxs)
|
||||
```
|
||||
Replace it with the following:<br>
|
||||
with the following:<br>
|
||||
```py
|
||||
self.deco_executor = decoder.bind(ctx=mx.cpu(), args=arg_dict, aux_states=auxs)
|
||||
```
|
||||
7. Add the following code to the end of the `generate()` function in the `Maker` class to save the result model as a `.json` file:<br>
|
||||
7. To save the result model as a `.json` file, add the following code to the end of the `generate()` function in the `Maker` class:<br>
|
||||
```py
|
||||
self.vgg_executor._symbol.save('{}-symbol.json'.format('vgg19'))
|
||||
self.deco_executor._symbol.save('{}-symbol.json'.format('nst_vgg19'))
|
||||
```
|
||||
8. Save and close the `make_image.py` file.
|
||||
|
||||
**Step 5**: Follow the instructions from the `README.md` file in the `fast_mrf_cnn` directory of the cloned repository and run the sample with a decoder model.
|
||||
For example, use the following code to run the sample with the pretrained decoder weights from the `models` folder and output shape:<br>
|
||||
#### 5. Run the sample with a decoder model according to the instructions from the `README.md` file in the `fast_mrf_cnn` directory of the cloned repository.
|
||||
For example, to run the sample with the pre-trained decoder weights from the `models` folder and output shape, use the following code:<br>
|
||||
```py
|
||||
import make_image
|
||||
maker = make_image.Maker('models/13', (1024, 768))
|
||||
maker.generate('output.jpg', '../images/tubingen.jpg')
|
||||
```
|
||||
The `models/13` string in the code above is composed of the following substrings:
|
||||
* `models/` -- path to the folder that contains `.nd` files with pretrained styles weights.
|
||||
* `13` -- prefix pointing to the default decoder for the repository, `13_decoder`.
|
||||
Where the `models/13` string is composed of the following substrings:
|
||||
* `models/`: path to the folder that contains .nd files with pre-trained styles weights
|
||||
* `13`: prefix pointing to 13_decoder, which is the default decoder for the repository.
|
||||
|
||||
> **NOTE**: If an error prompts with "No module named `cPickle`", try running the script from Step 5 in Python 2. After that return to Python 3 for the remaining steps.
|
||||
> **NOTE**: If you get an error saying "No module named 'cPickle'", try running the script from this step in Python 2. Then return to Python 3 for the remaining steps.
|
||||
|
||||
Any style can be selected from [collection of pretrained weights](https://pan.baidu.com/s/1skMHqYp). On the Chinese-language page, click the down arrow next to a size in megabytes. Then wait for an overlay box to appear, and click the blue button in it to download. The `generate()` function generates `nst_vgg19-symbol.json` and `vgg19-symbol.json` files for the specified shape. In the code, it is [1024 x 768] for a 4:3 ratio. You can specify another, for example, [224,224] for a square ratio.
|
||||
You can choose any style from [collection of pre-trained weights](https://pan.baidu.com/s/1skMHqYp). (On the Chinese-language page, click the down arrow next to a size in megabytes. Then wait for an overlay box to appear, and click the blue button in it to download.) The `generate()` function generates `nst_vgg19-symbol.json` and `vgg19-symbol.json` files for the specified shape. In the code, it is [1024 x 768] for a 4:3 ratio, and you can specify another, for example, [224,224] for a square ratio.
|
||||
|
||||
**Step 6**: Run the Model Optimizer to generate an Intermediate Representation (IR):
|
||||
#### 6. Run the Model Optimizer to generate an Intermediate Representation (IR):
|
||||
|
||||
1. Create a new directory. For example:<br>
|
||||
```sh
|
||||
mkdir nst_model
|
||||
```
|
||||
2. Copy the initial and generated model files to the created directory. For example, to copy the pretrained decoder weights from the `models` folder to the `nst_model` directory, run the following commands:<br>
|
||||
2. Copy the initial and generated model files to the created directory. For example, to copy the pre-trained decoder weights from the `models` folder to the `nst_model` directory, run the following commands:<br>
|
||||
```sh
|
||||
cp nst_vgg19-symbol.json nst_model
|
||||
cp vgg19-symbol.json nst_model
|
||||
@@ -110,8 +110,8 @@ cp models/13_decoder_auxs.nd nst_model
|
||||
```
|
||||
> **NOTE**: Make sure that all the `.params` and `.json` files are in the same directory as the `.nd` files. Otherwise, the conversion process fails.
|
||||
|
||||
3. Run the Model Optimizer for Apache MXNet. Use the `--nd_prefix_name` option to specify the decoder prefix and `--input_shape` to specify input shapes in [N,C,W,H] order. For example:<br>
|
||||
3. Run the Model Optimizer for MXNet. Use the `--nd_prefix_name` option to specify the decoder prefix and `--input_shape` to specify input shapes in [N,C,W,H] order. For example:<br>
|
||||
```sh
|
||||
mo --input_symbol <path/to/nst_model>/nst_vgg19-symbol.json --framework mxnet --output_dir <path/to/output_dir> --input_shape [1,3,224,224] --nd_prefix_name 13_decoder --pretrained_model <path/to/nst_model>/vgg19-0000.params
|
||||
```
|
||||
4. The IR is generated (`.bin`, `.xml` and `.mapping` files) in the specified output directory, and ready to be consumed by the OpenVINO Runtime.
|
||||
4. The IR is generated (`.bin`, `.xml` and `.mapping` files) in the specified output directory and ready to be consumed by the OpenVINO Runtime.
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# Converting an ONNX Faster R-CNN Model {#openvino_docs_MO_DG_prepare_model_convert_model_onnx_specific_Convert_Faster_RCNN}
|
||||
# Convert ONNX* Faster R-CNN Model {#openvino_docs_MO_DG_prepare_model_convert_model_onnx_specific_Convert_Faster_RCNN}
|
||||
|
||||
The instructions below are applicable **only** to the Faster R-CNN model converted to the ONNX file format from the [maskrcnn-benchmark model](https://github.com/facebookresearch/maskrcnn-benchmark):
|
||||
These instructions are applicable only to the Faster R-CNN model converted to the ONNX* file format from the [facebookresearch/maskrcnn-benchmark model](https://github.com/facebookresearch/maskrcnn-benchmark).
|
||||
|
||||
1. Download the pretrained model file from [onnx/models](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/faster-rcnn):
|
||||
* (commit-SHA: 8883e49e68de7b43e263d56b9ed156dfa1e03117).
|
||||
**Step 1**. Download the pre-trained model file from [onnx/models](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/faster-rcnn) (commit-SHA: 8883e49e68de7b43e263d56b9ed156dfa1e03117).
|
||||
|
||||
2. Generate the Intermediate Representation of the model, by changing your current working directory to the Model Optimizer installation directory, and running Model Optimizer with the following parameters:
|
||||
**Step 2**. To generate the Intermediate Representation (IR) of the model, change your current working directory to the Model Optimizer installation directory and run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
mo \
|
||||
--input_model FasterRCNN-10.onnx \
|
||||
@@ -15,9 +14,6 @@ The instructions below are applicable **only** to the Faster R-CNN model convert
|
||||
--transformations_config front/onnx/faster_rcnn.json
|
||||
```
|
||||
|
||||
Be aware that the height and width specified with the `input_shape` command line parameter could be different. For more information about supported input image dimensions and required pre- and post-processing steps, refer to the [Faster R-CNN article](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/faster-rcnn).
|
||||
Note that the height and width specified with the `input_shape` command line parameter could be different. Refer to the [documentation](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/faster-rcnn) for more information about supported input image dimensions and required pre- and post-processing steps.
|
||||
|
||||
3. Interpret the outputs of the generated IR: class indices, probabilities and box coordinates. Below are the outputs from the "DetectionOutput" layer:
|
||||
* class indices.
|
||||
* probabilities.
|
||||
* box coordinates.
|
||||
**Step 3**. Interpret the outputs. The generated IR file has several outputs: class indices, probabilities and box coordinates. These are outputs from the "DetectionOutput" layer.
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# Converting an ONNX GPT-2 Model {#openvino_docs_MO_DG_prepare_model_convert_model_onnx_specific_Convert_GPT2}
|
||||
# Convert ONNX* GPT-2 Model {#openvino_docs_MO_DG_prepare_model_convert_model_onnx_specific_Convert_GPT2}
|
||||
|
||||
[Public pretrained GPT-2 model](https://github.com/onnx/models/tree/master/text/machine_comprehension/gpt-2) is a large
|
||||
[Public pre-trained GPT-2 model](https://github.com/onnx/models/tree/master/text/machine_comprehension/gpt-2) is a large
|
||||
transformer-based language model with a simple objective: predict the next word, given all of the previous words within some text.
|
||||
|
||||
## Downloading the Pre-Trained Base GPT-2 Model
|
||||
## Download the Pre-Trained Base GPT-2 Model
|
||||
|
||||
To download the model, go to [this model](https://github.com/onnx/models/blob/master/text/machine_comprehension/gpt-2/model/gpt2-10.onnx), and press **Download**.
|
||||
To download the model, click **Download** on [https://github.com/onnx/models/blob/master/text/machine_comprehension/gpt-2/model/gpt2-10.onnx](https://github.com/onnx/models/blob/master/text/machine_comprehension/gpt-2/model/gpt2-10.onnx).
|
||||
|
||||
To download the model and sample test data, go to [this model](https://github.com/onnx/models/blob/master/text/machine_comprehension/gpt-2/model/gpt2-10.tar.gz), and press **Download**.
|
||||
To download the model and sample test data, click **Download** on [https://github.com/onnx/models/blob/master/text/machine_comprehension/gpt-2/model/gpt2-10.tar.gz](https://github.com/onnx/models/blob/master/text/machine_comprehension/gpt-2/model/gpt2-10.tar.gz).
|
||||
|
||||
## Converting an ONNX GPT-2 Model to IR
|
||||
## Convert ONNX* GPT-2 Model to IR
|
||||
|
||||
Generate the Intermediate Representation of the model GPT-2 by running Model Optimizer with the following parameters:
|
||||
To generate the Intermediate Representation (IR) of the model GPT-2, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
mo --input_model gpt2-10.onnx --input_shape [X,Y,Z] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# Converting an ONNX Mask R-CNN Model {#openvino_docs_MO_DG_prepare_model_convert_model_onnx_specific_Convert_Mask_RCNN}
|
||||
# Convert ONNX* Mask R-CNN Model {#openvino_docs_MO_DG_prepare_model_convert_model_onnx_specific_Convert_Mask_RCNN}
|
||||
|
||||
The instructions below are applicable **only** to the Mask R-CNN model converted to the ONNX file format from the [maskrcnn-benchmark model](https://github.com/facebookresearch/maskrcnn-benchmark).
|
||||
These instructions are applicable only to the Mask R-CNN model converted to the ONNX* file format from the [facebookresearch/maskrcnn-benchmark model](https://github.com/facebookresearch/maskrcnn-benchmark).
|
||||
|
||||
1. Download the pretrained model file from [onnx/models](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/mask-rcnn):
|
||||
* commit-SHA: 8883e49e68de7b43e263d56b9ed156dfa1e03117.
|
||||
**Step 1**. Download the pre-trained model file from [onnx/models](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/mask-rcnn) (commit-SHA: 8883e49e68de7b43e263d56b9ed156dfa1e03117).
|
||||
|
||||
2. Generate the Intermediate Representation of the model by changing your current working directory to the Model Optimizer installation directory and running Model Optimizer with the following parameters:
|
||||
**Step 2**. To generate the Intermediate Representation (IR) of the model, change your current working directory to the Model Optimizer installation directory and run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
mo \
|
||||
--input_model mask_rcnn_R_50_FPN_1x.onnx \
|
||||
@@ -15,12 +14,6 @@ The instructions below are applicable **only** to the Mask R-CNN model converted
|
||||
--transformations_config front/onnx/mask_rcnn.json
|
||||
```
|
||||
|
||||
Be aware that the height and width specified with the `input_shape` command line parameter could be different. For more information about supported input image dimensions and required pre- and post-processing steps, refer to the [documentation](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/mask-rcnn).
|
||||
Note that the height and width specified with the `input_shape` command line parameter could be different. Refer to the [documentation](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/mask-rcnn) for more information about supported input image dimensions and required pre- and post-processing steps.
|
||||
|
||||
3. Interpret the outputs of the generated IR file: masks, class indices, probabilities and box coordinates.
|
||||
* masks.
|
||||
* class indices.
|
||||
* probabilities.
|
||||
* box coordinates.
|
||||
|
||||
The first one is a layer with the name `6849/sink_port_0`, and rest are outputs from the `DetectionOutput` layer.
|
||||
**Step 3**. Interpret the outputs. The generated IR file has several outputs: masks, class indices, probabilities and box coordinates. The first one is a layer with the name "6849/sink_port_0". The rest three are outputs from the "DetectionOutput" layer.
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
# Converting a PyTorch BERT-NER Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_Bert_ner}
|
||||
# Convert PyTorch* BERT-NER Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_Bert_ner}
|
||||
|
||||
The goal of this article is to present a step-by-step guide on how to convert PyTorch BERT-NER model to OpenVINO IR. First, you need to download the model and convert it to ONNX.
|
||||
## Download and Convert the Model to ONNX*
|
||||
|
||||
To download a pre-trained model or train the model yourself, refer
|
||||
to the [instruction](https://github.com/kamalkraj/BERT-NER/blob/dev/README.md) in the
|
||||
BERT-NER model repository. The model with config files is stored in the `out_base` directory.
|
||||
|
||||
## Downloading and Converting the Model to ONNX
|
||||
|
||||
To download a pretrained model or train the model yourself, refer
|
||||
to the [instructions](https://github.com/kamalkraj/BERT-NER/blob/dev/README.md) in the
|
||||
BERT-NER model repository. The model with configuration files is stored in the `out_base` directory.
|
||||
|
||||
To convert the model to ONNX format, create and run the following script in the root
|
||||
directory of the model repository. If you download the pretrained model, you need
|
||||
To convert the model to ONNX* format, create and run the script with the following content in the root
|
||||
directory of the model repository. If you download the pre-trained model, you need
|
||||
to download [`bert.py`](https://github.com/kamalkraj/BERT-NER/blob/dev/bert.py) to run the script.
|
||||
The instructions were tested with the commit-SHA: `e5be564156f194f1becb0d82aeaf6e762d9eb9ed`.
|
||||
The instruction was tested with the repository hash commit `e5be564156f194f1becb0d82aeaf6e762d9eb9ed`.
|
||||
|
||||
```python
|
||||
import torch
|
||||
@@ -47,12 +44,12 @@ torch.onnx.export(ner_model,
|
||||
)
|
||||
```
|
||||
|
||||
The script generates ONNX model file `bert-ner.onnx`.
|
||||
The script generates ONNX* model file `bert-ner.onnx`.
|
||||
|
||||
## Converting an ONNX BERT-NER model to IR
|
||||
## Convert ONNX* BERT-NER model to IR
|
||||
|
||||
```bash
|
||||
mo --input_model bert-ner.onnx --input "input_mask[1 128],segment_ids[1 128],input_ids[1 128]"
|
||||
```
|
||||
|
||||
where `1` is `batch_size` and `128` is `sequence_length`.
|
||||
where `1` is `batch_size` and `128` is `sequence_length`.
|
||||
@@ -1,8 +1,6 @@
|
||||
# Converting a PyTorch Cascade RCNN R-101 Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_Cascade_RCNN_res101}
|
||||
# Convert PyTorch Cascade RCNN R-101 Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_Cascade_RCNN_res101}
|
||||
|
||||
The goal of this article is to present a step-by-step guide on how to convert a PyTorch Cascade RCNN R-101 model to OpenVINO IR. First, you need to download the model and convert it to ONNX.
|
||||
|
||||
## Downloading and Converting Model to ONNX
|
||||
## Download and Convert Model to ONNX
|
||||
|
||||
* Clone the [repository](https://github.com/open-mmlab/mmdetection):
|
||||
|
||||
@@ -11,9 +9,9 @@ git clone https://github.com/open-mmlab/mmdetection
|
||||
cd mmdetection
|
||||
```
|
||||
|
||||
> **NOTE**: To set up an environment, refer to the [instructions](https://github.com/open-mmlab/mmdetection/blob/master/docs/en/get_started.md#installation).
|
||||
> **NOTE**: To set up an environment, refer to this [instruction](https://github.com/open-mmlab/mmdetection/blob/master/docs/en/get_started.md#installation).
|
||||
|
||||
* Download the pretrained [model](https://download.openmmlab.com/mmdetection/v2.0/cascade_rcnn/cascade_rcnn_r101_fpn_1x_coco/cascade_rcnn_r101_fpn_1x_coco_20200317-0b6a2fbf.pth). The model is also available [here](https://github.com/open-mmlab/mmdetection/blob/master/configs/cascade_rcnn/README.md).
|
||||
* Download the pre-trained [model](https://download.openmmlab.com/mmdetection/v2.0/cascade_rcnn/cascade_rcnn_r101_fpn_1x_coco/cascade_rcnn_r101_fpn_1x_coco_20200317-0b6a2fbf.pth). You can also find the link to the model [here](https://github.com/open-mmlab/mmdetection/blob/master/configs/cascade_rcnn/README.md).
|
||||
|
||||
* To convert the model to ONNX format, use this [script](https://github.com/open-mmlab/mmdetection/blob/master/tools/deployment/pytorch2onnx.py).
|
||||
|
||||
@@ -21,10 +19,10 @@ cd mmdetection
|
||||
python3 tools/deployment/pytorch2onnx.py configs/cascade_rcnn/cascade_rcnn_r101_fpn_1x_coco.py cascade_rcnn_r101_fpn_1x_coco_20200317-0b6a2fbf.pth --output-file cascade_rcnn_r101_fpn_1x_coco.onnx
|
||||
```
|
||||
|
||||
The script generates ONNX model file `cascade_rcnn_r101_fpn_1x_coco.onnx` in the directory `tools/deployment/`. If required, specify the model name or output directory, using `--output-file <path-to-dir>/<model-name>.onnx`.
|
||||
The script generates ONNX model file `cascade_rcnn_r101_fpn_1x_coco.onnx` in the directory `tools/deployment/`. If required, you can specify the model name or output directory using `--output-file <path-to-dir>/<model-name>.onnx`
|
||||
|
||||
## Converting an ONNX Cascade RCNN R-101 Model to OpenVINO IR
|
||||
## Convert ONNX Cascade RCNN R-101 Model to IR
|
||||
|
||||
```bash
|
||||
mo --input_model cascade_rcnn_r101_fpn_1x_coco.onnx --mean_values [123.675,116.28,103.53] --scale_values [58.395,57.12,57.375]
|
||||
```
|
||||
```
|
||||
@@ -1,8 +1,8 @@
|
||||
# Converting a PyTorch F3Net Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_F3Net}
|
||||
# Convert PyTorch* F3Net Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_F3Net}
|
||||
|
||||
[F3Net](https://github.com/weijun88/F3Net): Fusion, Feedback and Focus for Salient Object Detection
|
||||
|
||||
## Cloning the F3Net Repository
|
||||
## Clone the F3Net Repository
|
||||
|
||||
To clone the repository, run the following command:
|
||||
|
||||
@@ -10,10 +10,10 @@ To clone the repository, run the following command:
|
||||
git clone http://github.com/weijun88/F3Net.git
|
||||
```
|
||||
|
||||
## Downloading and Converting the Model to ONNX
|
||||
## Download and Convert the Model to ONNX*
|
||||
|
||||
To download the pretrained model or train the model yourself, refer to the
|
||||
[instructions](https://github.com/weijun88/F3Net/blob/master/README.md) in the F3Net model repository. First, convert the model to ONNX format. Create and run the following Python script in the `src` directory of the model repository:
|
||||
To download the pre-trained model or train the model yourself, refer to the
|
||||
[instruction](https://github.com/weijun88/F3Net/blob/master/README.md) in the F3Net model repository. First, convert the model to ONNX\* format. Create and run the following Python script in the `src` directory of the model repository:
|
||||
```python
|
||||
import torch
|
||||
from dataset import Config
|
||||
@@ -24,9 +24,9 @@ net = F3Net(cfg)
|
||||
image = torch.zeros([1, 3, 352, 352])
|
||||
torch.onnx.export(net, image, 'f3net.onnx', export_params=True, do_constant_folding=True, opset_version=11)
|
||||
```
|
||||
The script generates the ONNX model file `f3net.onnx`. The model conversion was tested with the commit-SHA: `eecace3adf1e8946b571a4f4397681252f9dc1b8`.
|
||||
The script generates the ONNX\* model file f3net.onnx. This model conversion was tested with the repository hash commit `eecace3adf1e8946b571a4f4397681252f9dc1b8`.
|
||||
|
||||
## Converting an ONNX F3Net Model to IR
|
||||
## Convert ONNX* F3Net Model to IR
|
||||
|
||||
```sh
|
||||
mo --input_model <MODEL_DIR>/f3net.onnx
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Converting a PyTorch QuartzNet Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_QuartzNet}
|
||||
# Convert PyTorch* QuartzNet Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_QuartzNet}
|
||||
|
||||
[NeMo project](https://github.com/NVIDIA/NeMo) provides the QuartzNet model.
|
||||
|
||||
## Downloading the Pretrained QuartzNet Model
|
||||
## Download the Pre-Trained QuartzNet Model
|
||||
|
||||
To download the pretrained model, refer to the [NeMo Speech Models Catalog](https://ngc.nvidia.com/catalog/models/nvidia:nemospeechmodels).
|
||||
Here are the instructions on how to obtain QuartzNet in ONNX format.
|
||||
To download the pre-trained model, refer to the [NeMo Speech Models Catalog](https://ngc.nvidia.com/catalog/models/nvidia:nemospeechmodels).
|
||||
Here are the instructions on how to obtain QuartzNet in ONNX* format.
|
||||
|
||||
1. Install the NeMo toolkit, using the [instructions](https://github.com/NVIDIA/NeMo/tree/main#installation).
|
||||
1. Install the NeMo toolkit using the [instructions](https://github.com/NVIDIA/NeMo/tree/main#installation).
|
||||
|
||||
2. Run the following code:
|
||||
|
||||
@@ -16,16 +16,16 @@ import nemo
|
||||
import nemo.collections.asr as nemo_asr
|
||||
|
||||
quartznet = nemo_asr.models.EncDecCTCModel.from_pretrained(model_name="QuartzNet15x5Base-En")
|
||||
# Export QuartzNet model to ONNX format
|
||||
# Export QuartzNet model to ONNX* format
|
||||
quartznet.decoder.export('decoder_qn.onnx')
|
||||
quartznet.encoder.export('encoder_qn.onnx')
|
||||
quartznet.export('qn.onnx')
|
||||
```
|
||||
|
||||
This code produces 3 ONNX model files: `encoder_qn.onnx`, `decoder_qn.onnx`, `qn.onnx`.
|
||||
They are `decoder`, `encoder`, and a combined `decoder(encoder(x))` models, respectively.
|
||||
This code produces 3 ONNX* model files: `encoder_qn.onnx`, `decoder_qn.onnx`, `qn.onnx`.
|
||||
They are `decoder`, `encoder` and a combined `decoder(encoder(x))` models, respectively.
|
||||
|
||||
## Converting an ONNX QuartzNet model to IR
|
||||
## Convert ONNX* QuartzNet model to IR
|
||||
|
||||
If using a combined model:
|
||||
```sh
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
# Converting a PyTorch RCAN Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_RCAN}
|
||||
# Convert PyTorch* RCAN Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_RCAN}
|
||||
|
||||
[RCAN](https://github.com/yulunzhang/RCAN): Image Super-Resolution Using Very Deep Residual Channel Attention Networks
|
||||
|
||||
## Downloading and Converting the Model to ONNX
|
||||
## Download and Convert the Model to ONNX*
|
||||
|
||||
To download the pretrained model or train the model yourself, refer to the [instruction](https://github.com/yulunzhang/RCAN/blob/master/README.md) in the RCAN model repository. First, convert the model to ONNX format. Create and run the script with the following content in the root
|
||||
To download the pre-trained model or train the model yourself, refer to the
|
||||
[instruction](https://github.com/yulunzhang/RCAN/blob/master/README.md) in the RCAN model repository. Firstly,
|
||||
convert the model to ONNX\* format. Create and run the script with the following content in the root
|
||||
directory of the model repository:
|
||||
|
||||
```python
|
||||
from argparse import Namespace
|
||||
|
||||
@@ -21,9 +22,9 @@ net.eval()
|
||||
dummy_input = torch.randn(1, 3, 360, 640)
|
||||
torch.onnx.export(net, dummy_input, 'RCAN.onnx')
|
||||
```
|
||||
The script generates the ONNX model file `RCAN.onnx`. More information about model parameters (`n_resblocks`, `n_resgroups`, and others) and their different values can be found in the model repository. The model conversion was tested with the commit-SHA: `3339ebc59519c3bb2b5719b87dd36515ec7f3ba7`.
|
||||
The script generates the ONNX\* model file RCAN.onnx. You can find more information about model parameters (`n_resblocks`, `n_resgroups`, and others) in the model repository and use different values of them. The model conversion was tested with the repository hash commit `3339ebc59519c3bb2b5719b87dd36515ec7f3ba7`.
|
||||
|
||||
## Converting an ONNX RCAN Model to IR
|
||||
## Convert ONNX* RCAN Model to IR
|
||||
|
||||
```sh
|
||||
mo --input_model RCAN.onnx
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Converting a PyTorch RNN-T Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_RNNT}
|
||||
# Convert PyTorch* RNN-T Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_RNNT}
|
||||
|
||||
This guide covers conversion of RNN-T model from [MLCommons](https://github.com/mlcommons) repository. Follow
|
||||
the instructions below to export a PyTorch model into ONNX, before converting it to IR:
|
||||
This instruction covers conversion of RNN-T model from [MLCommons](https://github.com/mlcommons) repository. Follow
|
||||
the steps below to export a PyTorch* model into ONNX* before converting it to IR:
|
||||
|
||||
**Step 1**. Clone RNN-T PyTorch implementation from MLCommons repository (revision r1.0). Make a shallow clone to pull
|
||||
only RNN-T model without full repository. If you already have a full repository, skip this and go to **Step 2**:
|
||||
@@ -21,19 +21,19 @@ cd rnnt_for_openvino
|
||||
```
|
||||
|
||||
**Step 3**. Download pretrained weights for PyTorch implementation from [https://zenodo.org/record/3662521#.YG21DugzZaQ](https://zenodo.org/record/3662521#.YG21DugzZaQ).
|
||||
For UNIX-like systems, you can use `wget`:
|
||||
For UNIX*-like systems you can use `wget`:
|
||||
```bash
|
||||
wget https://zenodo.org/record/3662521/files/DistributedDataParallel_1576581068.9962234-epoch-100.pt
|
||||
```
|
||||
The link was taken from `setup.sh` in the `speech_recoginitin/rnnt` subfolder. You will get exactly the same weights as
|
||||
if you were following the guide from [https://github.com/mlcommons/inference/tree/master/speech_recognition/rnnt](https://github.com/mlcommons/inference/tree/master/speech_recognition/rnnt).
|
||||
if you were following the steps from [https://github.com/mlcommons/inference/tree/master/speech_recognition/rnnt](https://github.com/mlcommons/inference/tree/master/speech_recognition/rnnt).
|
||||
|
||||
**Step 4**. Install required Python packages:
|
||||
```bash
|
||||
pip3 install torch toml
|
||||
```
|
||||
|
||||
**Step 5**. Export RNN-T model into ONNX, using the script below. Copy the code below into a file named
|
||||
**Step 5**. Export RNN-T model into ONNX with the script below. Copy the code below into a file named
|
||||
`export_rnnt_to_onnx.py` and run it in the current directory `rnnt_for_openvino`:
|
||||
|
||||
> **NOTE**: If you already have a full clone of MLCommons inference repository, you need to
|
||||
@@ -103,6 +103,6 @@ mo --input_model rnnt_encoder.onnx --input "input[157 1 240],feature_length->157
|
||||
mo --input_model rnnt_prediction.onnx --input "symbol[1 1],hidden_in_1[2 1 320],hidden_in_2[2 1 320]"
|
||||
mo --input_model rnnt_joint.onnx --input "0[1 1 1024],1[1 1 320]"
|
||||
```
|
||||
> **NOTE**: The hardcoded value for sequence length = 157 was taken from the MLCommons, but conversion to IR preserves
|
||||
network [reshapeability](../../../../OV_Runtime_UG/ShapeInference.md). Therefore, input shapes can be changed manually to any value during either conversion or
|
||||
Please note that hardcoded value for sequence length = 157 was taken from the MLCommons but conversion to IR preserves
|
||||
network [reshapeability](../../../../OV_Runtime_UG/ShapeInference.md), this means you can change input shapes manually to any value either during conversion or
|
||||
inference.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Converting a PyTorch YOLACT Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_YOLACT}
|
||||
# Convert PyTorch* YOLACT Model {#openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_YOLACT}
|
||||
|
||||
You Only Look At CoefficienTs (YOLACT) is a simple, fully convolutional model for real-time instance segmentation.
|
||||
The PyTorch implementation is publicly available in [this GitHub repository](https://github.com/dbolya/yolact).
|
||||
The YOLACT++ model is not supported, because it uses deformable convolutional layers that cannot be represented in ONNX format.
|
||||
The PyTorch\* implementation is publicly available in [this GitHub* repository](https://github.com/dbolya/yolact).
|
||||
The YOLACT++ model is not supported, because it uses deformable convolutional layers that cannot be represented in ONNX* format.
|
||||
|
||||
## Creating a Patch File <a name="patch-file"></a>
|
||||
## Create a Patch File <a name="patch-file"></a>
|
||||
|
||||
Before converting the model, create a patch file for the repository.
|
||||
The patch modifies the framework code by adding a special command-line argument to the framework options. The argument enables inference graph dumping:
|
||||
The patch modifies the framework code by adding a special command-line argument to the framework options that enables inference graph dumping:
|
||||
|
||||
1. Go to a writable directory and create a `YOLACT_onnx_export.patch` file.
|
||||
2. Copy the following diff code to the file:
|
||||
@@ -123,7 +123,7 @@ index d83703b..f8c787c 100644
|
||||
```
|
||||
3. Save and close the file.
|
||||
|
||||
## Converting a YOLACT Model to the OpenVINO IR format
|
||||
## Convert YOLACT Model to the Intermediate Representation (IR) format
|
||||
|
||||
**Step 1**. Clone the GitHub repository and check out the commit:
|
||||
|
||||
@@ -138,16 +138,16 @@ git checkout 57b8f2d95e62e2e649b382f516ab41f949b57239
|
||||
|
||||
3. Set up the environment as described in `README.md`.
|
||||
|
||||
**Step 2**. Download a pretrained model from the list attached in the `Evaluation` section of `README.md` document, for example `yolact_base_54_800000.pth`.
|
||||
**Step 2**. Download a pre-trained model from the list attached in the `Evaluation` section of `README.md` document, for example `yolact_base_54_800000.pth`.
|
||||
|
||||
**Step 3**. Export the model to ONNX format.
|
||||
**Step 3**. Export the model to ONNX* format.
|
||||
|
||||
1. Apply the `YOLACT_onnx_export.patch` patch to the repository. Refer to the <a href="#patch-file">Create a Patch File</a> instructions if you do not have it:
|
||||
```sh
|
||||
git apply /path/to/patch/YOLACT_onnx_export.patch
|
||||
```
|
||||
|
||||
2. Evaluate the YOLACT model to export it to ONNX format:
|
||||
2. Evaluate the YOLACT model to export it to ONNX* format:
|
||||
|
||||
```sh
|
||||
python3 eval.py \
|
||||
@@ -178,7 +178,7 @@ mo \
|
||||
--scale_values "[58.40, 57.12, 57.38]"
|
||||
```
|
||||
|
||||
* If the backbone of the model is Darknet53-FPN, use the following MO command line:
|
||||
* If the backbone of the model is Darknet53-FPN, use the following command line:
|
||||
```sh
|
||||
mo \
|
||||
--input_model /path/to/yolact.onnx \
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
# Converting a TensorFlow Attention OCR Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_AttentionOCR_From_Tensorflow}
|
||||
# Convert TensorFlow Attention OCR Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_AttentionOCR_From_Tensorflow}
|
||||
|
||||
This tutorial explains how to convert the Attention OCR (AOCR) model from the [TensorFlow Attention OCR repository](https://github.com/emedvedev/attention-ocr) to the Intermediate Representation (IR).
|
||||
This tutorial explains how to convert the Attention OCR (AOCR) model from the [TensorFlow* Attention OCR repository](https://github.com/emedvedev/attention-ocr) to the Intermediate Representation (IR).
|
||||
|
||||
## Extracting a Model from `aocr` Library
|
||||
## Extract Model from `aocr` Library
|
||||
|
||||
To get an AOCR model, download `aocr` Python library:
|
||||
The easiest way to get an AOCR model is to download `aocr` Python\* library:
|
||||
```
|
||||
pip install git+https://github.com/emedvedev/attention-ocr.git@master#egg=aocr
|
||||
```
|
||||
This library contains a pretrained model and allows training and running AOCR, using the command line. After installation of `aocr`, extract the model:
|
||||
This library contains a pretrained model and allows to train and run AOCR using the command line. After installing `aocr`, you can extract the model:
|
||||
```
|
||||
aocr export --format=frozengraph model/path/
|
||||
```
|
||||
Once extracted, the model can be found in `model/path/` folder.
|
||||
After this step you can find the model in model/path/ folder.
|
||||
|
||||
## Converting the TensorFlow AOCR Model to IR
|
||||
## Convert the TensorFlow* AOCR Model to IR
|
||||
|
||||
The original AOCR model includes the preprocessing data, which contains:
|
||||
The original AOCR model contains data preprocessing which consists of the following steps:
|
||||
* Decoding input data to binary format where input data is an image represented as a string.
|
||||
* Resizing binary image to working resolution.
|
||||
|
||||
The resized image is sent to the convolution neural network (CNN). Because Model Optimizer does not support image decoding, the preprocessing part of the model should be cut off, using the `--input` command-line parameter.
|
||||
After that, the resized image is sent to the convolution neural network (CNN). The Model Optimizer does not support image decoding so you should cut of preprocessing part of the model using '--input' command line parameter.
|
||||
```sh
|
||||
mo \
|
||||
--input_model=model/path/frozen_graph.pb \
|
||||
@@ -32,4 +32,4 @@ mo \
|
||||
Where:
|
||||
* `map/TensorArrayStack/TensorArrayGatherV3:0[1 32 86 1]` - name of node producing tensor after preprocessing.
|
||||
* `transpose_1` - name of the node producing tensor with predicted characters.
|
||||
* `transpose_2` - name of the node producing tensor with predicted characters probabilities.
|
||||
* `transpose_2` - name of the node producing tensor with predicted characters probabilties
|
||||
@@ -1,11 +1,11 @@
|
||||
# Converting a TensorFlow BERT Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_BERT_From_Tensorflow}
|
||||
# Convert TensorFlow BERT Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_BERT_From_Tensorflow}
|
||||
|
||||
Pretrained models for BERT (Bidirectional Encoder Representations from Transformers) are
|
||||
Pre-trained models for BERT (Bidirectional Encoder Representations from Transformers) are
|
||||
[publicly available](https://github.com/google-research/bert).
|
||||
|
||||
## <a name="supported_models"></a>Supported Models
|
||||
|
||||
The following models from the pretrained [BERT model list](https://github.com/google-research/bert#pre-trained-models) are currently supported:
|
||||
Currently, the following models from the [pre-trained BERT model list](https://github.com/google-research/bert#pre-trained-models) are supported:
|
||||
|
||||
* `BERT-Base, Cased`
|
||||
* `BERT-Base, Uncased`
|
||||
@@ -15,7 +15,7 @@ The following models from the pretrained [BERT model list](https://github.com/go
|
||||
* `BERT-Large, Cased`
|
||||
* `BERT-Large, Uncased`
|
||||
|
||||
## Downloading the Pretrained BERT Model
|
||||
## Download the Pre-Trained BERT Model
|
||||
|
||||
Download and unzip an archive with the [BERT-Base, Multilingual Uncased Model](https://storage.googleapis.com/bert_models/2018_11_03/multilingual_L-12_H-768_A-12.zip).
|
||||
|
||||
@@ -26,11 +26,11 @@ After the archive is unzipped, the directory `uncased_L-12_H-768_A-12` is create
|
||||
* `bert_model.ckpt.meta`
|
||||
* `vocab.txt`
|
||||
|
||||
Pretrained model meta-graph files are `bert_model.ckpt.*`.
|
||||
Pre-trained model meta-graph files are `bert_model.ckpt.*`.
|
||||
|
||||
## Converting a TensorFlow BERT Model to IR
|
||||
## Convert TensorFlow BERT Model to IR
|
||||
|
||||
To generate the BERT Intermediate Representation (IR) of the model, run Model Optimizer with the following parameters:
|
||||
To generate the BERT Intermediate Representation (IR) of the model, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
mo \
|
||||
--input_meta_graph uncased_L-12_H-768_A-12/bert_model.ckpt.meta \
|
||||
@@ -38,12 +38,12 @@ To generate the BERT Intermediate Representation (IR) of the model, run Model Op
|
||||
--input Placeholder{i32},Placeholder_1{i32},Placeholder_2{i32}
|
||||
```
|
||||
|
||||
Pretrained models are not suitable for batch reshaping out-of-the-box because of multiple hardcoded shapes in the model.
|
||||
Pre-trained models are not suitable for batch reshaping out-of-the-box because of multiple hardcoded shapes in the model.
|
||||
|
||||
# Converting a Reshapable TensorFlow BERT Model to OpenVINO IR
|
||||
# Convert Reshape-able TensorFlow* BERT Model to the Intermediate Representation
|
||||
|
||||
Follow these steps to make a pretrained TensorFlow BERT model reshapable over batch dimension:
|
||||
1. Download a pretrained BERT model you want to use from the <a href="#supported_models">Supported Models list</a>
|
||||
Follow these steps to make pre-trained TensorFlow BERT model reshape-able over batch dimension:
|
||||
1. Download pre-trained BERT model you would like to use from the <a href="#supported_models">Supported Models list</a>
|
||||
2. Clone google-research/bert git repository:
|
||||
```sh
|
||||
https://github.com/google-research/bert.git
|
||||
@@ -57,11 +57,11 @@ cd bert
|
||||
git checkout eedf5716c
|
||||
```
|
||||
5. Download script to load GLUE data:
|
||||
* For UNIX-like systems, run the following command:
|
||||
* For UNIX*-like systems, run the following command:
|
||||
```sh
|
||||
wget https://gist.githubusercontent.com/W4ngatang/60c2bdb54d156a41194446737ce03e2e/raw/17b8dd0d724281ed7c3b2aeeda662b92809aadd5/download_glue_data.py
|
||||
```
|
||||
* For Windows systems:<br>
|
||||
* For Windows* systems:<br>
|
||||
Download the [Python script](https://gist.githubusercontent.com/W4ngatang/60c2bdb54d156a41194446737ce03e2e/raw/17b8dd0d724281ed7c3b2aeeda662b92809aadd5/download_glue_data.py) to the current working directory.
|
||||
6. Download GLUE data by running:
|
||||
```sh
|
||||
@@ -108,12 +108,12 @@ python3 run_classifier.py \
|
||||
--output_dir=./
|
||||
```
|
||||
|
||||
Run Model Optimizer with the following command line parameters to generate reshape-able BERT Intermediate Representation (IR):
|
||||
Run the Model Optimizer with the following command line parameters to generate reshape-able BERT Intermediate Representation (IR):
|
||||
```sh
|
||||
mo \
|
||||
--input_model inference_graph.pb \
|
||||
--input "IteratorGetNext:0{i32}[1 128],IteratorGetNext:1{i32}[1 128],IteratorGetNext:4{i32}[1 128]"
|
||||
```
|
||||
For other applicable parameters, refer to the [Convert Model from TensorFlow](../Convert_Model_From_TensorFlow.md) guide.
|
||||
For other applicable parameters, refer to [Convert Model from TensorFlow](../Convert_Model_From_TensorFlow.md).
|
||||
|
||||
For more information about reshape abilities, refer to the [Using Shape Inference](../../../../OV_Runtime_UG/ShapeInference.md) guide.
|
||||
For more information about reshape abilities, refer to [Using Shape Inference](../../../../OV_Runtime_UG/ShapeInference.md).
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Converting a TensorFlow CRNN Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_CRNN_From_Tensorflow}
|
||||
# Convert TensorFlow CRNN Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_CRNN_From_Tensorflow}
|
||||
|
||||
This tutorial explains how to convert a CRNN model to Intermediate Representation (IR).
|
||||
|
||||
There are several public versions of TensorFlow CRNN model implementation available on GitHub. This tutorial explains how to convert the model from
|
||||
the [https://github.com/MaybeShewill-CV/CRNN_Tensorflow](https://github.com/MaybeShewill-CV/CRNN_Tensorflow) repository to IR.
|
||||
If you have another implementation of CRNN model, it can be converted to OpenVINO IR in a similar way. You need to get inference graph and run Model Optimizer on it.
|
||||
On GitHub*, you can find several public versions of TensorFlow\* CRNN model implementation. This tutorial explains how to convert the model from
|
||||
the [https://github.com/MaybeShewill-CV/CRNN_Tensorflow](https://github.com/MaybeShewill-CV/CRNN_Tensorflow) repository to IR. If you
|
||||
have another implementation of CRNN model, you can convert it to IR in similar way: you need to get inference graph and run the Model Optimizer on it.
|
||||
|
||||
**To convert this model to the IR:**
|
||||
|
||||
@@ -18,19 +18,19 @@ If you have another implementation of CRNN model, it can be converted to OpenVIN
|
||||
git checkout 64f1f1867bffaacfeacc7a80eebf5834a5726122
|
||||
```
|
||||
|
||||
**Step 2.** Train the model, using framework or use the pretrained checkpoint provided in this repository.
|
||||
**Step 2.** Train the model using framework or use the pre-trained checkpoint provided in this repository.
|
||||
|
||||
**Step 3.** Create an inference graph:
|
||||
1. Go to the `CRNN_Tensorflow` directory of the cloned repository:
|
||||
1. Go to the `CRNN_Tensorflow` directory with the cloned repository:
|
||||
```sh
|
||||
cd path/to/CRNN_Tensorflow
|
||||
```
|
||||
2. Add `CRNN_Tensorflow` folder to `PYTHONPATH`.
|
||||
* For Linux OS:
|
||||
* For Linux\* OS:
|
||||
```sh
|
||||
export PYTHONPATH="${PYTHONPATH}:/path/to/CRNN_Tensorflow/"
|
||||
```
|
||||
* For Windows OS add `/path/to/CRNN_Tensorflow/` to the `PYTHONPATH` environment variable in settings.
|
||||
* For Windows\* OS add `/path/to/CRNN_Tensorflow/` to the `PYTHONPATH` environment variable in settings.
|
||||
3. Open the `tools/test_shadownet.py` script. After `saver.restore(sess=sess, save_path=weights_path)` line, add the following code:
|
||||
```python
|
||||
import tensorflow as tf
|
||||
@@ -44,9 +44,9 @@ python tools/test_shadownet.py --image_path data/test_images/test_01.jpg --weigh
|
||||
```
|
||||
If you want to use your checkpoint, replace the path in the `--weights_path` parameter with a path to your checkpoint.
|
||||
5. In the `CRNN_Tensorflow` directory, you will find the inference CRNN graph `frozen_graph.pb`. You can use this graph with the OpenVINO™ toolkit
|
||||
to convert the model into the IR and run inference.
|
||||
to convert the model into IR and run inference.
|
||||
|
||||
**Step 4.** Convert the model into the IR:
|
||||
**Step 4.** Convert the model into IR:
|
||||
```sh
|
||||
mo --input_model path/to/your/CRNN_Tensorflow/frozen_graph.pb
|
||||
```
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Converting a TensorFlow DeepSpeech Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_DeepSpeech_From_Tensorflow}
|
||||
# Convert TensorFlow DeepSpeech Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_DeepSpeech_From_Tensorflow}
|
||||
|
||||
[DeepSpeech project](https://github.com/mozilla/DeepSpeech) provides an engine to train speech-to-text models.
|
||||
|
||||
## Downloading the Pretrained DeepSpeech Model
|
||||
## Download the Pretrained DeepSpeech Model
|
||||
|
||||
Create a directory where model and metagraph with pretrained weights will be stored:
|
||||
```
|
||||
@@ -12,20 +12,20 @@ cd deepspeech
|
||||
[Pretrained English speech-to-text model](https://github.com/mozilla/DeepSpeech/releases/tag/v0.8.2) is publicly available.
|
||||
To download the model, follow the instruction below:
|
||||
|
||||
* For UNIX-like systems, run the following command:
|
||||
* For UNIX*-like systems, run the following command:
|
||||
```
|
||||
wget -O - https://github.com/mozilla/DeepSpeech/archive/v0.8.2.tar.gz | tar xvfz -
|
||||
wget -O - https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/deepspeech-0.8.2-checkpoint.tar.gz | tar xvfz -
|
||||
```
|
||||
* For Windows systems:
|
||||
1. Download [the archive with the model](https://github.com/mozilla/DeepSpeech/archive/v0.8.2.tar.gz).
|
||||
2. Download the [TensorFlow MetaGraph with pretrained weights](https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/deepspeech-0.8.2-checkpoint.tar.gz).
|
||||
* For Windows* systems:
|
||||
1. Download the archive with the model: [https://github.com/mozilla/DeepSpeech/archive/v0.8.2.tar.gz](https://github.com/mozilla/DeepSpeech/archive/v0.8.2.tar.gz).
|
||||
2. Download the TensorFlow\* MetaGraph with pretrained weights: [https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/deepspeech-0.8.2-checkpoint.tar.gz](https://github.com/mozilla/DeepSpeech/releases/download/v0.8.2/deepspeech-0.8.2-checkpoint.tar.gz).
|
||||
3. Unpack it with a file archiver application.
|
||||
|
||||
## Freezing the Model into a *.pb File
|
||||
## Freeze the Model into a *.pb File
|
||||
|
||||
After unpacking the archives above, you have to freeze the model. This requires
|
||||
TensorFlow version 1, which is not available under Python 3.8, so you need Python 3.7 or lower.
|
||||
After unpacking the archives above, you have to freeze the model. Note that this requires
|
||||
TensorFlow* version 1 which is not available under Python 3.8, so you need Python 3.7 or lower.
|
||||
Before freezing, deploy a virtual environment and install the required packages:
|
||||
```
|
||||
virtualenv --python=python3.7 venv-deep-speech
|
||||
@@ -40,24 +40,24 @@ python3 DeepSpeech.py --checkpoint_dir ../deepspeech-0.8.2-checkpoint --export_d
|
||||
After that, you will get the pretrained frozen model file `output_graph.pb` in the directory `deepspeech` created at
|
||||
the beginning. The model contains the preprocessing and main parts. The first preprocessing part performs conversion of input
|
||||
spectrogram into a form useful for speech recognition (mel). This part of the model is not convertible into
|
||||
the IR because it contains unsupported operations `AudioSpectrogram` and `Mfcc`.
|
||||
IR because it contains unsupported operations `AudioSpectrogram` and `Mfcc`.
|
||||
|
||||
The main and most computationally expensive part of the model converts the preprocessed audio into text.
|
||||
There are two specificities with the supported part of the model.
|
||||
|
||||
The first is that the model contains an input with sequence length. So the model can be converted with
|
||||
a fixed input length shape, thus the model is not reshapable.
|
||||
Refer to the [Using Shape Inference](../../../../OV_Runtime_UG/ShapeInference.md) guide.
|
||||
a fixed input length shape, thus the model is not reshapeable.
|
||||
Refer to the [Using Shape Inference](../../../../OV_Runtime_UG/ShapeInference.md).
|
||||
|
||||
The second is that the frozen model still has two variables: `previous_state_c` and `previous_state_h`, figure
|
||||
with the frozen *.pb model is below. It means that the model keeps training these variables at each inference.
|
||||
|
||||

|
||||
|
||||
At the first inference, the variables are initialized with zero tensors. After execution, the results of the `BlockLSTM'
|
||||
At the first inference the variables are initialized with zero tensors. After executing, the results of the `BlockLSTM`
|
||||
are assigned to cell state and hidden state, which are these two variables.
|
||||
|
||||
## Converting the Main Part of DeepSpeech Model into OpenVINO IR
|
||||
## Convert the Main Part of DeepSpeech Model into IR
|
||||
|
||||
Model Optimizer assumes that the output model is for inference only. That is why you should cut `previous_state_c`
|
||||
and `previous_state_h` variables off and resolve keeping cell and hidden states on the application level.
|
||||
@@ -66,7 +66,7 @@ There are certain limitations for the model conversion:
|
||||
- Time length (`time_len`) and sequence length (`seq_len`) are equal.
|
||||
- Original model cannot be reshaped, so you should keep original shapes.
|
||||
|
||||
To generate the IR, run Model Optimizer with the following parameters:
|
||||
To generate the IR, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
mo \
|
||||
--input_model output_graph.pb \
|
||||
@@ -76,6 +76,6 @@ mo \
|
||||
|
||||
Where:
|
||||
* `input_lengths->[16]` Replaces the input node with name "input_lengths" with a constant tensor of shape [1] with a
|
||||
single integer value of 16. This means that the model now can consume input sequences of length 16 only.
|
||||
single integer value 16. This means that the model now can consume input sequences of length 16 only.
|
||||
* `input_node[1 16 19 26],previous_state_h[1 2048],previous_state_c[1 2048]` replaces the variables with a placeholder.
|
||||
* `--output ".../GatherNd_1,.../GatherNd,logits" ` output node names.
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# Converting TensorFlow EfficientDet Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_EfficientDet_Models}
|
||||
# Convert TensorFlow EfficientDet Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_EfficientDet_Models}
|
||||
|
||||
This tutorial explains how to convert EfficientDet public object detection models to the Intermediate Representation (IR).
|
||||
This tutorial explains how to convert EfficientDet\* public object detection models to the Intermediate Representation (IR).
|
||||
|
||||
## <a name="efficientdet-to-ir"></a>Converting EfficientDet Model to the IR
|
||||
## <a name="efficientdet-to-ir"></a>Convert EfficientDet Model to IR
|
||||
|
||||
There are several public versions of EfficientDet model implementation available on GitHub. This tutorial explains how to
|
||||
convert models from the [repository](https://github.com/google/automl/tree/master/efficientdet)
|
||||
(commit 96e1fee) to the OpenVINO format.
|
||||
On GitHub*, you can find several public versions of EfficientDet model implementation. This tutorial explains how to
|
||||
convert models from the [https://github.com/google/automl/tree/master/efficientdet](https://github.com/google/automl/tree/master/efficientdet)
|
||||
repository (commit 96e1fee) to IR.
|
||||
|
||||
### Getting a Frozen TensorFlow Model
|
||||
### Get Frozen TensorFlow\* Model
|
||||
|
||||
Follow the instructions below to get frozen TensorFlow EfficientDet model. EfficientDet-D4 model is an example:
|
||||
Follow the instructions below to get frozen TensorFlow EfficientDet model. We use EfficientDet-D4 model as an example:
|
||||
|
||||
1. Clone the repository:<br>
|
||||
```sh
|
||||
@@ -28,7 +28,7 @@ python3 -m pip install -r requirements.txt
|
||||
python3 -m pip install --upgrade tensorflow-model-optimization
|
||||
```
|
||||
4. Download and extract the model checkpoint [efficientdet-d4.tar.gz](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d4.tar.gz)
|
||||
referenced in the **"Pretrained EfficientDet Checkpoints"** section of the model repository:<br>
|
||||
referenced in the "Pre-trained EfficientDet Checkpoints" section of the model repository:<br>
|
||||
```sh
|
||||
wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d4.tar.gz
|
||||
tar zxvf efficientdet-d4.tar.gz
|
||||
@@ -37,13 +37,13 @@ tar zxvf efficientdet-d4.tar.gz
|
||||
```sh
|
||||
mo --runmode=saved_model --model_name=efficientdet-d4 --ckpt_path=efficientdet-d4 --saved_model_dir=savedmodeldir
|
||||
```
|
||||
As a result, the frozen model file `savedmodeldir/efficientdet-d4_frozen.pb` will be generated.
|
||||
As a result the frozen model file `savedmodeldir/efficientdet-d4_frozen.pb` will be generated.
|
||||
|
||||
> **NOTE**: For custom trained models, specify `--hparams` flag to `config.yaml` which was used during training.
|
||||
|
||||
> **NOTE**: If you see an error `AttributeError: module 'tensorflow_core.python.keras.api._v2.keras.initializers' has no attribute 'variance_scaling'`, apply the fix from the [patch](https://github.com/google/automl/pull/846).
|
||||
> **NOTE**: If you see an error `AttributeError: module 'tensorflow_core.python.keras.api._v2.keras.initializers' has no attribute 'variance_scaling'` apply the fix from the [patch](https://github.com/google/automl/pull/846).
|
||||
|
||||
### Converting an EfficientDet TensorFlow Model to the IR
|
||||
### Convert EfficientDet TensorFlow Model to the IR
|
||||
|
||||
To generate the IR of the EfficientDet TensorFlow model, run:<br>
|
||||
```sh
|
||||
@@ -55,20 +55,20 @@ mo \
|
||||
```
|
||||
|
||||
Where `$IMAGE_SIZE` is the size that the input image of the original TensorFlow model will be resized to. Different
|
||||
EfficientDet models were trained with different input image sizes. To determine the right one, refer to the `efficientdet_model_param_dict`
|
||||
EfficientDet models were trained with different input image sizes. To determine the right one refer to the `efficientdet_model_param_dict`
|
||||
dictionary in the [hparams_config.py](https://github.com/google/automl/blob/96e1fee/efficientdet/hparams_config.py#L304) file.
|
||||
The attribute `image_size` specifies the shape to be defined for the model conversion.
|
||||
The attribute `image_size` specifies the shape to be specified for the model conversion.
|
||||
|
||||
The `transformations_config` command line parameter specifies the configuration json file containing hints
|
||||
for the Model Optimizer on how to convert the model and trigger transformations implemented in the
|
||||
to the Model Optimizer on how to convert the model and trigger transformations implemented in the
|
||||
`<PYTHON_SITE_PACKAGES>/openvino/tools/mo/front/tf/AutomlEfficientDet.py`. The json file contains some parameters which must be changed if you
|
||||
train the model yourself and modified the `hparams_config` file or the parameters are different from the ones used for EfficientDet-D4.
|
||||
The attribute names are self-explanatory or match the name in the `hparams_config` file.
|
||||
|
||||
> **NOTE**: The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. For more information about the parameter, refer to the **When to Reverse Input Channels** section of the [Converting a Model to Intermediate Representation (IR)](../Converting_Model.md) guide.
|
||||
> **NOTE**: The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. For more information about the parameter, refer to **When to Reverse Input Channels** section of [Converting a Model to Intermediate Representation (IR)](../Converting_Model.md).
|
||||
|
||||
OpenVINO™ toolkit provides samples that can be used to infer EfficientDet model.
|
||||
For more information, refer to the [Open Model Zoo Demos](@ref omz_demos).
|
||||
OpenVINO™ toolkit provides samples that can be used to infer EfficientDet model. For more information, refer to
|
||||
[Open Model Zoo Demos](@ref omz_demos) and
|
||||
|
||||
## <a name="efficientdet-ir-results-interpretation"></a>Interpreting Results of the TensorFlow Model and the IR
|
||||
|
||||
@@ -90,4 +90,4 @@ The output of the IR is a list of 7-element tuples: `[image_id, class_id, confid
|
||||
* `x_max` -- normalized `x` coordinate of the upper right corner of the detected object.
|
||||
* `y_max` -- normalized `y` coordinate of the upper right corner of the detected object.
|
||||
|
||||
The first element with `image_id = -1` means end of data.
|
||||
The first element with `image_id = -1` means end of data.
|
||||
@@ -1,6 +1,6 @@
|
||||
# Converting TensorFlow FaceNet Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_FaceNet_From_Tensorflow}
|
||||
# Convert TensorFlow FaceNet Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_FaceNet_From_Tensorflow}
|
||||
|
||||
[Public pretrained FaceNet models](https://github.com/davidsandberg/facenet#pre-trained-models) contain both training
|
||||
[Public pre-trained FaceNet models](https://github.com/davidsandberg/facenet#pre-trained-models) contain both training
|
||||
and inference part of graph. Switch between this two states is manageable with placeholder value.
|
||||
Intermediate Representation (IR) models are intended for inference, which means that train part is redundant.
|
||||
|
||||
@@ -10,19 +10,19 @@ There are two inputs in this network: boolean `phase_train` which manages state
|
||||
|
||||

|
||||
|
||||
## Converting a TensorFlow FaceNet Model to the IR
|
||||
## Convert TensorFlow FaceNet Model to IR
|
||||
|
||||
To generate a FaceNet OpenVINO model, feed a TensorFlow FaceNet model to Model Optimizer with the following parameters:
|
||||
To generate FaceNet IR provide TensorFlow FaceNet model to Model Optimizer with parameters:
|
||||
```sh
|
||||
mo
|
||||
--input_model path_to_model/model_name.pb \
|
||||
--freeze_placeholder_with_value "phase_train->False"
|
||||
```
|
||||
|
||||
The batch joining pattern transforms to a placeholder with the model default shape if `--input_shape` or `--batch`*/*`-b` are not
|
||||
provided. Otherwise, the placeholder shape has custom parameters.
|
||||
Batch joining pattern transforms to placeholder with model default shape if `--input_shape` or `--batch`/`-b` was not
|
||||
provided. Otherwise, placeholder shape has custom parameters.
|
||||
|
||||
* `--freeze_placeholder_with_value "phase_train->False"` to switch graph to inference mode
|
||||
* `--batch`*/*`-b` is applicable to override original network batch
|
||||
* `--batch`/`-b` is applicable to override original network batch
|
||||
* `--input_shape` is applicable with or without `--input`
|
||||
* other options are applicable
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Converting a TensorFlow GNMT Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_GNMT_From_Tensorflow}
|
||||
# Convert TensorFlow GNMT Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_GNMT_From_Tensorflow}
|
||||
|
||||
This tutorial explains how to convert Google Neural Machine Translation (GNMT) model to the Intermediate Representation (IR).
|
||||
This tutorial explains how to convert Google\* Neural Machine Translation (GNMT) model to the Intermediate Representation (IR).
|
||||
|
||||
There are several public versions of TensorFlow GNMT model implementation available on GitHub. This tutorial explains how to convert the GNMT model from the [TensorFlow Neural Machine Translation (NMT) repository](https://github.com/tensorflow/nmt) to the IR.
|
||||
On GitHub*, you can find several public versions of TensorFlow* GNMT model implementation. This tutorial explains how to convert the GNMT model from the [TensorFlow* Neural Machine Translation (NMT) repository](https://github.com/tensorflow/nmt) to the IR.
|
||||
|
||||
## Creating a Patch File <a name="patch-file"></a>
|
||||
## Create a Patch File <a name="patch-file"></a>
|
||||
|
||||
Before converting the model, you need to create a patch file for the repository. The patch modifies the framework code by adding a special command-line argument to the framework options that enables inference graph dumping:
|
||||
|
||||
@@ -137,9 +137,9 @@ index f5823d8..a733748 100644
|
||||
```
|
||||
3. Save and close the file.
|
||||
|
||||
## Converting a GNMT Model to the IR
|
||||
## Convert GNMT Model to IR
|
||||
|
||||
> **NOTE**: Use TensorFlow version 1.13 or lower.
|
||||
> **NOTE**: Please, use TensorFlow version 1.13 or lower.
|
||||
|
||||
**Step 1**. Clone the GitHub repository and check out the commit:
|
||||
|
||||
@@ -187,7 +187,7 @@ python -m nmt.nmt
|
||||
If you use different checkpoints, use the corresponding values for the `src`,`tgt`,`ckpt`,`hparams_path`, and `vocab_prefix` parameters.
|
||||
Inference checkpoint `inference_GNMT_graph` and frozen inference graph `frozen_GNMT_inference_graph.pb` will appear in the `/path/to/dump/model/` folder.
|
||||
|
||||
To generate `vocab.bpe.32000`, execute the `nmt/scripts/wmt16_en_de.sh` script. If you face an issue of a size mismatch between the checkpoint graph's embedding layer and vocabulary (both src and target), make sure you add the following code to the `nmt.py` file to the `extend_hparams` function after the line 508 (after initialization of the `src_vocab_size` and `tgt_vocab_size` variables):
|
||||
To generate `vocab.bpe.32000`, execute the `nmt/scripts/wmt16_en_de.sh` script. If you face an issue of a size mismatch between the checkpoint graph's embedding layer and vocabulary (both src and target), we recommend you to add the following code to the `nmt.py` file to the `extend_hparams` function after the line 508 (after initialization of the `src_vocab_size` and `tgt_vocab_size` variables):
|
||||
```py
|
||||
src_vocab_size -= 1
|
||||
tgt_vocab_size -= 1
|
||||
@@ -215,9 +215,9 @@ Output cutting:
|
||||
|
||||
* `LookupTableFindV2` operation is cut from the output and the `dynamic_seq2seq/decoder/decoder/GatherTree` node is treated as a new exit point.
|
||||
|
||||
For more information about model cutting, refer to the [Cutting Off Parts of a Model](../Cutting_Model.md) guide.
|
||||
For more information about model cutting, refer to [Cutting Off Parts of a Model](../Cutting_Model.md).
|
||||
|
||||
## Using a GNMT Model <a name="run_GNMT"></a>
|
||||
## How to Use GNMT Model <a name="run_GNMT"></a>
|
||||
|
||||
> **NOTE**: This step assumes you have converted a model to the Intermediate Representation.
|
||||
|
||||
@@ -225,7 +225,7 @@ Inputs of the model:
|
||||
* `IteratorGetNext/placeholder_out_port_0` input with shape `[batch_size, max_sequence_length]` contains `batch_size` decoded input sentences.
|
||||
Every sentence is decoded the same way as indices of sentence elements in vocabulary and padded with index of `eos` (end of sentence symbol). If the length of the sentence is less than `max_sequence_length`, remaining elements are filled with index of `eos` token.
|
||||
|
||||
* `IteratorGetNext/placeholder_out_port_1` input with shape `[batch_size]` contains sequence lengths for every sentence from the first input.
|
||||
* `IteratorGetNext/placeholder_out_port_1` input with shape `[batch_size]` contains sequence lengths for every sentence from the first input. \
|
||||
For example, if `max_sequence_length = 50`, `batch_size = 1` and the sentence has only 30 elements, then the input tensor for `IteratorGetNext/placeholder_out_port_1` should be `[30]`.
|
||||
|
||||
|
||||
@@ -233,16 +233,17 @@ Outputs of the model:
|
||||
|
||||
* `dynamic_seq2seq/decoder/decoder/GatherTree` tensor with shape `[max_sequence_length * 2, batch, beam_size]`,
|
||||
that contains `beam_size` best translations for every sentence from input (also decoded as indices of words in
|
||||
vocabulary).
|
||||
> **NOTE**: The shape of this tensor in TensorFlow can be different: instead of `max_sequence_length * 2`, it can be any value less than that, because OpenVINO™ does not support dynamic shapes of outputs, while TensorFlow can stop decoding iterations when `eos` symbol is generated.
|
||||
vocabulary). \
|
||||
> **NOTE**: Shape of this tensor in TensorFlow\* can be different: instead of `max_sequence_length * 2`, it can be any value less than that, because OpenVINO™ does not support dynamic shapes of outputs, while TensorFlow can stop decoding iterations when `eos` symbol is generated.*
|
||||
|
||||
#### Running GNMT IR <a name="run_GNMT"></a>
|
||||
#### How to RUN GNMT IR <a name="run_GNMT"></a>
|
||||
|
||||
1. With benchmark app:
|
||||
```sh
|
||||
benchmark_app -m <path to the generated GNMT IR> -d CPU
|
||||
```
|
||||
|
||||
|
||||
2. With OpenVINO Runtime Python API:
|
||||
|
||||
> **NOTE**: Before running the example, insert a path to your GNMT `.xml` and `.bin` files into `MODEL_PATH` and `WEIGHTS_PATH`, and fill `input_data_tensor` and `seq_lengths` tensors according to your input data.
|
||||
@@ -273,4 +274,4 @@ exec_net = ie.load_network(network=net, device_name="CPU")
|
||||
result_ie = exec_net.infer(input_data)
|
||||
```
|
||||
|
||||
For more information about Python API, refer to the [OpenVINO Runtime Python API](ie_python_api/api.html) guide.
|
||||
For more information about Python API, refer to [OpenVINO Runtime Python API](ie_python_api/api.html).
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Converting a TensorFlow Neural Collaborative Filtering Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_NCF_From_Tensorflow}
|
||||
# Convert TensorFlow Neural Collaborative Filtering Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_NCF_From_Tensorflow}
|
||||
|
||||
This tutorial explains how to convert Neural Collaborative Filtering (NCF) model to the OpenVINO Intermediate Representation.
|
||||
This tutorial explains how to convert Neural Collaborative Filtering (NCF) model to Intermediate Representation (IR).
|
||||
|
||||
[Public TensorFlow NCF model](https://github.com/tensorflow/models/tree/master/official/recommendation) does not contain pre-trained weights. To convert this model to the IR:
|
||||
1. Use [the instructions](https://github.com/tensorflow/models/tree/master/official/recommendation#train-and-evaluate-model) from this repository to train the model.
|
||||
2. Freeze the inference graph you get in the previous step in `model_dir`, following
|
||||
the instructions from the **Freezing Custom Models in Python** section of the
|
||||
[Converting a TensorFlow Model](../Convert_Model_From_TensorFlow.md) guide.
|
||||
2. Freeze the inference graph you get on previous step in `model_dir` following
|
||||
the instructions from the Freezing Custom Models in Python* section of
|
||||
[Converting a TensorFlow* Model](../Convert_Model_From_TensorFlow.md).
|
||||
Run the following commands:
|
||||
```python
|
||||
import tensorflow as tf
|
||||
@@ -22,13 +22,13 @@ graph_io.write_graph(frozen, './', 'inference_graph.pb', as_text=False)
|
||||
```
|
||||
where `rating/BiasAdd` is an output node.
|
||||
|
||||
3. Convert the model to the OpenVINO format. If you look at your frozen model, you can see that
|
||||
3. Convert the model to the IR.If you look at your frozen model, you can see that
|
||||
it has one input that is split into four `ResourceGather` layers. (Click image to zoom in.)
|
||||
|
||||

|
||||
|
||||
However, as the Model Optimizer does not support such data feeding, you should skip it. Cut
|
||||
the edges incoming in `ResourceGather` port 1:
|
||||
But as the Model Optimizer does not support such data feeding, you should skip it. Cut
|
||||
the edges incoming in `ResourceGather`s port 1:
|
||||
```sh
|
||||
mo --input_model inference_graph.pb \
|
||||
--input 1:embedding/embedding_lookup,1:embedding_1/embedding_lookup, \
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
# Converting TensorFlow Object Detection API Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Object_Detection_API_Models}
|
||||
# Convert TensorFlow Object Detection API Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Object_Detection_API_Models}
|
||||
|
||||
> **NOTES**:
|
||||
> * Starting with the 2022.1 release, Model Optimizer can convert the TensorFlow Object Detection API Faster and Mask RCNNs topologies differently. By default, Model Optimizer adds operation "Proposal" to the generated IR. This operation needs an additional input to the model with name "image_info" which should be fed with several values describing the preprocessing applied to the input image (refer to the [Proposal](../../../../ops/detection/Proposal_4.md) operation specification for more information). However, this input is redundant for the models trained and inferred with equal size images. Model Optimizer can generate IR for such models and insert operation [DetectionOutput](../../../../ops/detection/DetectionOutput_1.md) instead of `Proposal`. The `DetectionOutput` operation does not require additional model input "image_info". Moreover, for some models the produced inference results are closer to the original TensorFlow model. In order to trigger new behavior, the attribute "operation_to_add" in the corresponding JSON transformation configuration file should be set to value "DetectionOutput" instead of default one "Proposal".
|
||||
> * Starting with the 2021.1 release, Model Optimizer converts the TensorFlow Object Detection API SSDs, Faster and Mask RCNNs topologies keeping shape-calculating sub-graphs by default, so topologies can be re-shaped in the OpenVINO Runtime using dedicated reshape API. Refer to the [Using Shape Inference](../../../../OV_Runtime_UG/ShapeInference.md) guide for more information on how to use this feature. It is possible to change the both spatial dimensions of the input image and batch size.
|
||||
> * To generate IRs for TF 1 SSD topologies, Model Optimizer creates a number of `PriorBoxClustered` operations instead of a constant node with prior boxes calculated for the particular input image size. This change allows you to reshape the topology in the OpenVINO Runtime using dedicated API. The reshaping is supported for all SSD topologies except FPNs, which contain hardcoded shapes for some operations preventing from changing topology input shape.
|
||||
> * Starting with the 2022.1 release, the Model Optimizer can convert the TensorFlow\* Object Detection API Faster and Mask RCNNs topologies differently. By default, the Model Optimizer adds operation "Proposal" to the generated IR. This operation needs an additional input to the model with name "image_info" which should be fed with several values describing the pre-processing applied to the input image (refer to the [Proposal](../../../../ops/detection/Proposal_4.md) operation specification for more information). However, this input is redundant for the models trained and inferred with equal size images. Model Optimizer can generate IR for such models and insert operation [DetectionOutput](../../../../ops/detection/DetectionOutput_1.md) instead of `Proposal`. The `DetectionOutput` operation does not require additional model input "image_info" and moreover, for some models the produced inference results are closer to the original TensorFlow\* model. In order to trigger new behavior the attribute "operation_to_add" in the corresponding JSON transformation configuration file should be set to value "DetectionOutput" instead of default one "Proposal".
|
||||
> * Starting with the 2021.1 release, the Model Optimizer converts the TensorFlow\* Object Detection API SSDs, Faster and Mask RCNNs topologies keeping shape-calculating sub-graphs by default, so topologies can be re-shaped in the OpenVINO Runtime using dedicated reshape API. Refer to [Using Shape Inference](../../../../OV_Runtime_UG/ShapeInference.md) for more information on how to use this feature. It is possible to change the both spatial dimensions of the input image and batch size.
|
||||
> * To generate IRs for TF 1 SSD topologies, the Model Optimizer creates a number of `PriorBoxClustered` operations instead of a constant node with prior boxes calculated for the particular input image size. This change allows you to reshape the topology in the OpenVINO Runtime using dedicated API. The reshaping is supported for all SSD topologies except FPNs which contain hardcoded shapes for some operations preventing from changing topology input shape.
|
||||
|
||||
## Converting a Model
|
||||
## How to Convert a Model
|
||||
|
||||
You can download TensorFlow Object Detection API models from the <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md">TensorFlow 1 Detection Model Zoo</a> or <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_detection_zoo.md">TensorFlow 2 Detection Model Zoo</a>.
|
||||
You can download TensorFlow\* Object Detection API models from the <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_detection_zoo.md">TensorFlow 1 Detection Model Zoo</a> or <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_detection_zoo.md">TensorFlow 2 Detection Model Zoo</a>.
|
||||
|
||||
> **NOTE**: Before converting, make sure you have configured Model Optimizer. For configuration steps, refer to the [Configuring Model Optimizer](../../../Deep_Learning_Model_Optimizer_DevGuide.md).
|
||||
> **NOTE**: Before converting, make sure you have configured the Model Optimizer. For configuration steps, refer to [Configuring the Model Optimizer](../../../Deep_Learning_Model_Optimizer_DevGuide.md).
|
||||
|
||||
To convert a TensorFlow Object Detection API model, run the `mo` command with the following required parameters:
|
||||
To convert a TensorFlow\* Object Detection API model, run the `mo` command with the following required parameters:
|
||||
|
||||
* `--input_model <path_to_frozen.pb>` --- File with a pretrained model (binary or text .pb file after freezing) OR `--saved_model_dir <path_to_saved_model>` for the TensorFlow 2 models
|
||||
* `--transformations_config <path_to_subgraph_replacement_configuration_file.json>` --- A subgraph replacement configuration file with transformations description. For the models downloaded from the TensorFlow Object Detection API zoo, you can find the configuration files in the `<PYTHON_SITE_PACKAGES>/openvino/tools/mo/front/tf` directory. Use:
|
||||
* `--input_model <path_to_frozen.pb>` --- File with a pre-trained model (binary or text .pb file after freezing) OR `--saved_model_dir <path_to_saved_model>` for the TensorFlow\* 2 models
|
||||
* `--transformations_config <path_to_subgraph_replacement_configuration_file.json>` --- A subgraph replacement configuration file with transformations description. For the models downloaded from the TensorFlow\* Object Detection API zoo, you can find the configuration files in the `<PYTHON_SITE_PACKAGES>/openvino/tools/mo/front/tf` directory. Use:
|
||||
* `ssd_v2_support.json` --- for frozen SSD topologies from the models zoo version up to 1.13.X inclusively
|
||||
* `ssd_support_api_v.1.14.json` --- for SSD topologies trained using the TensorFlow Object Detection API version 1.14 up to 1.14.X inclusively
|
||||
* `ssd_support_api_v.1.15.json` --- for SSD topologies trained using the TensorFlow Object Detection API version 1.15 up to 2.0
|
||||
* `ssd_support_api_v.2.0.json` --- for SSD topologies trained using the TensorFlow Object Detection API version 2.0 up to 2.3.X inclusively
|
||||
* `ssd_support_api_v.2.4.json` --- for SSD topologies trained using the TensorFlow Object Detection API version 2.4 or higher
|
||||
* `efficient_det_support_api_v.2.0.json` --- for EfficientDet topologies trained using the TensorFlow Object Detection API version 2.0 up to 2.3.X inclusively
|
||||
* `efficient_det_support_api_v.2.4.json` --- for EfficientDet topologies trained using the TensorFlow Object Detection API version 2.4 or higher
|
||||
* `faster_rcnn_support.json` --- for Faster R-CNN topologies from the TF 1.X models zoo trained with TensorFlow version up to 1.6.X inclusively
|
||||
* `faster_rcnn_support_api_v1.7.json` --- for Faster R-CNN topologies trained using the TensorFlow Object Detection API version 1.7.0 up to 1.9.X inclusively
|
||||
* `faster_rcnn_support_api_v1.10.json` --- for Faster R-CNN topologies trained using the TensorFlow Object Detection API version 1.10.0 up to 1.12.X inclusively
|
||||
* `faster_rcnn_support_api_v1.13.json` --- for Faster R-CNN topologies trained using the TensorFlow Object Detection API version 1.13.X
|
||||
* `faster_rcnn_support_api_v1.14.json` --- for Faster R-CNN topologies trained using the TensorFlow Object Detection API version 1.14.0 up to 1.14.X inclusively
|
||||
* `faster_rcnn_support_api_v1.15.json` --- for Faster R-CNN topologies trained using the TensorFlow Object Detection API version 1.15.0 up to 2.0
|
||||
* `faster_rcnn_support_api_v2.0.json` --- for Faster R-CNN topologies trained using the TensorFlow Object Detection API version 2.0 up to 2.3.X inclusively
|
||||
* `faster_rcnn_support_api_v2.4.json` --- for Faster R-CNN topologies trained using the TensorFlow Object Detection API version 2.4 or higher
|
||||
* `mask_rcnn_support.json` --- for Mask R-CNN topologies from the TF 1.X models zoo trained with TensorFlow version 1.9.0 or lower.
|
||||
* `mask_rcnn_support_api_v1.7.json` --- for Mask R-CNN topologies trained using the TensorFlow Object Detection API version 1.7.0 up to 1.9.X inclusively
|
||||
* `mask_rcnn_support_api_v1.11.json` --- for Mask R-CNN topologies trained using the TensorFlow Object Detection API version 1.11.0 up to 1.12.X inclusively
|
||||
* `mask_rcnn_support_api_v1.13.json` --- for Mask R-CNN topologies trained using the TensorFlow Object Detection API version 1.13.0 up to 1.13.X inclusively
|
||||
* `mask_rcnn_support_api_v1.14.json` --- for Mask R-CNN topologies trained using the TensorFlow Object Detection API version 1.14.0 up to 1.14.X inclusively
|
||||
* `mask_rcnn_support_api_v1.15.json` --- for Mask R-CNN topologies trained using the TensorFlow Object Detection API version 1.15.0 up to 2.0
|
||||
* `mask_rcnn_support_api_v2.0.json` --- for Mask R-CNN topologies trained using the TensorFlow Object Detection API version 2.0 up to 2.3.X inclusively
|
||||
* `mask_rcnn_support_api_v2.4.json` --- for Mask R-CNN topologies trained using the TensorFlow Object Detection API version 2.4 or higher
|
||||
* `rfcn_support.json` --- for RFCN topology from the models zoo trained with TensorFlow version up to 1.9.X inclusively
|
||||
* `rfcn_support_api_v1.10.json` --- for RFCN topology from the models zoo frozen with TensorFlow version 1.10.0 up to 1.12.X inclusively
|
||||
* `rfcn_support_api_v1.13.json` --- for RFCN topology from the models zoo frozen with TensorFlow version 1.13.X
|
||||
* `rfcn_support_api_v1.14.json` --- for RFCN topology from the models zoo frozen with TensorFlow version 1.14.0 or higher
|
||||
* `--tensorflow_object_detection_api_pipeline_config <path_to_pipeline.config>` --- A special configuration file that describes the topology hyper-parameters and structure of the TensorFlow Object Detection API model. For the models downloaded from the TensorFlow Object Detection API zoo, the configuration file is named `pipeline.config`. If you plan to train a model yourself, you can find templates for these files in the [models repository](https://github.com/tensorflow/models/tree/master/research/object_detection/samples/configs).
|
||||
* `--input_shape` (optional) --- A custom input image shape. For more information how the `--input_shape` parameter is handled for the TensorFlow Object Detection API models, refer to the [Custom Input Shape](#custom-input-shape) guide.
|
||||
* `ssd_support_api_v.1.14.json` --- for SSD topologies trained using the TensorFlow\* Object Detection API version 1.14 up to 1.14.X inclusively
|
||||
* `ssd_support_api_v.1.15.json` --- for SSD topologies trained using the TensorFlow\* Object Detection API version 1.15 up to 2.0
|
||||
* `ssd_support_api_v.2.0.json` --- for SSD topologies trained using the TensorFlow\* Object Detection API version 2.0 up to 2.3.X inclusively
|
||||
* `ssd_support_api_v.2.4.json` --- for SSD topologies trained using the TensorFlow\* Object Detection API version 2.4 or higher
|
||||
* `efficient_det_support_api_v.2.0.json` --- for EfficientDet topologies trained using the TensorFlow\* Object Detection API version 2.0 up to 2.3.X inclusively
|
||||
* `efficient_det_support_api_v.2.4.json` --- for EfficientDet topologies trained using the TensorFlow\* Object Detection API version 2.4 or higher
|
||||
* `faster_rcnn_support.json` --- for Faster R-CNN topologies from the TF 1.X models zoo trained with TensorFlow\* version up to 1.6.X inclusively
|
||||
* `faster_rcnn_support_api_v1.7.json` --- for Faster R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.7.0 up to 1.9.X inclusively
|
||||
* `faster_rcnn_support_api_v1.10.json` --- for Faster R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.10.0 up to 1.12.X inclusively
|
||||
* `faster_rcnn_support_api_v1.13.json` --- for Faster R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.13.X
|
||||
* `faster_rcnn_support_api_v1.14.json` --- for Faster R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.14.0 up to 1.14.X inclusively
|
||||
* `faster_rcnn_support_api_v1.15.json` --- for Faster R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.15.0 up to 2.0
|
||||
* `faster_rcnn_support_api_v2.0.json` --- for Faster R-CNN topologies trained using the TensorFlow\* Object Detection API version 2.0 up to 2.3.X inclusively
|
||||
* `faster_rcnn_support_api_v2.4.json` --- for Faster R-CNN topologies trained using the TensorFlow\* Object Detection API version 2.4 or higher
|
||||
* `mask_rcnn_support.json` --- for Mask R-CNN topologies from the TF 1.X models zoo trained with TensorFlow\* version 1.9.0 or lower.
|
||||
* `mask_rcnn_support_api_v1.7.json` --- for Mask R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.7.0 up to 1.9.X inclusively
|
||||
* `mask_rcnn_support_api_v1.11.json` --- for Mask R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.11.0 up to 1.12.X inclusively
|
||||
* `mask_rcnn_support_api_v1.13.json` --- for Mask R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.13.0 up to 1.13.X inclusively
|
||||
* `mask_rcnn_support_api_v1.14.json` --- for Mask R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.14.0 up to 1.14.X inclusively
|
||||
* `mask_rcnn_support_api_v1.15.json` --- for Mask R-CNN topologies trained using the TensorFlow\* Object Detection API version 1.15.0 up to 2.0
|
||||
* `mask_rcnn_support_api_v2.0.json` --- for Mask R-CNN topologies trained using the TensorFlow\* Object Detection API version 2.0 up to 2.3.X inclusively
|
||||
* `mask_rcnn_support_api_v2.4.json` --- for Mask R-CNN topologies trained using the TensorFlow\* Object Detection API version 2.4 or higher
|
||||
* `rfcn_support.json` --- for RFCN topology from the models zoo trained with TensorFlow\* version up to 1.9.X inclusively
|
||||
* `rfcn_support_api_v1.10.json` --- for RFCN topology from the models zoo frozen with TensorFlow\* version 1.10.0 up to 1.12.X inclusively
|
||||
* `rfcn_support_api_v1.13.json` --- for RFCN topology from the models zoo frozen with TensorFlow\* version 1.13.X
|
||||
* `rfcn_support_api_v1.14.json` --- for RFCN topology from the models zoo frozen with TensorFlow\* version 1.14.0 or higher
|
||||
* `--tensorflow_object_detection_api_pipeline_config <path_to_pipeline.config>` --- A special configuration file that describes the topology hyper-parameters and structure of the TensorFlow Object Detection API model. For the models downloaded from the TensorFlow\* Object Detection API zoo, the configuration file is named `pipeline.config`. If you plan to train a model yourself, you can find templates for these files in the [models repository](https://github.com/tensorflow/models/tree/master/research/object_detection/samples/configs).
|
||||
* `--input_shape` (optional) --- A custom input image shape. Refer to [Custom Input Shape](#custom-input-shape) for more information how the `--input_shape` parameter is handled for the TensorFlow* Object Detection API models.
|
||||
|
||||
> **NOTE**: The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. If you convert a TensorFlow Object Detection API model to use with the OpenVINO sample applications, you must specify the `--reverse_input_channels` parameter. For more information about the parameter, refer to the **When to Reverse Input Channels** section of the [Converting a Model to Intermediate Representation (IR)](../Converting_Model.md) guide.
|
||||
> **NOTE**: The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. If you convert a TensorFlow\* Object Detection API model to use with the OpenVINO sample applications, you must specify the `--reverse_input_channels` parameter. For more information about the parameter, refer to **When to Reverse Input Channels** section of [Converting a Model to Intermediate Representation (IR)](../Converting_Model.md).
|
||||
|
||||
Additionally to the mandatory parameters listed above you can use optional conversion parameters if needed. A full list of parameters is available in the [Converting a TensorFlow Model](../Convert_Model_From_TensorFlow.md) guide.
|
||||
Additionally to the mandatory parameters listed above you can use optional conversion parameters if needed. A full list of parameters is available in the [Converting a TensorFlow* Model](../Convert_Model_From_TensorFlow.md) topic.
|
||||
|
||||
For example, if you downloaded the pre-trained [SSD InceptionV2 topology](http://download.tensorflow.org/models/object_detection/ssd_inception_v2_coco_2018_01_28.tar.gz) and extracted archive to the directory `/tmp/ssd_inception_v2_coco_2018_01_28`, the sample command line to convert the model looks as follows:
|
||||
For example, if you downloaded the [pre-trained SSD InceptionV2 topology](http://download.tensorflow.org/models/object_detection/ssd_inception_v2_coco_2018_01_28.tar.gz) and extracted archive to the directory `/tmp/ssd_inception_v2_coco_2018_01_28`, the sample command line to convert the model looks as follows:
|
||||
|
||||
```
|
||||
mo --input_model=/tmp/ssd_inception_v2_coco_2018_01_28/frozen_inference_graph.pb --transformations_config front/tf/ssd_v2_support.json --tensorflow_object_detection_api_pipeline_config /tmp/ssd_inception_v2_coco_2018_01_28/pipeline.config --reverse_input_channels
|
||||
@@ -57,29 +57,30 @@ mo --input_model=/tmp/ssd_inception_v2_coco_2018_01_28/frozen_inference_graph.pb
|
||||
|
||||
## OpenVINO™ Toolkit Samples and Open Model Zoo Demos
|
||||
|
||||
OpenVINO comes with a number of samples to demonstrate use of OpenVINO Runtime API. Additionally,
|
||||
Open Model Zoo provides set of demo applications to show implementation of close to real life applications,
|
||||
OpenVINO comes with a number of samples to demonstrate use of OpenVINO Runtime API, additionally,
|
||||
Open Model Zoo provides set of demo applications to show implementation of close to real life applications
|
||||
based on deep learning in various tasks, including Image Classification, Visual Object Detection, Text Recognition,
|
||||
Speech Recognition, Natural Language Processing and others. Refer to the links below for more details.
|
||||
|
||||
|
||||
* [OpenVINO Samples](../../../../OV_Runtime_UG/Samples_Overview.md)
|
||||
* [Open Model Zoo Demos](@ref omz_demos)
|
||||
|
||||
## Feeding Input Images to the Samples
|
||||
## Important Notes About Feeding Input Images to the Samples
|
||||
|
||||
There are several important notes about feeding input images to the samples:
|
||||
|
||||
1. OpenVINO samples stretch input image to the size of the input operation without preserving aspect ratio. This behavior is usually correct for most topologies (including SSDs), but incorrect for other models like Faster R-CNN, Mask R-CNN and R-FCN. These models usually use keeps aspect ratio resizer. The type of preprocessing is defined in the pipeline configuration file in the section `image_resizer`. If keeping aspect ratio is used, then it is necessary to resize image before passing it to the sample and optionally pad the resized image with 0s (if the attribute "pad_to_max_dimension" in the pipeline.config is equal to "true").
|
||||
1. OpenVINO samples stretch input image to the size of the input operation without preserving aspect ratio. This behavior is usually correct for most topologies (including SSDs), but incorrect for other models like Faster R-CNN, Mask R-CNN and R-FCN. These models usually use keeps aspect ratio resizer. The type of pre-processing is defined in the pipeline configuration file in the section `image_resizer`. If keeping aspect ratio is used, then it is necessary to resize image before passing it to the sample and optionally pad the resized image with 0s (if the attribute "pad_to_max_dimension" in the pipeline.config is equal to "true").
|
||||
|
||||
2. TensorFlow implementation of image resize may be different from the one implemented in the sample. Even reading input image from compressed format (like `.jpg`) could give different results in the sample and TensorFlow. If it is necessary to compare accuracy between the TensorFlow and the OpenVINO, it is recommended to pass pre-resized input image in a non-compressed format (like `.bmp`).
|
||||
2. TensorFlow\* implementation of image resize may be different from the one implemented in the sample. Even reading input image from compressed format (like `.jpg`) could give different results in the sample and TensorFlow\*. So, if it is necessary to compare accuracy between the TensorFlow\* and the OpenVINO it is recommended to pass pre-resized input image in a non-compressed format (like `.bmp`).
|
||||
|
||||
3. If you want to infer the model with the OpenVINO samples, convert the model specifying the `--reverse_input_channels` command line parameter. The samples load images in BGR channels order, while TensorFlow models were trained with images in RGB order. When the `--reverse_input_channels` command line parameter is specified, Model Optimizer performs first convolution or other channel dependent operation weights modification so the output will be like the image is passed with RGB channels order.
|
||||
3. If you want to infer the model with the OpenVINO samples, convert the model specifying the `--reverse_input_channels` command line parameter. The samples load images in BGR channels order, while TensorFlow* models were trained with images in RGB order. When the `--reverse_input_channels` command line parameter is specified, the Model Optimizer performs first convolution or other channel dependent operation weights modification so the output will be like the image is passed with RGB channels order.
|
||||
|
||||
4. Read carefully the messages printed by Model Optimizer during a model conversion. They contain important instructions on how to prepare input data before running the inference and how to interpret the output.
|
||||
4. Read carefully messaged printed by the Model Optimizer during a model conversion. They contain important instructions on how to prepare input data before running the inference and how to interpret the output.
|
||||
|
||||
@anchor custom-input-shape
|
||||
## Custom Input Shape
|
||||
Model Optimizer handles the command line parameter `--input_shape` for TensorFlow Object Detection API models in a special way depending on the image resizer type defined in the `pipeline.config` file. TensorFlow Object Detection API generates different `Preprocessor` sub-graph based on the image resizer type. Model Optimizer supports two types of image resizer:
|
||||
Model Optimizer handles the command line parameter `--input_shape` for TensorFlow\* Object Detection API models in a special way depending on the image resizer type defined in the `pipeline.config` file. TensorFlow\* Object Detection API generates different `Preprocessor` sub-graph based on the image resizer type. Model Optimizer supports two types of image resizer:
|
||||
* `fixed_shape_resizer` --- *Stretches* input image to the specific height and width. The `pipeline.config` snippet below shows a `fixed_shape_resizer` sample definition:
|
||||
```
|
||||
image_resizer {
|
||||
@@ -98,20 +99,20 @@ image_resizer {
|
||||
}
|
||||
}
|
||||
```
|
||||
If an additional parameter "pad_to_max_dimension" is equal to "true", then the resized image will be padded with 0s to the square image of size "max_dimension".
|
||||
If an additional parameter "pad_to_max_dimension" is equal to "true" then the resized image will be padded with 0s to the square image of size "max_dimension".
|
||||
|
||||
### Fixed Shape Resizer Replacement
|
||||
* If the `--input_shape` command line parameter is not specified, Model Optimizer generates an input operation with the height and width as defined in the `pipeline.config`.
|
||||
* If the `--input_shape` command line parameter is not specified, the Model Optimizer generates an input operation with the height and width as defined in the `pipeline.config`.
|
||||
|
||||
* If the `--input_shape [1, H, W, 3]` command line parameter is specified, Model Optimizer sets the input operation height to `H` and width to `W` and convert the model. However, the conversion may fail because of the following reasons:
|
||||
* The model is not reshape-able, meaning that it's not possible to change the size of the model input image. For example, SSD FPN models have `Reshape` operations with hard-coded output shapes, but the input size to these `Reshape` instances depends on the input image size. In this case, Model Optimizer shows an error during the shape inference phase. Run Model Optimizer with `--log_level DEBUG` to see the inferred operations output shapes to see the mismatch.
|
||||
* Custom input shape is too small. For example, if you specify `--input_shape [1,100,100,3]` to convert a SSD Inception V2 model, one of convolution or pooling nodes decreases input tensor spatial dimensions to non-positive values. In this case, Model Optimizer shows error message like this: '[ ERROR ] Shape [ 1 -1 -1 256] is not fully defined for output X of "node_name".'
|
||||
* If the `--input_shape [1, H, W, 3]` command line parameter is specified, the Model Optimizer sets the input operation height to `H` and width to `W` and convert the model. However, the conversion may fail because of the following reasons:
|
||||
* The model is not reshape-able, meaning that it's not possible to change the size of the model input image. For example, SSD FPN models have `Reshape` operations with hard-coded output shapes, but the input size to these `Reshape` instances depends on the input image size. In this case, the Model Optimizer shows an error during the shape inference phase. Run the Model Optimizer with `--log_level DEBUG` to see the inferred operations output shapes to see the mismatch.
|
||||
* Custom input shape is too small. For example, if you specify `--input_shape [1,100,100,3]` to convert a SSD Inception V2 model, one of convolution or pooling nodes decreases input tensor spatial dimensions to non-positive values. In this case, the Model Optimizer shows error message like this: '[ ERROR ] Shape [ 1 -1 -1 256] is not fully defined for output X of "node_name".'
|
||||
|
||||
|
||||
### Keeping Aspect Ratio Resizer Replacement
|
||||
* If the `--input_shape` command line parameter is not specified, Model Optimizer generates an input operation with both height and width equal to the value of parameter `min_dimension` in the `keep_aspect_ratio_resizer`.
|
||||
### Keep Aspect Ratio Resizer Replacement
|
||||
* If the `--input_shape` command line parameter is not specified, the Model Optimizer generates an input operation with both height and width equal to the value of parameter `min_dimension` in the `keep_aspect_ratio_resizer`.
|
||||
|
||||
* If the `--input_shape [1, H, W, 3]` command line parameter is specified, Model Optimizer scales the specified input image height `H` and width `W` to satisfy the `min_dimension` and `max_dimension` constraints defined in the `keep_aspect_ratio_resizer`. The following function calculates the input operation height and width:
|
||||
* If the `--input_shape [1, H, W, 3]` command line parameter is specified, the Model Optimizer scales the specified input image height `H` and width `W` to satisfy the `min_dimension` and `max_dimension` constraints defined in the `keep_aspect_ratio_resizer`. The following function calculates the input operation height and width:
|
||||
|
||||
```python
|
||||
def calculate_shape_keeping_aspect_ratio(H: int, W: int, min_dimension: int, max_dimension: int):
|
||||
@@ -122,16 +123,16 @@ def calculate_shape_keeping_aspect_ratio(H: int, W: int, min_dimension: int, max
|
||||
```
|
||||
The `--input_shape` command line parameter should be specified only if the "pad_to_max_dimension" does not exist of is set to "false" in the `keep_aspect_ratio_resizer`.
|
||||
|
||||
Models with `keep_aspect_ratio_resizer` were trained to recognize object in real aspect ratio, in contrast with most of the classification topologies trained to recognize objects stretched vertically and horizontally as well. By default, Model Optimizer converts topologies with `keep_aspect_ratio_resizer` to consume a square input image. If the non-square image is provided as input, it is stretched without keeping aspect ratio that results to object detection quality decrease.
|
||||
Models with `keep_aspect_ratio_resizer` were trained to recognize object in real aspect ratio, in contrast with most of the classification topologies trained to recognize objects stretched vertically and horizontally as well. By default, the Model Optimizer converts topologies with `keep_aspect_ratio_resizer` to consume a square input image. If the non-square image is provided as input, it is stretched without keeping aspect ratio that results to object detection quality decrease.
|
||||
|
||||
> **NOTE**: It is highly recommended to specify the `--input_shape` command line parameter for the models with `keep_aspect_ratio_resizer`, if the input image dimensions are known in advance.
|
||||
> **NOTE**: It is highly recommended specifying the `--input_shape` command line parameter for the models with `keep_aspect_ratio_resizer` if the input image dimensions are known in advance.
|
||||
|
||||
## Model Conversion Process in Detail
|
||||
## Detailed Explanations of Model Conversion Process
|
||||
|
||||
This section is intended for users who want to understand how Model Optimizer performs Object Detection API models conversion in details. The information in this section is also useful for users having complex models that are not converted with Model Optimizer out of the box. It is highly recommended to read the **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](../../customize_model_optimizer/Customize_Model_Optimizer.md) documentation first to understand sub-graph replacement concepts which are used here.
|
||||
This section is intended for users who want to understand how the Model Optimizer performs Object Detection API models conversion in details. The knowledge given in this section is also useful for users having complex models that are not converted with the Model Optimizer out of the box. It is highly recommended to read the **Graph Transformation Extensions** section in the [Model Optimizer Extensibility](../../customize_model_optimizer/Customize_Model_Optimizer.md) documentation first to understand sub-graph replacement concepts which are used here.
|
||||
|
||||
It is also important to open the model in the [TensorBoard](https://www.tensorflow.org/guide/summaries_and_tensorboard) to see the topology structure. Model Optimizer can create an event file that can be then fed to the TensorBoard tool. Run Model Optimizer, providing two command line parameters:
|
||||
* `--input_model <path_to_frozen.pb>` --- Path to the frozen model.
|
||||
It is also important to open the model in the [TensorBoard](https://www.tensorflow.org/guide/summaries_and_tensorboard) to see the topology structure. Model Optimizer can create an event file that can be then fed to the TensorBoard* tool. Run the Model Optimizer with providing two command line parameters:
|
||||
* `--input_model <path_to_frozen.pb>` --- Path to the frozen model
|
||||
* `--tensorboard_logdir` --- Path to the directory where TensorBoard looks for the event files.
|
||||
|
||||
Implementation of the transformations for Object Detection API models is located in the file [https://github.com/openvinotoolkit/openvino/blob/releases/2022/1/tools/mo/openvino/tools/mo/front/tf/ObjectDetectionAPI.py](https://github.com/openvinotoolkit/openvino/blob/releases/2022/1/tools/mo/openvino/tools/mo/front/tf/ObjectDetectionAPI.py). Refer to the code in this file to understand the details of the conversion process.
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# Converting a TensorFlow RetinaNet Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_RetinaNet_From_Tensorflow}
|
||||
# Converting TensorFlow RetinaNet Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_RetinaNet_From_Tensorflow}
|
||||
|
||||
This tutorial explains how to convert a RetinaNet model to the Intermediate Representation (IR).
|
||||
This tutorial explains how to convert RetinaNet model to the Intermediate Representation (IR).
|
||||
|
||||
[Public RetinaNet model](https://github.com/fizyr/keras-retinanet) does not contain pretrained TensorFlow weights.
|
||||
To convert this model to the TensorFlow format, follow the [Reproduce Keras to TensorFlow Conversion tutorial](@ref omz_models_model_retinanet_tf).
|
||||
[Public RetinaNet model](https://github.com/fizyr/keras-retinanet) does not contain pretrained TensorFlow\* weights.
|
||||
To convert this model to the TensorFlow\* format, you can use [Reproduce Keras* to TensorFlow* Conversion tutorial](@ref omz_models_model_retinanet_tf).
|
||||
|
||||
After converting the model to TensorFlow format, run the Model Optimizer command below:
|
||||
After you convert the model to TensorFlow* format, run the Model Optimizer command below:
|
||||
```sh
|
||||
mo --input "input_1[1 1333 1333 3]" --input_model retinanet_resnet50_coco_best_v2.1.0.pb --data_type FP32 --transformations_config front/tf/retinanet.json
|
||||
```
|
||||
|
||||
Where `transformations_config` command-line parameter specifies the configuration json file containing model conversion hints for the Model Optimizer.
|
||||
The json file contains some parameters that need to be changed if you train the model yourself. It also contains information on how to match endpoints
|
||||
to replace the subgraph nodes. After the model is converted to the OpenVINO IR format, the output nodes will be replaced with DetectionOutput layer.
|
||||
to replace the subgraph nodes. After the model is converted to IR, the output nodes will be replaced with DetectionOutput layer.
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
# Converting TensorFlow Slim Image Classification Model Library Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Slim_Library_Models}
|
||||
# Convert TensorFlow Slim Image Classification Model Library Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Slim_Library_Models}
|
||||
|
||||
<a href="https://github.com/tensorflow/models/tree/master/research/slim/README.md">TensorFlow-Slim Image Classification Model Library</a> is a library to define, train and evaluate classification models in TensorFlow. The library contains Python scripts defining the classification topologies together with checkpoint files for several pre-trained classification topologies. To convert a TensorFlow-Slim library model, complete the following steps:
|
||||
<a href="https://github.com/tensorflow/models/tree/master/research/slim/README.md">TensorFlow\*-Slim Image Classification Model Library</a> is a library to define, train and evaluate classification models in TensorFlow\*. The library contains Python scripts defining the classification topologies together with checkpoint files for several pre-trained classification topologies. To convert a TensorFlow\*-Slim library model, complete the following steps:
|
||||
|
||||
1. Download the TensorFlow-Slim models [git repository](https://github.com/tensorflow/models).
|
||||
1. Download the TensorFlow\*-Slim models [git repository](https://github.com/tensorflow/models).
|
||||
2. Download the pre-trained model [checkpoint](https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models).
|
||||
3. Export the inference graph.
|
||||
4. Convert the model using the Model Optimizer.
|
||||
|
||||
The [Example of an Inception V1 Model Conversion](#example_of_an_inception_v1_model_conversion) below illustrates the process of converting an Inception V1 Model.
|
||||
The [Example of an Inception V1 Model Conversion](#example_of_an_inception_v1_model_conversion) section below illustrates the process of converting an Inception V1 Model.
|
||||
|
||||
## Example of an Inception V1 Model Conversion <a name="example_of_an_inception_v1_model_conversion"></a>
|
||||
This example demonstrates how to convert the model on Linux OSes, but it could be easily adopted for the Windows OSes.
|
||||
This example demonstrates how to convert the model on Linux\* OSes, but it could be easily adopted for the Windows\* OSes.
|
||||
|
||||
**Step 1**. Create a new directory to clone the TensorFlow-Slim git repository to:
|
||||
Step 1. Create a new directory to clone the TensorFlow\*-Slim git repository to:
|
||||
|
||||
```sh
|
||||
mkdir tf_models
|
||||
@@ -21,7 +21,7 @@ mkdir tf_models
|
||||
git clone https://github.com/tensorflow/models.git tf_models
|
||||
```
|
||||
|
||||
**Step 2**. Download and unpack the [Inception V1 model checkpoint file](http://download.tensorflow.org/models/inception_v1_2016_08_28.tar.gz):
|
||||
Step 2. Download and unpack the [Inception V1 model checkpoint file](http://download.tensorflow.org/models/inception_v1_2016_08_28.tar.gz):
|
||||
|
||||
```sh
|
||||
wget http://download.tensorflow.org/models/inception_v1_2016_08_28.tar.gz
|
||||
@@ -30,7 +30,7 @@ wget http://download.tensorflow.org/models/inception_v1_2016_08_28.tar.gz
|
||||
tar xzvf inception_v1_2016_08_28.tar.gz
|
||||
```
|
||||
|
||||
**Step 3**. Export the inference graph --- the protobuf file (`.pb`) containing the architecture of the topology. This file *does not* contain the neural network weights and cannot be used for inference.
|
||||
Step 3. Export the inference graph --- the protobuf file (`.pb`) containing the architecture of the topology. Note, this file *doesn't* contain the neural network weights and cannot be used for inference.
|
||||
|
||||
```sh
|
||||
python3 tf_models/research/slim/export_inference_graph.py \
|
||||
@@ -53,7 +53,7 @@ InceptionV1/Logits/Predictions/Reshape_1
|
||||
```
|
||||
The tool finds one input node with name `input`, type `float32`, fixed image size `(224,224,3)` and undefined batch size `-1`. The output node name is `InceptionV1/Logits/Predictions/Reshape_1`.<br>
|
||||
|
||||
**Step 4**. Convert the model with the Model Optimizer:
|
||||
Step 4. Convert the model with the Model Optimizer:
|
||||
|
||||
```sh
|
||||
mo --input_model ./inception_v1_inference_graph.pb --input_checkpoint ./inception_v1.ckpt -b 1 --mean_value [127.5,127.5,127.5] --scale 127.5
|
||||
@@ -61,10 +61,10 @@ mo --input_model ./inception_v1_inference_graph.pb --input_checkpoint ./inceptio
|
||||
|
||||
The `-b` command line parameter is required because the Model Optimizer cannot convert a model with undefined input size.
|
||||
|
||||
For the information on why `--mean_values` and `--scale` command-line parameters are used, refer to the [Mean and Scale Values for TensorFlow-Slim Models](#tf_slim_mean_scale_values).
|
||||
Refer to the [Mean and Scale Values for TensorFlow\*-Slim Models](#tf_slim_mean_scale_values) for the information why `--mean_values` and `--scale` command line parameters are used.
|
||||
|
||||
## Mean and Scale Values for TensorFlow-Slim Models <a name="tf_slim_mean_scale_values"></a>
|
||||
The TensorFlow-Slim Models were trained with normalized input data. There are several different normalization algorithms used in the Slim library. OpenVINO classification sample does not perform image pre-processing except resizing to the input layer size. It is necessary to pass mean and scale values to the Model Optimizer so they are embedded into the generated IR in order to get correct classification results.
|
||||
## Mean and Scale Values for TensorFlow\*-Slim Models <a name="tf_slim_mean_scale_values"></a>
|
||||
The TensorFlow\*-Slim Models were trained with normalized input data. There are several different normalization algorithms used in the Slim library. OpenVINO classification sample does not perform image pre-processing except resizing to the input layer size. It is necessary to pass mean and scale values to the Model Optimizer so they are embedded into the generated IR in order to get correct classification results.
|
||||
|
||||
The file [preprocessing_factory.py](https://github.com/tensorflow/models/blob/master/research/slim/preprocessing/preprocessing_factory.py) contains a dictionary variable `preprocessing_fn_map` defining mapping between the model type and pre-processing function to be used. The function code should be analyzed to figure out the mean/scale values.
|
||||
|
||||
@@ -83,8 +83,8 @@ The [inception_preprocessing.py](https://github.com/tensorflow/models/blob/maste
|
||||
|
||||
Firstly, the `image` is converted to data type `tf.float32` and the values in the tensor are scaled to the `[0, 1]` range using the [tf.image.convert_image_dtype](https://www.tensorflow.org/api_docs/python/tf/image/convert_image_dtype) function. Then the `0.5` is subtracted from the image values and values multiplied by `2.0`. The final image range of values is `[-1, 1]`.
|
||||
|
||||
OpenVINO classification sample reads an input image as a three-dimensional array of integer values from the range `[0, 255]`. In order to scale them to `[-1, 1]` range, the mean value `127.5` for each image channel should be specified as well as a scale factor `127.5`.
|
||||
OpenVINO classification sample reads an input image as a three-dimensional array of integer values from the range `[0, 255]`. In order to scale them to `[-1, 1]` range, the mean value `127.5` for each image channel should be specified as well as scale factor `127.5`.
|
||||
|
||||
Similarly, the mean/scale values can be determined for other Slim models.
|
||||
|
||||
The exact mean/scale values are defined in the table with list of supported TensorFlow-Slim models at the [Converting a TensorFlow Model](../Convert_Model_From_TensorFlow.md) guide.
|
||||
The exact mean/scale values are defined in the table with list of supported TensorFlow\*-Slim models at the [Converting a TensorFlow* Model](../Convert_Model_From_TensorFlow.md).
|
||||
@@ -1,16 +1,16 @@
|
||||
# Converting TensorFlow Wide and Deep Family Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_WideAndDeep_Family_Models}
|
||||
# Convert TensorFlow Wide and Deep Family Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_WideAndDeep_Family_Models}
|
||||
|
||||
The Wide and Deep models is a combination of wide and deep parts for memorization and generalization of object features respectively.
|
||||
These models can contain different types of object features such as numerical, categorical, sparse and sequential features. These feature types are specified
|
||||
through Tensorflow tf.feature_column API. Table below presents what feature types are supported by the OpenVINO toolkit.
|
||||
through Tensorflow* tf.feature_column API. Table below presents what feature types are supported by the OpenVINO™ toolkit.
|
||||
|
||||
| numeric | (weighted) categorical | categorical with hash | bucketized | sequential | crossed |
|
||||
|:-------:|:----------------------:|:---------------------:|:----------:|:----------:|:-------:|
|
||||
| yes | yes | no | yes | yes | no |
|
||||
|
||||
> **NOTE**: The categorical with hash and crossed features are currently unsupported since OpenVINO does not cover tensors of the `string` type and operations with them.
|
||||
**NOTE**: the categorical with hash and crossed features are currently unsupported since The OpenVINO™ toolkit does not support tensors of `string` type and operations with them.
|
||||
|
||||
## Preparing an Example of Wide and Deep Model
|
||||
## Prepare an Example of Wide and Deep Model
|
||||
|
||||
**Step 1**. Clone the GitHub repository with TensorFlow models and move to the directory with an example of Wide and Deep model:
|
||||
|
||||
@@ -81,13 +81,13 @@ def build_model_columns():
|
||||
return wide_columns, deep_columns
|
||||
```
|
||||
|
||||
After that, start training with the following command:
|
||||
After that start training by the following command:
|
||||
|
||||
```sh
|
||||
python census_main.py
|
||||
```
|
||||
|
||||
## Converting the Wide and Deep Model to IR
|
||||
## Convert the Wide and Deep Model to IR
|
||||
|
||||
Use the following command line to convert the saved model file with the checkpoint:
|
||||
|
||||
@@ -130,4 +130,4 @@ The model contains operations unsupported by the OpenVINO™ toolkit such as
|
||||
The pruning is specified through `--input` option. The prunings for `IteratorGetNext:*` nodes correspond to numeric features.
|
||||
The pruning for each categorical feature consists of three prunings for the following nodes: `*/to_sparse_input/indices:0`, `*/hash_table_Lookup/LookupTableFindV2:0`, and `*/to_sparse_input/dense_shape:0`.
|
||||
|
||||
The above command line generates an OpenVINO model for a batch of two objects, with the total number of actual categorical feature values equal to 10 and maximum size of a sparse categorical feature for one object equal to 50.
|
||||
The above command line generates IR for a batch of two objects, with total number of actual categorical feature values equal to 10 and maximum size of sparse categorical feature for one object equal to 50.
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
# Converting a TensorFlow XLNet Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_XLNet_From_Tensorflow}
|
||||
# Convert TensorFlow XLNet Model {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_XLNet_From_Tensorflow}
|
||||
|
||||
Pretrained models for XLNet (Bidirectional Encoder Representations from Transformers) are
|
||||
Pre-trained models for XLNet (Bidirectional Encoder Representations from Transformers) are
|
||||
[publicly available](https://github.com/zihangdai/xlnet).
|
||||
|
||||
## Supported Models
|
||||
|
||||
The following models from the pretrained [XLNet model list](https://github.com/zihangdai/xlnet#pre-trained-models) are currently supported:
|
||||
Currently, the following models from the [pre-trained XLNet model list](https://github.com/zihangdai/xlnet#pre-trained-models) are supported:
|
||||
|
||||
* **[`XLNet-Large, Cased`](https://storage.googleapis.com/xlnet/released_models/cased_L-24_H-1024_A-16.zip)**
|
||||
* **[`XLNet-Base, Cased`](https://storage.googleapis.com/xlnet/released_models/cased_L-12_H-768_A-12.zip)**
|
||||
|
||||
## Downloading the Pretrained Base XLNet Model
|
||||
## Download the Pre-Trained Base XLNet Model
|
||||
|
||||
Download and unzip an archive with the [XLNet-Base, Cased](https://storage.googleapis.com/xlnet/released_models/cased_L-12_H-768_A-12.zip).
|
||||
|
||||
After the archive is unzipped, the directory `cased_L-12_H-768_A-12` is created and contains the following files:
|
||||
* TensorFlow checkpoint (`xlnet_model.ckpt`), containing the pretrained weights (which is actually 3 files)
|
||||
* TensorFlow checkpoint (`xlnet_model.ckpt`) containing the pre-trained weights (which is actually 3 files)
|
||||
* sentence piece model (`spiece.model`) used for (de)tokenization
|
||||
* config file (`xlnet_config.json`), which specifies the hyperparameters of the model
|
||||
* config file (`xlnet_config.json`) which specifies the hyperparameters of the model
|
||||
|
||||
To get pb-file from the archive contents, you need to do the following.
|
||||
|
||||
@@ -37,7 +37,7 @@ To get pb-file from the archive contents, you need to do the following.
|
||||
|
||||
2. Save and run the following Python script in `~/XLNet-Base/xlnet`:
|
||||
|
||||
> **NOTE**: The original model repository has been tested with TensorFlow 1.13.1 under Python2.
|
||||
**Note** The original model repository has been tested with TensorFlow 1.13.1 under Python2.
|
||||
|
||||
```python
|
||||
from collections import namedtuple
|
||||
@@ -95,17 +95,17 @@ with tf.compat.v1.Session() as sess:
|
||||
```
|
||||
|
||||
|
||||
## Downloading the Pretrained Large XLNet Model
|
||||
## Download the Pre-Trained Large XLNet Model
|
||||
|
||||
Download and unzip an archive with the [XLNet-Large, Cased](https://storage.googleapis.com/xlnet/released_models/cased_L-24_H-1024_A-16.zip).
|
||||
|
||||
After unzipping the archive, the directory `cased_L-12_H-1024_A-16` is created and contains the following files:
|
||||
After the archive is unzipped, the directory `cased_L-12_H-1024_A-16` is created and contains the following files:
|
||||
|
||||
* TensorFlow checkpoint (`xlnet_model.ckpt`) containing the pretrained weights (which is actually 3 files)
|
||||
* TensorFlow checkpoint (`xlnet_model.ckpt`) containing the pre-trained weights (which is actually 3 files)
|
||||
* sentence piece model (`spiece.model`) used for (de)tokenization
|
||||
* config file (`xlnet_config.json`) which specifies the hyperparameters of the model
|
||||
|
||||
To get `pb-file` from the archive contents, follow the instructions below:
|
||||
To get pb-file from the archive contents, you need to do the following.
|
||||
|
||||
1. Run commands
|
||||
|
||||
@@ -119,6 +119,8 @@ To get `pb-file` from the archive contents, follow the instructions below:
|
||||
mkdir try_save
|
||||
```
|
||||
|
||||
|
||||
|
||||
2. Save and run the following Python script in `~/XLNet-Large/xlnet`:
|
||||
|
||||
```python
|
||||
@@ -178,10 +180,11 @@ with tf.compat.v1.Session() as sess:
|
||||
|
||||
The script should save into `~/XLNet-Large/xlnet`.
|
||||
|
||||
## Converting a frozen TensorFlow XLNet Model to IR
|
||||
|
||||
To generate the XLNet Intermediate Representation (IR) of the model, run Model Optimizer with the following parameters:
|
||||
|
||||
## Convert frozen TensorFlow XLNet Model to IR
|
||||
|
||||
To generate the XLNet Intermediate Representation (IR) of the model, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
mo --input_model path-to-model/model_frozen.pb \
|
||||
--input "input_mask[50 1],input_ids[50 1],seg_ids[50 1]"
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
# Converting TensorFlow YOLO Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_YOLO_From_Tensorflow}
|
||||
# Convert TensorFlow YOLO Models {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_YOLO_From_Tensorflow}
|
||||
|
||||
This document explains how to convert real-time object detection YOLOv1, YOLOv2, YOLOv3 and YOLOv4 public models to the Intermediate Representation (IR). All YOLO models are originally implemented in the DarkNet framework and consist of two files:
|
||||
* The `.cfg` file with model configurations
|
||||
* The `.weights` file with model weights
|
||||
This document explains how to convert real-time object detection YOLOv1\*, YOLOv2\*, YOLOv3\* and YOLOv4\* public models to the Intermediate Representation (IR). All YOLO\* models are originally implemented in the DarkNet\* framework and consist of two files:
|
||||
* `.cfg` file with model configurations
|
||||
* `.weights` file with model weights
|
||||
|
||||
Depending on a YOLO model version, the Model Optimizer converts it differently:
|
||||
|
||||
- YOLOv4 must be first converted from Keras to TensorFlow 2.
|
||||
- YOLOv4 must be first converted from Keras\* to TensorFlow 2\*.
|
||||
- YOLOv3 has several implementations. This tutorial uses a TensorFlow implementation of YOLOv3 model, which can be directly converted to an IR.
|
||||
- YOLOv1 and YOLOv2 models must be first converted to TensorFlow using DarkFlow.
|
||||
- YOLOv1 and YOLOv2 models must be first converted to TensorFlow\* using DarkFlow\*.
|
||||
|
||||
## <a name="yolov4-to-ir"></a>Converting a YOLOv4 Model to IR
|
||||
## <a name="yolov4-to-ir"></a>Convert YOLOv4 Model to IR
|
||||
|
||||
This section explains how to convert the YOLOv4 Keras model from the [repository](https://github.com/david8862/keras-YOLOv3-model-set) to an IR. To convert the YOLOv4 model, follow the instructions below:
|
||||
This section explains how to convert the YOLOv4 Keras\* model from the [https://github.com/david8862/keras-YOLOv3-model-set](https://github.com/david8862/keras-YOLOv3-model-set) repository to an IR. To convert the YOLOv4 model, follow the instructions below:
|
||||
|
||||
1. Download YOLOv4 weights and associated with it cfg file:
|
||||
- for YOLOv4 ([weights](https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights)/[config file](https://github.com/david8862/keras-YOLOv3-model-set/raw/6c9aff7bb0c1660704ad07c85739e95885676e5b/cfg/yolov4.cfg))
|
||||
@@ -23,7 +23,7 @@ This section explains how to convert the YOLOv4 Keras model from the [repository
|
||||
git clone https://github.com/david8862/keras-YOLOv3-model-set
|
||||
```
|
||||
|
||||
3. Convert the model to the TensorFlow 2 format:
|
||||
3. Convert the model to the TensorFlow 2\* format:
|
||||
- for YOLOv4:
|
||||
```sh
|
||||
python keras-YOLOv3-model-set/tools/model_converter/convert.py <path_to_cfg_file>/yolov4.cfg <path_to_weights>/yolov4.weights <saved_model_dir>
|
||||
@@ -40,10 +40,10 @@ python keras-YOLOv3-model-set/tools/model_converter/convert.py <path_to_cfg_file
|
||||
mo --saved_model_dir yolov4 --output_dir models/IRs --input_shape [1,608,608,3] --model_name yolov4
|
||||
```
|
||||
|
||||
## <a name="yolov3-to-ir"></a>Converting YOLOv3 Model to the OpenVINO format
|
||||
## <a name="yolov3-to-ir"></a>Convert YOLOv3 Model to IR
|
||||
|
||||
There are several public versions of TensorFlow YOLOv3 model implementation available on GitHub. This section explains how to convert YOLOv3 model from
|
||||
the [repository](https://github.com/mystic123/tensorflow-yolo-v3) (commit ed60b90) to an IR , but the process is similar for other versions of TensorFlow YOLOv3 model.
|
||||
On GitHub*, you can find several public versions of TensorFlow YOLOv3 model implementation. This section explains how to convert YOLOv3 model from
|
||||
the [https://github.com/mystic123/tensorflow-yolo-v3](https://github.com/mystic123/tensorflow-yolo-v3) repository (commit ed60b90) to an IR , but the process is similar for other versions of TensorFlow YOLOv3 model.
|
||||
|
||||
### <a name="yolov3-overview"></a>Overview of YOLOv3 Model Architecture
|
||||
Originally, YOLOv3 model includes feature extractor called `Darknet-53` with three branches at the end that make detections at three different scales. These branches must end with the YOLO `Region` layer.
|
||||
@@ -53,7 +53,7 @@ Originally, YOLOv3 model includes feature extractor called `Darknet-53` with thr
|
||||
simple layers. This badly affects performance. For this reason, the main idea of YOLOv3 model conversion to IR is to cut off these
|
||||
custom `Region`-like parts of the model and complete the model with the `Region` layers where required.
|
||||
|
||||
### Dumping a YOLOv3 TensorFlow Model
|
||||
### Dump YOLOv3 TensorFlow\* Model
|
||||
To dump TensorFlow model out of [https://github.com/mystic123/tensorflow-yolo-v3](https://github.com/mystic123/tensorflow-yolo-v3) GitHub repository (commit ed60b90), follow the instructions below:
|
||||
|
||||
1. Clone the repository:<br>
|
||||
@@ -86,12 +86,12 @@ At this step, you may receive a warning like `WARNING:tensorflow:Entity <...> co
|
||||
pip3 install --user gast==0.2.2
|
||||
```
|
||||
|
||||
If you have YOLOv3 weights trained for an input image with the size different from 416 (320, 608 or your own), provide the `--size` key with the size of your image specified while running the converter. For example, run the following command for an image with size 608:
|
||||
If you have YOLOv3 weights trained for an input image with the size different from 416 (320, 608 or your own), please provide the `--size` key with the size of your image specified while running the converter. For example, run the following command for an image with size 608:
|
||||
```sh
|
||||
python3 convert_weights_pb.py --class_names coco.names --data_format NHWC --weights_file yolov3_608.weights --size 608
|
||||
```
|
||||
|
||||
### Converting a YOLOv3 TensorFlow Model to the OpenVINO format
|
||||
### Convert YOLOv3 TensorFlow Model to IR
|
||||
|
||||
To solve the problems explained in the <a href="#yolov3-overview">YOLOv3 architecture overview</a> section, use the `yolo_v3.json` or `yolo_v3_tiny.json` (depending on a model) configuration file with custom operations located in the `<OPENVINO_INSTALL_DIR>/tools/model_optimizer/extensions/front/tf` repository.
|
||||
|
||||
@@ -120,7 +120,7 @@ where:
|
||||
you can use `yolov3.cfg` or `yolov3-tiny.cfg` configuration file from https://github.com/david8862/keras-YOLOv3-model-set/tree/master/cfg. Replace the default values in `custom_attributes` with the parameters that
|
||||
follow the `[yolo]` titles in the configuration file.
|
||||
- `anchors` is an optional parameter that is not used while inference of the model, but it used in a demo to parse `Region` layer output
|
||||
- `entry_points` is a node name list to cut off the model and append the `Region` layer with custom attributes specified above.
|
||||
- `entry_points` is a node name list to cut off the model and append the Region layer with custom attributes specified above.
|
||||
|
||||
|
||||
To generate an IR of the YOLOv3 TensorFlow model, run:<br>
|
||||
@@ -146,23 +146,23 @@ where:
|
||||
* `--batch` defines shape of model input. In the example, `--batch` is equal to 1, but you can also specify other integers larger than 1.
|
||||
* `--transformations_config` adds missing `Region` layers to the model. In the IR, the `Region` layer has name `RegionYolo`.
|
||||
|
||||
> **NOTE**: The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. For more information about the parameter, refer to the **When to Reverse Input Channels** section of the [Converting a Model to Intermediate Representation (IR)](../Converting_Model.md) guide.
|
||||
> **NOTE**: The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. For more information about the parameter, refer to **When to Reverse Input Channels** section of [Converting a Model to Intermediate Representation (IR)](../Converting_Model.md).
|
||||
|
||||
OpenVINO™ toolkit provides a demo that uses YOLOv3 model. Refer to the [Object Detection C++ Demo](@ref omz_demos_object_detection_demo_cpp) for more information.
|
||||
OpenVINO™ toolkit provides a demo that uses YOLOv3 model. For more information, refer to [Object Detection C++ Demo](@ref omz_demos_object_detection_demo_cpp).
|
||||
|
||||
## Converting YOLOv1 and YOLOv2 Models to the IR
|
||||
## Convert YOLOv1 and YOLOv2 Models to the IR
|
||||
|
||||
Before converting, choose a YOLOv1 or YOLOv2 model version that best suits your task. Download model configuration file and corresponding weight file:
|
||||
Before converting Choose a YOLOv1 or YOLOv2 model version that best suits your task. Download model configuration file and corresponding weight file:
|
||||
* From [DarkFlow repository](https://github.com/thtrieu/darkflow): configuration files are stored in the `cfg` directory, links to weight files are given in the `README.md` file. The files from this repository are adapted for conversion to TensorFlow using DarkFlow.
|
||||
* From DarkNet website and repository: configuration files are stored in the `cfg` directory of the [repository](https://github.com/pjreddie/darknet), links to weight files are given on the [YOLOv1](https://pjreddie.com/darknet/yolov1/) and [YOLOv2](https://pjreddie.com/darknet/yolov2/) websites.
|
||||
|
||||
To convert DarkNet YOLOv1 and YOLOv2 models to the OpenVINO format, follow these steps:
|
||||
To convert DarkNet YOLOv1 and YOLOv2 models to IR, follow the next steps:
|
||||
|
||||
1. <a href="#install-darkflow">Install DarkFlow </a>
|
||||
2. <a href="#yolov1-v2-to-tf">Convert DarkNet YOLOv1 or YOLOv2 model to TensorFlow</a> using DarkFlow
|
||||
3. <a href="#yolov1-v2-to-ir">Convert TensorFlow YOLOv1 or YOLOv2 model to IR</a>
|
||||
|
||||
#### <a name="install-darkflow"></a>Installing DarkFlow
|
||||
#### <a name="install-darkflow"></a>Install DarkFlow*
|
||||
|
||||
You need DarkFlow to convert YOLOv1 and YOLOv2 models to TensorFlow. To install DarkFlow:
|
||||
1. Install DarkFlow [required dependencies](https://github.com/thtrieu/darkflow#dependencies).
|
||||
@@ -174,11 +174,11 @@ git clone https://github.com/thtrieu/darkflow.git
|
||||
```sh
|
||||
cd darkflow
|
||||
```
|
||||
4. Install DarkFlow, using the instructions from the `README.md` file in the [DarkFlow repository](https://github.com/thtrieu/darkflow/blob/master/README.md#getting-started).
|
||||
4. Install DarkFlow using the instructions from the `README.md` file in the [DarkFlow repository](https://github.com/thtrieu/darkflow/blob/master/README.md#getting-started).
|
||||
|
||||
#### <a name="yolov1-v2-to-tf"></a>Converting a DarkNet YOLOv1 or YOLOv2 Model to TensorFlow
|
||||
#### <a name="yolov1-v2-to-tf"></a>Convert DarkNet\* YOLOv1 or YOLOv2 Model to TensorFlow\*
|
||||
|
||||
To convert YOLOv1 or YOLOv2 model to TensorFlow, go to the root directory of the cloned DarkFlow repository, place the previously downloaded \*.cfg and \*.weights files in the current directory and run the following command:<br>
|
||||
To convert YOLOv1 or YOLOv2 model to TensorFlow, go to the root directory of the cloned DarkFlow repository, place downloaded above \*.cfg and \*.weights files in the current directory and run the following command:<br>
|
||||
- For YOLOv1:
|
||||
```sh
|
||||
python3 flow --model yolov1.cfg --load yolov1.weights --savepb
|
||||
@@ -196,12 +196,12 @@ General conversion command is:
|
||||
```sh
|
||||
python3 flow --model <path_to_model>/<model_name>.cfg --load <path_to_model>/<model_name>.weights --labels <path_to_dataset_labels_file> --savepb
|
||||
```
|
||||
For YOLOv1, the `--labels` argument can be skipped. If the model was successfully converted, you can find the `<model_name>.meta` and `<model_name>.pb` files.
|
||||
For YOLOv1 the argument `--labels` can be skipped. If the model was successfully converted, you can find the `<model_name>.meta` and `<model_name>.pb` files
|
||||
in `built_graph` subdirectory of the cloned DarkFlow repository.
|
||||
|
||||
File `<model_name>.pb` is a TensorFlow representation of the YOLO model.
|
||||
|
||||
#### <a name="yolov1-v2-to-ir"></a>Converting a TensorFlow YOLOv1 or YOLOv2 Model to the IR
|
||||
#### <a name="yolov1-v2-to-ir"></a>Convert TensorFlow YOLOv1 or YOLOv2 Model to the IR
|
||||
|
||||
Converted TensorFlow YOLO model is missing `Region` layer and its parameters. Original YOLO `Region` layer parameters are stored in the configuration `<path_to_model>/<model_name>.cfg`
|
||||
file under the `[region]` title.
|
||||
@@ -209,10 +209,10 @@ file under the `[region]` title.
|
||||
To recreate the original model structure, use the corresponding yolo `.json` configuration file with custom operations and `Region` layer
|
||||
parameters when converting the model to the IR. This file is located in the `<OPENVINO_INSTALL_DIR>/tools/model_optimizer/extensions/front/tf` directory.
|
||||
|
||||
If chosen model has specific values of these parameters,
|
||||
If chosen model has specific values of this parameters,
|
||||
create another configuration file with custom operations and use it for conversion.
|
||||
|
||||
To generate the IR of the YOLOv1 model, provide TensorFlow YOLOv1 or YOLOv2 model to Model Optimizer with the following parameters:<br>
|
||||
To generate the IR of the YOLOv1 model, provide TensorFlow YOLOv1 or YOLOv2 model to the Model Optimizer with the following parameters:<br>
|
||||
```sh
|
||||
mo
|
||||
--input_model <path_to_model>/<model_name>.pb \
|
||||
@@ -226,6 +226,6 @@ where:
|
||||
* `--scale` specifies scale factor that input values will be divided by.
|
||||
The model was trained with input values in the range `[0,1]`. OpenVINO™ toolkit samples read input images as values in `[0,255]` range, so the scale 255 must be applied.
|
||||
* `--transformations_config` adds missing `Region` layers to the model. In the IR, the `Region` layer has name `RegionYolo`.
|
||||
For other applicable parameters, refer to the [Convert Model from TensorFlow](../Convert_Model_From_TensorFlow.md) guide.
|
||||
For other applicable parameters, refer to [Convert Model from TensorFlow](../Convert_Model_From_TensorFlow.md).
|
||||
|
||||
> **NOTE**: The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. For more information about the parameter, refer to the **When to Reverse Input Channels** section of the [Converting a Model to Intermediate Representation (IR)](../Converting_Model.md) guide.
|
||||
> **NOTE**: The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. For more information about the parameter, refer to **When to Reverse Input Channels** section of [Converting a Model to Intermediate Representation (IR)](../Converting_Model.md).
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Converting a TensorFlow Language Model on One Billion Word Benchmark {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_lm_1b_From_Tensorflow}
|
||||
# Convert TensorFlow Language Model on One Billion Word Benchmark {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_lm_1b_From_Tensorflow}
|
||||
|
||||
## Downloading a Pre-trained Language Model on One Billion Word Benchmark
|
||||
## Download the Pre-trained Language Model on One Billion Word Benchmark
|
||||
|
||||
TensorFlow provides a pretrained [Language Model on One Billion Word Benchmark](https://github.com/tensorflow/models/tree/r2.3.0/research/lm_1b).
|
||||
TensorFlow* provides [a pre-trained Language Model on One Billion Word Benchmark](https://github.com/tensorflow/models/tree/r2.3.0/research/lm_1b).
|
||||
|
||||
To download the model for IR conversion, follow the instructions:
|
||||
To download the model for IR conversion, please follow the instruction:
|
||||
1. Create new directory to store the model:
|
||||
```shell
|
||||
mkdir lm_1b
|
||||
@@ -41,7 +41,7 @@ wget http://download.tensorflow.org/models/LM_LSTM_CNN/all_shards-2016-09-10/ckp
|
||||
wget http://download.tensorflow.org/models/LM_LSTM_CNN/all_shards-2016-09-10/ckpt-softmax8
|
||||
```
|
||||
|
||||
Once you have downloaded the pretrained model files, you will have the `lm_1b` directory with the following hierarchy:
|
||||
After you download the pre-trained model files, you will have the `lm_1b` directory with the following hierarchy:
|
||||
|
||||
```
|
||||
lm_1b/
|
||||
@@ -64,23 +64,24 @@ lm_1b/
|
||||
|
||||

|
||||
|
||||
The frozen model still has two variables: `Variable` and `Variable_1`.
|
||||
As you can see, the frozen model still has two variables: `Variable` and `Variable_1`.
|
||||
It means that the model keeps training those variables at each inference.
|
||||
|
||||
At the first inference of this graph, the variables are initialized by initial values.
|
||||
After executing the `lstm` nodes, results of execution are assigned to these two variables.
|
||||
|
||||
With each inference of the `lm_1b` graph, `lstm` initial states data is taken from previous inference
|
||||
from variables, and states of current inference of `lstm` is reassigned to the same variables.
|
||||
from variables and states of current inference of `lstm` is reassigned to the same variables.
|
||||
|
||||
It helps the model to remember the context of the words that it takes as input.
|
||||
|
||||
## Converting a TensorFlow Language Model on One Billion Word Benchmark to IR
|
||||
## Convert TensorFlow Language Model on One Billion Word Benchmark to IR
|
||||
|
||||
Model Optimizer assumes that output model is for inference only.
|
||||
Therefore, you should cut those variables off and resolve keeping cell and hidden states on application level.
|
||||
The Model Optimizer assumes that output model is for inference only.
|
||||
That is why you should cut those variables off and resolve keeping cell and hidden states on application level.
|
||||
|
||||
There is a certain limitation for the model conversion: the original model cannot be reshaped, so you should keep original shapes.
|
||||
There is a certain limitations for the model conversion:
|
||||
- Original model cannot be reshaped, so you should keep original shapes.
|
||||
|
||||
To generate the `lm_1b` Intermediate Representation (IR), provide TensorFlow `lm_1b` model to the
|
||||
Model Optimizer with parameters:
|
||||
@@ -96,5 +97,5 @@ Model Optimizer with parameters:
|
||||
|
||||
Where:
|
||||
* `--input char_embedding/EmbeddingLookupUnique/Unique:0,char_embedding/EmbeddingLookupUnique/Unique:1,Variable/read,Variable_1/read`
|
||||
and `--input_shape [50],[50],[1,9216],[1,9216]` replace the variables with a placeholder.
|
||||
and `--input_shape [50],[50],[1,9216],[1,9216]` replace the variables with a placeholder
|
||||
* `--output softmax_out,lstm/lstm_0/concat_2,lstm/lstm_1/concat_2` specifies output node name and names of LSTM cell states.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
# Extending Model Optimizer with Caffe Python Layers {#openvino_docs_MO_DG_prepare_model_customize_model_optimizer_Extending_Model_Optimizer_With_Caffe_Python_Layers}
|
||||
# Extending Model Optimizer with Caffe* Python Layers {#openvino_docs_MO_DG_prepare_model_customize_model_optimizer_Extending_Model_Optimizer_With_Caffe_Python_Layers}
|
||||
|
||||
This article provides instructions on how to support a custom Caffe operation written only in Python. For example, the
|
||||
[Faster-R-CNN model](http://dl.dropboxusercontent.com/s/o6ii098-bu51d139/faster_rcnn_models.tgz?dl=0) implemented in
|
||||
This section provides instruction on how to support a custom Caffe operation written only in Python. For example, the
|
||||
[Faster-R-CNN model](http://dl.dropboxusercontent.com/s/o6ii098bu51d139/faster_rcnn_models.tgz?dl=0) implemented in
|
||||
Caffe contains a custom proposal layer written in Python. The layer is described in the
|
||||
[Faster-R-CNN prototxt](https://raw.githubusercontent.com/rbgirshick/py-faster-rcnn/master/models/pascal_voc/VGG16/faster_rcnn_end2end/test.prototxt) in the following way:
|
||||
```sh
|
||||
@@ -20,24 +20,23 @@ layer {
|
||||
}
|
||||
```
|
||||
|
||||
This article describes only a procedure on how to extract operator attributes in Model Optimizer. The rest of the
|
||||
operation enabling pipeline and information on how to support other Caffe operations (written in C++) is described in
|
||||
the [Customize_Model_Optimizer](Customize_Model_Optimizer.md) guide.
|
||||
This section describes only a procedure on how to extract operator attributes in the Model Optimizer. The rest of the
|
||||
operation enabling pipeline and documentation on how to support other Caffe operations (written in C++) is described in
|
||||
the main document [Customize_Model_Optimizer](Customize_Model_Optimizer.md).
|
||||
|
||||
## Writing Extractor for Caffe Python Layer
|
||||
Custom Caffe Python layers have an attribute `type` (defining the type of the operation) equal to `Python` and two
|
||||
mandatory attributes `module` and `layer` in the `python_param` dictionary. The `module` defines the Python module name
|
||||
with the layer implementation, while `layer` value is an operation type defined by a user. In order to extract
|
||||
with the layer implementation, while `layer` value is an operation type defined by an user. In order to extract
|
||||
attributes for such an operation it is necessary to implement extractor class inherited from the
|
||||
`CaffePythonFrontExtractorOp` class instead of `FrontExtractorOp` class, used for standard framework layers. The `op`
|
||||
`CaffePythonFrontExtractorOp` class instead of `FrontExtractorOp` class used for standard framework layers. The `op`
|
||||
class attribute value should be set to the `module + "." + layer` value so the extractor is triggered for this kind of
|
||||
operation.
|
||||
|
||||
Below is a simplified example of the extractor for the custom operation Proposal from the mentioned Faster-R-CNN model.
|
||||
The full code with additional checks can be found [here](https://github.com/openvinotoolkit/openvino/blob/releases/2022/1/tools/mo/openvino/tools/mo/front/caffe/proposal_python_ext.py).
|
||||
|
||||
The sample code uses operation `ProposalOp` which corresponds to `Proposal` operation described in the [Available Operations Sets](../../../ops/opset.md)
|
||||
page. For a detailed explanation of the extractor, refer to the source code below.
|
||||
Here is a simplified example of the extractor for the custom operation Proposal from Faster-R-CNN model mentioned above.
|
||||
The full code with additional checks is provided in the [https://github.com/openvinotoolkit/openvino/blob/releases/2022/1/tools/mo/openvino/tools/mo/front/caffe/proposal_python_ext.py](https://github.com/openvinotoolkit/openvino/blob/releases/2022/1/tools/mo/openvino/tools/mo/front/caffe/proposal_python_ext.py) file. The sample code uses
|
||||
operation `ProposalOp` which corresponds to `Proposal` operation described in the [Available Operations Sets](../../../ops/opset.md)
|
||||
document. Refer to the source code below for a detailed explanation of the extractor.
|
||||
|
||||
```py
|
||||
from openvino.tools.mo.ops.proposal import ProposalOp
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# ONNX Format Support {#ONNX_Format_Support}
|
||||
|
||||
|
||||
Since the 2020.4 release, OpenVINO™ has supported native usage of ONNX models. The `core.read_model()` method, which is the recommended approach to reading models, provides a uniform way to work with OpenVINO IR and ONNX formats alike. Example:
|
||||
|
||||
@sphinxdirective
|
||||
.. tab:: C++
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
ov::Core core;
|
||||
std::shared_ptr<ov::Model> model = core.read_model("model.xml")
|
||||
|
||||
.. tab:: Python
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import openvino.runtime as ov
|
||||
core = ov.Core()
|
||||
model = core.read_model("model.xml")
|
||||
@endsphinxdirective
|
||||
|
||||
While ONNX models are directly supported by OpenVINO™, it can be useful to convert them to IR format to take advantage of advanced OpenVINO optimization tools and features. For information on how to convert an ONNX model to the OpenVINO IR format, see the [Converting an ONNX Model](https://github.com/openvinotoolkit/openvino/pull/MO_DG/prepare_model/convert_model/Convert_Model_From_ONNX.md) page.
|
||||
|
||||
### Reshape Feature
|
||||
OpenVINO™ does not provide a mechanism to specify pre-processing for the ONNX format, like mean value subtraction or reverse input channels. If an ONNX model contains dynamic shapes for input, please see the [Changing input shapes](ShapeInference.md) documentation.
|
||||
|
||||
### Weights Saved in External Files
|
||||
OpenVINO™ supports ONNX models that store weights in external files. It is especially useful for models larger than 2GB because of protobuf limitations. To read such models:
|
||||
|
||||
@sphinxdirective
|
||||
.. tab:: C++
|
||||
|
||||
* Use the `read_model` overload that takes `modelPath` as the input parameter (both `std::string` and `std::wstring`).
|
||||
* The `binPath` argument of `read_model` should be empty. Otherwise, a runtime exception is thrown because paths to external weights are saved directly in the ONNX model.
|
||||
* Reading models with external weights is **NOT** supported by the `read_model()` overload.
|
||||
|
||||
.. tab:: Python
|
||||
|
||||
* Use the `model` parameter in the `openvino.runtime.Core.read_model(model : "path_to_onnx_file")` method.
|
||||
* The `weights` parameter, for the path to the binary weight file, should be empty. Otherwise, a runtime exception is thrown because paths to external weights are saved directly in the ONNX model.
|
||||
* Reading models with external weights is **NOT** supported by the `read_model(weights: "path_to_bin_file")` parameter.
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
Paths to external weight files are saved in an ONNX model. They are relative to the model's directory path, which means that for a model located at `workspace/models/model.onnx` and a weights file at `workspace/models/data/weights.bin`, the path saved in the model would be: `data/weights.bin`.
|
||||
|
||||
Note that a single model can use many external weights files.
|
||||
What is more, data of many tensors can be stored in a single external weights file, processed using offset and length values, which can also be saved in a model.
|
||||
|
||||
The following input parameters are NOT supported for ONNX models and should be passed as empty (none) or not at all:
|
||||
|
||||
* for `ReadNetwork` (C++):
|
||||
* `const std::wstring& binPath`
|
||||
* `const std::string& binPath`
|
||||
* `const Tensor& weights`
|
||||
* for [openvino.runtime.Core.read_model](https://docs.openvino.ai/latest/api/ie_python_api/_autosummary/openvino.runtime.Core.html#openvino.runtime.Core.read_model)
|
||||
* `weights`
|
||||
|
||||
|
||||
You can find more details about the external data mechanism in [ONNX documentation](https://github.com/onnx/onnx/blob/master/docs/ExternalData.md).
|
||||
To convert a model to use the external data feature, you can use [ONNX helper functions](https://github.com/onnx/onnx/blob/master/onnx/external_data_helper.py).
|
||||
|
||||
Unsupported types of tensors:
|
||||
* string
|
||||
* complex64
|
||||
* complex128
|
||||
@@ -64,7 +64,6 @@
|
||||
FakeQuantize-1 <openvino_docs_ops_quantization_FakeQuantize_1>
|
||||
FloorMod-1 <openvino_docs_ops_arithmetic_FloorMod_1>
|
||||
Floor-1 <openvino_docs_ops_arithmetic_Floor_1>
|
||||
GridSample-9 <openvino_docs_ops_image_GridSample_9>
|
||||
GRN-1 <openvino_docs_ops_normalization_GRN_1>
|
||||
GRUCell-3 <openvino_docs_ops_sequence_GRUCell_3>
|
||||
GRUSequence-5 <openvino_docs_ops_sequence_GRUSequence_5>
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# OpenVINO™ Python API Exclusives {#openvino_docs_OV_UG_Python_API_exclusives}
|
||||
# OpenVINO™ Python API exclusives {#openvino_docs_OV_UG_Python_API_exclusives}
|
||||
|
||||
OpenVINO™ Runtime Python API offers additional features and helpers to enhance user experience. The main goal of Python API is to provide user-friendly and simple yet powerful tool for Python users.
|
||||
OpenVINO™ Runtime Python API is exposing additional features and helpers to elevate user experience. Main goal of Python API is to provide user-friendly and simple, still powerful, tool for Python users.
|
||||
|
||||
## Easier Model Compilation
|
||||
## Easier model compilation
|
||||
|
||||
`CompiledModel` can be easily created with the helper method. It hides the creation of `Core` and applies `AUTO` inference mode by default.
|
||||
`CompiledModel` can be easily created with the helper method. It hides `Core` creation and applies `AUTO` device by default.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py auto_compilation
|
||||
|
||||
## Model/CompiledModel Inputs and Outputs
|
||||
## Model/CompiledModel inputs and outputs
|
||||
|
||||
Besides functions aligned to C++ API, some of them have their Python counterparts or extensions. For example, `Model` and `CompiledModel` inputs/outputs can be accessed via properties.
|
||||
Besides functions aligned to C++ API, some of them have their Pythonic counterparts or extensions. For example, `Model` and `CompiledModel` inputs/outputs can be accessed via properties.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py properties_example
|
||||
|
||||
@@ -18,21 +18,21 @@ Refer to Python API documentation on which helper functions or properties are av
|
||||
|
||||
## Working with Tensor
|
||||
|
||||
Python API allows passing data as tensors. The `Tensor` object holds a copy of the data from the given array. The `dtype` of *numpy* arrays is converted to OpenVINO™ types automatically.
|
||||
Python API allows passing data as tensors. `Tensor` object holds a copy of the data from the given array. `dtype` of numpy arrays is converted to OpenVINO™ types automatically.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py tensor_basics
|
||||
|
||||
### Shared Memory Mode
|
||||
### Shared memory mode
|
||||
|
||||
`Tensor` objects can share the memory with *numpy* arrays. By specifying the `shared_memory` argument, the `Tensor` object does not copy data. Instead, it has access to the memory of the *numpy* array.
|
||||
`Tensor` objects can share the memory with numpy arrays. By specifing `shared_memory` argument, a `Tensor` object does not perform copy of data and has access to the memory of the numpy array.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py tensor_shared_mode
|
||||
|
||||
## Running Inference
|
||||
## Running inference
|
||||
|
||||
Python API supports extra calling methods to synchronous and asynchronous modes for inference.
|
||||
|
||||
All infer methods allow users to pass data as popular *numpy* arrays, gathered in either Python dicts or lists.
|
||||
All infer methods allow users to pass data as popular numpy arrays, gathered in either Python dicts or lists.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py passing_numpy_array
|
||||
|
||||
@@ -40,54 +40,54 @@ Results from inference can be obtained in various ways:
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py getting_results
|
||||
|
||||
### Synchronous Mode - Extended
|
||||
### Synchronous mode - extended
|
||||
|
||||
Python API provides different synchronous calls to infer model, which block the application execution. Additionally, these calls return results of inference:
|
||||
Python API provides different synchronous calls to infer model, which block the application execution. Additionally these calls return results of inference:
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py sync_infer
|
||||
|
||||
### AsyncInferQueue
|
||||
|
||||
Asynchronous mode pipelines can be supported with a wrapper class called `AsyncInferQueue`. This class automatically spawns the pool of `InferRequest` objects (also called "jobs") and provides synchronization mechanisms to control the flow of the pipeline.
|
||||
Asynchronous mode pipelines can be supported with wrapper class called `AsyncInferQueue`. This class automatically spawns pool of `InferRequest` objects (also called "jobs") and provides synchronization mechanisms to control flow of the pipeline.
|
||||
|
||||
Each job is distinguishable by a unique `id`, which is in the range from 0 up to the number of jobs specified in the `AsyncInferQueue` constructor.
|
||||
Each job is distinguishable by unique `id`, which is in the range from 0 up to number of jobs specified in `AsyncInferQueue` constructor.
|
||||
|
||||
The `start_async` function call is not required to be synchronized - it waits for any available job if the queue is busy/overloaded. Every `AsyncInferQueue` code block should end with the `wait_all` function which provides the "global" synchronization of all jobs in the pool and ensure that access to them is safe.
|
||||
Function call `start_async` is not required to be synchronized, it waits for any available job if queue is busy/overloaded. Every `AsyncInferQueue` code block should end with `wait_all` function. It provides "global" synchronization of all jobs in the pool and ensure that access to them is safe.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py asyncinferqueue
|
||||
|
||||
#### Acquiring Results from Requests
|
||||
#### Acquire results from requests
|
||||
|
||||
After the call to `wait_all`, jobs and their data can be safely accessed. Acquiring a specific job with `[id]` will return the `InferRequest` object, which will result in seamless retrieval of the output data.
|
||||
After the call to `wait_all`, jobs and their data can be safely accessed. Acquring of a specific job with `[id]` returns `InferRequest` object, which results in seamless retrieval of the output data.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py asyncinferqueue_access
|
||||
|
||||
#### Setting Callbacks
|
||||
#### Setting callbacks
|
||||
|
||||
Another feature of `AsyncInferQueue` is the ability to set callbacks. When callback is set, any job that ends inference calls upon the Python function. The callback function must have two arguments: one is the request that calls the callback, which provides the `InferRequest` API; the other is called "userdata", which provides the possibility of passing runtime values. Those values can be of any Python type and later used within the callback function.
|
||||
Another feature of `AsyncInferQueue` is ability of setting callbacks. When callback is set, any job that ends inference, calls upon Python function. Callback function must have two arguments. First is the request that calls the callback, it provides `InferRequest` API. Second one being called "userdata", provides possibility of passing runtime values, which can be of any Python type and later used inside callback function.
|
||||
|
||||
The callback of `AsyncInferQueue` is uniform for every job. When executed, GIL is acquired to ensure safety of data manipulation inside the function.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py asyncinferqueue_set_callback
|
||||
|
||||
### Working with u1, u4 and i4 Element Types
|
||||
### Working with u1, u4 and i4 element types
|
||||
|
||||
Since OpenVINO™ supports low precision element types, there are a few ways to handle them in Python.
|
||||
To create an input tensor with such element types, you may need to pack your data in the new *numpy* array, with which the byte size matches the original input size:
|
||||
Since openvino supports low precision element types there are few ways how to handle them in python.
|
||||
To create an input tensor with such element types you may need to pack your data in new numpy array which byte size matches original input size:
|
||||
@snippet docs/snippets/ov_python_exclusives.py packing_data
|
||||
|
||||
To extract low precision values from a tensor into the *numpy* array, you can use the following helper:
|
||||
To extract low precision values from tensor into numpy array you can use next helper:
|
||||
@snippet docs/snippets/ov_python_exclusives.py unpacking
|
||||
|
||||
### Release of GIL
|
||||
### Releasing the GIL
|
||||
|
||||
Some functions in Python API release the Global Lock Interpreter (GIL) while running work-intensive code. This can help you achieve more parallelism in your application, using Python threads. For more information about GIL, refer to the Python documentation.
|
||||
Some functions in Python API release the Global Lock Interpreter (GIL) while running work-intensive code. It can help you to achieve more parallelism in your application using Python threads. For more information about GIL please refer to the Python documentation.
|
||||
|
||||
@snippet docs/snippets/ov_python_exclusives.py releasing_gil
|
||||
|
||||
> **NOTE**: While GIL is released, functions can still modify and/or operate on Python objects in C++. Hence, there is no reference counting. You should pay attention to thread safety in case sharing of these objects with another thread occurs. It might affect code only if multiple threads are spawned in Python.
|
||||
> **NOTE**: While GIL is released functions can still modify and/or operate on Python objects in C++, thus there is no reference counting. User is responsible for thread safety if sharing of these objects with other thread occurs. It can affects your code only if multiple threads are spawned in Python.:
|
||||
|
||||
#### List of Functions that Release the GIL
|
||||
#### List of functions that release the GIL
|
||||
- openvino.runtime.AsyncInferQueue.start_async
|
||||
- openvino.runtime.AsyncInferQueue.is_ready
|
||||
- openvino.runtime.AsyncInferQueue.wait_all
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
:maxdepth: 1
|
||||
:hidden:
|
||||
|
||||
Basic OpenVINO Workflow <openvino_docs_get_started_get_started_demos>
|
||||
openvino_inference_engine_samples_classification_sample_async_README
|
||||
openvino_inference_engine_ie_bridges_python_sample_classification_sample_async_README
|
||||
openvino_inference_engine_samples_hello_classification_README
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Changing Input Shapes {#openvino_docs_OV_UG_ShapeInference}
|
||||
|
||||
# Changing input shapes {#openvino_docs_OV_UG_ShapeInference}
|
||||
|
||||
## Introduction (C++)
|
||||
|
||||
@sphinxdirective
|
||||
.. raw:: html
|
||||
@@ -9,28 +9,28 @@
|
||||
@endsphinxdirective
|
||||
|
||||
OpenVINO™ provides capabilities to change model input shape during the runtime.
|
||||
It may be useful when you want to feed model an input that has different size than model input shape.
|
||||
If you need to do this only once, prepare a model with updated shapes via Model Optimizer. See [Specifying --input_shape Command-line Parameter](@ref when_to_specify_input_shapes) for more information. For all the other cases, follow the instructions below.
|
||||
It may be useful in case you would like to feed model an input that has different size than model input shape.
|
||||
In case you need to do this only once [prepare a model with updated shapes via Model Optimizer](@ref when_to_specify_input_shapes) for all the other cases follow instructions further.
|
||||
|
||||
### Setting a New Input Shape with Reshape Method
|
||||
### Set a new input shape with reshape method
|
||||
|
||||
The `ov::Model::reshape` method updates input shapes and propagates them down to the outputs of the model through all intermediate layers.
|
||||
For example, changing the batch size and spatial dimensions of input of a model with an image input:
|
||||
Example: Changing the batch size and spatial dimensions of input of a model with an image input:
|
||||
|
||||

|
||||
|
||||
Consider the code below to achieve that:
|
||||
Please see the code to achieve that:
|
||||
|
||||
@snippet snippets/ShapeInference.cpp picture_snippet
|
||||
|
||||
### Setting a New Batch Size with set_batch Method
|
||||
### Set a new batch size with set_batch method
|
||||
|
||||
The meaning of the model batch may vary depending on the model design.
|
||||
Meaning of the model batch may vary depending on the model design.
|
||||
In order to change the batch dimension of the model, [set the ov::Layout](@ref declare_model_s_layout) and call the `ov::set_batch` method.
|
||||
|
||||
@snippet snippets/ShapeInference.cpp set_batch
|
||||
|
||||
The `ov::set_batch` method is a high level API of the `ov::Model::reshape` functionality, so all information about the `ov::Model::reshape` method implications are applicable for `ov::set_batch` too, including the troubleshooting section.
|
||||
`ov::set_batch` method is a high level API of `ov::Model::reshape` functionality, so all information about `ov::Model::reshape` method implications are applicable for `ov::set_batch` too, including the troubleshooting section.
|
||||
|
||||
Once the input shape of `ov::Model` is set, call the `ov::Core::compile_model` method to get an `ov::CompiledModel` object for inference with updated shapes.
|
||||
|
||||
@@ -39,17 +39,17 @@ There are other approaches to change model input shapes during the stage of [IR
|
||||
### Dynamic Shape Notice
|
||||
|
||||
Shape-changing functionality could be used to turn dynamic model input into a static one and vice versa.
|
||||
It is recommended to always set static shapes when the shape of data is not going to change from one inference to another.
|
||||
Setting static shapes can avoid possible functional limitations, memory, and runtime overheads for dynamic shapes which may vary depending on hardware plugin and model used.
|
||||
To learn more about dynamic shapes in OpenVINO, see the [Dynamic Shapes](../OV_Runtime_UG/ov_dynamic_shapes.md) page.
|
||||
It is recommended to always set static shapes in case if the shape of data is not going to change from one inference to another.
|
||||
Setting static shapes avoids possible functional limitations, memory and run time overheads for dynamic shapes that vary depending on hardware plugin and model used.
|
||||
To learn more about dynamic shapes in OpenVINO please see a [dedicated article](../OV_Runtime_UG/ov_dynamic_shapes.md).
|
||||
|
||||
### Usage of the Reshape Method <a name="usage_of_reshape_method"></a>
|
||||
### Usage of Reshape Method <a name="usage_of_reshape_method"></a>
|
||||
|
||||
The primary method of the feature is `ov::Model::reshape`. It is overloaded to better serve two main use cases:
|
||||
|
||||
1) To change the input shape of the model with a single input, you may pass a new shape to the method. See the example of adjusting spatial dimensions to the input image below:
|
||||
1) To change input shape of model with single input you may pass new shape into the method. Please see the example of adjusting spatial dimensions to the input image:
|
||||
|
||||
@snippet snippets/ShapeInference.cpp spatial_reshape
|
||||
@snippet snippets/ShapeInference.cpp spatial_reshape
|
||||
|
||||
To do the opposite - resize input image to the input shapes of the model, use the [pre-processing API](../OV_Runtime_UG/preprocessing_overview.md).
|
||||
|
||||
@@ -80,9 +80,9 @@ To do the opposite - resize input image to the input shapes of the model, use th
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
The usage scenarios of the `reshape` feature can be found in [OpenVINO Samples](Samples_Overview.md), starting with the [Hello Reshape Sample](../../samples/cpp/hello_reshape_ssd/README.md).
|
||||
Please find usage scenarios of `reshape` feature in our [samples](Samples_Overview.md) starting with [Hello Reshape Sample](../../samples/cpp/hello_reshape_ssd/README.md).
|
||||
|
||||
In practice, some models are not ready to be reshaped. In such cases, a new input shape cannot be set with Model Optimizer or the `ov::Model::reshape` method.
|
||||
Practically, some models are not ready to be reshaped. In this case, a new input shape cannot be set with the Model Optimizer or the `ov::Model::reshape` method.
|
||||
|
||||
@anchor troubleshooting_reshape_errors
|
||||
### Troubleshooting Reshape Errors
|
||||
@@ -92,8 +92,8 @@ Shape collision during shape propagation may be a sign that a new shape does not
|
||||
Changing the model input shape may result in intermediate operations shape collision.
|
||||
|
||||
Examples of such operations:
|
||||
* The [Reshape](../ops/shape/Reshape_1.md) operation with a hard-coded output shape value.
|
||||
* The [MatMul](../ops/matrix/MatMul_1.md) operation with the `Const` second input and this input cannot be resized by spatial dimensions due to operation semantics.
|
||||
* [Reshape](../ops/shape/Reshape_1.md) operation with a hard-coded output shape value
|
||||
* [MatMul](../ops/matrix/MatMul_1.md) operation with the `Const` second input cannot be resized by spatial dimensions due to operation semantics
|
||||
|
||||
Model structure and logic should not change significantly after model reshaping.
|
||||
- The Global Pooling operation is commonly used to reduce output feature map of classification models output.
|
||||
@@ -101,7 +101,7 @@ Having the input of the shape [N, C, H, W], Global Pooling returns the output of
|
||||
Model architects usually express Global Pooling with the help of the `Pooling` operation with the fixed kernel size [H, W].
|
||||
During spatial reshape, having the input of the shape [N, C, H1, W1], Pooling with the fixed kernel size [H, W] returns the output of the shape [N, C, H2, W2], where H2 and W2 are commonly not equal to `1`.
|
||||
It breaks the classification model structure.
|
||||
For example, the publicly available [Inception family models from TensorFlow](https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models) have this issue.
|
||||
For example, [publicly available Inception family models from TensorFlow*](https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models) have this issue.
|
||||
|
||||
- Changing the model input shape may significantly affect its accuracy.
|
||||
For example, Object Detection models from TensorFlow have resizing restrictions by design.
|
||||
@@ -112,22 +112,22 @@ For details, refer to the [Tensorflow Object Detection API models resizing techn
|
||||
### How To Fix Non-Reshape-able Model
|
||||
|
||||
Some operators which prevent normal shape propagation can be fixed. To do so you can:
|
||||
* see if the issue can be fixed via changing the values of some operators' input.
|
||||
For example, the most common problem of non-reshape-able models is a `Reshape` operator with hard-coded output shape.
|
||||
* see if the issue can be fixed via changing the values of some operators input.
|
||||
E.g. most common problem of non-reshape-able models is a `Reshape` operator with hardcoded output shape.
|
||||
You can cut-off hard-coded 2nd input of `Reshape` and fill it in with relaxed values.
|
||||
For the following example on the picture, the Model Optimizer CLI should be:
|
||||
For the following example on the picture Model Optimizer CLI should be:
|
||||
```sh
|
||||
mo --input_model path/to/model --input data[8,3,224,224],1:reshaped[2]->[0 -1]`
|
||||
```
|
||||
With `1:reshaped[2]`, it's requested to cut the 2nd input (counting from zero, so `1:` means the 2nd input) of the operation named `reshaped` and replace it with a `Parameter` with shape `[2]`.
|
||||
With `->[0 -1]`, this new `Parameter` is replaced by a `Constant` operator which has the `[0, -1]` value.
|
||||
Since the `Reshape` operator has `0` and `-1` as specific values (see the meaning in [this specification](../ops/shape/Reshape_1.md)), it allows propagating shapes freely without losing the intended meaning of `Reshape`.
|
||||
With `1:reshaped[2]` we request to cut 2nd input (counting from zero, so `1:` means 2nd inputs) of operation named `reshaped` and replace it with a `Parameter` with shape `[2]`.
|
||||
With `->[0 -1]` we replace this new `Parameter` by a `Constant` operator which has value `[0, -1]`.
|
||||
Since `Reshape` operator has `0` and `-1` as a specific values (see the meaning in [the specification](../ops/shape/Reshape_1.md)) it allows to propagate shapes freely without losing the intended meaning of `Reshape`.
|
||||
|
||||

|
||||
|
||||
* transform the model during Model Optimizer conversion on the back phase. For more information, see the [Model Optimizer extension](../MO_DG/prepare_model/customize_model_optimizer/Customize_Model_Optimizer.md).
|
||||
* transform OpenVINO Model during the runtime. For more information, see [OpenVINO Runtime Transformations](../Extensibility_UG/ov_transformations.md).
|
||||
* modify the original model with the help of the original framework.
|
||||
* transform model during Model Optimizer conversion on the back phase. See [Model Optimizer extension article](../MO_DG/prepare_model/customize_model_optimizer/Customize_Model_Optimizer.md)
|
||||
* transform OpenVINO Model during the runtime. See [OpenVINO Runtime Transformations article](../Extensibility_UG/ov_transformations.md)
|
||||
* modify the original model with the help of original framework
|
||||
|
||||
### Extensibility
|
||||
OpenVINO provides a special mechanism that allows adding support of shape inference for custom operations. This mechanism is described in the [Extensibility documentation](../Extensibility_UG/Intro.md)
|
||||
@@ -141,17 +141,17 @@ OpenVINO provides a special mechanism that allows adding support of shape infere
|
||||
@endsphinxdirective
|
||||
|
||||
OpenVINO™ provides capabilities to change model input shape during the runtime.
|
||||
It may be useful when you want to feed model an input that has different size than model input shape.
|
||||
If you need to do this only once, prepare a model with updated shapes via Model Optimizer. See [specifying input shapes](@ref when_to_specify_input_shapes) for more information. For all the other cases, follow the instructions below.
|
||||
It may be useful in case you would like to feed model an input that has different size than model input shape.
|
||||
In case you need to do this only once [prepare a model with updated shapes via Model Optimizer](@ref when_to_specify_input_shapes) for all the other cases follow instructions further.
|
||||
|
||||
### Setting a New Input Shape with Reshape Method
|
||||
### Set a new input shape with reshape method
|
||||
|
||||
The [Model.reshape](api/ie_python_api/_autosummary/openvino.runtime.Model.html#openvino.runtime.Model.reshape) method updates input shapes and propagates them down to the outputs of the model through all intermediate layers.
|
||||
Example: Changing the batch size and spatial dimensions of input of a model with an image input:
|
||||
|
||||

|
||||
|
||||
Consider the code below to achieve that:
|
||||
Please see the code to achieve that:
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -161,9 +161,9 @@ Consider the code below to achieve that:
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
### Setting a New Batch Size with the set_batch Method
|
||||
### Set a new batch size with set_batch method
|
||||
|
||||
The meaning of the model batch may vary depending on the model design.
|
||||
Meaning of the model batch may vary depending on the model design.
|
||||
In order to change the batch dimension of the model, [set the layout](@ref declare_model_s_layout) for inputs and call the [set_batch](api/ie_python_api/_autosummary/openvino.runtime.set_batch.html) method.
|
||||
|
||||
@sphinxdirective
|
||||
@@ -183,15 +183,15 @@ There are other approaches to change model input shapes during the stage of [IR
|
||||
### Dynamic Shape Notice
|
||||
|
||||
Shape-changing functionality could be used to turn dynamic model input into a static one and vice versa.
|
||||
It is recommended to always set static shapes when the shape of data is not going to change from one inference to another.
|
||||
Setting static shapes can avoid possible functional limitations, memory, and runtime overheads for dynamic shapes which may vary depending on hardware plugin and used model.
|
||||
To learn more about dynamic shapes in OpenVINO, see the [Dynamic Shapes](../OV_Runtime_UG/ov_dynamic_shapes.md) article.
|
||||
It is recommended to always set static shapes in case if the shape of data is not going to change from one inference to another.
|
||||
Setting static shapes avoids possible functional limitations, memory and run time overheads for dynamic shapes that vary depending on hardware plugin and model used.
|
||||
To learn more about dynamic shapes in OpenVINO please see a [dedicated article](../OV_Runtime_UG/ov_dynamic_shapes.md).
|
||||
|
||||
### Usage of the Reshape Method <a name="usage_of_reshape_method"></a>
|
||||
### Usage of Reshape Method <a name="usage_of_reshape_method"></a>
|
||||
|
||||
The primary method of the feature is [Model.reshape](api/ie_python_api/_autosummary/openvino.runtime.Model.html#openvino.runtime.Model.reshape). It is overloaded to better serve two main use cases:
|
||||
|
||||
1) To change the input shape of a model with a single input, you may pass a new shape to the method. See the example of adjusting spatial dimensions to the input image:
|
||||
1) To change input shape of model with single input you may pass new shape into the method. Please see the example of adjusting spatial dimensions to the input image:
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -204,12 +204,12 @@ The primary method of the feature is [Model.reshape](api/ie_python_api/_autosumm
|
||||
To do the opposite - resize input image to the input shapes of the model, use the [pre-processing API](../OV_Runtime_UG/preprocessing_overview.md).
|
||||
|
||||
2) Otherwise, you can express reshape plan via dictionary mapping input and its new shape:
|
||||
Dictionary keys could be:
|
||||
* The `str` key specifies input by its name.
|
||||
* The `int` key specifies input by its index.
|
||||
* The `openvino.runtime.Output` key specifies input by passing the actual input object.
|
||||
Dictionary keys could be
|
||||
* `str` specifies input by its name
|
||||
* `int` specifies input by its index
|
||||
* `openvino.runtime.Output` specifies input by passing actual input object
|
||||
|
||||
Dictionary values (representing new shapes) could be:
|
||||
Dictionary values (representing new shapes) could be
|
||||
* `list`
|
||||
* `tuple`
|
||||
* `PartialShape`
|
||||
@@ -236,9 +236,9 @@ Dictionary values (representing new shapes) could be:
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
The usage scenarios of the `reshape` feature can be found in [OpenVINO Samples](Samples_Overview.md), starting with the [Hello Reshape Sample](../../samples/python/hello_reshape_ssd/README.md).
|
||||
Please find usage scenarios of `reshape` feature in our [samples](Samples_Overview.md), starting with [Hello Reshape Sample](../../samples/python/hello_reshape_ssd/README.md).
|
||||
|
||||
In practice, some models are not ready to be reshaped. In such cases, a new input shape cannot be set with Model Optimizer or the `Model.reshape` method.
|
||||
Practically, some models are not ready to be reshaped. In this case, a new input shape cannot be set with the Model Optimizer or the `Model.reshape` method.
|
||||
|
||||
### Troubleshooting Reshape Errors
|
||||
|
||||
@@ -256,7 +256,7 @@ Having the input of the shape [N, C, H, W], Global Pooling returns the output of
|
||||
Model architects usually express Global Pooling with the help of the `Pooling` operation with the fixed kernel size [H, W].
|
||||
During spatial reshape, having the input of the shape [N, C, H1, W1], Pooling with the fixed kernel size [H, W] returns the output of the shape [N, C, H2, W2], where H2 and W2 are commonly not equal to `1`.
|
||||
It breaks the classification model structure.
|
||||
For example, the publicly available [Inception family models from TensorFlow](https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models) have this issue.
|
||||
For example, [publicly available Inception family models from TensorFlow*](https://github.com/tensorflow/models/tree/master/research/slim#pre-trained-models) have this issue.
|
||||
|
||||
- Changing the model input shape may significantly affect its accuracy.
|
||||
For example, Object Detection models from TensorFlow have resizing restrictions by design.
|
||||
@@ -267,21 +267,21 @@ For details, refer to the [Tensorflow Object Detection API models resizing techn
|
||||
|
||||
Some operators which prevent normal shape propagation can be fixed. To do so you can:
|
||||
* see if the issue can be fixed via changing the values of some operators input.
|
||||
For example, the most common problem of non-reshape-able models is a `Reshape` operator with hard-coded output shape.
|
||||
E.g. most common problem of non-reshape-able models is a `Reshape` operator with hardcoded output shape.
|
||||
You can cut-off hard-coded 2nd input of `Reshape` and fill it in with relaxed values.
|
||||
For the following example on the picture Model Optimizer CLI should be:
|
||||
```sh
|
||||
mo --input_model path/to/model --input data[8,3,224,224],1:reshaped[2]->[0 -1]`
|
||||
```
|
||||
With `1:reshaped[2]`, it's requested to cut the 2nd input (counting from zero, so `1:` means the 2nd input) of the operation named `reshaped` and replace it with a `Parameter` with shape `[2]`.
|
||||
With `->[0 -1]`, this new `Parameter` is replaced by a `Constant` operator which has value `[0, -1]`.
|
||||
Since the `Reshape` operator has `0` and `-1` as specific values (see the meaning in [this specification](../ops/shape/Reshape_1.md)), it allows propagating shapes freely without losing the intended meaning of `Reshape`.
|
||||
With `1:reshaped[2]` we request to cut 2nd input (counting from zero, so `1:` means 2nd inputs) of operation named `reshaped` and replace it with a `Parameter` with shape `[2]`.
|
||||
With `->[0 -1]` we replace this new `Parameter` by a `Constant` operator which has value `[0, -1]`.
|
||||
Since `Reshape` operator has `0` and `-1` as a specific values (see the meaning in [the specification](../ops/shape/Reshape_1.md)) it allows to propagate shapes freely without losing the intended meaning of `Reshape`.
|
||||
|
||||

|
||||
|
||||
* transform the model during Model Optimizer conversion on the back phase. See [Model Optimizer extension](../MO_DG/prepare_model/customize_model_optimizer/Customize_Model_Optimizer.md).
|
||||
* transform OpenVINO Model during the runtime. See [OpenVINO Runtime Transformations](../Extensibility_UG/ov_transformations.md).
|
||||
* modify the original model with the help of the original framework.
|
||||
* transform model during Model Optimizer conversion on the back phase. See [Model Optimizer extension article](../MO_DG/prepare_model/customize_model_optimizer/Customize_Model_Optimizer.md)
|
||||
* transform OpenVINO Model during the runtime. See [OpenVINO Runtime Transformations article](../Extensibility_UG/ov_transformations.md)
|
||||
* modify the original model with the help of original framework
|
||||
|
||||
### Extensibility
|
||||
OpenVINO provides a special mechanism that allows adding support of shape inference for custom operations. This mechanism is described in the [Extensibility documentation](../Extensibility_UG/Intro.md)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Automatic Device Selection {#openvino_docs_OV_UG_supported_plugins_AUTO}
|
||||
# Automatic device selection {#openvino_docs_OV_UG_supported_plugins_AUTO}
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -10,16 +10,13 @@
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
This article introduces how Automatic Device Selection works and how to use it for inference.
|
||||
|
||||
## How AUTO Works
|
||||
|
||||
The Automatic Device Selection mode, or AUTO for short, uses a "virtual" or a "proxy" device,
|
||||
which does not bind to a specific type of hardware, but rather selects the processing unit for inference automatically.
|
||||
It detects available devices, picks the one best-suited for the task, and configures its optimization settings.
|
||||
This way, you can write the application once and deploy it anywhere.
|
||||
|
||||
The selection also depends on your performance requirements, defined by the “hints” configuration API, as well as device priority list limitations, if you choose to exclude some hardware from the process.
|
||||
The selection also depends on your performance requirements, defined by the “hints” configuration API, as well as
|
||||
device priority list limitations, if you choose to exclude some hardware from the process.
|
||||
|
||||
The logic behind the choice is as follows:
|
||||
1. Check what supported devices are available.
|
||||
@@ -27,7 +24,6 @@ The logic behind the choice is as follows:
|
||||
3. Select the highest-priority device capable of supporting the given model, as listed in the table below.
|
||||
4. If model’s precision is FP32 but there is no device capable of supporting it, offload the model to a device supporting FP16.
|
||||
|
||||
@sphinxdirective
|
||||
+----------+------------------------------------------------------+-------------------------------------+
|
||||
| Device || Supported || Supported |
|
||||
| Priority || Device || model precision |
|
||||
@@ -44,90 +40,74 @@ The logic behind the choice is as follows:
|
||||
| 4 || Intel® CPU | FP32, FP16, INT8, BIN |
|
||||
| || (e.g. Intel® Core™ i7-1165G7) | |
|
||||
+----------+------------------------------------------------------+-------------------------------------+
|
||||
@endsphinxdirective
|
||||
|
||||
To put it simply, when loading the model to the first device on the list fails, AUTO will try to load it to the next device in line, until one of them succeeds.
|
||||
What is important, **AUTO always starts inference with the CPU of the system**, as it provides very low latency and can start inference with no additional delays.
|
||||
What is important, **AUTO always starts inference with the CPU**, as it provides very low latency and can start inference with no additional delays.
|
||||
While the CPU is performing inference, AUTO continues to load the model to the device best suited for the purpose and transfers the task to it when ready.
|
||||
This way, the devices which are much slower in compiling models, GPU being the best example, do not impede inference at its initial stages.
|
||||
For example, if you use a CPU and a GPU, the first-inference latency of AUTO will be better than that of using GPU alone.
|
||||
For example, if you use a CPU and a GPU, first-inference latency of AUTO will be better than GPU itself.
|
||||
|
||||
Note that if you choose to exclude CPU from the priority list, it will be unable to support the initial model compilation stage.
|
||||
Note that if you choose to exclude the CPU from the priority list, it will also be unable to support the initial model compilation stage.
|
||||
|
||||
![autoplugin_accelerate]
|
||||
|
||||
This mechanism can be easily observed in the [Using AUTO with Benchmark app sample](#using-auto-with-openvino-samples-and-benchmark-app) section, showing how the first-inference latency (the time it takes to compile the model and perform the first inference) is reduced when using AUTO. For example:
|
||||
This mechanism can be easily observed in our Benchmark Application sample ([see here](#Benchmark App Info)), showing how the first-inference latency (the time it takes to compile the model and perform the first inference) is reduced when using AUTO. For example:
|
||||
|
||||
```sh
|
||||
benchmark_app -m ../public/alexnet/FP32/alexnet.xml -d GPU -niter 128
|
||||
```
|
||||
@sphinxdirective
|
||||
.. code-block:: sh
|
||||
|
||||
```sh
|
||||
benchmark_app -m ../public/alexnet/FP32/alexnet.xml -d AUTO -niter 128
|
||||
```
|
||||
./benchmark_app -m ../public/alexnet/FP32/alexnet.xml -d GPU -niter 128
|
||||
@endsphinxdirective
|
||||
|
||||
@sphinxdirective
|
||||
.. code-block:: sh
|
||||
|
||||
./benchmark_app -m ../public/alexnet/FP32/alexnet.xml -d AUTO -niter 128
|
||||
@endsphinxdirective
|
||||
|
||||
|
||||
@sphinxdirective
|
||||
.. note::
|
||||
|
||||
The longer the process runs, the closer realtime performance will be to that of the best-suited device.
|
||||
@endsphinxdirective
|
||||
|
||||
## Using AUTO
|
||||
## Using the Auto-Device Plugin
|
||||
|
||||
|
||||
Following the OpenVINO™ naming convention, the Automatic Device Selection mode is assigned the label of “AUTO.” It may be defined with no additional parameters, resulting in defaults being used, or configured further with the following setup options:
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
+--------------------------------+----------------------------------------------------------------------+
|
||||
| | Property | | Values and Description |
|
||||
+================================+======================================================================+
|
||||
| | <device candidate list> | | **Values**: |
|
||||
| | | | empty |
|
||||
| | | | `AUTO` |
|
||||
| | | | `AUTO: <device names>` (comma-separated, no spaces) |
|
||||
| | | | |
|
||||
| | | | Lists the devices available for selection. |
|
||||
| | | | The device sequence will be taken as priority from high to low. |
|
||||
| | | | If not specified, `AUTO` will be used as default, |
|
||||
| | | | and all devices will be "viewed" as candidates. |
|
||||
+--------------------------------+----------------------------------------------------------------------+
|
||||
| | `ov::device:priorities` | | **Values**: |
|
||||
| | | | `<device names>` (comma-separated, no spaces) |
|
||||
| | | | |
|
||||
| | | | Specifies the devices for AUTO to select. |
|
||||
| | | | The device sequence will be taken as priority from high to low. |
|
||||
| | | | This configuration is optional. |
|
||||
+--------------------------------+----------------------------------------------------------------------+
|
||||
| | `ov::hint::performance_mode` | | **Values**: |
|
||||
| | | | `ov::hint::PerformanceMode::LATENCY` |
|
||||
| | | | `ov::hint::PerformanceMode::THROUGHPUT` |
|
||||
| | | | `ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT` |
|
||||
| | | | |
|
||||
| | | | Specifies the performance option preferred by the application. |
|
||||
+--------------------------------+----------------------------------------------------------------------+
|
||||
| | `ov::hint::model_priority` | | **Values**: |
|
||||
| | | | `ov::hint::Priority::HIGH` |
|
||||
| | | | `ov::hint::Priority::MEDIUM` |
|
||||
| | | | `ov::hint::Priority::LOW` |
|
||||
| | | | |
|
||||
| | | | Indicates the priority for a model. |
|
||||
| | | | IMPORTANT: This property is not fully supported yet. |
|
||||
+--------------------------------+----------------------------------------------------------------------+
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------------------------+
|
||||
| Property | Property values | Description |
|
||||
+===========================+===============================================+===========================================================+
|
||||
| <device candidate list> | | AUTO: <device names> | | Lists the devices available for selection. |
|
||||
| | | comma-separated, no spaces | | The device sequence will be taken as priority |
|
||||
| | | | | from high to low. |
|
||||
| | | | | If not specified, “AUTO” will be used as default |
|
||||
| | | | | and all devices will be included. |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------------------------+
|
||||
| ov::device:priorities | | device names | | Specifies the devices for Auto-Device plugin to select. |
|
||||
| | | comma-separated, no spaces | | The device sequence will be taken as priority |
|
||||
| | | | | from high to low. |
|
||||
| | | | | This configuration is optional. |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------------------------+
|
||||
| ov::hint::performance_mode| | ov::hint::PerformanceMode::LATENCY | | Specifies the performance mode preferred |
|
||||
| | | ov::hint::PerformanceMode::THROUGHPUT | | by the application. |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------------------------+
|
||||
| ov::hint::model_priority | | ov::hint::Priority::HIGH | | Indicates the priority for a model. |
|
||||
| | | ov::hint::Priority::MEDIUM | | Importantly! |
|
||||
| | | ov::hint::Priority::LOW | | This property is still not fully supported |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------------------------+
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
Inference with AUTO is configured similarly to when device plugins are used:
|
||||
you compile the model on the plugin with configuration and execute inference.
|
||||
|
||||
### Device Candidates and Priority
|
||||
The device candidate list enables you to customize the priority and limit the choice of devices available to AUTO.
|
||||
- If <device candidate list> is not specified, AUTO assumes all the devices present in the system can be used.
|
||||
- If `AUTO` without any device names is specified, AUTO assumes all the devices present in the system can be used, and will load the network to all devices and run inference based on their default priorities, from high to low.
|
||||
|
||||
To specify the priority of devices, enter the device names in the priority order (from high to low) in `AUTO: <device names>`, or use the `ov::device:priorities` property.
|
||||
|
||||
See the following code for using AUTO and specifying devices:
|
||||
### Device candidate list
|
||||
The device candidate list allows users to customize the priority and limit the choice of devices available to the AUTO plugin. If not specified, the plugin assumes all the devices present in the system can be used. Note, that OpenVINO™ Runtime lets you use “GPU” as an alias for “GPU.0” in function calls.
|
||||
The following commands are accepted by the API:
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -145,88 +125,32 @@ See the following code for using AUTO and specifying devices:
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
Note that OpenVINO Runtime lets you use “GPU” as an alias for “GPU.0” in function calls. More details on enumerating devices can be found in [Working with devices](supported_plugins/Device_Plugins.md).
|
||||
|
||||
#### Checking Available Devices
|
||||
|
||||
To check what devices are present in the system, you can use Device API, as listed below. For information on how to use it, see [Query device properties and configuration](supported_plugins/config_properties.md).
|
||||
To check what devices are present in the system, you can use Device API. For information on how to do it, check [Query device properties and configuration](supported_plugins/config_properties.md)
|
||||
|
||||
For C++
|
||||
@sphinxdirective
|
||||
.. code-block:: sh
|
||||
|
||||
.. tab:: C++
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ov::runtime::Core::get_available_devices()
|
||||
|
||||
See the Hello Query Device C++ Sample for reference.
|
||||
|
||||
.. tab:: Python
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
openvino.runtime.Core.available_devices
|
||||
|
||||
See the Hello Query Device Python Sample for reference.
|
||||
|
||||
ov::runtime::Core::get_available_devices() (see Hello Query Device C++ Sample)
|
||||
@endsphinxdirective
|
||||
|
||||
#### Excluding Devices from Device Candidate List
|
||||
|
||||
You can also exclude hardware devices from AUTO, for example, to reserve CPU for other jobs. AUTO will not use the device for inference then. To do that, add a minus sign (-) before CPU in `AUTO: <device names>`, as in the following example:
|
||||
|
||||
For Python
|
||||
@sphinxdirective
|
||||
.. code-block:: sh
|
||||
|
||||
.. tab:: C++
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ov::CompiledModel compiled_model = core.compile_model(model, "AUTO:-CPU");
|
||||
|
||||
.. tab:: Python
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
compiled_model = core.compile_model(model=model, device_name="AUTO:-CPU")
|
||||
|
||||
openvino.runtime.Core.available_devices (see Hello Query Device Python Sample)
|
||||
@endsphinxdirective
|
||||
|
||||
AUTO will then query all available devices and remove CPU from the candidate list.
|
||||
|
||||
Note that if you choose to exclude CPU from device candidate list, CPU will not be able to support the initial model compilation stage. See more information in [How AUTO Works](#how-auto-works).
|
||||
### Performance Hints
|
||||
The `ov::hint::performance_mode` property enables you to specify a performance mode for the plugin to be more efficient for particular use cases.
|
||||
|
||||
### Performance Hints for AUTO
|
||||
The `ov::hint::performance_mode` property enables you to specify a performance option for AUTO to be more efficient for particular use cases.
|
||||
#### ov::hint::PerformanceMode::THROUGHPUT
|
||||
This mode prioritizes high throughput, balancing between latency and power. It is best suited for tasks involving multiple jobs, like inference of video feeds or large numbers of images.
|
||||
|
||||
> **NOTE**: Currently, the `ov::hint` property is supported by CPU and GPU devices only.
|
||||
|
||||
#### THROUGHPUT
|
||||
This option prioritizes high throughput, balancing between latency and power. It is best suited for tasks involving multiple jobs, such as inference of video feeds or large numbers of images.
|
||||
|
||||
> **NOTE**: If no performance hint is set explicitly, AUTO will set THROUGHPUT for devices that have not set `ov::device::properties`. For example, if you have both a CPU and a GPU in the system, this command `core.compile_model("AUTO", ov::device::properties("CPU", ov::enable_profiling(true)))` will set THROUGHPUT for the GPU only. No hint will be set for the CPU although it's the selected device.
|
||||
|
||||
#### LATENCY
|
||||
This option prioritizes low latency, providing short response time for each inference job. It performs best for tasks where inference is required for a single input image, e.g. a medical analysis of an ultrasound scan image. It also fits the tasks of real-time or nearly real-time applications, such as an industrial robot's response to actions in its environment or obstacle avoidance for autonomous vehicles.
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
.. _cumulative throughput:
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
#### CUMULATIVE_THROUGHPUT
|
||||
While `LATENCY` and `THROUGHPUT` can select one target device with your preferred performance option, the `CUMULATIVE_THROUGHPUT` option enables running inference on multiple devices for higher throughput. With `CUMULATIVE_THROUGHPUT`, AUTO loads the network model to all available devices in the candidate list, and then runs inference on them based on the default or specified priority.
|
||||
|
||||
CUMULATIVE_THROUGHPUT has similar behavior as [the Multi-Device execution mode (MULTI)](./multi_device.md). The only difference is that CUMULATIVE_THROUGHPUT uses the devices specified by AUTO, which means that it's not mandatory to add devices manually, while with MULTI, you need to specify the devices before inference.
|
||||
|
||||
With the CUMULATIVE_THROUGHPUT option:
|
||||
- If `AUTO` without any device names is specified, and the system has more than one GPU devices, AUTO will remove CPU from the device candidate list to keep GPU running at full capacity.
|
||||
- If device priority is specified, AUTO will run inference requests on devices based on the priority. In the following example, AUTO will always try to use GPU first, and then use CPU if GPU is busy:
|
||||
```sh
|
||||
ov::CompiledModel compiled_model = core.compile_model(model, "AUTO:GPU,CPU", ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT));
|
||||
```
|
||||
|
||||
#### Code Examples
|
||||
#### ov::hint::PerformanceMode::LATENCY
|
||||
This mode prioritizes low latency, providing short response time for each inference job. It performs best for tasks where inference is required for a single input image, like a medical analysis of an ultrasound scan image. It also fits the tasks of real-time or nearly real-time applications, such as an industrial robot's response to actions in its environment or obstacle avoidance for autonomous vehicles.
|
||||
Note that currently the `ov::hint` property is supported by CPU and GPU devices only.
|
||||
|
||||
To enable performance hints for your application, use the following code:
|
||||
@sphinxdirective
|
||||
@@ -245,13 +169,8 @@ To enable performance hints for your application, use the following code:
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
#### Disabling Auto-Batching for THROUGHPUT and CUMULATIVE_THROUGHPUT
|
||||
|
||||
The `ov::hint::PerformanceMode::THROUGHPUT` mode and the `ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT` mode will trigger Auto-Batching (for example, for the GPU device) by default. You can disable it by setting `ov::hint::allow_auto_batching(false)`, or change the default timeout value to a large number, e.g. `ov::auto_batch_timeout(1000)`. See [Automatic Batching](./automatic_batching.md) for more details.
|
||||
|
||||
### Configuring Model Priority
|
||||
|
||||
The `ov::hint::model_priority` property enables you to control the priorities of models in the Auto-Device plugin. A high-priority model will be loaded to a supported high-priority device. A lower-priority model will not be loaded to a device that is occupied by a higher-priority model.
|
||||
### ov::hint::model_priority
|
||||
The property enables you to control the priorities of models in the Auto-Device plugin. A high-priority model will be loaded to a supported high-priority device. A lower-priority model will not be loaded to a device that is occupied by a higher-priority model.
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -270,10 +189,8 @@ The `ov::hint::model_priority` property enables you to control the priorities of
|
||||
@endsphinxdirective
|
||||
|
||||
## Configuring Individual Devices and Creating the Auto-Device plugin on Top
|
||||
|
||||
Although the methods described above are currently the preferred way to execute inference with AUTO, the following steps can be also used as an alternative. It is currently available as a legacy feature and used if the device candidate list includes Myriad devices, uncapable of utilizing the Performance Hints option.
|
||||
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
.. tab:: C++
|
||||
@@ -290,21 +207,23 @@ Although the methods described above are currently the preferred way to execute
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
## Using AUTO with OpenVINO Samples and Benchmark app
|
||||
|
||||
<a name="Benchmark App Info"></a>
|
||||
## Using AUTO with OpenVINO™ Samples and the Benchmark App
|
||||
To see how the Auto-Device plugin is used in practice and test its performance, take a look at OpenVINO™ samples. All samples supporting the "-d" command-line option (which stands for "device") will accept the plugin out-of-the-box. The Benchmark Application will be a perfect place to start – it presents the optimal performance of the plugin without the need for additional settings, like the number of requests or CPU threads. To evaluate the AUTO performance, you can use the following commands:
|
||||
|
||||
For unlimited device choice:
|
||||
@sphinxdirective
|
||||
.. code-block:: sh
|
||||
|
||||
```sh
|
||||
benchmark_app –d AUTO –m <model> -i <input> -niter 1000
|
||||
```
|
||||
benchmark_app –d AUTO –m <model> -i <input> -niter 1000
|
||||
@endsphinxdirective
|
||||
|
||||
For limited device choice:
|
||||
@sphinxdirective
|
||||
.. code-block:: sh
|
||||
|
||||
```sh
|
||||
benchmark_app –d AUTO:CPU,GPU,MYRIAD –m <model> -i <input> -niter 1000
|
||||
```
|
||||
benchmark_app –d AUTO:CPU,GPU,MYRIAD –m <model> -i <input> -niter 1000
|
||||
@endsphinxdirective
|
||||
|
||||
For more information, refer to the [C++](../../samples/cpp/benchmark_app/README.md) or [Python](../../tools/benchmark_tool/README.md) version instructions.
|
||||
|
||||
@@ -318,11 +237,5 @@ For more information, refer to the [C++](../../samples/cpp/benchmark_app/README.
|
||||
No demos are yet fully optimized for AUTO, by means of selecting the most suitable device, using the GPU streams/throttling, and so on.
|
||||
@endsphinxdirective
|
||||
|
||||
## See Also
|
||||
|
||||
- [Debugging AUTO](AutoPlugin_Debugging.md)
|
||||
- [Running on Multiple Devices Simultaneously](./multi_device.md)
|
||||
- [Supported Devices](supported_plugins/Supported_Devices.md)
|
||||
|
||||
|
||||
[autoplugin_accelerate]: ../img/autoplugin_accelerate.png
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
# Automatic Batching {#openvino_docs_OV_UG_Automatic_Batching}
|
||||
|
||||
The Automatic Batching Execution mode (or Auto-batching for short) performs automatic batching on-the-fly to improve device utilization by grouping inference requests together, with no programming effort from the user.
|
||||
With Automatic Batching, gathering the input and scattering the output from the individual inference requests required for the batch happen transparently, without affecting the application code.
|
||||
## (Automatic) Batching Execution
|
||||
|
||||
This article provides a preview of the new Automatic Batching function, including how it works, its configurations, and testing performance.
|
||||
The Automatic-Batching is a preview of the new functionality in the OpenVINO™ toolkit. It performs on-the-fly automatic batching (i.e. grouping inference requests together) to improve device utilization, with no programming effort from the user.
|
||||
Inputs gathering and outputs scattering from the individual inference requests required for the batch happen transparently, without affecting the application code.
|
||||
|
||||
## Enabling/Disabling Automatic Batching
|
||||
The feature primarily targets existing code written for inferencing many requests (each instance with the batch size 1). To obtain corresponding performance improvements, the application must be *running many inference requests simultaneously*.
|
||||
As explained below, the auto-batching functionality can be also used via a special *virtual* device.
|
||||
|
||||
Auto-batching primarily targets the existing code written for inferencing many requests, each instance with the batch size 1. To obtain corresponding performance improvements, the application **must be running many inference requests simultaneously**.
|
||||
Auto-batching can also be used via a particular *virtual* device.
|
||||
|
||||
Batching is a straightforward way of leveraging the compute power of GPU and saving on communication overheads. Automatic Batching is "implicitly" triggered on the GPU when `ov::hint::PerformanceMode::THROUGHPUT` is specified for the `ov::hint::performance_mode` property for the `compile_model` or `set_property` calls.
|
||||
Batching is a straightforward way of leveraging the GPU compute power and saving on communication overheads. The automatic batching is _implicitly_ triggered on the GPU when the `ov::hint::PerformanceMode::THROUGHPUT` is specified for the `ov::hint::performance_mode` property for the compile_model or set_property calls.
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -29,11 +27,8 @@ Batching is a straightforward way of leveraging the compute power of GPU and sav
|
||||
@endsphinxtabset
|
||||
|
||||
|
||||
To enable Auto-batching in the legacy apps not akin to the notion of performance hints, you need to use the **explicit** device notion, such as `BATCH:GPU`.
|
||||
> **NOTE**: You can disable the Auto-Batching (for example, for the GPU device) from being triggered by the `ov::hint::PerformanceMode::THROUGHPUT`. To do that, pass the `ov::hint::allow_auto_batching` set to **false** in addition to the `ov::hint::performance_mode`:
|
||||
|
||||
### Disabling Automatic Batching
|
||||
|
||||
Auto-Batching can be disabled (for example, for the GPU device) to prevent being triggered by `ov::hint::PerformanceMode::THROUGHPUT`. To do that, set `ov::hint::allow_auto_batching` to **false** in addition to the `ov::hint::performance_mode`, as shown below:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -52,20 +47,10 @@ Auto-Batching can be disabled (for example, for the GPU device) to prevent being
|
||||
@endsphinxtabset
|
||||
|
||||
|
||||
## Configuring Automatic Batching
|
||||
Following the OpenVINO naming convention, the *batching* device is assigned the label of *BATCH*. The configuration options are as follows:
|
||||
Alternatively, to enable the Auto-Batching in the legacy apps not akin to the notion of the performance hints, you may need to use the **explicit** device notion, such as 'BATCH:GPU'. In both cases (the *throughput* hint or explicit BATCH device), the optimal batch size selection happens automatically (the implementation queries the `ov::optimal_batch_size` property from the device, passing the model's graph as the parameter). The actual value depends on the model and device specifics, for example, on-device memory for the dGPUs.
|
||||
Auto-Batching support is not limited to the GPUs, but if a device does not support the `ov::optimal_batch_size` yet, it can work with the auto-batching only when specifying an explicit batch size, for example, "BATCH:<device>(16)".
|
||||
|
||||
| Parameter name | Parameter description | Examples |
|
||||
| :--- | :--- |:-----------------------------------------------------------------------------|
|
||||
| `AUTO_BATCH_DEVICE` | The name of the device to apply Automatic batching, with the optional batch size value in brackets. | `BATCH:GPU` triggers the automatic batch size selection. `BATCH:GPU(4)` directly specifies the batch size. |
|
||||
| `ov::auto_batch_timeout` | The timeout value, in ms. (1000 by default) | You can reduce the timeout value to avoid performance penalty when the data arrives too unevenly. For example, set it to "100", or the contrary, i.e., make it large enough to accommodate input preparation (e.g. when it is a serial process). |
|
||||
|
||||
## Automatic Batch Size Selection
|
||||
|
||||
In both the THROUGHPUT hint and the explicit BATCH device cases, the optimal batch size is selected automatically, as the implementation queries the `ov::optimal_batch_size` property from the device and passes the model graph as the parameter. The actual value depends on the model and device specifics, for example, the on-device memory for dGPUs.
|
||||
The support for Auto-batching is not limited to GPU. However, if a device does not support `ov::optimal_batch_size` yet, to work with Auto-batching, an explicit batch size must be specified, e.g., `BATCH:<device>(16)`.
|
||||
|
||||
This "automatic batch size selection" works on the presumption that the application queries `ov::optimal_number_of_infer_requests` to create the requests of the returned number and run them simultaneously:
|
||||
This _automatic batch size selection_ assumes that the application queries the `ov::optimal_number_of_infer_requests` to create and run the returned number of requests simultaneously:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -83,13 +68,10 @@ This "automatic batch size selection" works on the presumption that the applicat
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
If not enough inputs were collected, the `timeout` value makes the transparent execution fall back to the execution of individual requests. Configuration-wise, this is the AUTO_BATCH_TIMEOUT property.
|
||||
The timeout, which adds itself to the execution time of the requests, heavily penalizes the performance. To avoid this, in cases when your parallel slack is bounded, give the OpenVINO an additional hint.
|
||||
|
||||
### Optimizing Performance by Limiting Batch Size
|
||||
|
||||
If not enough inputs were collected, the `timeout` value makes the transparent execution fall back to the execution of individual requests. This value can be configured via the `AUTO_BATCH_TIMEOUT` property.
|
||||
The timeout, which adds itself to the execution time of the requests, heavily penalizes the performance. To avoid this, when your parallel slack is bounded, provide OpenVINO with an additional hint.
|
||||
|
||||
For example, when the application processes only 4 video streams, there is no need to use a batch larger than 4. The most future-proof way to communicate the limitations on the parallelism is to equip the performance hint with the optional `ov::hint::num_requests` configuration key set to 4. This will limit the batch size for the GPU and the number of inference streams for the CPU, hence each device uses `ov::hint::num_requests` while converting the hint to the actual device configuration options:
|
||||
For example, the application processes only 4 video streams, so there is no need to use a batch larger than 4. The most future-proof way to communicate the limitations on the parallelism is to equip the performance hint with the optional `ov::hint::num_requests` configuration key set to 4. For the GPU this will limit the batch size, for the CPU - the number of inference streams, so each device uses the `ov::hint::num_requests` while converting the hint to the actual device configuration options:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -108,47 +90,44 @@ For example, when the application processes only 4 video streams, there is no ne
|
||||
@endsphinxtabset
|
||||
|
||||
|
||||
For the *explicit* usage, you can limit the batch size by using `BATCH:GPU(4)`, where 4 is the number of requests running in parallel.
|
||||
For the *explicit* usage, you can limit the batch size using "BATCH:GPU(4)", where 4 is the number of requests running in parallel.
|
||||
|
||||
## Other Performance Considerations
|
||||
### Other Performance Considerations
|
||||
|
||||
To achieve the best performance with Automatic Batching, the application should:
|
||||
- Operate inference requests of the number that represents the multiple of the batch size. In the example above, for batch size 4, the application should operate 4, 8, 12, 16, etc. requests.
|
||||
- Use the requests that are grouped by the batch size together. For example, the first 4 requests are inferred, while the second group of the requests is being populated. Essentially, Automatic Batching shifts the asynchronicity from the individual requests to the groups of requests that constitute the batches.
|
||||
- Balance the `timeout` value vs. the batch size. For example, in many cases, having a smaller `timeout` value/batch size may yield better performance than having a larger batch size with a `timeout` value that is not large enough to accommodate the full number of the required requests.
|
||||
- When Automatic Batching is enabled, the `timeout` property of `ov::CompiledModel` can be changed anytime, even after the loading/compilation of the model. For example, setting the value to 0 disables Auto-batching effectively, as the collection of requests would be omitted.
|
||||
- Carefully apply Auto-batching to the pipelines. For example, in the conventional "video-sources -> detection -> classification" flow, it is most beneficial to do Auto-batching over the inputs to the detection stage. The resulting number of detections is usually fluent, which makes Auto-batching less applicable for the classification stage.
|
||||
To achieve the best performance with the Automatic Batching, the application should:
|
||||
- Operate the number of inference requests that represents the multiple of the batch size. In the above example, for batch size 4, the application should operate 4, 8, 12, 16, etc. requests.
|
||||
- Use the requests, grouped by the batch size, together. For example, the first 4 requests are inferred, while the second group of the requests is being populated. Essentially, the Automatic Batching shifts the asynchronousity from the individual requests to the groups of requests that constitute the batches.
|
||||
- Balance the 'timeout' value vs the batch size. For example, in many cases having a smaller timeout value/batch size may yield better performance than large batch size, but with the timeout value that is not large enough to accommodate the full number of the required requests.
|
||||
- When the Automatic Batching is enabled, the 'timeout' property of the `ov::CompiledModel` can be changed any time, even after model loading/compilation. For example, setting the value to 0 effectively disables the auto-batching, as requests' collection would be omitted.
|
||||
- Carefully apply the auto-batching to the pipelines. For example for the conventional video-sources->detection->classification flow, it is the most benefical to do auto-batching over the inputs to the detection stage. Whereas the resulting number of detections is usually fluent, which makes the auto-batching less applicable for the classification stage.
|
||||
|
||||
The following are limitations of the current implementations:
|
||||
- Although it is less critical for the throughput-oriented scenarios, the load time with Auto-batching increases by almost double.
|
||||
- Certain networks are not safely reshapable by the "batching" dimension (specified as `N` in the layout terms). Besides, if the batching dimension is not zeroth, Auto-batching will not be triggered "implicitly" by the throughput hint.
|
||||
- The "explicit" notion, for example, `BATCH:GPU`, using the relaxed dimensions tracking, often makes Auto-batching possible. For example, this method unlocks most **detection networks**.
|
||||
- When *forcing* Auto-batching via the "explicit" device notion, make sure that you validate the results for correctness.
|
||||
- Performance improvements happen at the cost of the growth of memory footprint. However, Auto-batching queries the available memory (especially for dGPU) and limits the selected batch size accordingly.
|
||||
- Although less critical for the throughput-oriented scenarios, the load-time with auto-batching increases by almost 2x.
|
||||
- Certain networks are not safely reshape-able by the "batching" dimension (specified as 'N' in the layouts terms). Also, if the batching dimension is not zero-th, the auto-batching is not triggered _implicitly_ by the throughput hint.
|
||||
- The _explicit_ notion, for example, "BATCH:GPU", uses the relaxed dimensions tracking, often making the auto-batching possible. For example, this trick unlocks most **detection networks**.
|
||||
- - When *forcing* the auto-batching via the explicit device notion, make sure to validate the results for correctness.
|
||||
- Performance improvements happen at the cost of the memory footprint growth, yet the auto-batching queries the available memory (especially for the dGPUs) and limits the selected batch size accordingly.
|
||||
|
||||
|
||||
### Configuring the Automatic Batching
|
||||
Following the OpenVINO convention for devices names, the *batching* device is named *BATCH*. The configuration options are as follows:
|
||||
|
||||
## Testing Performance with Benchmark_app
|
||||
The `benchmark_app` sample, that has both [C++](../../samples/cpp/benchmark_app/README.md) and [Python](../../tools/benchmark_tool/README.md) versions, is the best way to evaluate the performance of Automatic Batching:
|
||||
- The most straightforward way is using the performance hints:
|
||||
| Parameter name | Parameter description | Default | Examples |
|
||||
| :--- | :--- | :--- |:-----------------------------------------------------------------------------|
|
||||
| "AUTO_BATCH_DEVICE" | Device name to apply the automatic batching and optional batch size in brackets | N/A | "BATCH:GPU" which triggers the automatic batch size selection. Another example is the device name (to apply the batching) with directly specified batch size "BATCH:GPU(4)" |
|
||||
| "AUTO_BATCH_TIMEOUT" | timeout value, in ms | 1000 | you can reduce the timeout value (to avoid performance penalty when the data arrives too non-evenly) e.g. pass the "100", or in contrast make it large enough e.g. to accommodate inputs preparation (e.g. when it is serial process) |
|
||||
|
||||
### Testing Automatic Batching Performance with the Benchmark_App
|
||||
The `benchmark_app`, that exists in both [C++](../../samples/cpp/benchmark_app/README.md) and [Python](../../tools/benchmark_tool/README.md) versions, is the best way to evaluate the performance of the Automatic Batching:
|
||||
- The most straighforward way is performance hints:
|
||||
- benchmark_app **-hint tput** -d GPU -m 'path to your favorite model'
|
||||
- You can also use the "explicit" device notion to override the strict rules of the implicit reshaping by the batch dimension:
|
||||
- Overriding the strict rules of implicit reshaping by the batch dimension via the explicit device notion:
|
||||
- benchmark_app **-hint none -d BATCH:GPU** -m 'path to your favorite model'
|
||||
- or override the automatically deduced batch size as well:
|
||||
- Finally, overriding the automatically-deduced batch size as well:
|
||||
- $benchmark_app -hint none -d **BATCH:GPU(16)** -m 'path to your favorite model'
|
||||
- This example also applies to CPU or any other device that generally supports batch execution.
|
||||
- Keep in mind that some shell versions (e.g. `bash`) may require adding quotes around complex device names, i.e. `-d "BATCH:GPU(16)"` in this example.
|
||||
- notice that some shell versions (e.g. `bash`) may require adding quotes around complex device names, i.e. -d "BATCH:GPU(16)"
|
||||
|
||||
Note that Benchmark_app performs a warm-up run of a *single* request. As Auto-Batching requires significantly more requests to execute in batch, this warm-up run hits the default timeout value (1000 ms), as reported in the following example:
|
||||
The last example is also applicable to the CPU or any other device that generally supports the batched execution.
|
||||
|
||||
```
|
||||
[ INFO ] First inference took 1000.18ms
|
||||
```
|
||||
This value also exposed as the final execution statistics on the `benchmark_app` exit:
|
||||
```
|
||||
[ INFO ] Latency:
|
||||
[ INFO ] Max: 1000.18 ms
|
||||
```
|
||||
This is NOT the actual latency of the batched execution, so you are recommended to refer to other metrics in the same log, for example, "Median" or "Average" execution.
|
||||
|
||||
### Additional Resources
|
||||
### See Also
|
||||
[Supported Devices](supported_plugins/Supported_Devices.md)
|
||||
|
||||
@@ -1,28 +1,31 @@
|
||||
# Deploying Your Application with Deployment Manager {#openvino_docs_install_guides_deployment_manager_tool}
|
||||
# Deployment Manager {#openvino_docs_install_guides_deployment_manager_tool}
|
||||
|
||||
The OpenVINO™ Deployment Manager is a Python command-line tool that creates a deployment package by assembling the model, OpenVINO IR files, your application, and associated dependencies into a runtime package for your target device. This tool is delivered within the Intel® Distribution of OpenVINO™ toolkit for Linux, Windows and macOS release packages. It is available in the `<INSTALL_DIR>/tools/deployment_manager` directory after installation.
|
||||
|
||||
This article provides instructions on how to create a package with Deployment Manager and then deploy the package to your target systems.
|
||||
The Deployment Manager is a Python* command-line tool that creates a deployment package by assembling the model, IR files, your application, and associated dependencies into a runtime package for your target device. This tool is delivered within the Intel® Distribution of OpenVINO™ toolkit for Linux*, Windows* and macOS* release packages and is available after installation in the `<INSTALL_DIR>/tools/deployment_manager` directory.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
To use the Deployment Manager tool, the following requirements need to be met:
|
||||
* Intel® Distribution of OpenVINO™ toolkit is installed. See the [Installation Guide](../../install_guides/installing-openvino-overview.md) for instructions on different operating systems.
|
||||
* Intel® Distribution of OpenVINO™ toolkit
|
||||
* To run inference on a target device other than CPU, device drivers must be pre-installed:
|
||||
* **For GPU**, see [Configurations for Intel® Processor Graphics (GPU)](../../install_guides/configurations-for-intel-gpu.md).
|
||||
* **For NCS2**, see [Intel® Neural Compute Stick 2 section](../../install_guides/configurations-for-ncs2.md)
|
||||
* **For VPU**, see [Configurations for Intel® Vision Accelerator Design with Intel® Movidius™ VPUs](../../install_guides/configurations-for-ivad-vpu.md).
|
||||
* **For GNA**, see [Intel® Gaussian & Neural Accelerator (GNA)](../../install_guides/configurations-for-intel-gna.md)
|
||||
* **For Linux**, see the following sections in the [installation instructions for Linux](../../install_guides/installing-openvino-linux.md):
|
||||
* Steps for [Intel® Processor Graphics (GPU)](../../install_guides/configurations-for-intel-gpu.md) section
|
||||
* Steps for [Intel® Neural Compute Stick 2 section](../../install_guides/configurations-for-ncs2.md)
|
||||
* Steps for [Intel® Vision Accelerator Design with Intel® Movidius™ VPUs](../../install_guides/installing-openvino-config-ivad-vpu.md)
|
||||
* Steps for [Intel® Gaussian & Neural Accelerator (GNA)](../../install_guides/configurations-for-intel-gna.md)
|
||||
* **For Windows**, see the following sections in the [installation instructions for Windows](../../install_guides/installing-openvino-windows.md):
|
||||
* Steps for [Intel® Processor Graphics (GPU)](../../install_guides/configurations-for-intel-gpu.md)
|
||||
* Steps for the [Intel® Vision Accelerator Design with Intel® Movidius™ VPUs](../../install_guides/installing-openvino-config-ivad-vpu.md)
|
||||
* **For macOS**, see the following section in the [installation instructions for macOS](../../install_guides/installing-openvino-macos.md):
|
||||
* Steps for [Intel® Neural Compute Stick 2 section](../../install_guides/configurations-for-ncs2.md)
|
||||
|
||||
> **IMPORTANT**: The operating system on the target system must be the same as the development system on which you are creating the package. For example, if the target system is Ubuntu 18.04, the deployment package must be created from the OpenVINO™ toolkit installed on Ubuntu 18.04.
|
||||
|
||||
> **TIP**: If your application requires additional dependencies, including the Microsoft Visual C++ Redistributable, use the ['--user_data' option](https://docs.openvino.ai/latest/openvino_docs_install_guides_deployment_manager_tool.html#run-standard-cli-mode) to add them to the deployment archive. Install these dependencies on the target host before running inference.
|
||||
|
||||
## Creating Deployment Package Using Deployment Manager
|
||||
## Create Deployment Package Using Deployment Manager
|
||||
|
||||
To create a deployment package that includes inference-related components of OpenVINO™ toolkit, you can run the Deployment Manager tool in either interactive or standard CLI mode .
|
||||
There are two ways to create a deployment package that includes inference-related components of the OpenVINO™ toolkit: you can run the Deployment Manager tool in either interactive or standard CLI mode.
|
||||
|
||||
### Running Deployment Manager in Interactive Mode
|
||||
### Run Interactive Mode
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -32,9 +35,9 @@ To create a deployment package that includes inference-related components of Ope
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
The interactive mode provides a user-friendly command-line interface that guides through the process with text prompts.
|
||||
Interactive mode provides a user-friendly command-line interface that will guide you through the process with text prompts.
|
||||
|
||||
To launch the Deployment Manager in interactive mode, open a new terminal window, go to the Deployment Manager tool directory, and run the tool script without parameters:
|
||||
To launch the Deployment Manager in interactive mode, open a new terminal window, go to the Deployment Manager tool directory and run the tool script without parameters:
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -66,23 +69,23 @@ The target device selection dialog is displayed:
|
||||
|
||||

|
||||
|
||||
Use the options provided on the screen to complete the selection of the target devices, and press **Enter** to proceed to the package generation dialog. To interrupt the generation process and exit the program, type **q** and press **Enter**.
|
||||
Use the options provided on the screen to complete selection of the target devices and press **Enter** to proceed to the package generation dialog. if you want to interrupt the generation process and exit the program, type **q** and press **Enter**.
|
||||
|
||||
Once the selection is accepted, the package generation dialog will appear:
|
||||
Once you accept the selection, the package generation dialog is displayed:
|
||||
|
||||

|
||||
|
||||
The target devices selected in the previous step appear on the screen. To go back and change the selection, type **b** and press **Enter**. Use the default settings, or use the following options to configure the generation process:
|
||||
The target devices you have selected at the previous step appear on the screen. To go back and change the selection, type **b** and press **Enter**. Use the options provided to configure the generation process, or use the default settings.
|
||||
|
||||
* `o. Change output directory` (optional): the path to the output directory. By default, it is set to your home directory.
|
||||
* `o. Change output directory` (optional): Path to the output directory. By default, it's set to your home directory.
|
||||
|
||||
* `u. Provide (or change) path to folder with user data` (optional): the path to a directory with user data (OpenVINO IR, model, dataset, etc.) files and subdirectories required for inference, which will be added to the deployment archive. By default, it is set to `None`, which means that copying the user data to the target system need to be done separately.
|
||||
* `u. Provide (or change) path to folder with user data` (optional): Path to a directory with user data (IRs, models, datasets, etc.) files and subdirectories required for inference, which will be added to the deployment archive. By default, it's set to `None`, which means you will separately copy the user data to the target system.
|
||||
|
||||
* `t. Change archive name` (optional): the deployment archive name without extension. By default, it is set to `openvino_deployment_package`.
|
||||
* `t. Change archive name` (optional): Deployment archive name without extension. By default, it is set to `openvino_deployment_package`.
|
||||
|
||||
After all the parameters are set, type **g** and press **Enter** to generate the package for the selected target devices. To interrupt the generation process and exit the program, type **q** and press **Enter**.
|
||||
Once all the parameters are set, type **g** and press **Enter** to generate the package for the selected target devices. To interrupt the generation process and exit the program, type **q** and press **Enter**.
|
||||
|
||||
Once the script has successfully completed, the deployment package is generated in the specified output directory.
|
||||
The script successfully completes and the deployment package is generated in the specified output directory.
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -92,7 +95,7 @@ Once the script has successfully completed, the deployment package is generated
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
### Running Deployment Manager in Standard CLI Mode
|
||||
### Run Standard CLI Mode
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -102,9 +105,9 @@ Once the script has successfully completed, the deployment package is generated
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
You can also run the Deployment Manager tool in the standard CLI mode. In this mode, specify the target devices and other parameters as command-line arguments of the Deployment Manager Python script. This mode facilitates integrating the tool in an automation pipeline.
|
||||
Alternatively, you can run the Deployment Manager tool in the standard CLI mode. In this mode, you specify the target devices and other parameters as command-line arguments of the Deployment Manager Python script. This mode facilitates integrating the tool in an automation pipeline.
|
||||
|
||||
To launch the Deployment Manager tool in the standard mode: open a new terminal window, go to the Deployment Manager tool directory, and run the tool command with the following syntax:
|
||||
To launch the Deployment Manager tool in the standard mode, open a new terminal window, go to the Deployment Manager tool directory and run the tool command with the following syntax:
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -133,16 +136,15 @@ To launch the Deployment Manager tool in the standard mode: open a new terminal
|
||||
|
||||
The following options are available:
|
||||
|
||||
* `<--targets>` (required): the list of target devices to run inference. To specify more than one target, separate them with spaces, for example, `--targets cpu gpu vpu`.
|
||||
To get a list of currently available targets, run the program with the `-h` option.
|
||||
* `<--targets>` (required): List of target devices to run inference. To specify more than one target, separate them with spaces. For example: `--targets cpu gpu vpu`. You can get a list of currently available targets by running the program with the `-h` option.
|
||||
|
||||
* `[--output_dir]` (optional): the path to the output directory. By default, it is set to your home directory.
|
||||
* `[--output_dir]` (optional): Path to the output directory. By default, it is set to your home directory.
|
||||
|
||||
* `[--archive_name]` (optional): a deployment archive name without extension. By default, it is set to `openvino_deployment_package`.
|
||||
* `[--archive_name]` (optional): Deployment archive name without extension. By default, it is set to `openvino_deployment_package`.
|
||||
|
||||
* `[--user_data]` (optional): the path to a directory with user data (OpenVINO IR, model, dataset, etc.) files and subdirectories required for inference, which will be added to the deployment archive. By default, it is set to `None`, which means copying the user data to the target system need to be performed separately.
|
||||
* `[--user_data]` (optional): Path to a directory with user data (IRs, models, datasets, etc.) files and subdirectories required for inference, which will be added to the deployment archive. By default, it's set to `None`, which means you will separately copy the user data to the target system.
|
||||
|
||||
Once the script has successfully completed, the deployment package is generated in the output directory specified.
|
||||
The script successfully completes, and the deployment package is generated in the output directory specified.
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -152,15 +154,15 @@ Once the script has successfully completed, the deployment package is generated
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
## Deploying Package on Target Systems
|
||||
## Deploy Package on Target Systems
|
||||
|
||||
Once the Deployment Manager has successfully completed, the `.tar.gz` (on Linux or macOS) or `.zip` (on Windows) package is generated in the specified output directory.
|
||||
After the Deployment Manager has successfully completed, you can find the generated `.tar.gz` (for Linux or macOS) or `.zip` (for Windows) package in the output directory you specified.
|
||||
|
||||
To deploy the OpenVINO Runtime components from the development machine to the target system, perform the following steps:
|
||||
|
||||
1. Copy the generated archive to the target system by using your preferred method.
|
||||
1. Copy the generated archive to the target system using your preferred method.
|
||||
|
||||
2. Extract the archive to the destination directory on the target system. If the name of your archive is different from the default one shown below, replace `openvino_deployment_package` with your specified name.
|
||||
2. Unpack the archive into the destination directory on the target system (if your archive name is different from the default shown below, replace the `openvino_deployment_package` with the name you use).
|
||||
@sphinxdirective
|
||||
|
||||
.. tab:: Linux
|
||||
@@ -183,22 +185,21 @@ To deploy the OpenVINO Runtime components from the development machine to the ta
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
The package is unpacked to the destination directory and the following files and subdirectories are created:
|
||||
|
||||
Now, the package is extracted to the destination directory. The following files and subdirectories are created:
|
||||
* `setupvars.sh` — Copy of `setupvars.sh`
|
||||
* `runtime` — Contains the OpenVINO runtime binary files.
|
||||
* `install_dependencies` — Snapshot of the `install_dependencies` directory from the OpenVINO installation directory.
|
||||
* `<user_data>` — The directory with the user data (IRs, datasets, etc.) you specified while configuring the package.
|
||||
|
||||
* `setupvars.sh` — a copy of `setupvars.sh`.
|
||||
* `runtime` — contains the OpenVINO runtime binary files.
|
||||
* `install_dependencies` — a snapshot of the `install_dependencies` directory from the OpenVINO installation directory.
|
||||
* `<user_data>` — the directory with the user data (OpenVINO IR, model, dataset, etc.) specified while configuring the package.
|
||||
|
||||
3. On a target Linux system, to run inference on a target Intel® GPU, Intel® Movidius™ VPU, or Intel® Vision Accelerator Design with Intel® Movidius™ VPUs, install additional dependencies by running the `install_openvino_dependencies.sh` script:
|
||||
For Linux, to run inference on a target Intel® GPU, Intel® Movidius™ VPU, or Intel® Vision Accelerator Design with Intel® Movidius™ VPUs, you need to install additional dependencies by running the `install_openvino_dependencies.sh` script on the target machine:
|
||||
|
||||
```sh
|
||||
cd <destination_dir>/openvino/install_dependencies
|
||||
sudo -E ./install_openvino_dependencies.sh
|
||||
```
|
||||
|
||||
4. Set up the environment variables:
|
||||
Set up the environment variables:
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -225,4 +226,4 @@ sudo -E ./install_openvino_dependencies.sh
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
Now, you have finished the deployment of the OpenVINO Runtime components to the target system.
|
||||
You have now finished the deployment of the OpenVINO Runtime components to the target system.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Deploying Your Applications with OpenVINO™ {#openvino_deployment_guide}
|
||||
# Deploy with OpenVINO {#openvino_deployment_guide}
|
||||
|
||||
@sphinxdirective
|
||||
|
||||
@@ -11,44 +11,58 @@
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
Once the [OpenVINO™ application development](../integrate_with_your_application.md) has been finished, application developers usually need to deploy their applications to end users. There are several ways to achieve that:
|
||||
Once the [OpenVINO application development](../integrate_with_your_application.md) has been finished, usually application developers need to deploy their applications to end users. There are several ways how to achieve that:
|
||||
|
||||
- Set a dependency on the existing prebuilt packages, also called "centralized distribution":
|
||||
- using Debian / RPM packages - a recommended way for Linux operating systems;
|
||||
- using PIP package manager on PyPI - the default approach for Python-based applications;
|
||||
- using Docker images - if the application should be deployed as a Docker image, use a pre-built OpenVINO™ Runtime Docker image as a base image in the Dockerfile for the application container image. For more information about OpenVINO Docker images, refer to [Installing OpenVINO on Linux from Docker](../../install_guides/installing-openvino-docker-linux.md) and [Installing OpenVINO on Windows from Docker](../../install_guides/installing-openvino-docker-windows.md).
|
||||
Furthermore, to customize your OpenVINO Docker image, use the [Docker CI Framework](https://github.com/openvinotoolkit/docker_ci) to generate a Dockerfile and built the image.
|
||||
- Grab a necessary functionality of OpenVINO together with your application, also called "local distribution":
|
||||
- using [OpenVINO Deployment Manager](deployment-manager-tool.md) - providing a convenient way for creating a distribution package;
|
||||
- using the advanced [local distribution](local-distribution.md) approach;
|
||||
- using [a static version of OpenVINO Runtime linked to the final app](https://github.com/openvinotoolkit/openvino/wiki/StaticLibraries).
|
||||
- Set a dependency on existing prebuilt packages (so called _centralized distribution_):
|
||||
- Using Debian / RPM packages, a recommended way for a family of Linux operation systems
|
||||
- Using pip package manager on PyPi, default approach for Python-based applications
|
||||
- Using Docker images. If the application should be deployed as a Docker image, developer can use a pre-built runtime OpenVINO Docker image as a base image in the Dockerfile for the application container image. You can find more info about available OpenVINO Docker images in the Install Guides for [Linux](../../install_guides/installing-openvino-docker-linux.md) and [Windows](../../install_guides/installing-openvino-docker-windows.md).
|
||||
Also, if you need to customize OpenVINO Docker image, you can use [Docker CI Framework](https://github.com/openvinotoolkit/docker_ci) to generate a Dockerfile and built it.
|
||||
- Grab a necessary functionality of OpenVINO together with your application (so-called _local distribution_):
|
||||
- Using [OpenVINO Deployment manager](deployment-manager-tool.md) providing a convinient way create a distribution package
|
||||
- Using advanced [Local distribution](local-distribution.md) approach
|
||||
- Using [static version of OpenVINO Runtime linked into the final app](https://github.com/openvinotoolkit/openvino/wiki/StaticLibraries)
|
||||
|
||||
The table below shows which distribution type can be used for what target operating system:
|
||||
The table below shows which distribution type can be used depending on target operation system:
|
||||
|
||||
| Distribution type | Operating systems |
|
||||
@sphinxdirective
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<div class="collapsible-section" data-title="Click to expand/collapse">
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
| Distribution type | Operation systems |
|
||||
|------- ---------- | ----------------- |
|
||||
| Debian packages | Ubuntu 18.04 long-term support (LTS), 64-bit; Ubuntu 20.04 long-term support (LTS), 64-bit |
|
||||
| RMP packages | Red Hat Enterprise Linux 8, 64-bit |
|
||||
| Docker images | Ubuntu 18.04 long-term support (LTS), 64-bit; Ubuntu 20.04 long-term support (LTS), 64-bit; Red Hat Enterprise Linux 8, 64-bit; Windows Server Core base LTSC 2019, 64-bit; Windows 10, version 20H2, 64-bit |
|
||||
| PyPI (PIP package manager) | See [https://pypi.org/project/openvino/](https://pypi.org/project/openvino/) |
|
||||
| [OpenVINO Deployment Manager](deployment-manager-tool.md) | All operating systems |
|
||||
| [Local distribution](local-distribution.md) | All operating systems |
|
||||
| [Build OpenVINO statically and link to the final app](https://github.com/openvinotoolkit/openvino/wiki/StaticLibraries) | All operating systems |
|
||||
| PyPi (pip package manager) | See [https://pypi.org/project/openvino/](https://pypi.org/project/openvino/) |
|
||||
| [OpenVINO Deployment Manager](deployment-manager-tool.md) | All operation systems |
|
||||
| [Local distribution](local-distribution.md) | All operation systems |
|
||||
| [Build OpenVINO statically and link into the final app](https://github.com/openvinotoolkit/openvino/wiki/StaticLibraries) | All operation systems |
|
||||
|
||||
## Granularity of Major Distribution Types
|
||||
@sphinxdirective
|
||||
|
||||
The granularity of OpenVINO packages may vary for different distribution types. For example, the PyPI distribution of OpenVINO has a [single 'openvino' package](https://pypi.org/project/openvino/) that contains all the runtime libraries and plugins, while a [local distribution](local-distribution.md) is a more configurable type providing higher granularity. Below are important details of the set of libraries included in the OpenVINO Runtime package:
|
||||
.. raw:: html
|
||||
|
||||
</div>
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
Depending on the distribution type, the granularity of OpenVINO packages may vary: PyPi distribution [OpenVINO has a single package 'openvino'](https://pypi.org/project/openvino/) containing all the runtime libraries and plugins, while more configurable ways like [Local distribution](local-distribution.md) provide higher granularity, so it is important to now some details about the set of libraries which are part of OpenVINO Runtime package:
|
||||
|
||||
![deployment_simplified]
|
||||
|
||||
- The main library `openvino` is used by users' C++ applications to link against with. The library provides all OpenVINO Runtime public APIs, including both API 2.0 and the previous Inference Engine and nGraph APIs. For C language applications, `openvino_c` is additionally required for distribution.
|
||||
- The "optional" plugin libraries like `openvino_intel_cpu_plugin` (matching the `openvino_.+_plugin` pattern) are used to provide inference capabilities on specific devices or additional capabilities like [Hetero Execution](../hetero_execution.md) and [Multi-Device Execution](../multi_device.md).
|
||||
- The "optional" plugin libraries like `openvino_ir_frontend` (matching `openvino_.+_frontend`) are used to provide capabilities to read models of different file formats such as OpenVINO IR, ONNX, and PaddlePaddle.
|
||||
- The main library `openvino` is used by C++ user's applications to link against with. The library provides all OpenVINO Runtime public API for both OpenVINO API 2.0 and Inference Engine, nGraph APIs. For C language applications `openvino_c` is additionally required for distribution.
|
||||
- The _optional_ plugin libraries like `openvino_intel_cpu_plugin` (matching `openvino_.+_plugin` pattern) are used to provide inference capabilities on specific devices or additional capabitilies like [Hetero execution](../hetero_execution.md) or [Multi-Device execution](../multi_device.md).
|
||||
- The _optional_ plugin libraries like `openvino_ir_frontnend` (matching `openvino_.+_frontend`) are used to provide capabilities to read models of different file formats like OpenVINO IR, ONNX or Paddle.
|
||||
|
||||
Here the term "optional" means that if the application does not use the capability enabled by the plugin, the plugin library or a package with the plugin is not needed in the final distribution.
|
||||
The _optional_ means that if the application does not use the capability enabled by the plugin, the plugin's library or package with the plugin is not needed in the final distribution.
|
||||
|
||||
Building a local distribution will require more detailed information, and you will find it in the dedicated [Libraries for Local Distribution](local-distribution.md) article.
|
||||
The information above covers granularity aspects of majority distribution types, more detailed information is only needed and provided in [Local Distribution](local-distribution.md).
|
||||
|
||||
> **NOTE**: Depending on your target OpenVINO devices, the following configurations might be needed for deployed machines: [Configurations for GPU](../../install_guides/configurations-for-intel-gpu.md), [Configurations for GNA](../../install_guides/configurations-for-intel-gna.md), [Configurations for NCS2](../../install_guides/configurations-for-ncs2.md), [Configurations for VPU](../../install_guides/configurations-for-ivad-vpu.md).
|
||||
> **NOTE**: Depending on target OpenVINO devices, you also have to use [Configurations for GPU](../../install_guides/configurations-for-intel-gpu.md), [Configurations for GNA](../../install_guides/configurations-for-intel-gna.md), [Configurations for NCS2](../../install_guides/configurations-for-ncs2.md) or [Configurations for VPU](../../install_guides/installing-openvino-config-ivad-vpu.md) for proper configuration of deployed machines.
|
||||
|
||||
[deployment_simplified]: ../../img/deployment_simplified.png
|
||||
|
||||
@@ -1,38 +1,37 @@
|
||||
# Libraries for Local Distribution {#openvino_docs_deploy_local_distribution}
|
||||
# Local distribution {#openvino_docs_deploy_local_distribution}
|
||||
|
||||
With a local distribution, each C or C++ application/installer will have its own copies of OpenVINO Runtime binaries. However, OpenVINO has a scalable plugin-based architecture, which means that some components can be loaded in runtime only when they are really needed. Therefore, it is important to understand which minimal set of libraries is really needed to deploy the application. This guide helps you to achieve that goal.
|
||||
The local distribution implies that each C or C++ application / installer will have its own copies of OpenVINO Runtime binaries. However, OpenVINO has a scalable plugin-based architecture which implies that some components can be loaded in runtime only if they are really needed. So, it is important to understand which minimal set of libraries is really needed to deploy the application and this guide helps to achieve this goal.
|
||||
|
||||
> **NOTE**: The steps below are operation system independent and refer to a library file name without any prefixes (like `lib` on Unix systems) or suffixes (like `.dll` on Windows OS). Do not put `.lib` files on Windows OS to the distribution, because such files are needed only on a linker stage.
|
||||
|
||||
Local dsitribution is also appropriate for OpenVINO binaries built from sources using [Build instructions](https://github.com/openvinotoolkit/openvino/wiki#how-to-build), but the guide below supposes OpenVINO Runtime is built dynamically. For case of [Static OpenVINO Runtime](https://github.com/openvinotoolkit/openvino/wiki/StaticLibraries) select the required OpenVINO capabilities on CMake configuration stage using [CMake Options for Custom Compilation](https://github.com/openvinotoolkit/openvino/wiki/CMakeOptionsForCustomCompilation), the build and link the OpenVINO components into the final application.
|
||||
|
||||
> **NOTE**: The steps below are operating system independent and refer to a library file name without any prefixes (like `lib` on Unix systems) or suffixes (like `.dll` on Windows OS). Do not put `.lib` files on Windows OS to the distribution, because such files are needed only on a linker stage.
|
||||
### C++ or C language
|
||||
|
||||
## Library Requirements for C++ and C Languages
|
||||
Independently on language used to write the application, `openvino` must always be put to the final distribution since is a core library which orshectrates with all the inference and frontend plugins.
|
||||
If your application is written with C language, then you need to put `openvino_c` additionally.
|
||||
|
||||
Independent on the language used to write the application, the `openvino` library must always be put to the final distribution, since it's a core library which orchestrates with all the inference and frontend plugins. In Intel® Distribution of OpenVINO™ toolkit, `openvino` depends on the TBB libraries which are used by OpenVINO Runtime to optimally saturate the devices with computations, so it must be put to the distribution package.
|
||||
The `plugins.xml` file with information about inference devices must also be taken as support file for `openvino`.
|
||||
|
||||
If your application is written with C language, you need to put the `openvino_c` library additionally.
|
||||
> **NOTE**: in Intel Distribution of OpenVINO, `openvino` depends on TBB libraries which are used by OpenVINO Runtime to optimally saturate the devices with computations, so it must be put to the distribution package
|
||||
|
||||
The `plugins.xml` file with information about inference devices must also be taken as a support file for `openvino`.
|
||||
### Pluggable components
|
||||
|
||||
|
||||
## Libraries for Pluggable Components
|
||||
|
||||
The picture below presents dependencies between the OpenVINO Runtime core and pluggable libraries:
|
||||
The picture below demonstrates dependnecies between the OpenVINO Runtime core and pluggable libraries:
|
||||
|
||||
![deployment_full]
|
||||
|
||||
### Libraries for Compute Devices
|
||||
#### Compute devices
|
||||
|
||||
For each inference device, OpenVINO Runtime has its own plugin library:
|
||||
- `openvino_intel_cpu_plugin` for [Intel® CPU devices](../supported_plugins/CPU.md).
|
||||
- `openvino_intel_gpu_plugin` for [Intel® GPU devices](../supported_plugins/GPU.md).
|
||||
- `openvino_intel_gna_plugin` for [Intel® GNA devices](../supported_plugins/GNA.md).
|
||||
- `openvino_intel_myriad_plugin` for [Intel® MYRIAD devices](../supported_plugins/MYRIAD.md).
|
||||
- `openvino_intel_hddl_plugin` for [Intel® HDDL device](../supported_plugins/HDDL.md).
|
||||
- `openvino_arm_cpu_plugin` for [ARM CPU devices](../supported_plugins/ARM_CPU.md).
|
||||
- `openvino_intel_cpu_plugin` for [Intel CPU devices](../supported_plugins/CPU.md)
|
||||
- `openvino_intel_gpu_plugin` for [Intel GPU devices](../supported_plugins/GPU.md)
|
||||
- `openvino_intel_gna_plugin` for [Intel GNA devices](../supported_plugins/GNA.md)
|
||||
- `openvino_intel_myriad_plugin` for [Intel MYRIAD devices](../supported_plugins/MYRIAD.md)
|
||||
- `openvino_intel_hddl_plugin` for [Intel HDDL device](../supported_plugins/HDDL.md)
|
||||
- `openvino_arm_cpu_plugin` for [ARM CPU devices](../supported_plugins/ARM_CPU.md)
|
||||
|
||||
Depending on what devices are used in the app, the appropriate libraries need to be put to the distribution package.
|
||||
Depending on what devices is used in the app, put the appropriate libraries to the distribution package.
|
||||
|
||||
As it is shown on the picture above, some plugin libraries may have OS-specific dependencies which are either backend libraries or additional supports files with firmware, etc. Refer to the table below for details:
|
||||
|
||||
@@ -106,59 +105,58 @@ As it is shown on the picture above, some plugin libraries may have OS-specific
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
### Libraries for Execution Modes
|
||||
#### Execution capabilities
|
||||
|
||||
The `HETERO`, `MULTI`, `BATCH` and `AUTO` execution modes can also be used explicitly or implicitly by the application. Use the following recommendation scheme to decide whether to put the appropriate libraries to the distribution package:
|
||||
- If [AUTO](../auto_device_selection.md) is used explicitly in the application or `ov::Core::compile_model` is used without specifying a device, put `openvino_auto_plugin` to the distribution.
|
||||
`HETERO`, `MULTI`, `BATCH`, `AUTO` execution capabilities can also be used explicitly or implicitly by the application. Use the following recommendation scheme to decide whether to put the appropriate libraries to the distribution package:
|
||||
- If [AUTO](../auto_device_selection.md) is used explicitly in the application or `ov::Core::compile_model` is used without specifying a device, put the `openvino_auto_plugin` to the distribution
|
||||
> **NOTE**: Auto device selection relies on [inference device plugins](../supported_plugins/Device_Plugins.md), so if are not sure what inference devices are available on target machine, put all inference plugin libraries to the distribution. If the `ov::device::priorities` is used for `AUTO` to specify a limited device list, grab the corresponding device plugins only.
|
||||
|
||||
> **NOTE**: Automatic Device Selection relies on [inference device plugins](../supported_plugins/Device_Plugins.md). If you are not sure about what inference devices are available on target system, put all the inference plugin libraries to the distribution. If `ov::device::priorities` is used for `AUTO` to specify a limited device list, grab the corresponding device plugins only.
|
||||
- If [MULTI](../multi_device.md) is used explicitly, put the `openvino_auto_plugin` to the distribution
|
||||
- If [HETERO](../hetero_execution.md) is either used explicitly or `ov::hint::performance_mode` is used with GPU, put the `openvino_hetero_plugin` to the distribution
|
||||
- If [BATCH](../automatic_batching.md) is either used explicitly or `ov::hint::performance_mode` is used with GPU, put the `openvino_batch_plugin` to the distribution
|
||||
|
||||
- If [MULTI](../multi_device.md) is used explicitly, put `openvino_auto_plugin` to the distribution.
|
||||
- If [HETERO](../hetero_execution.md) is either used explicitly or `ov::hint::performance_mode` is used with GPU, put `openvino_hetero_plugin` to the distribution.
|
||||
- If [BATCH](../automatic_batching.md) is either used explicitly or `ov::hint::performance_mode` is used with GPU, put `openvino_batch_plugin` to the distribution.
|
||||
|
||||
### Frontend Libraries for Reading Models
|
||||
#### Reading models
|
||||
|
||||
OpenVINO Runtime uses frontend libraries dynamically to read models in different formats:
|
||||
- `openvino_ir_frontend` is used to read OpenVINO IR.
|
||||
- `openvino_onnx_frontend` is used to read ONNX file format.
|
||||
- `openvino_paddle_frontend` is used to read Paddle file format.
|
||||
- To read OpenVINO IR `openvino_ir_frontend` is used
|
||||
- To read ONNX file format `openvino_onnx_frontend` is used
|
||||
- To read Paddle file format `openvino_paddle_frontend` is used
|
||||
|
||||
Depending on the model format types that are used in the application in `ov::Core::read_model`, pick up the appropriate libraries.
|
||||
Depending on what types of model file format are used in the application in `ov::Core::read_model`, peek up the appropriate libraries.
|
||||
|
||||
> **NOTE**: To optimize the size of final distribution package, you are recommended to convert models to OpenVINO IR by using [Model Optimizer](../../MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md). This way you don't have to keep ONNX, PaddlePaddle, and other frontend libraries in the distribution package.
|
||||
> **NOTE**: The recommended way to optimize the size of final distribution package is to [convert models using Model Optimizer](../../MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md) to OpenVINO IR, in this case you don't have to keep ONNX, Paddle and other frontend libraries in the distribution package.
|
||||
|
||||
### (Legacy) Preprocessing via G-API
|
||||
#### (Legacy) Preprocessing via G-API
|
||||
|
||||
> **NOTE**: [G-API](../../gapi/gapi_intro.md) preprocessing is a legacy functionality, use [preprocessing capabilities from OpenVINO 2.0](../preprocessing_overview.md) which do not require any additional libraries.
|
||||
|
||||
If the application uses `InferenceEngine::PreProcessInfo::setColorFormat` or `InferenceEngine::PreProcessInfo::setResizeAlgorithm` methods, OpenVINO Runtime dynamically loads `openvino_gapi_preproc` plugin to perform preprocessing via G-API.
|
||||
|
||||
## Examples
|
||||
### Examples
|
||||
|
||||
**CPU + OpenVINO IR in C application**
|
||||
#### CPU + IR in C-written application
|
||||
|
||||
In this example, the application is written in C language, performs inference on CPU, and reads models stored as the OpenVINO IR format. The following libraries are used:
|
||||
- The `openvino_c` library is a main dependency of the application. It links against this library.
|
||||
- The `openvino` library is used as a private dependency for `openvino_c` and is also used in the deployment.
|
||||
- `openvino_intel_cpu_plugin` is used for inference.
|
||||
- `openvino_ir_frontend` is used to read source models.
|
||||
C-written application performs inference on CPU and reads models stored as OpenVINO IR:
|
||||
- `openvino_c` library is a main dependency of the application. It links against this library
|
||||
- `openvino` is used as a private dependency for `openvino` and also used in the deployment
|
||||
- `openvino_intel_cpu_plugin` is used for inference
|
||||
- `openvino_ir_frontend` is used to read source model
|
||||
|
||||
**MULTI execution on GPU and MYRIAD in `tput` mode**
|
||||
#### MULTI execution on GPU and MYRIAD in tput mode
|
||||
|
||||
In this example, the application is written in C++, performs inference [simultaneously on GPU and MYRIAD devices](../multi_device.md) with the `ov::hint::PerformanceMode::THROUGHPUT` property set, and reads models stored in the ONNX format. The following libraries are used:
|
||||
- The `openvino` library is a main dependency of the application. It links against this library.
|
||||
- `openvino_intel_gpu_plugin` and `openvino_intel_myriad_plugin` are used for inference.
|
||||
- `openvino_auto_plugin` is used for Multi-Device Execution.
|
||||
- `openvino_auto_batch_plugin` can be also put to the distribution to improve the saturation of [Intel® GPU](../supported_plugins/GPU.md) device. If there is no such plugin, [Automatic Batching](../automatic_batching.md) is turned off.
|
||||
- `openvino_onnx_frontend` is used to read source models.
|
||||
C++ written application performs inference [simultaneously on GPU and MYRIAD devices](../multi_device.md) with `ov::hint::PerformanceMode::THROUGHPUT` property, reads models stored in ONNX file format:
|
||||
- `openvino` library is a main dependency of the application. It links against this library
|
||||
- `openvino_intel_gpu_plugin` and `openvino_intel_myriad_plugin` are used for inference
|
||||
- `openvino_auto_plugin` is used for `MULTI` multi-device execution
|
||||
- `openvino_auto_batch_plugin` can be also put to the distribution to improve saturation of [Intel GPU](../supported_plugins/GPU.md) device. If there is no such plugin, [Automatic batching](../automatic_batching.md) is turned off.
|
||||
- `openvino_onnx_frontend` is used to read source model
|
||||
|
||||
**Auto-Device Selection between HDDL and CPU**
|
||||
#### Auto device selection between HDDL and CPU
|
||||
|
||||
In this example, the application is written in C++, performs inference with the [Automatic Device Selection](../auto_device_selection.md) mode, limiting device list to HDDL and CPU, and reads models [created using C++ code](../model_representation.md). The following libraries are used:
|
||||
- The `openvino` library is a main dependency of the application. It links against this library.
|
||||
- `openvino_auto_plugin` is used to enable Automatic Device Selection.
|
||||
- `openvino_intel_hddl_plugin` and `openvino_intel_cpu_plugin` are used for inference. AUTO selects between CPU and HDDL devices according to their physical existence on the deployed machine.
|
||||
C++ written application performs inference with [automatic device selection](../auto_device_selection.md) with device list limited to HDDL and CPU, model is [created using C++ code](../model_representation.md):
|
||||
- `openvino` library is a main dependency of the application. It links against this library
|
||||
- `openvino_auto_plugin` is used to enable automatic device selection feature
|
||||
- `openvino_intel_hddl_plugin` and `openvino_intel_cpu_plugin` are used for inference, `AUTO` selects between CPU and HDDL devices according to their physical existance on deployed machine.
|
||||
- No frontend library is needed because `ov::Model` is created in code.
|
||||
|
||||
[deployment_full]: ../../img/deployment_full.png
|
||||
|
||||
@@ -12,13 +12,19 @@
|
||||
|
||||
@endsphinxdirective
|
||||
|
||||
> **NOTE**: Before start using OpenVINO™ Runtime, make sure you set all environment variables during the installation. If you did not, follow the instructions from the _Set the Environment Variables_ section in the installation guides:
|
||||
> * [For Windows* 10](../install_guides/installing-openvino-windows.md)
|
||||
> * [For Linux*](../install_guides/installing-openvino-linux.md)
|
||||
> * [For macOS*](../install_guides/installing-openvino-macos.md)
|
||||
> * To build an open source version, use the [OpenVINO™ Runtime Build Instructions](https://github.com/openvinotoolkit/openvino/wiki/BuildingCode).
|
||||
|
||||
Following these steps, you can implement a typical OpenVINO™ Runtime inference pipeline in your application. Before proceeding, make sure you have [installed OpenVINO Runtime](../install_guides/installing-openvino-runtime.md) and set environment variables (run `<INSTALL_DIR>/setupvars.sh` for Linux or `setupvars.bat` for Windows, otherwise, the `OpenVINO_DIR` variable won't be configured properly to pass `find_package` calls).
|
||||
## Use OpenVINO™ Runtime API to Implement Inference Pipeline
|
||||
|
||||
This section provides step-by-step instructions to implement a typical inference pipeline with the OpenVINO™ Runtime C++ API:
|
||||
|
||||
![ie_api_use_cpp]
|
||||
|
||||
## Step 1. Create OpenVINO™ Runtime Core
|
||||
### Step 1. Create OpenVINO™ Runtime Core
|
||||
|
||||
Include next files to work with OpenVINO™ Runtime:
|
||||
|
||||
@@ -56,9 +62,9 @@ Use the following code to create OpenVINO™ Core to manage available devices an
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
## Step 2. Compile the Model
|
||||
### Step 2. Compile the Model
|
||||
|
||||
`ov::CompiledModel` class represents a device specific compiled model. `ov::CompiledModel` allows you to get information inputs or output ports by a tensor name or index. This approach is aligned with the majority of frameworks.
|
||||
`ov::CompiledModel` class represents a device specific compiled model. `ov::CompiledModel` allows you to get information inputs or output ports by a tensor name or index, this approach is aligned with the majority of frameworks.
|
||||
|
||||
Compile the model for a specific device using `ov::Core::compile_model()`:
|
||||
|
||||
@@ -137,7 +143,7 @@ The code above creates a compiled model associated with a single hardware device
|
||||
It is possible to create as many compiled models as needed and use them simultaneously (up to the limitation of the hardware resources).
|
||||
To learn how to change the device configuration, read the [Query device properties](./supported_plugins/config_properties.md) article.
|
||||
|
||||
## Step 3. Create an Inference Request
|
||||
### Step 3. Create an Inference Request
|
||||
|
||||
`ov::InferRequest` class provides methods for model inference in OpenVINO™ Runtime. Create an infer request using the following code (see [InferRequest detailed documentation](./ov_infer_request.md) for more details):
|
||||
|
||||
@@ -157,7 +163,7 @@ To learn how to change the device configuration, read the [Query device properti
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
## Step 4. Set Inputs
|
||||
### Step 4. Set Inputs
|
||||
|
||||
You can use external memory to create `ov::Tensor` and use the `ov::InferRequest::set_input_tensor` method to put this tensor on the device:
|
||||
|
||||
@@ -177,9 +183,9 @@ You can use external memory to create `ov::Tensor` and use the `ov::InferRequest
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
## Step 5. Start Inference
|
||||
### Step 5. Start Inference
|
||||
|
||||
OpenVINO™ Runtime supports inference in either synchronous or asynchronous mode. Using the Async API can improve application's overall frame-rate: instead of waiting for inference to complete, the app can keep working on the host while the accelerator is busy. You can use `ov::InferRequest::start_async` to start model inference in the asynchronous mode and call `ov::InferRequest::wait` to wait for the inference results:
|
||||
OpenVINO™ Runtime supports inference in either synchronous or asynchronous mode. Using the Async API can improve application's overall frame-rate, because rather than wait for inference to complete, the app can keep working on the host, while the accelerator is busy. You can use `ov::InferRequest::start_async` to start model inference in the asynchronous mode and call `ov::InferRequest::wait` to wait for the inference results:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -197,9 +203,9 @@ OpenVINO™ Runtime supports inference in either synchronous or asynchronous mod
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
This section demonstrates a simple pipeline. To get more information about other ways to perform inference, read the dedicated ["Run inference" section](./ov_infer_request.md).
|
||||
This section demonstrates a simple pipeline, to get more information about other ways to perform inference, read the dedicated ["Run inference" section](./ov_infer_request.md).
|
||||
|
||||
## Step 6. Process the Inference Results
|
||||
### Step 6. Process the Inference Results
|
||||
|
||||
Go over the output tensors and process the inference results.
|
||||
|
||||
@@ -219,13 +225,11 @@ Go over the output tensors and process the inference results.
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
## Step 7. Link and Build Your Application with OpenVINO™ Runtime (example)
|
||||
## Link and Build Your C++ Application with OpenVINO™ Runtime
|
||||
|
||||
This step may differ for different projects. In this example, a C++ application is used, together with CMake for project configuration.
|
||||
The example uses CMake for project configuration.
|
||||
|
||||
For details on additional CMake build options, refer to the [CMake page](https://cmake.org/cmake/help/latest/manual/cmake.1.html#manual:cmake(1)).
|
||||
|
||||
### Create a structure for the project:
|
||||
1. **Create a structure** for the project:
|
||||
``` sh
|
||||
project/
|
||||
├── CMakeLists.txt - CMake file to build
|
||||
@@ -236,25 +240,29 @@ For details on additional CMake build options, refer to the [CMake page](https:/
|
||||
...
|
||||
```
|
||||
|
||||
### Include OpenVINO™ Runtime libraries in `project/CMakeLists.txt`
|
||||
2. **Include OpenVINO™ Runtime libraries** in `project/CMakeLists.txt`
|
||||
|
||||
@snippet snippets/CMakeLists.txt cmake:integration_example
|
||||
|
||||
To build your project using CMake with the default build tools currently available on your machine, execute the following commands:
|
||||
|
||||
> **NOTE**: Make sure you set environment variables first by running `<INSTALL_DIR>/setupvars.sh` (or `setupvars.bat` for Windows). Otherwise the `OpenVINO_DIR` variable won't be configured properly to pass `find_package` calls.
|
||||
|
||||
```sh
|
||||
cd build/
|
||||
cmake ../project
|
||||
cmake --build .
|
||||
```
|
||||
It's allowed to specify additional build options (e.g. to build CMake project on Windows with a specific build tools). Please refer to the [CMake page](https://cmake.org/cmake/help/latest/manual/cmake.1.html#manual:cmake(1)) for details.
|
||||
|
||||
## Additional Resources
|
||||
## Run Your Application
|
||||
|
||||
Congratulations, you have made your first application with OpenVINO™ toolkit, now you may run it.
|
||||
|
||||
## See also
|
||||
|
||||
- See the [OpenVINO Samples](Samples_Overview.md) page or the [Open Model Zoo Demos](https://docs.openvino.ai/latest/omz_demos.html) page for specific examples of how OpenVINO pipelines are implemented for applications like image classification, text prediction, and many others.
|
||||
- [OpenVINO™ Runtime Preprocessing](./preprocessing_overview.md)
|
||||
- [Using Encrypted Models with OpenVINO™](./protecting_model_guide.md)
|
||||
- [OpenVINO Samples](Samples_Overview.md)
|
||||
- [Open Model Zoo Demos](https://docs.openvino.ai/latest/omz_demos.html)
|
||||
|
||||
[ie_api_flow_cpp]: img/BASIC_IE_API_workflow_Cpp.svg
|
||||
[ie_api_use_cpp]: img/IMPLEMENT_PIPELINE_with_API_C.svg
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
# Layout API Overview {#openvino_docs_OV_UG_Layout_Overview}
|
||||
# Layout API overview {#openvino_docs_OV_UG_Layout_Overview}
|
||||
|
||||
## Introduction
|
||||
|
||||
In few words, with layout `NCHW` it is easier to understand what model's shape `{8, 3, 224, 224}` means. Without layout it is just a 4-dimensional tensor.
|
||||
|
||||
|
||||
Concept of layout helps you (and your application) to understand what does each particular dimension of input/output tensor mean. For example, if your input has shape `{1, 3, 720, 1280}` and layout "NCHW" - it is clear that `N(batch) = 1`, `C(channels) = 3`, `H(height) = 720` and `W(width) = 1280`. Without layout information `{1, 3, 720, 1280}` doesn't give any idea to your application what these number mean and how to resize input image to fit model's expectations.
|
||||
|
||||
|
||||
The concept of layout helps you (and your application) to understand what each particular dimension of input/output tensor means. For example, if your input has the `{1, 3, 720, 1280}` shape and the `NCHW` layout, it is clear that `N(batch) = 1`, `C(channels) = 3`, `H(height) = 720`, and `W(width) = 1280`. Without the layout information, the `{1, 3, 720, 1280}` tuple does not give any idea to your application on what these numbers mean and how to resize the input image to fit the expectations of the model.
|
||||
Reasons when you may want to care about input/output layout:
|
||||
- Perform model modification:
|
||||
- Apply [preprocessing](./preprocessing_overview.md) steps, like subtract means, divide by scales, resize image, convert RGB<->BGR
|
||||
- Set/get batch for a model
|
||||
- Same operations, used during model conversion phase, see [Model Optimizer Embedding Preprocessing Computation](../MO_DG/prepare_model/Additional_Optimizations.md)
|
||||
- Improve readability of a model's input and output
|
||||
|
||||
With the `NCHW` layout, it is easier to understand what the `{8, 3, 224, 224}` model shape means. Without the layout, it is just a 4-dimensional tensor.
|
||||
## Layout syntax
|
||||
|
||||
Below is a list of cases where input/output layout is important:
|
||||
- Performing model modification:
|
||||
- Applying the [preprocessing](./preprocessing_overview.md) steps, such as subtracting means, dividing by scales, resizing an image, and converting `RGB`<->`BGR`.
|
||||
- Setting/getting a batch for a model.
|
||||
- Doing the same operations as used during the model conversion phase. For more information, refer to the [Model Optimizer Embedding Preprocessing Computation](../MO_DG/prepare_model/Additional_Optimizations.md) guide.
|
||||
- Improving the readability of a model input and output.
|
||||
|
||||
## Syntax of Layout
|
||||
|
||||
### Short Syntax
|
||||
The easiest way is to fully specify each dimension with one alphabet letter.
|
||||
### Short
|
||||
The easiest way is to fully specify each dimension with one alphabetical letter
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -35,10 +36,10 @@ The easiest way is to fully specify each dimension with one alphabet letter.
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
This assigns `N` to the first dimension, `C` to the second, `H` to the third, and `W` to the fourth.
|
||||
This assigns 'N' to first dimension, 'C' to second, 'H' to 3rd and 'W' to 4th
|
||||
|
||||
### Advanced Syntax
|
||||
The advanced syntax allows assigning a word to a dimension. To do this, wrap a layout with square brackets `[]` and specify each name separated by a comma `,`.
|
||||
### Advanced
|
||||
Advanced syntax allows assigning a word to a dimension. To do this, wrap layout with square brackets `[]` and specify each name separated by comma `,`
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -57,8 +58,8 @@ The advanced syntax allows assigning a word to a dimension. To do this, wrap a l
|
||||
@endsphinxtabset
|
||||
|
||||
|
||||
### Partially Defined Layout
|
||||
If a certain dimension is not important, its name can be set to `?`.
|
||||
### Partially defined layout
|
||||
If some dimension is not important, it's name can be set to `?`
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -77,8 +78,8 @@ If a certain dimension is not important, its name can be set to `?`.
|
||||
@endsphinxtabset
|
||||
|
||||
|
||||
### Dynamic Layout
|
||||
If several dimensions are not important, an ellipsis `...` can be used to specify those dimensions.
|
||||
### Dynamic layout
|
||||
If number of dimensions is not important, ellipsis `...` can be used to specify variadic number of dimensions.
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -96,16 +97,16 @@ If several dimensions are not important, an ellipsis `...` can be used to specif
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
### Predefined Names
|
||||
### Predefined names
|
||||
|
||||
A layout has some pre-defined dimension names, widely used in computer vision:
|
||||
- `N`/`Batch` - batch size
|
||||
- `C`/`Channels` - channels
|
||||
- `D`/`Depth` - depth
|
||||
- `H`/`Height` - height
|
||||
- `W`/`Width` - width
|
||||
Layout has pre-defined some widely used in computer vision dimension names:
|
||||
- N/Batch - batch size
|
||||
- C/Channels - channels dimension
|
||||
- D/Depth - depth
|
||||
- H/Height - height
|
||||
- W/Width - width
|
||||
|
||||
These names are used in [PreProcessing API](./preprocessing_overview.md). There is a set of helper functions to get appropriate dimension index from a layout.
|
||||
These names are used in [PreProcessing API](./preprocessing_overview.md) and there is a set of helper functions to get appropriate dimension index from layout
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -125,11 +126,11 @@ These names are used in [PreProcessing API](./preprocessing_overview.md). There
|
||||
|
||||
### Equality
|
||||
|
||||
Layout names are case-insensitive, which means that `Layout("NCHW")` = `Layout("nChW") = `Layout("[N,c,H,w]")`.
|
||||
Layout names are case-insensitive, which means that ```Layout("NCHW") == Layout("nChW") == Layout("[N,c,H,w]")```
|
||||
|
||||
### Dump Layout
|
||||
### Dump layout
|
||||
|
||||
A layout can be converted to a string in the advanced syntax format. It can be useful for debugging and serialization purposes.
|
||||
Layout can be converted to string in advanced syntax format. Can be useful for debugging and serialization purposes
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -149,4 +150,4 @@ A layout can be converted to a string in the advanced syntax format. It can be u
|
||||
|
||||
## See also
|
||||
|
||||
* API Reference: <code>ov::Layout</code> C++ class
|
||||
* <code>ov::Layout</code> C++ class documentation
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
# Inference Pipeline {#openvino_2_0_inference_pipeline}
|
||||
|
||||
To infer models with OpenVINO™ Runtime, you usually need to perform the following steps in the application pipeline:
|
||||
1. <a href="#create-core">Create a Core object.</a>
|
||||
- 1.1. <a href="#load-extensions">(Optional) Load extensions.</a>
|
||||
2. <a href="#read-model">Read a model from a drive.</a>
|
||||
- 2.1. <a href="#perform-preprocessing">(Optional) Perform model preprocessing.</a>
|
||||
3. <a href="#load-model-to-device">Load the model to the device.</a>
|
||||
4. <a href="#create-inference-request">Create an inference request.</a>
|
||||
5. <a href="#fill-tensor">Fill input tensors with data.</a>
|
||||
6. <a href="#start-inference">Start inference.</a>
|
||||
7. <a href="#process-results">Process the inference results.</a>
|
||||
Usually, to infer models with OpenVINO™ Runtime, you need to make the following steps in the application pipeline:
|
||||
- 1. Create Core object
|
||||
- 1.1. (Optional) Load extensions
|
||||
- 2. Read a model from a drive
|
||||
- 2.1. (Optional) Perform model preprocessing
|
||||
- 3. Load the model to the device
|
||||
- 4. Create an inference request
|
||||
- 5. Fill input tensors with data
|
||||
- 6. Start inference
|
||||
- 7. Process the inference results
|
||||
|
||||
Based on the steps, the following code demostrates how to change the application code to migrate to API 2.0.
|
||||
The following code shows how to change the application code in each step to migrate to OpenVINO™ Runtime 2.0.
|
||||
|
||||
## <a name="create-core"></a>1. Create a Core Object
|
||||
## 1. Create Core
|
||||
|
||||
**Inference Engine API**
|
||||
Inference Engine API:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -29,7 +29,7 @@ Based on the steps, the following code demostrates how to change the application
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
**API 2.0**
|
||||
OpenVINO™ Runtime API 2.0:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -43,11 +43,11 @@ Based on the steps, the following code demostrates how to change the application
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
### <a name="load-extensions"></a>1.1 (Optional) Load Extensions
|
||||
### 1.1 (Optional) Load extensions
|
||||
|
||||
To load a model with custom operations, you need to add extensions for these operations. It is highly recommended to use [OpenVINO Extensibility API](../../Extensibility_UG/Intro.md) to write extensions. However, you can also load the old extensions to the new OpenVINO™ Runtime:
|
||||
To load a model with custom operations, you need to add extensions for these operations. We highly recommend using [OpenVINO Extensibility API](../../Extensibility_UG/Intro.md) to write extensions, but if you already have old extensions you can also load them to the new OpenVINO™ Runtime:
|
||||
|
||||
**Inference Engine API**
|
||||
Inference Engine API:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -61,7 +61,7 @@ To load a model with custom operations, you need to add extensions for these ope
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
**API 2.0**
|
||||
OpenVINO™ Runtime API 2.0:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -75,9 +75,9 @@ To load a model with custom operations, you need to add extensions for these ope
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
## <a name="read-model"></a>2. Read a Model from a Drive
|
||||
## 2. Read a model from a drive
|
||||
|
||||
**Inference Engine API**
|
||||
Inference Engine API:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -91,7 +91,7 @@ To load a model with custom operations, you need to add extensions for these ope
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
**API 2.0**
|
||||
OpenVINO™ Runtime API 2.0:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -105,17 +105,18 @@ To load a model with custom operations, you need to add extensions for these ope
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
Reading a model has the same structure as the example in the [model creation migration guide](./graph_construction.md).
|
||||
Read model has the same structure as in the example from [Model Creation](./graph_construction.md) migration guide.
|
||||
|
||||
You can combine reading and compiling a model into a single call `ov::Core::compile_model(filename, devicename)`.
|
||||
Note, you can combine read and compile model stages into a single call `ov::Core::compile_model(filename, devicename)`.
|
||||
|
||||
### <a name="perform-preprocessing"></a>2.1 (Optional) Perform Model Preprocessing
|
||||
### 2.1 (Optional) Perform model preprocessing
|
||||
|
||||
When the application input data does not perfectly match the model input format, preprocessing may be necessary. See [preprocessing in API 2.0](./preprocessing.md) for more details.
|
||||
When application's input data doesn't perfectly match the model's input format, preprocessing steps may be necessary.
|
||||
See a detailed guide on [how to migrate preprocessing in OpenVINO Runtime API 2.0](./preprocessing.md)
|
||||
|
||||
## <a name="load-model-to-device"></a>3. Load the Model to the Device
|
||||
## 3. Load the Model to the Device
|
||||
|
||||
**Inference Engine API**
|
||||
Inference Engine API:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -129,7 +130,7 @@ When the application input data does not perfectly match the model input format,
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
**API 2.0**
|
||||
OpenVINO™ Runtime API 2.0:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -143,11 +144,11 @@ When the application input data does not perfectly match the model input format,
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
If you need to configure devices with additional parameters for OpenVINO Runtime, refer to [Configuring Devices](./configure_devices.md).
|
||||
If you need to configure OpenVINO Runtime devices with additional configuration parameters, refer to the [Configure devices](./configure_devices.md) guide.
|
||||
|
||||
## <a name="create-inference-request"></a>4. Create an Inference Request
|
||||
## 4. Create an Inference Request
|
||||
|
||||
**Inference Engine API**
|
||||
Inference Engine API:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -161,7 +162,7 @@ If you need to configure devices with additional parameters for OpenVINO Runtime
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
**API 2.0**
|
||||
OpenVINO™ Runtime API 2.0:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -175,11 +176,9 @@ If you need to configure devices with additional parameters for OpenVINO Runtime
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
## <a name="fill-tensor"></a>5. Fill Input Tensors with Data
|
||||
## 5. Fill input tensors
|
||||
|
||||
**Inference Engine API**
|
||||
|
||||
The Inference Engine API fills inputs with data of the `I32` precision (**not** aligned with the original model):
|
||||
The Inference Engine API fills inputs as `I32` precision (**not** aligned with the original model):
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -249,9 +248,7 @@ The Inference Engine API fills inputs with data of the `I32` precision (**not**
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
**API 2.0**
|
||||
|
||||
API 2.0 fills inputs with data of the `I64` precision (aligned with the original model):
|
||||
OpenVINO™ Runtime API 2.0 fills inputs as `I64` precision (aligned with the original model):
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -321,9 +318,9 @@ API 2.0 fills inputs with data of the `I64` precision (aligned with the original
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
## <a name="start-inference"></a>6. Start Inference
|
||||
## 6. Start Inference
|
||||
|
||||
**Inference Engine API**
|
||||
Inference Engine API:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -361,7 +358,7 @@ API 2.0 fills inputs with data of the `I64` precision (aligned with the original
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
**API 2.0**
|
||||
OpenVINO™ Runtime API 2.0:
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -399,11 +396,9 @@ API 2.0 fills inputs with data of the `I64` precision (aligned with the original
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
## <a name="process-results"></a>7. Process the Inference Results
|
||||
## 7. Process the Inference Results
|
||||
|
||||
**Inference Engine API**
|
||||
|
||||
The Inference Engine API processes outputs as they are of the `I32` precision (**not** aligned with the original model):
|
||||
The Inference Engine API processes outputs as `I32` precision (**not** aligned with the original model):
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
@@ -473,12 +468,9 @@ The Inference Engine API processes outputs as they are of the `I32` precision (*
|
||||
|
||||
@endsphinxtabset
|
||||
|
||||
**API 2.0**
|
||||
|
||||
API 2.0 processes outputs:
|
||||
|
||||
- as they are of the `I32` precision (**not** aligned with the original model) for OpenVINO IR v10 models, to match the <a href="openvino_2_0_transition_guide#differences-api20-ie">old behavior</a>.
|
||||
- as they are of the `I64` precision (aligned with the original model) for OpenVINO IR v11, ONNX, ov::Model and PaddlePaddle models, to match the <a href="openvino_2_0_transition_guide#differences-api20-ie">new behavior</a>.
|
||||
OpenVINO™ Runtime API 2.0 processes outputs:
|
||||
- For IR v10 as `I32` precision (**not** aligned with the original model) to match the **old** behavior.
|
||||
- For IR v11, ONNX, ov::Model, Paddle as `I64` precision (aligned with the original model) to match the **new** behavior.
|
||||
|
||||
@sphinxtabset
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user