Compare commits
46 Commits
enable_din
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3adb3d03a0 | ||
|
|
23fae3b1bc | ||
|
|
a28fd2e009 | ||
|
|
6f0db3330a | ||
|
|
c01f50e3ff | ||
|
|
8bc724d160 | ||
|
|
bbddb89171 | ||
|
|
6367206ea8 | ||
|
|
f4b2f950f2 | ||
|
|
59e9f50ec6 | ||
|
|
0a21205ad4 | ||
|
|
4fde957689 | ||
|
|
6a50ea3c74 | ||
|
|
88c8143dd8 | ||
|
|
f094ef81f0 | ||
|
|
de81bbbbc2 | ||
|
|
9faf18b0ff | ||
|
|
1d03b0813b | ||
|
|
27bf494355 | ||
|
|
9f6c3e997f | ||
|
|
7965213014 | ||
|
|
e5a6077877 | ||
|
|
0649865372 | ||
|
|
32b6362076 | ||
|
|
17008c9389 | ||
|
|
5f2045909e | ||
|
|
a04d59d779 | ||
|
|
926a0591ff | ||
|
|
1aa0c0ca0d | ||
|
|
4752237871 | ||
|
|
336a69ec24 | ||
|
|
be7c70c8c4 | ||
|
|
65439eda5d | ||
|
|
1b2eed0bbe | ||
|
|
dcf9247bc8 | ||
|
|
adb4703d82 | ||
|
|
d18d8a457f | ||
|
|
20ad8b43a1 | ||
|
|
2bcc94064f | ||
|
|
3e2037c943 | ||
|
|
ea639a8c48 | ||
|
|
7e88a9d6c8 | ||
|
|
71e7015d39 | ||
|
|
3fb60dc41c | ||
|
|
47939684df | ||
|
|
82cdc116c1 |
5
.github/ISSUE_TEMPLATE/good_first_issue.yml
vendored
5
.github/ISSUE_TEMPLATE/good_first_issue.yml
vendored
@@ -41,10 +41,7 @@ body:
|
||||
Any materials related to the task, such as operator specifications,
|
||||
discussions, guides.
|
||||
value: |
|
||||
- [What is OpenVINO?](https://github.com/openvinotoolkit/openvino#what-is-openvino-toolkit)
|
||||
- [Contribution guide](https://github.com/openvinotoolkit/openvino/blob/master/CONTRIBUTING.md)
|
||||
- [Blog post on contributing to OpenVINO](https://github.com/openvinotoolkit/openvino/blob/master/CONTRIBUTING.md)
|
||||
- [User documentation](https://docs.openvino.ai/)
|
||||
- [Contribution guide - start here!](https://github.com/openvinotoolkit/openvino/blob/master/CONTRIBUTING.md)
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
15
.github/workflows/android_arm64.yml
vendored
15
.github/workflows/android_arm64.yml
vendored
@@ -5,6 +5,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/**'
|
||||
|
||||
concurrency:
|
||||
# github.ref is not unique in post-commit
|
||||
@@ -169,3 +170,17 @@ jobs:
|
||||
|
||||
- name: Show ccache stats
|
||||
run: ${SCCACHE_PATH} --show-stats
|
||||
|
||||
Overall_Status:
|
||||
name: ci/gha_overall_status_android
|
||||
needs: [Smart_CI, Build]
|
||||
if: ${{ always() }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check status of all jobs
|
||||
if: >-
|
||||
${{
|
||||
contains(needs.*.result, 'failure') ||
|
||||
contains(needs.*.result, 'cancelled')
|
||||
}}
|
||||
run: exit 1
|
||||
|
||||
10
.github/workflows/build_doc.yml
vendored
10
.github/workflows/build_doc.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
packages: graphviz texlive liblua5.2-0 libclang1-9 libclang-cpp9
|
||||
version: 3.0
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
id: cp310
|
||||
with:
|
||||
python-version: '3.10'
|
||||
@@ -68,19 +68,19 @@ jobs:
|
||||
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
|
||||
|
||||
- name: 'Upload doxygen.log'
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: doxygen_build_log_${{ env.PR_NUMBER }}.log
|
||||
path: build/docs/doxygen.log
|
||||
|
||||
- name: 'Upload sphinx.log'
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sphinx_build_log_${{ env.PR_NUMBER }}.log
|
||||
path: build/docs/sphinx.log
|
||||
|
||||
- name: 'Upload docs html'
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_docs_html_${{ env.PR_NUMBER }}.zip
|
||||
path: build/docs/openvino_docs_html.zip
|
||||
@@ -99,7 +99,7 @@ jobs:
|
||||
|
||||
- name: 'Upload test results'
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_docs_pytest
|
||||
path: build/docs/_artifacts/
|
||||
|
||||
2
.github/workflows/coverage.yml
vendored
2
.github/workflows/coverage.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Setup python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10.10'
|
||||
architecture: 'x64'
|
||||
|
||||
1
.github/workflows/coverity.yml
vendored
1
.github/workflows/coverity.yml
vendored
@@ -1,5 +1,6 @@
|
||||
name: Coverity (Ubuntu 20.04, Python 3.11)
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# run daily at 00:00
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
20
.github/workflows/fedora.yml
vendored
20
.github/workflows/fedora.yml
vendored
@@ -166,7 +166,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz
|
||||
@@ -174,7 +174,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino RPM packages
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_rpm_packages
|
||||
path: ${{ env.BUILD_DIR }}/*.rpm
|
||||
@@ -182,7 +182,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino tests package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz
|
||||
@@ -242,3 +242,17 @@ jobs:
|
||||
python3 -c 'from openvino.frontend import FrontEndManager; assert len(FrontEndManager().get_available_front_ends()) == 6'
|
||||
benchmark_app --help
|
||||
ovc --help
|
||||
|
||||
Overall_Status:
|
||||
name: ci/gha_overall_status_fedora
|
||||
needs: [Smart_CI, Build, RPM_Packages]
|
||||
if: ${{ always() }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check status of all jobs
|
||||
if: >-
|
||||
${{
|
||||
contains(needs.*.result, 'failure') ||
|
||||
contains(needs.*.result, 'cancelled')
|
||||
}}
|
||||
run: exit 1
|
||||
|
||||
@@ -108,7 +108,7 @@ jobs:
|
||||
key: ${{ runner.os }}-${{ runner.arch }}-tests-functional-cpu-stamp-${{ github.sha }}
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-functional-cpu
|
||||
|
||||
2
.github/workflows/job_cxx_unit_tests.yml
vendored
2
.github/workflows/job_cxx_unit_tests.yml
vendored
@@ -271,7 +271,7 @@ jobs:
|
||||
${INSTALL_TEST_DIR}/ov_hetero_func_tests --gtest_print_time=1 --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVHeteroFuncTests.xml
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-cpp
|
||||
|
||||
2
.github/workflows/job_python_unit_tests.yml
vendored
2
.github/workflows/job_python_unit_tests.yml
vendored
@@ -313,7 +313,7 @@ jobs:
|
||||
python3 ${OPENVINO_REPO}/docs/snippets/main.py
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-python
|
||||
|
||||
@@ -123,7 +123,7 @@ jobs:
|
||||
df -h
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-torch-models
|
||||
|
||||
2
.github/workflows/job_samples_tests.yml
vendored
2
.github/workflows/job_samples_tests.yml
vendored
@@ -124,7 +124,7 @@ jobs:
|
||||
--junitxml=$INSTALL_TEST_DIR/TEST-SamplesSmokeTests.xml
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-samples
|
||||
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
TEST_DEVICE: CPU
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-tensorflow-hub-models
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
name: TensorFlow Hub Performance Models tests
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
runner:
|
||||
description: 'Machine on which the tests would run'
|
||||
type: string
|
||||
required: true
|
||||
container:
|
||||
description: 'JSON to be converted to the value of the "container" configuration for the job'
|
||||
type: string
|
||||
required: false
|
||||
default: '{"image": null}'
|
||||
event:
|
||||
description: 'Event that triggered the workflow. E.g., "schedule" for nightly runs'
|
||||
type: string
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
TensorFlow_Hub_Performance_Models_Tests:
|
||||
name: TensorFlow Hub Performance Models tests
|
||||
timeout-minutes: ${{ inputs.event == 'schedule' && 400 || 25 }}
|
||||
runs-on: ${{ inputs.runner }}
|
||||
container: ${{ fromJSON(inputs.container) }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input
|
||||
OPENVINO_REPO: ${{ github.workspace }}/openvino
|
||||
INSTALL_DIR: ${{ github.workspace }}/install
|
||||
INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests
|
||||
MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests
|
||||
steps:
|
||||
|
||||
- name: Check sudo
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
run: if [ "$(id -u)" -eq 0 ]; then apt update && apt --assume-yes install sudo; fi
|
||||
|
||||
- name: Download OpenVINO package
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: openvino_package
|
||||
path: ${{ env.INSTALL_DIR }}
|
||||
|
||||
- name: Download OpenVINO tests package
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.INSTALL_TEST_DIR }}
|
||||
|
||||
# Needed as ${{ github.workspace }} is not working correctly when using Docker
|
||||
- name: Setup Variables
|
||||
run: |
|
||||
echo "OPENVINO_REPO=$GITHUB_WORKSPACE/openvino" >> "$GITHUB_ENV"
|
||||
echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV"
|
||||
echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV"
|
||||
echo "MODEL_HUB_TESTS_INSTALL_DIR=$GITHUB_WORKSPACE/install/tests/model_hub_tests" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Extract OpenVINO packages
|
||||
run: |
|
||||
pushd ${INSTALL_DIR}
|
||||
tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR}
|
||||
popd
|
||||
|
||||
pushd ${INSTALL_TEST_DIR}
|
||||
tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR}
|
||||
popd
|
||||
|
||||
- name: Fetch setup_python action
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
.github/actions/setup_python/action.yml
|
||||
sparse-checkout-cone-mode: false
|
||||
path: 'openvino'
|
||||
|
||||
- name: Install dependencies
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
run: |
|
||||
# install git (required to build pip deps from the sources)
|
||||
sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates
|
||||
|
||||
- name: Setup Python 3.11
|
||||
uses: ./openvino/.github/actions/setup_python
|
||||
with:
|
||||
version: '3.11'
|
||||
should-setup-pip-paths: 'false'
|
||||
self-hosted-runner: ${{ contains(inputs.runner, 'aks') }}
|
||||
|
||||
- name: Install OpenVINO Python wheels
|
||||
run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-*
|
||||
|
||||
- name: Install TF Hub tests requirements
|
||||
run: python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/requirements.txt
|
||||
|
||||
- name: Install Hub Performance tests requirements
|
||||
run: python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/performance_tests/requirements.txt
|
||||
|
||||
- name: Performance Hub Tests
|
||||
run: |
|
||||
export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH
|
||||
python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/performance_tests/ -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-tf_hub_performance.html --self-contained-html -v
|
||||
env:
|
||||
TYPE: ${{ inputs.event == 'schedule' && 'nightly' || 'precommit'}}
|
||||
TEST_DEVICE: CPU
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-tensorflow-hub-performance-models
|
||||
path: |
|
||||
${{ env.INSTALL_TEST_DIR }}/TEST*.html
|
||||
if-no-files-found: 'error'
|
||||
27
.github/workflows/linux.yml
vendored
27
.github/workflows/linux.yml
vendored
@@ -228,7 +228,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz
|
||||
@@ -236,7 +236,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino developer package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_developer_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_developer_package.tar.gz
|
||||
@@ -244,7 +244,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino debian packages
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_debian_packages
|
||||
path: ${{ env.BUILD_DIR }}/*.deb
|
||||
@@ -252,7 +252,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino tests package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz
|
||||
@@ -372,7 +372,7 @@ jobs:
|
||||
|
||||
- name: Upload Conformance Artifacts
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: conformance_artifacts_${{ matrix.TEST_TYPE }}-${{ env.TEST_DEVICE }}
|
||||
path: ${{ env.CONFORMANCE_ARTIFACTS_DIR }}/conformance_artifacts.tar.gz
|
||||
@@ -430,21 +430,6 @@ jobs:
|
||||
runner: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores' }}
|
||||
event: ${{ github.event_name }}
|
||||
|
||||
# TODO: Switch back to self-hosted runners
|
||||
# container:
|
||||
# image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04
|
||||
# volumes:
|
||||
# - /mount:/mount
|
||||
TensorFlow_Hub_Performance_Models_Tests:
|
||||
name: TensorFlow Hub Performance Models tests
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test ||
|
||||
fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test
|
||||
needs: [ Build, Smart_CI ]
|
||||
uses: ./.github/workflows/job_tensorflow_hub_performance_models_tests.yml
|
||||
with:
|
||||
runner: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores' }}
|
||||
event: ${{ github.event_name }}
|
||||
|
||||
# TODO: Switch back to self-hosted runners
|
||||
# container:
|
||||
# image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04
|
||||
@@ -591,7 +576,7 @@ jobs:
|
||||
Overall_Status:
|
||||
name: ci/gha_overall_status
|
||||
needs: [Smart_CI, Build, Debian_Packages, Samples, Conformance, ONNX_Runtime, CXX_Unit_Tests, Python_Unit_Tests,
|
||||
CPU_Functional_Tests, TensorFlow_Hub_Models_Tests, TensorFlow_Hub_Performance_Models_Tests, PyTorch_Models_Tests, NVIDIA_Plugin]
|
||||
CPU_Functional_Tests, TensorFlow_Hub_Models_Tests, PyTorch_Models_Tests, NVIDIA_Plugin]
|
||||
if: ${{ always() }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
10
.github/workflows/linux_arm64.yml
vendored
10
.github/workflows/linux_arm64.yml
vendored
@@ -225,7 +225,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz
|
||||
@@ -233,7 +233,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino developer package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_developer_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_developer_package.tar.gz
|
||||
@@ -241,7 +241,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino debian packages
|
||||
if: ${{ 'false' }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_debian_packages
|
||||
path: ${{ env.BUILD_DIR }}/*.deb
|
||||
@@ -249,7 +249,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino tests package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz
|
||||
@@ -346,7 +346,7 @@ jobs:
|
||||
event: ${{ github.event_name }}
|
||||
|
||||
Overall_Status:
|
||||
name: ci/gha_overall_status
|
||||
name: ci/gha_overall_status_linux_arm64
|
||||
needs: [Smart_CI, Build, Debian_Packages, Samples, ONNX_Runtime, CXX_Unit_Tests, Python_Unit_Tests, CPU_Functional_Tests,
|
||||
TensorFlow_Hub_Models_Tests, TensorFlow_Hub_Performance_Models_Tests, PyTorch_Models_Tests]
|
||||
if: ${{ always() }}
|
||||
|
||||
@@ -5,6 +5,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/**'
|
||||
|
||||
concurrency:
|
||||
# github.ref is not unique in post-commit
|
||||
@@ -206,7 +207,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz
|
||||
@@ -214,7 +215,7 @@ jobs:
|
||||
|
||||
- name: Upload selective build statistics package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_selective_build_stat
|
||||
path: ${{ env.BUILD_DIR }}/openvino_selective_build_stat.tar.gz
|
||||
@@ -222,7 +223,7 @@ jobs:
|
||||
|
||||
- name: Upload OpenVINO tests package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz
|
||||
@@ -332,3 +333,17 @@ jobs:
|
||||
with:
|
||||
runner: 'aks-linux-8-cores-32gb'
|
||||
image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:22.04'
|
||||
|
||||
Overall_Status:
|
||||
name: ci/gha_overall_status_linux_cc
|
||||
needs: [Smart_CI, Build, CC_Build, CPU_Functional_Tests]
|
||||
if: ${{ always() }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check status of all jobs
|
||||
if: >-
|
||||
${{
|
||||
contains(needs.*.result, 'failure') ||
|
||||
contains(needs.*.result, 'cancelled')
|
||||
}}
|
||||
run: exit 1
|
||||
|
||||
14
.github/workflows/linux_riscv.yml
vendored
14
.github/workflows/linux_riscv.yml
vendored
@@ -206,3 +206,17 @@ jobs:
|
||||
source ${OPENVINO_BUILD_DIR}/dependencies/deactivate_conanbuild.sh
|
||||
env:
|
||||
CMAKE_TOOLCHAIN_FILE: ${{ env.OPENVINO_BUILD_DIR }}/dependencies/conan_toolchain.cmake
|
||||
|
||||
Overall_Status:
|
||||
name: ci/gha_overall_status_linux_riscv
|
||||
needs: [Smart_CI, Build]
|
||||
if: ${{ always() }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check status of all jobs
|
||||
if: >-
|
||||
${{
|
||||
contains(needs.*.result, 'failure') ||
|
||||
contains(needs.*.result, 'cancelled')
|
||||
}}
|
||||
run: exit 1
|
||||
|
||||
4
.github/workflows/mac.yml
vendored
4
.github/workflows/mac.yml
vendored
@@ -196,7 +196,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz
|
||||
@@ -204,7 +204,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino tests package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz
|
||||
|
||||
4
.github/workflows/mac_arm64.yml
vendored
4
.github/workflows/mac_arm64.yml
vendored
@@ -195,7 +195,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz
|
||||
@@ -203,7 +203,7 @@ jobs:
|
||||
|
||||
- name: Upload openvino tests package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz
|
||||
|
||||
2
.github/workflows/mo.yml
vendored
2
.github/workflows/mo.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
|
||||
12
.github/workflows/py_checks.yml
vendored
12
.github/workflows/py_checks.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.8'
|
||||
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
git diff > samples_diff.diff
|
||||
working-directory: samples/python
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: samples_diff
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
git diff > ie_python_diff.diff
|
||||
working-directory: src/bindings/python/src/compatibility/openvino
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: ie_python_diff
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
git diff > pyngraph_diff.diff
|
||||
working-directory: src/bindings/python/src/compatibility/ngraph
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: pyngraph_diff
|
||||
@@ -101,7 +101,7 @@ jobs:
|
||||
git diff > pyopenvino_diff.diff
|
||||
working-directory: src/bindings/python/src/openvino
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: pyopenvino_diff
|
||||
@@ -119,7 +119,7 @@ jobs:
|
||||
git diff > wheel_diff.diff
|
||||
working-directory: src/bindings/python/wheel
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: wheel_diff
|
||||
|
||||
65
.github/workflows/windows.yml
vendored
65
.github/workflows/windows.yml
vendored
@@ -5,12 +5,14 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/**'
|
||||
concurrency:
|
||||
# github.ref is not unique in post-commit
|
||||
group: ${{ github.event_name == 'push' && github.run_id || github.ref }}-windows
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
PIP_CACHE_PATH: /mount/caches/pip/win
|
||||
PYTHON_VERSION: '3.11'
|
||||
|
||||
jobs:
|
||||
@@ -87,8 +89,10 @@ jobs:
|
||||
uses: ./openvino/.github/actions/setup_python
|
||||
with:
|
||||
version: ${{ env.PYTHON_VERSION }}
|
||||
should-setup-pip-paths: 'false'
|
||||
self-hosted-runner: 'false'
|
||||
pip-cache-path: ${{ env.PIP_CACHE_PATH }}
|
||||
should-setup-pip-paths: 'true'
|
||||
self-hosted-runner: 'true'
|
||||
show-cache-info: 'true'
|
||||
|
||||
- name: Install python dependencies
|
||||
run: |
|
||||
@@ -109,6 +113,9 @@ jobs:
|
||||
# For running Paddle frontend unit tests
|
||||
# python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt
|
||||
|
||||
# For getting rid of SSL issues during model downloading for unit tests
|
||||
python3 -m pip install certifi
|
||||
|
||||
- name: Install sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.3
|
||||
with:
|
||||
@@ -124,6 +131,9 @@ jobs:
|
||||
- name: Configure Developer Command Prompt for Microsoft Visual C++
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Set SSL_CERT_FILE for model downloading for unit tests
|
||||
run: echo SSL_CERT_FILE=$(python3 -m certifi) >> $env:GITHUB_ENV
|
||||
|
||||
- name: CMake configure
|
||||
run: |
|
||||
cmake -G "${{ env.CMAKE_GENERATOR }}" `
|
||||
@@ -185,14 +195,14 @@ jobs:
|
||||
cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} --verbose
|
||||
|
||||
- name: Upload openvino package
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_package
|
||||
path: ${{ env.BUILD_DIR }}/openvino_package.zip
|
||||
if-no-files-found: 'error'
|
||||
|
||||
- name: Upload openvino tests package
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.BUILD_DIR }}/openvino_tests.zip
|
||||
@@ -248,7 +258,7 @@ jobs:
|
||||
with:
|
||||
version: ${{ env.PYTHON_VERSION }}
|
||||
should-setup-pip-paths: 'false'
|
||||
self-hosted-runner: 'false'
|
||||
self-hosted-runner: 'true'
|
||||
|
||||
- name: Build cpp samples
|
||||
run: |
|
||||
@@ -272,7 +282,7 @@ jobs:
|
||||
WORKSPACE: ${{ env.INSTALL_DIR }}
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-samples
|
||||
@@ -286,7 +296,7 @@ jobs:
|
||||
defaults:
|
||||
run:
|
||||
shell: pwsh
|
||||
runs-on: aks-win-4-cores-8gb
|
||||
runs-on: aks-win-8-cores-16gb
|
||||
env:
|
||||
OPENVINO_REPO: "${{ github.workspace }}\\openvino"
|
||||
OPENVINO_CONTRIB_REPO: "${{ github.workspace }}\\openvino_contrib"
|
||||
@@ -329,8 +339,9 @@ jobs:
|
||||
uses: ./openvino/.github/actions/setup_python
|
||||
with:
|
||||
version: ${{ env.PYTHON_VERSION }}
|
||||
pip-cache-path: ${{ env.PIP_CACHE_PATH }}
|
||||
should-setup-pip-paths: 'false'
|
||||
self-hosted-runner: 'false'
|
||||
self-hosted-runner: 'true'
|
||||
|
||||
- name: Install OpenVINO Python wheels
|
||||
run: |
|
||||
@@ -344,6 +355,9 @@ jobs:
|
||||
|
||||
- name: Install Python API tests dependencies
|
||||
run: |
|
||||
# To enable pytest parallel features
|
||||
python3 -m pip install pytest-xdist[psutil]
|
||||
|
||||
# For torchvision to OpenVINO preprocessing converter
|
||||
python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}/python/preprocess/torchvision/requirements.txt
|
||||
|
||||
@@ -369,13 +383,17 @@ jobs:
|
||||
run: |
|
||||
python3 -m pytest -s ${{ env.INSTALL_TEST_DIR }}/mo/unit_tests --ignore=${{ env.INSTALL_TEST_DIR }}/mo/unit_tests/mo/front/mxnet --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-ModelOptimizer.xml
|
||||
|
||||
- name: Install Python Layer tests dependencies
|
||||
run: |
|
||||
# layer test requirements
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
|
||||
# Ticket - 115085
|
||||
- name: PyTorch Layer Tests
|
||||
if: ${{ 'false' }}
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/pytorch_tests -m precommit --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-pytorch.xml
|
||||
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/pytorch_tests -n logical -m precommit --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-pytorch.xml
|
||||
env:
|
||||
TEST_DEVICE: CPU
|
||||
|
||||
@@ -383,11 +401,9 @@ jobs:
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
|
||||
:: requires 'unit_tests' from 'tools/mo'
|
||||
set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\mo;%PYTHONPATH%
|
||||
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/onnx_tests -m "not launch_only_if_manually_specified and precommit" --junitxml=${INSTALL_TEST_DIR}/TEST-onnx.xml
|
||||
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/onnx_tests -n logical -m "not launch_only_if_manually_specified and precommit" --junitxml=${INSTALL_TEST_DIR}/TEST-onnx.xml
|
||||
env:
|
||||
TEST_DEVICE: CPU
|
||||
TEST_PRECISION: FP16
|
||||
@@ -396,8 +412,6 @@ jobs:
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
|
||||
:: requires 'unit_tests' from 'tools/mo'
|
||||
set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\mo;%PYTHONPATH%
|
||||
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow_tests/ --use_new_frontend -m precommit_tf_fe --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_fe.xml
|
||||
@@ -409,8 +423,6 @@ jobs:
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
|
||||
:: requires 'unit_tests' from 'tools/mo'
|
||||
set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\mo;%PYTHONPATH%
|
||||
|
||||
@@ -422,14 +434,12 @@ jobs:
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow_tests/test_tf_Roll.py --ir_version=10 --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_Roll.xml
|
||||
|
||||
- name: TensorFlow 2 Layer Tests - Legacy FE
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow2_keras_tests/test_tf2_keras_activation.py --ir_version=11 --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf2_Activation.xml -k "sigmoid"
|
||||
env:
|
||||
TEST_DEVICE: CPU
|
||||
@@ -439,7 +449,6 @@ jobs:
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow_lite_tests/ --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tfl_fe.xml
|
||||
env:
|
||||
TEST_DEVICE: CPU
|
||||
@@ -459,8 +468,6 @@ jobs:
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
|
||||
:: Used for 'test_utils' installed in '<test_package>\python\openvino\test_utils'
|
||||
set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\python\openvino\test_utils;${{ env.INSTALL_TEST_DIR }}\python;%PYTHONPATH%
|
||||
|
||||
@@ -473,8 +480,6 @@ jobs:
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
|
||||
:: Used for 'test_utils' installed in '<test_package>\python\openvino\test_utils'
|
||||
set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\python\openvino\test_utils;${{ env.INSTALL_TEST_DIR }}\python;%PYTHONPATH%
|
||||
|
||||
@@ -489,8 +494,6 @@ jobs:
|
||||
fromJSON(needs.smart_ci.outputs.affected_components).PDPD_FE.test
|
||||
shell: cmd
|
||||
run: |
|
||||
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
|
||||
|
||||
call "${{ env.INSTALL_DIR }}\\setupvars.bat" && python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/py_frontend_tests --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-test_py_fontend.xml
|
||||
|
||||
- name: OVC unit tests
|
||||
@@ -499,7 +502,7 @@ jobs:
|
||||
run: python3 -m pytest -s ${{ env.INSTALL_TEST_DIR }}/ovc/unit_tests --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-OpenVinoConversion.xml
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-python
|
||||
@@ -589,7 +592,7 @@ jobs:
|
||||
call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_onnx_frontend_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ONNXFrontend.xml
|
||||
|
||||
- name: TensorFlow Common frontend tests
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test ||
|
||||
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test ||
|
||||
fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test
|
||||
shell: cmd
|
||||
run: |
|
||||
@@ -720,7 +723,7 @@ jobs:
|
||||
call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_hetero_func_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVHeteroFuncTests.xml
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-cpp
|
||||
@@ -777,7 +780,7 @@ jobs:
|
||||
with:
|
||||
version: ${{ env.PYTHON_VERSION }}
|
||||
should-setup-pip-paths: 'false'
|
||||
self-hosted-runner: 'false'
|
||||
self-hosted-runner: 'true'
|
||||
|
||||
- name: Install python dependencies
|
||||
shell: cmd
|
||||
@@ -805,7 +808,7 @@ jobs:
|
||||
key: ${{ runner.os }}-tests-functional-cpu-stamp-${{ github.sha }}
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-functional-cpu
|
||||
|
||||
@@ -22,6 +22,7 @@ on:
|
||||
- '**/conformance/**'
|
||||
branches:
|
||||
- master
|
||||
- 'releases/**'
|
||||
|
||||
concurrency:
|
||||
# github.ref is not unique in post-commit
|
||||
@@ -103,6 +104,9 @@ jobs:
|
||||
# For running TensorFlow Lite frontend unit tests
|
||||
python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/tensorflow_lite/tests/requirements.txt
|
||||
|
||||
# For getting rid of SSL issues during model downloading for unit tests
|
||||
python3 -m pip install certifi
|
||||
|
||||
# Disabled because of CVS-95904
|
||||
# For running Paddle frontend unit tests
|
||||
# python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt
|
||||
@@ -114,6 +118,9 @@ jobs:
|
||||
- name: Configure Developer Command Prompt for Microsoft Visual C++
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Set SSL_CERT_FILE for model downloading for unit tests
|
||||
run: echo SSL_CERT_FILE=$(python3 -m certifi) >> $env:GITHUB_ENV
|
||||
|
||||
- name: CMake configure - CC COLLECT
|
||||
run: |
|
||||
cmake -G "${{ env.CMAKE_GENERATOR }}" `
|
||||
@@ -211,7 +218,7 @@ jobs:
|
||||
|
||||
- name: Upload selective build statistics package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_selective_build_stat
|
||||
path: ${{ env.BUILD_DIR }}/openvino_selective_build_stat.zip
|
||||
@@ -219,7 +226,7 @@ jobs:
|
||||
|
||||
- name: Upload OpenVINO tests package
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openvino_tests
|
||||
path: ${{ env.BUILD_DIR }}/openvino_tests.zip
|
||||
@@ -373,7 +380,7 @@ jobs:
|
||||
timeout-minutes: 45
|
||||
|
||||
- name: Upload Test Results
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: test-results-functional-cpu
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,7 +7,7 @@ cmake-build*
|
||||
!__init__.py
|
||||
!__main__.py
|
||||
# and sphinx documentation folders
|
||||
!docs/_*
|
||||
!docs/sphinx_setup/_*
|
||||
|
||||
# developer tools
|
||||
*.idea
|
||||
|
||||
@@ -4,8 +4,14 @@
|
||||
|
||||
OpenVINO™ is always looking for opportunities to improve and your contributions
|
||||
play a big role in this process. There are several ways you can make the
|
||||
product better:
|
||||
product better.
|
||||
|
||||
# Table of Contents
|
||||
1. [Forms of contribution](#Forms-of-contribution)
|
||||
2. [Technical guide](#Technical-guide)
|
||||
|
||||
|
||||
## Forms of contribution
|
||||
|
||||
### Provide Feedback
|
||||
|
||||
@@ -32,7 +38,7 @@ product better:
|
||||
If you want to help improving OpenVINO, choose one of the issues reported in
|
||||
[GitHub Issue Tracker](https://github.com/openvinotoolkit/openvino/issues) and
|
||||
[create a Pull Request](./CONTRIBUTING_PR.md) addressing it. Consider one of the
|
||||
tasks listed as [first-time contributions](https://github.com/openvinotoolkit/openvino/issues/17502).
|
||||
tasks listed as [first-time contributions](https://github.com/orgs/openvinotoolkit/projects/3).
|
||||
If the feature you want to develop is more complex or not well defined by the reporter,
|
||||
it is always a good idea to [discuss it](https://github.com/openvinotoolkit/openvino/discussions)
|
||||
with OpenVINO developers first. Before creating a new PR, check if nobody is already
|
||||
@@ -81,6 +87,66 @@ product better:
|
||||
share your expertise with the community. Check GitHub Discussions and
|
||||
Issues to see if you can help someone.
|
||||
|
||||
## Technical guide
|
||||
|
||||
This section lists all the necessary steps required to set up your environment, build OpenVINO locally, and run tests for specific components. It's a perfect place to start when you have just picked a Good First Issue and are wondering how to start working on it.
|
||||
|
||||
Keep in mind that we are here to help - **do not hesitate to ask the development team if something is not clear**. Such questions allow us to keep improving our documentation.
|
||||
|
||||
### 1. Prerequisites
|
||||
|
||||
You can start with the following links:
|
||||
- [What is OpenVINO?](https://github.com/openvinotoolkit/openvino#what-is-openvino-toolkit)
|
||||
- [OpenVINO architecture](https://github.com/openvinotoolkit/openvino/blob/master/src/docs/architecture.md)
|
||||
- [User documentation](https://docs.openvino.ai/)
|
||||
- [Blog post on contributing to OpenVINO](https://medium.com/openvino-toolkit/how-to-contribute-to-an-ai-open-source-project-c741f48e009e)
|
||||
- [Pick up a Good First Issue](https://github.com/orgs/openvinotoolkit/projects/3)
|
||||
|
||||
### 2. Building the project
|
||||
|
||||
In order to build the project, follow the [build instructions for your specific OS](https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build.md).
|
||||
|
||||
### 3. Familiarize yourself with the component you'll be working with
|
||||
|
||||
Choose the component your Good First Issue is related to. You can run tests to make sure it works correctly.
|
||||
|
||||
##### APIs
|
||||
- [C API](https://github.com/openvinotoolkit/openvino/tree/master/src/bindings/c)
|
||||
- [Core](https://github.com/openvinotoolkit/openvino/tree/master/src/core)
|
||||
- [Python API](https://github.com/openvinotoolkit/openvino/tree/master/src/bindings/python)
|
||||
|
||||
##### Frontends
|
||||
- [IR Frontend](https://github.com/openvinotoolkit/openvino/tree/master/src/frontends/ir)
|
||||
- [ONNX Frontend](https://github.com/openvinotoolkit/openvino/tree/master/src/frontends/onnx)
|
||||
- [PaddlePaddle Frontend](https://github.com/openvinotoolkit/openvino/tree/master/src/frontends/paddle)
|
||||
- [PyTorch Frontend](https://github.com/openvinotoolkit/openvino/tree/master/src/frontends/pytorch)
|
||||
- [TensorFlow Frontend](https://github.com/openvinotoolkit/openvino/tree/master/src/frontends/tensorflow)
|
||||
|
||||
##### Plugins
|
||||
- [Auto plugin](https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/auto)
|
||||
- [CPU plugin](https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/intel_cpu)
|
||||
- [GPU plugin](https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/intel_gpu)
|
||||
- [Hetero plugin](https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/hetero)
|
||||
- [Template plugin](https://github.com/openvinotoolkit/openvino/tree/master/src/plugins/template)
|
||||
|
||||
##### Tools
|
||||
- [Benchmark Tool](https://github.com/openvinotoolkit/openvino/tree/master/tools/benchmark_tool)
|
||||
- [Model Optimizer](https://github.com/openvinotoolkit/openvino/tree/master/tools/mo)
|
||||
|
||||
##### Others
|
||||
- [Documentation](https://github.com/openvinotoolkit/openvino/blob/master/CONTRIBUTING_DOCS.md)
|
||||
|
||||
### 3. Start working on your Good First Issue
|
||||
|
||||
Use the issue description and locally built OpenVINO to complete the task. Remember that you can always ask users tagged in the "Contact points" section for help!
|
||||
|
||||
### 4. Submit a PR with your changes
|
||||
|
||||
Follow our [Good Pull Request guidelines](https://github.com/openvinotoolkit/openvino/blob/master/CONTRIBUTING_PR.md).
|
||||
|
||||
### 5. Wait for a review
|
||||
|
||||
We'll make sure to review your Pull Request as soon as possible and provide you with our feedback. You can expect a merge once your changes are validated with automatic tests and approved by maintainers.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -3,70 +3,43 @@
|
||||
Configurations for Intel® NPU with OpenVINO™
|
||||
===============================================
|
||||
|
||||
|
||||
.. meta::
|
||||
:description: Learn how to provide additional configuration for Intel®
|
||||
NPU to work with the OpenVINO™ toolkit on your system.
|
||||
|
||||
|
||||
|
||||
Drivers and Dependencies
|
||||
########################
|
||||
The Intel® NPU device requires a proper driver to be installed in the system.
|
||||
Make sure you use the most recent supported driver for your hardware setup.
|
||||
|
||||
|
||||
The Intel® NPU device requires a proper driver to be installed on the system.
|
||||
.. tab-set::
|
||||
|
||||
.. tab-item:: Linux
|
||||
|
||||
The driver is maintained as open source and may be found in the following repository,
|
||||
together with comprehensive information on installation and system requirements:
|
||||
`github.com/intel/linux-npu-driver <https://github.com/intel/linux-npu-driver>`__
|
||||
|
||||
It is recommended to check for the latest version of the driver.
|
||||
|
||||
Linux
|
||||
####################
|
||||
Make sure you use a supported OS version, as well as install make, gcc,
|
||||
and Linux kernel headers. To check the NPU state, use the ``dmesg``
|
||||
command in the console. A successful boot-up of the NPU should give you
|
||||
a message like this one:
|
||||
|
||||
``[ 797.193201] [drm] Initialized intel_vpu 0.<version number> for 0000:00:0b.0 on minor 0``
|
||||
|
||||
Prerequisites
|
||||
++++++++++++++++++++
|
||||
The current requirement for inference on NPU is Ubuntu 22.04 with the kernel
|
||||
version of 6.6 or higher.
|
||||
|
||||
Ensure that make, gcc, and Linux kernel headers are installed. Use the following command to install the required software:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
sudo apt-get install gcc make linux-headers-generic
|
||||
|
||||
|
||||
Configuration steps
|
||||
++++++++++++++++++++
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Windows
|
||||
####################
|
||||
|
||||
Intel® NPU driver for Windows is available through Windows Update.
|
||||
|
||||
|
||||
|
||||
|
||||
What’s Next?
|
||||
####################
|
||||
|
||||
Now you are ready to try out OpenVINO™. You can use the following tutorials to write your applications using Python and C/C++.
|
||||
|
||||
* Developing in Python:
|
||||
|
||||
* `Start with tensorflow models with OpenVINO™ <notebooks/101-tensorflow-to-openvino-with-output.html>`__
|
||||
* `Start with ONNX and PyTorch models with OpenVINO™ <notebooks/102-pytorch-onnx-to-openvino-with-output.html>`__
|
||||
* `Start with PaddlePaddle models with OpenVINO™ <notebooks/103-paddle-to-openvino-classification-with-output.html>`__
|
||||
|
||||
* Developing in C/C++:
|
||||
|
||||
* :doc:`Image Classification Async C++ Sample <openvino_inference_engine_samples_classification_sample_async_README>`
|
||||
* :doc:`Hello Classification C++ Sample <openvino_inference_engine_samples_hello_classification_README>`
|
||||
* :doc:`Hello Reshape SSD C++ Sample <openvino_inference_engine_samples_hello_reshape_ssd_README>`
|
||||
.. tab-item:: Windows
|
||||
|
||||
The Intel® NPU driver for Windows is available through Windows Update but
|
||||
it may also be installed manually by downloading the
|
||||
`NPU driver package <https://www.intel.com/content/www/us/en/download-center/home.html>`__ and following the
|
||||
`Windows driver installation guide <https://support.microsoft.com/en-us/windows/update-drivers-manually-in-windows-ec62f46c-ff14-c91d-eead-d7126dc1f7b6>`__.
|
||||
|
||||
If a driver has already been installed you should be able to find
|
||||
'Intel(R) NPU Accelerator' in Windows Device Manager. If you
|
||||
cannot find such a device, the NPU is most likely listed in "Other devices"
|
||||
as "Multimedia Video Controller."
|
||||
|
||||
@@ -23,7 +23,7 @@ Install OpenVINO™ 2023.2
|
||||
|
||||
<script type="module" crossorigin src="_static/selector-tool/assets/index-f34d1fad.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<iframe id="selector" src="_static/selector-tool/selector-c1c409a.html" style="width: 100%; border: none" title="Download Intel® Distribution of OpenVINO™ Toolkit"></iframe>
|
||||
<iframe id="selector" src="_static/selector-tool/selector-5cca680.html" style="width: 100%; border: none" title="Download Intel® Distribution of OpenVINO™ Toolkit"></iframe>
|
||||
|
||||
.. warning::
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ Installing OpenVINO Runtime with Conan Package Manager
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python3 -m pip install conan>=2.0.8
|
||||
python3 -m pip install 'conan>=2.0.8'
|
||||
|
||||
2. Create a ``conanfile.txt`` file for your OpenVINO project and add "*openvino*" dependency in there:
|
||||
|
||||
|
||||
@@ -58,30 +58,37 @@ The Jupyter notebooks are categorized into following classes:
|
||||
|
||||
Below you will find a selection of recommended tutorials that demonstrate inference on a particular model. These tutorials are guaranteed to provide a great experience with inference in OpenVINO:
|
||||
|
||||
|
||||
.. showcase::
|
||||
:title: 272-paint-by-example
|
||||
:img: https://camo.githubusercontent.com/79d83ce8fc6813a503f372bacb7dc709c79d9560060df3dc92196b9849cc33a9/68747470733a2f2f757365722d696d616765732e67697468756275736572636f6e74656e742e636f6d2f3130333232363538302f3233363935343931382d66333634623232372d323933632d346637382d613962662d3964636562636231303334612e706e67
|
||||
|
||||
Paint by Example using Stable Diffusion and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 271-sdxl-turbo
|
||||
:img: _images/271-sdxl-turbo-with-output_30_1.png
|
||||
|
||||
Single step image generation using SDXL-turbo and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 270-sound-generation-audioldm2
|
||||
:img: https://github.com/openvinotoolkit/openvino_notebooks/assets/76463150/c93a0f86-d9cf-4bd1-93b9-e27532170d75
|
||||
|
||||
Sound Generation with AudioLDM2 and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 269-film-slowmo
|
||||
:img: https://github.com/googlestaging/frame-interpolation/raw/main/moment.gif
|
||||
|
||||
Frame interpolation using FILM and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 268-table-question-answering
|
||||
:img: _static/images/notebook_eye.png
|
||||
|
||||
Table Question Answering using TAPAS and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 267-distil-whisper-asr
|
||||
:img: _static/images/notebook_eye.png
|
||||
|
||||
Automatic speech recognition using Distil-Whisper and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 266-speculative-sampling
|
||||
:img: _static/images/notebook_eye.png
|
||||
|
||||
Text Generation via Speculative Sampling, KV Caching, and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 265-wuerstchen-image-generation
|
||||
:img: https://user-images.githubusercontent.com/76161256/277724498-6917c558-d74c-4cc9-b81a-679ce0a299ee.png
|
||||
@@ -100,60 +107,18 @@ Below you will find a selection of recommended tutorials that demonstrate infere
|
||||
|
||||
Image generation with Latent Consistency Model and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 263-lcm-lora-controlnet
|
||||
:img: https://user-images.githubusercontent.com/29454499/284292122-f146e16d-7233-49f7-a401-edcb714b5288.png
|
||||
|
||||
Text-to-Image Generation with LCM LoRA and ControlNet Conditioning.
|
||||
|
||||
.. showcase::
|
||||
:title: 262-softvc-voice-conversion
|
||||
:img: _static/images/notebook_eye.png
|
||||
|
||||
SoftVC VITS Singing Voice Conversion and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 261-fast-segment-anything
|
||||
:img: https://user-images.githubusercontent.com/26833433/248551984-d98f0f6d-7535-45d0-b380-2e1440b52ad7.jpg
|
||||
|
||||
Object segmentation with FastSAM and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 259-decidiffusion-image-generation
|
||||
:img: https://user-images.githubusercontent.com/29454499/274927904-cd734349-9954-4656-ab96-08a903e846ef.png
|
||||
|
||||
Image generation with DeciDiffusion and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 258-blip-diffusion-subject-generation
|
||||
:img: https://user-images.githubusercontent.com/76161256/275485611-0ecf621f-b544-44ae-8258-8a49be704989.png
|
||||
|
||||
Subject-driven image generation and editing using BLIP Diffusion and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 257-llava-multimodal-chatbot
|
||||
:img: https://raw.githubusercontent.com/haotian-liu/LLaVA/main/images/llava_logo.png
|
||||
|
||||
Visual-language assistant with LLaVA and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 256-bark-text-to-audio
|
||||
:img: https://user-images.githubusercontent.com/29454499/269278630-9a770279-0045-480e-95f2-1a2f2d0a5115.png
|
||||
|
||||
Text-to-speech generation using Bark and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 254-llm-chatbot
|
||||
:img: _static/images/notebook_eye.png
|
||||
|
||||
Create an LLM-powered Chatbot using OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 253-zeroscope-text2video
|
||||
:img: https://camo.githubusercontent.com/64eec6e52d060ca971c5a3be3f0d60e712907c98b4661b454d7e3e9575c2bc6b/68747470733a2f2f68756767696e67666163652e636f2f64617461736574732f68756767696e67666163652f646f63756d656e746174696f6e2d696d616765732f7265736f6c76652f6d61696e2f6469666675736572732f646172746876616465725f63657270656e73652e676966
|
||||
|
||||
Video generation with ZeroScope and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 251-tiny-sd-image-generation
|
||||
:img: https://user-images.githubusercontent.com/29454499/260904650-274fc2f9-24d2-46a3-ac3d-d660ec3c9a19.png
|
||||
|
||||
Image Generation with Tiny-SD and OpenVINO.
|
||||
|
||||
|
||||
.. note::
|
||||
If there are any issues while running the notebooks, refer to the **Troubleshooting** and **FAQ** sections in the :doc:`Installation Guide <notebooks_installation>` or start a GitHub
|
||||
|
||||
@@ -17,6 +17,12 @@ Tutorials that explain how to optimize and quantize models with OpenVINO tools.
|
||||
|
||||
Convert TensorFlow Hub models to OpenVINO Intermediate Representation (IR).
|
||||
|
||||
.. showcase::
|
||||
:title: 125-lraspp-segmentation
|
||||
:img: _static/images/notebook_eye.png
|
||||
|
||||
Semantic segmentation with LRASPP MobileNet v3 and OpenVINO
|
||||
|
||||
.. showcase::
|
||||
:title: 125-convnext-classification
|
||||
:img: _static/images/notebook_eye.png
|
||||
|
||||
@@ -11,6 +11,22 @@ Model Demos
|
||||
|
||||
Demos that demonstrate inference on a particular model.
|
||||
|
||||
.. showcase::
|
||||
:title: 272-paint-by-example
|
||||
:img: https://camo.githubusercontent.com/79d83ce8fc6813a503f372bacb7dc709c79d9560060df3dc92196b9849cc33a9/68747470733a2f2f757365722d696d616765732e67697468756275736572636f6e74656e742e636f6d2f3130333232363538302f3233363935343931382d66333634623232372d323933632d346637382d613962662d3964636562636231303334612e706e67
|
||||
|
||||
Paint by Example using Stable Diffusion and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 271-sdxl-turbo
|
||||
:img: _images/271-sdxl-turbo-with-output_30_1.png
|
||||
|
||||
Single step image generation using SDXL-turbo and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 270-sound-generation-audioldm2
|
||||
:img: https://github.com/openvinotoolkit/openvino_notebooks/assets/76463150/c93a0f86-d9cf-4bd1-93b9-e27532170d75
|
||||
|
||||
.. showcase::
|
||||
:title: 269-film-slowmo
|
||||
:img: https://github.com/googlestaging/frame-interpolation/raw/main/moment.gif
|
||||
@@ -53,6 +69,12 @@ Demos that demonstrate inference on a particular model.
|
||||
|
||||
Image generation with Latent Consistency Model and OpenVINO.
|
||||
|
||||
.. showcase::
|
||||
:title: 263-lcm-lora-controlnet
|
||||
:img: https://user-images.githubusercontent.com/29454499/284292122-f146e16d-7233-49f7-a401-edcb714b5288.png
|
||||
|
||||
Text-to-Image Generation with LCM LoRA and ControlNet Conditioning.
|
||||
|
||||
.. showcase::
|
||||
:title: 262-softvc-voice-conversion
|
||||
:img: _static/images/notebook_eye.png
|
||||
@@ -125,6 +147,12 @@ Demos that demonstrate inference on a particular model.
|
||||
|
||||
Universal segmentation with OneFormer and OpenVINO™.
|
||||
|
||||
.. showcase::
|
||||
:title: 248-ssd-b1
|
||||
:img: https://user-images.githubusercontent.com/29454499/258651862-28b63016-c5ff-4263-9da8-73ca31100165.jpeg
|
||||
|
||||
Image generation with Stable Diffusion XL and OpenVINO™.
|
||||
|
||||
.. showcase::
|
||||
:title: 248-stable-diffusion-xl
|
||||
:img: https://user-images.githubusercontent.com/29454499/258651862-28b63016-c5ff-4263-9da8-73ca31100165.jpeg
|
||||
|
||||
@@ -14,17 +14,18 @@ Inference Device Support
|
||||
:maxdepth: 1
|
||||
:hidden:
|
||||
|
||||
openvino_docs_OV_UG_query_api
|
||||
openvino_docs_OV_UG_supported_plugins_CPU
|
||||
openvino_docs_OV_UG_supported_plugins_GPU
|
||||
openvino_docs_OV_UG_supported_plugins_NPU
|
||||
openvino_docs_OV_UG_supported_plugins_GNA
|
||||
openvino_docs_OV_UG_query_api
|
||||
|
||||
|
||||
OpenVINO™ Runtime can infer deep learning models using the following device types:
|
||||
|
||||
* :doc:`CPU <openvino_docs_OV_UG_supported_plugins_CPU>`
|
||||
* :doc:`GPU <openvino_docs_OV_UG_supported_plugins_GPU>`
|
||||
* :doc:`NPU <openvino_docs_OV_UG_supported_plugins_NPU>`
|
||||
* :doc:`GNA <openvino_docs_OV_UG_supported_plugins_GNA>`
|
||||
* :doc:`Arm® CPU <openvino_docs_OV_UG_supported_plugins_CPU>`
|
||||
|
||||
@@ -33,26 +34,25 @@ For a more detailed list of hardware, see :doc:`Supported Devices <openvino_docs
|
||||
.. _devicesupport-feature-support-matrix:
|
||||
|
||||
|
||||
|
||||
Feature Support Matrix
|
||||
#######################################
|
||||
|
||||
The table below demonstrates support of key features by OpenVINO device plugins.
|
||||
|
||||
========================================================================================= ============================ =============== ===============
|
||||
Capability CPU GPU GNA
|
||||
========================================================================================= ============================ =============== ===============
|
||||
:doc:`Heterogeneous execution <openvino_docs_OV_UG_Hetero_execution>` Yes Yes No
|
||||
:doc:`Multi-device execution <openvino_docs_OV_UG_Running_on_multiple_devices>` Yes Yes Partial
|
||||
:doc:`Automatic batching <openvino_docs_OV_UG_Automatic_Batching>` No Yes No
|
||||
:doc:`Multi-stream execution <openvino_docs_deployment_optimization_guide_tput>` Yes (Intel® x86-64 only) Yes No
|
||||
:doc:`Models caching <openvino_docs_OV_UG_Model_caching_overview>` Yes Partial Yes
|
||||
:doc:`Dynamic shapes <openvino_docs_OV_UG_DynamicShapes>` Yes Partial No
|
||||
:doc:`Import/Export <openvino_ecosystem>` Yes No Yes
|
||||
:doc:`Preprocessing acceleration <openvino_docs_OV_UG_Preprocessing_Overview>` Yes Yes No
|
||||
:doc:`Stateful models <openvino_docs_OV_UG_model_state_intro>` Yes No Yes
|
||||
:doc:`Extensibility <openvino_docs_Extensibility_UG_Intro>` Yes Yes No
|
||||
========================================================================================= ============================ =============== ===============
|
||||
========================================================================================= ============================ ========== =========== ===========
|
||||
Capability CPU GPU NPU GNA
|
||||
========================================================================================= ============================ ========== =========== ===========
|
||||
:doc:`Heterogeneous execution <openvino_docs_OV_UG_Hetero_execution>` Yes Yes No
|
||||
:doc:`Multi-device execution <openvino_docs_OV_UG_Running_on_multiple_devices>` Yes Yes Partial
|
||||
:doc:`Automatic batching <openvino_docs_OV_UG_Automatic_Batching>` No Yes No
|
||||
:doc:`Multi-stream execution <openvino_docs_deployment_optimization_guide_tput>` Yes (Intel® x86-64 only) Yes No
|
||||
:doc:`Models caching <openvino_docs_OV_UG_Model_caching_overview>` Yes Partial Yes
|
||||
:doc:`Dynamic shapes <openvino_docs_OV_UG_DynamicShapes>` Yes Partial No
|
||||
:doc:`Import/Export <openvino_ecosystem>` Yes No Yes
|
||||
:doc:`Preprocessing acceleration <openvino_docs_OV_UG_Preprocessing_Overview>` Yes Yes No
|
||||
:doc:`Stateful models <openvino_docs_OV_UG_model_state_intro>` Yes No Yes
|
||||
:doc:`Extensibility <openvino_docs_Extensibility_UG_Intro>` Yes Yes No
|
||||
========================================================================================= ============================ ========== =========== ===========
|
||||
|
||||
For more details on plugin-specific feature limitations, see the corresponding plugin pages.
|
||||
|
||||
|
||||
@@ -452,6 +452,15 @@ Below is a list of such operations:
|
||||
|
||||
The behavior depends on specific parameters of the operations and hardware configuration.
|
||||
|
||||
.. important::
|
||||
|
||||
While working on a fine tuned model, inference may give an inaccuracy and performance drop
|
||||
on GPU if winograd convolutions are selected. This issue can be fixed by disabling winograd
|
||||
convolutions:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
compiled_model = core.compile_model(ov_model, device_name=devStr1, config={ "GPU_DISABLE_WINOGRAD_CONVOLUTION": True })
|
||||
|
||||
GPU Performance Checklist: Summary
|
||||
#######################################
|
||||
|
||||
@@ -3,27 +3,158 @@
|
||||
NPU Device
|
||||
==========
|
||||
|
||||
|
||||
.. meta::
|
||||
:description: The NPU plugin in the Intel® Distribution of OpenVINO™ toolkit
|
||||
aims at high performance inference of neural
|
||||
networks on the low-power NPU processing device.
|
||||
:description: OpenVINO™ supports the Neural Processing Unit,
|
||||
a low-power processing device dedicated to running AI inference.
|
||||
|
||||
|
||||
NPU is a new generation of low-power processing unit dedicated to processing neural networks.
|
||||
The NPU plugin is a core part of the OpenVINO™ toolkit. For its in-depth description, see:
|
||||
The Neural Processing Unit is a low-power hardware solution, introduced with the
|
||||
Intel® Core™ Ultra generation of CPUs (formerly known as Meteor Lake). It enables
|
||||
you to offload certain neural network computation tasks from other devices,
|
||||
for more streamlined resource management.
|
||||
|
||||
..
|
||||
- `NPU plugin developer documentation < cmake_options_for_custom_compilation.md ??? >`__.
|
||||
- `NPU plugin source files < ??? >`__.
|
||||
For an in-depth description of the NPU plugin, see:
|
||||
|
||||
• `NPU plugin developer documentation <https://github.com/openvinotoolkit/npu_plugin/blob/develop/docs/VPUX_DG/index.md>`__
|
||||
• `OpenVINO Runtime NPU plugin source files <https://github.com/openvinotoolkit/npu_plugin>`__
|
||||
|
||||
|
||||
| **Supported Platforms:**
|
||||
| Host: Intel® Core™ Ultra (former Meteor Lake)
|
||||
| NPU device: NPU 3720
|
||||
| OS: Ubuntu* 20, MS Windows* 11 (both 64-bit)
|
||||
|
||||
|
||||
| **Supported Inference Data Types**
|
||||
| The NPU plugin supports the following data types as inference precision of internal primitives:
|
||||
| Floating-point data types: f32, f16O
|
||||
| Quantized data types: u8 (quantized models may be int8 or mixed fp16-int8)
|
||||
| Computation precision for the HW is fp16.
|
||||
|
|
||||
| For more details on how to get a quantized model, refer to the
|
||||
:doc:`Model Optimization guide <openvino_docs_model_optimization_guide>`, and
|
||||
:doc:`NNCF tool quantization guide <basic_quantization_flow>`.
|
||||
|
||||
|
||||
|
||||
Model Caching
|
||||
#############################
|
||||
|
||||
Model Caching helps reduce application startup delays by exporting and reusing the compiled
|
||||
model automatically. The following two compilation-related metrics are crucial in this area:
|
||||
|
||||
| **First Ever Inference Latency (FEIL)**
|
||||
| Measures all steps required to compile and execute a model on the device for the
|
||||
first time. It includes model compilation time, the time required to load and
|
||||
initialize the model on the device and the first inference execution.
|
||||
| **First Inference Latency (FIL)**
|
||||
| Measures the time required to load and initialize the pre-compiled model on the
|
||||
device and the first inference execution.
|
||||
|
||||
|
||||
UMD Dynamic Model Caching
|
||||
+++++++++++++++++++++++++++++
|
||||
|
||||
UMD model caching is a solution enabled by default in the current NPU driver.
|
||||
It improves time to first inference (FIL) by storing the model in the cache
|
||||
after the compilation (included in FEIL), based on a hash key. The process
|
||||
may be summarized in three stages:
|
||||
|
||||
1. UMD generates the key from the input IR model and build arguments
|
||||
2. UMD requests the DirectX Shader cache session to store the model
|
||||
with the computed key.
|
||||
3. All subsequent requests to compile the same IR model with the same arguments
|
||||
use the pre-compiled model, reading it from the cache instead of recompiling.
|
||||
|
||||
|
||||
OpenVINO Model Caching
|
||||
+++++++++++++++++++++++++++++
|
||||
|
||||
OpenVINO Model Caching is a common mechanism for all OpenVINO device plugins and
|
||||
can be enabled by setting the ``ov::cache_dir`` property. This way, the UMD model
|
||||
caching is automatically bypassed by the NPU plugin, which means the model
|
||||
will only be stored in the OpenVINO cache after compilation. When a cache hit
|
||||
occurs for subsequent compilation requests, the plugin will import the model
|
||||
instead of recompiling it.
|
||||
|
||||
For more details about OpenVINO model caching, see the
|
||||
:doc:`Model Caching Overview <openvino_docs_OV_UG_Model_caching_overview>`.
|
||||
|
||||
|
||||
Supported Features and properties
|
||||
#######################################
|
||||
|
||||
The NPU device is currently supported by AUTO and MULTI inference modes.
|
||||
|
||||
The NPU support in OpenVINO is still under active development and may
|
||||
offer a limited set of supported OpenVINO features.
|
||||
|
||||
**Supported Properties:**
|
||||
|
||||
.. tab-set::
|
||||
|
||||
.. tab-item:: Read-write properties
|
||||
|
||||
.. code-block::
|
||||
|
||||
ov::caching_properties
|
||||
ov::enable_profiling
|
||||
ov::hint::performance_mode
|
||||
ov::hint::num_requests
|
||||
ov::hint::model_priority
|
||||
ov::hint::enable_cpu_pinning
|
||||
ov::log::level
|
||||
ov::device::id
|
||||
ov::cache_dir
|
||||
ov::internal::exclusive_async_requests
|
||||
ov::intel_vpux::dpu_groups
|
||||
ov::intel_vpux::dma_engines
|
||||
ov::intel_vpux::compilation_mode
|
||||
ov::intel_vpux::compilation_mode_params
|
||||
ov::intel_vpux::print_profiling
|
||||
ov::intel_vpux::profiling_output_file
|
||||
ov::intel_vpux::vpux_platform
|
||||
ov::intel_vpux::use_elf_compiler_backend
|
||||
|
||||
.. tab-item:: Read-only properties
|
||||
|
||||
.. code-block::
|
||||
|
||||
ov::supported_properties
|
||||
ov::streams::num
|
||||
ov::optimal_number_of_infer_requests
|
||||
ov::range_for_async_infer_requests
|
||||
ov::range_for_streams
|
||||
ov::available_devices
|
||||
ov::device::uuid
|
||||
ov::device::architecture
|
||||
ov::device::full_name
|
||||
ov::intel_vpux::device_total_mem_size
|
||||
ov::intel_vpux::driver_version
|
||||
|
||||
.. note::
|
||||
|
||||
The optimum number of inference requests returned by the plugin
|
||||
based on the performance mode is **4 for THROUGHPUT** and **1 for LATENCY**.
|
||||
The default mode for the NPU device is LATENCY.
|
||||
|
||||
|
||||
Limitations
|
||||
#############################
|
||||
|
||||
* Currently, only the models with static shapes are supported on NPU.
|
||||
* If the path to the model file includes non-Unicode symbols, such as in Chinese,
|
||||
the model cannot be used for inference on NPU. It will return an error.
|
||||
* Running the Alexnet model with NPU may result in a drop in accuracy.
|
||||
At this moment, the googlenet-v4 model is recommended for classification tasks.
|
||||
|
||||
|
||||
Additional Resources
|
||||
#############################
|
||||
|
||||
* `Vision colorization Notebook <notebooks/222-vision-image-colorization-with-output.html>`__
|
||||
* `Classification Benchmark C++ Demo <https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/classification_benchmark_demo/cpp>`__
|
||||
* `3D Human Pose Estimation Python Demo <https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/3d_segmentation_demo/python>`__
|
||||
* `Object Detection C++ Demo <https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/object_detection_demo/cpp>`__
|
||||
* `Object Detection Python Demo <https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/object_detection_demo/python>`__
|
||||
* `POT-specific sample with sparse resnet-50 generation <https://github.com/openvinotoolkit/openvino/tree/master/tools/pot/openvino/tools/pot/api/samples/prune_and_quantize>`__
|
||||
|
||||
@@ -3,35 +3,37 @@
|
||||
Query Device Properties - Configuration
|
||||
=======================================
|
||||
|
||||
|
||||
|
||||
.. meta::
|
||||
:description: Learn the details on the process of querying different device
|
||||
properties and configuration values at runtime.
|
||||
|
||||
|
||||
The OpenVINO™ toolkit supports inference with several types of devices (processors or accelerators).
|
||||
This section provides a high-level description of the process of querying of different device properties and configuration values at runtime.
|
||||
This article provides an overview of how to query different device properties
|
||||
and configuration values at runtime.
|
||||
|
||||
OpenVINO runtime has two types of properties:
|
||||
|
||||
- Read only properties which provide information about the devices (such as device name or execution capabilities, etc.)
|
||||
and information about configuration values used to compile the model (``ov::CompiledModel``) .
|
||||
- Mutable properties which are primarily used to configure the ``ov::Core::compile_model`` process and affect final
|
||||
inference on a specific set of devices. Such properties can be set globally per device via ``ov::Core::set_property``
|
||||
or locally for particular model in the ``ov::Core::compile_model`` and the ``ov::Core::query_model`` calls.
|
||||
- **Read only properties** which provide information about devices, such as device
|
||||
name and execution capabilities, and information about configuration values
|
||||
used to compile the model - ``ov::CompiledModel``.
|
||||
- **Mutable properties**, primarily used to configure the ``ov::Core::compile_model``
|
||||
process and affect final inference on a specific set of devices. Such properties
|
||||
can be set globally per device via ``ov::Core::set_property`` or locally for a
|
||||
particular model in the ``ov::Core::compile_model`` and ``ov::Core::query_model``
|
||||
calls.
|
||||
|
||||
|
||||
An OpenVINO property is represented as a named constexpr variable with a given string name and a type.
|
||||
The following example represents a read-only property with a C++ name of ``ov::available_devices``,
|
||||
a string name of ``AVAILABLE_DEVICES`` and a type of ``std::vector<std::string>``:
|
||||
An OpenVINO property is represented as a named constexpr variable with a given string
|
||||
name and a type. The following example represents a read-only property with the C++ name
|
||||
of ``ov::available_devices``, the string name of ``AVAILABLE_DEVICES`` and the type of
|
||||
``std::vector<std::string>``:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
static constexpr Property<std::vector<std::string>, PropertyMutability::RO> available_devices{"AVAILABLE_DEVICES"};
|
||||
|
||||
|
||||
Refer to the :doc:`Hello Query Device С++ Sample <openvino_inference_engine_samples_hello_query_device_README>` sources and
|
||||
Refer to the :doc:`Hello Query Device C++ Sample <openvino_inference_engine_samples_hello_query_device_README>` sources and
|
||||
the :doc:`Multi-Device execution <openvino_docs_OV_UG_Running_on_multiple_devices>` documentation for examples of using
|
||||
setting and getting properties in user applications.
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
Automatic Device Selection
|
||||
==========================
|
||||
|
||||
.. meta::
|
||||
:description: The Automatic Device Selection mode in OpenVINO™ Runtime
|
||||
detects available devices and selects the optimal processing
|
||||
unit for inference automatically.
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
@@ -10,34 +15,25 @@ Automatic Device Selection
|
||||
|
||||
Debugging Auto-Device Plugin <openvino_docs_OV_UG_supported_plugins_AUTO_debugging>
|
||||
|
||||
.. meta::
|
||||
:description: The Automatic Device Selection mode in OpenVINO™ Runtime
|
||||
detects available devices and selects the optimal processing
|
||||
unit for inference automatically.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
2. Check precisions of the input model (for detailed information on precisions read more on the ``ov::device::capabilities``).
|
||||
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.
|
||||
4. If model's precision is FP32 but there is no device capable of supporting it, offload the model to a device supporting FP16.
|
||||
|
||||
|
||||
+----------+-----------------------------------------------------+------------------------------------+
|
||||
@@ -53,7 +49,18 @@ The logic behind the choice is as follows:
|
||||
| 3 | Intel® CPU | FP32, FP16, INT8, BIN |
|
||||
| | (e.g. Intel® Core™ i7-1165G7) | |
|
||||
+----------+-----------------------------------------------------+------------------------------------+
|
||||
| 4 | Intel® NPU | |
|
||||
| | (e.g. Intel® Core™ Ultra) | |
|
||||
+----------+-----------------------------------------------------+------------------------------------+
|
||||
|
||||
.. note::
|
||||
|
||||
Note that NPU is currently excluded from the default priority list. To use it for inference, you
|
||||
need to specify it explicitly
|
||||
|
||||
|
||||
How AUTO Works
|
||||
##############
|
||||
|
||||
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 starts inference with the CPU of the system by default**, as it provides very low latency and can start inference with no additional delays.
|
||||
@@ -61,12 +68,19 @@ While the CPU is performing inference, AUTO continues to load the model to the d
|
||||
This way, the devices which are much slower in compiling models, GPU being the best example, do not impact 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.
|
||||
|
||||
Note that if you choose to exclude CPU from the priority list or disable the initial CPU acceleration feature via ``ov::intel_auto::enable_startup_fallback``, it will be unable to support the initial model compilation stage. The models with dynamic input/output or stateful :doc:`stateful<openvino_docs_OV_UG_model_state_intro>` operations will be loaded to the CPU if it is in the candidate list. Otherwise, these models will follow the normal flow and be loaded to the device based on priority.
|
||||
Note that if you choose to exclude CPU from the priority list or disable the initial
|
||||
CPU acceleration feature via ``ov::intel_auto::enable_startup_fallback``, it will be
|
||||
unable to support the initial model compilation stage. The models with dynamic
|
||||
input/output or stateful :doc:`stateful<openvino_docs_OV_UG_model_state_intro>`
|
||||
operations will be loaded to the CPU if it is in the candidate list. Otherwise,
|
||||
these models will follow the normal flow and be loaded to the device based on priority.
|
||||
|
||||
.. image:: _static/images/autoplugin_accelerate.svg
|
||||
|
||||
|
||||
This mechanism can be easily observed in the :ref:`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 the :ref:`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:
|
||||
|
||||
|
||||
.. code-block:: sh
|
||||
@@ -88,8 +102,9 @@ This mechanism can be easily observed in the :ref:`Using AUTO with Benchmark app
|
||||
Using AUTO
|
||||
##########
|
||||
|
||||
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:
|
||||
|
||||
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:
|
||||
|
||||
+----------------------------------------------+--------------------------------------------------------------------+
|
||||
| Property(C++ version) | Values and Description |
|
||||
@@ -205,7 +220,6 @@ The code samples on this page assume following import(Python)/using (C++) are in
|
||||
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.
|
||||
@@ -496,3 +510,4 @@ Additional Resources
|
||||
- :doc:`Running on Multiple Devices Simultaneously <openvino_docs_OV_UG_Running_on_multiple_devices>`
|
||||
- :doc:`Supported Devices <openvino_docs_OV_UG_supported_plugins_Supported_Devices>`
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ repo_directory = "notebooks"
|
||||
repo_owner = "openvinotoolkit"
|
||||
repo_name = "openvino_notebooks"
|
||||
repo_branch = "tree/main"
|
||||
artifacts_link = "http://repository.toolbox.iotg.sclab.intel.com/projects/ov-notebook/0.1.0-latest/20231114220808/dist/rst_files/"
|
||||
artifacts_link = "http://repository.toolbox.iotg.sclab.intel.com/projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/"
|
||||
blacklisted_extensions = ['.xml', '.bin']
|
||||
notebooks_repo = "https://github.com/openvinotoolkit/openvino_notebooks/blob/main/"
|
||||
notebooks_binder = "https://mybinder.org/v2/gh/openvinotoolkit/openvino_notebooks/HEAD?filepath="
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
OpenVINO™ Runtime API Tutorial
|
||||
==============================
|
||||
|
||||
This notebook explains the basics of the OpenVINO Runtime API. It
|
||||
covers:
|
||||
This notebook explains the basics of the OpenVINO Runtime API.
|
||||
|
||||
The notebook is divided into sections with headers. The next cell
|
||||
contains global requirements for installation and imports. Each section
|
||||
is standalone and does not depend on any previous sections. All models
|
||||
used in this tutorial are provided as examples. These model files can be
|
||||
replaced with your own models. The exact outputs will be different, but
|
||||
the process is the same.
|
||||
|
||||
**Table of contents:**
|
||||
|
||||
|
||||
- `Loading OpenVINO Runtime and Showing
|
||||
Info <#loading-openvino-runtime-and-showing-info>`__
|
||||
@@ -13,6 +22,7 @@ covers:
|
||||
- `PaddlePaddle Model <#paddlepaddle-model>`__
|
||||
- `TensorFlow Model <#tensorflow-model>`__
|
||||
- `TensorFlow Lite Model <#tensorflow-lite-model>`__
|
||||
- `PyTorch Model <#pytorch-model>`__
|
||||
|
||||
- `Getting Information about a
|
||||
Model <#getting-information-about-a-model>`__
|
||||
@@ -28,19 +38,11 @@ covers:
|
||||
|
||||
- `Caching a Model <#caching-a-model>`__
|
||||
|
||||
The notebook is divided into sections with headers. The next cell
|
||||
contains global requirements installation and imports. Each section is
|
||||
standalone and does not depend on any previous sections. A segmentation
|
||||
and classification OpenVINO IR model and a segmentation ONNX model are
|
||||
provided as examples. These model files can be replaced with your own
|
||||
models. The exact outputs will be different, but the process is the
|
||||
same.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Required imports. Please execute this cell first.
|
||||
%pip install -q "openvino>=2023.1.0"
|
||||
%pip install requests tqdm
|
||||
%pip install -q "openvino>=2023.1.0"
|
||||
%pip install requests tqdm ipywidgets
|
||||
|
||||
# Fetch `notebook_utils` module
|
||||
import urllib.request
|
||||
@@ -55,19 +57,44 @@ same.
|
||||
.. parsed-literal::
|
||||
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
Requirement already satisfied: requests in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (2.31.0)
|
||||
Requirement already satisfied: tqdm in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (4.66.1)
|
||||
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from requests) (3.3.1)
|
||||
Requirement already satisfied: idna<4,>=2.5 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from requests) (3.4)
|
||||
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from requests) (2.0.7)
|
||||
Requirement already satisfied: certifi>=2017.4.17 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from requests) (2023.7.22)
|
||||
Requirement already satisfied: requests in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (2.31.0)
|
||||
Requirement already satisfied: tqdm in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (4.66.1)
|
||||
Requirement already satisfied: ipywidgets in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (8.1.1)
|
||||
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from requests) (3.3.2)
|
||||
Requirement already satisfied: idna<4,>=2.5 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from requests) (3.6)
|
||||
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from requests) (2.1.0)
|
||||
Requirement already satisfied: certifi>=2017.4.17 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from requests) (2023.11.17)
|
||||
Requirement already satisfied: comm>=0.1.3 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipywidgets) (0.2.0)
|
||||
Requirement already satisfied: ipython>=6.1.0 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipywidgets) (8.12.3)
|
||||
Requirement already satisfied: traitlets>=4.3.1 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipywidgets) (5.14.0)
|
||||
Requirement already satisfied: widgetsnbextension~=4.0.9 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipywidgets) (4.0.9)
|
||||
Requirement already satisfied: jupyterlab-widgets~=3.0.9 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipywidgets) (3.0.9)
|
||||
Requirement already satisfied: backcall in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (0.2.0)
|
||||
Requirement already satisfied: decorator in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (5.1.1)
|
||||
Requirement already satisfied: jedi>=0.16 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (0.19.1)
|
||||
Requirement already satisfied: matplotlib-inline in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (0.1.6)
|
||||
Requirement already satisfied: pickleshare in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (0.7.5)
|
||||
Requirement already satisfied: prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (3.0.41)
|
||||
Requirement already satisfied: pygments>=2.4.0 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (2.17.2)
|
||||
Requirement already satisfied: stack-data in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (0.6.3)
|
||||
Requirement already satisfied: typing-extensions in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (4.8.0)
|
||||
Requirement already satisfied: pexpect>4.3 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from ipython>=6.1.0->ipywidgets) (4.9.0)
|
||||
Requirement already satisfied: parso<0.9.0,>=0.8.3 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets) (0.8.3)
|
||||
Requirement already satisfied: ptyprocess>=0.5 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets) (0.7.0)
|
||||
Requirement already satisfied: wcwidth in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from prompt-toolkit!=3.0.37,<3.1.0,>=3.0.30->ipython>=6.1.0->ipywidgets) (0.2.12)
|
||||
Requirement already satisfied: executing>=1.2.0 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (2.0.1)
|
||||
Requirement already satisfied: asttokens>=2.1.0 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (2.4.1)
|
||||
Requirement already satisfied: pure-eval in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (0.2.2)
|
||||
Requirement already satisfied: six>=1.12.0 in /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets) (1.16.0)
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
Loading OpenVINO Runtime and Showing Info
|
||||
-----------------------------------------
|
||||
|
||||
Initialize OpenVINO Runtime with Core()
|
||||
|
||||
|
||||
Initialize OpenVINO Runtime with ``ov.Core()``
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -103,6 +130,8 @@ be faster.
|
||||
Loading a Model
|
||||
---------------
|
||||
|
||||
|
||||
|
||||
After initializing OpenVINO Runtime, first read the model file with
|
||||
``read_model()``, then compile it to the specified device with the
|
||||
``compile_model()`` method.
|
||||
@@ -115,6 +144,8 @@ using a tool dedicated to this task.
|
||||
OpenVINO IR Model
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
An OpenVINO IR (Intermediate Representation) model consists of an
|
||||
``.xml`` file, containing information about network topology, and a
|
||||
``.bin`` file, containing the weights and biases binary data. Models in
|
||||
@@ -167,7 +198,7 @@ notebooks.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.bin')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.bin')
|
||||
|
||||
|
||||
|
||||
@@ -184,6 +215,8 @@ notebooks.
|
||||
ONNX Model
|
||||
~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
`ONNX <https://onnx.ai/>`__ is an open format built to represent machine
|
||||
learning models. ONNX defines a common set of operators - the building
|
||||
blocks of machine learning and deep learning models - and a common file
|
||||
@@ -214,7 +247,7 @@ points to the filename of an ONNX model.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/segmentation.onnx')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/segmentation.onnx')
|
||||
|
||||
|
||||
|
||||
@@ -237,6 +270,8 @@ The ONNX model can be exported to OpenVINO IR with ``save_model()``:
|
||||
PaddlePaddle Model
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
`PaddlePaddle <https://www.paddlepaddle.org.cn/documentation/docs/en/guides/index_en.html>`__
|
||||
models saved for inference can also be passed to OpenVINO Runtime
|
||||
without any conversion step. Pass the filename with extension to
|
||||
@@ -268,7 +303,7 @@ without any conversion step. Pass the filename with extension to
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/inference.pdiparams')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/inference.pdiparams')
|
||||
|
||||
|
||||
|
||||
@@ -289,16 +324,10 @@ without any conversion step. Pass the filename with extension to
|
||||
TensorFlow Model
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
TensorFlow models saved in frozen graph format can also be passed to
|
||||
``read_model`` starting in OpenVINO 2022.3.
|
||||
|
||||
**NOTE**: Directly loading TensorFlow models is available as a
|
||||
preview feature in the OpenVINO 2022.3 release. Fully functional
|
||||
support will be provided in the upcoming 2023 releases. Currently
|
||||
support is limited to only frozen graph inference format. Other
|
||||
TensorFlow model formats must be converted to OpenVINO IR using
|
||||
`model conversion
|
||||
API <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow.html>`__.
|
||||
|
||||
TensorFlow models saved in frozen graph format can also be passed to
|
||||
``read_model``.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -318,7 +347,7 @@ TensorFlow models saved in frozen graph format can also be passed to
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.pb')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.pb')
|
||||
|
||||
|
||||
|
||||
@@ -339,6 +368,8 @@ TensorFlow models saved in frozen graph format can also be passed to
|
||||
TensorFlow Lite Model
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
`TFLite <https://www.tensorflow.org/lite>`__ models saved for inference
|
||||
can also be passed to OpenVINO Runtime. Pass the filename with extension
|
||||
``.tflite`` to ``read_model`` and exported an OpenVINO IR with
|
||||
@@ -352,7 +383,7 @@ It is pre-trained model optimized to work with TensorFlow Lite.
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
tflite_model_url = 'https://tfhub.dev/tensorflow/lite-model/inception_v4_quant/1/default/1?lite-format=tflite'
|
||||
tflite_model_url = 'https://www.kaggle.com/models/tensorflow/inception/frameworks/tfLite/variations/v4-quant/versions/1?lite-format=tflite'
|
||||
tflite_model_path = Path('model/classification.tflite')
|
||||
|
||||
download_file(tflite_model_url, filename=tflite_model_path.name, directory=tflite_model_path.parent)
|
||||
@@ -368,7 +399,7 @@ It is pre-trained model optimized to work with TensorFlow Lite.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.tflite')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.tflite')
|
||||
|
||||
|
||||
|
||||
@@ -385,9 +416,43 @@ It is pre-trained model optimized to work with TensorFlow Lite.
|
||||
|
||||
ov.save_model(model_tflite, output_model="model/exported_tflite_model.xml")
|
||||
|
||||
PyTorch Model
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
`PyTorch <https://pytorch.org/>`__ models can not be directly passed to
|
||||
``core.read_model``. ``ov.Model`` for model objects from this framework
|
||||
can be obtained using ``ov.convert_model`` API. You can find more
|
||||
details in `pytorch-to-openvino <../102-pytorch-to-openvino>`__
|
||||
notebook. In this tutorial we will use
|
||||
`resnet18 <https://pytorch.org/vision/main/models/generated/torchvision.models.resnet18.html>`__
|
||||
model form torchvision library. After conversion model using
|
||||
``ov.convert_model``, it can be compiled on device using
|
||||
``core.compile_model`` or saved on disk for the next usage using
|
||||
``ov.save_model``
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import openvino as ov
|
||||
import torch
|
||||
from torchvision.models import resnet18, ResNet18_Weights
|
||||
|
||||
core = ov.Core()
|
||||
|
||||
pt_model = resnet18(weights=ResNet18_Weights.IMAGENET1K_V1)
|
||||
example_input = torch.zeros((1, 3, 224, 224))
|
||||
ov_model_pytorch = ov.convert_model(pt_model, example_input=example_input)
|
||||
|
||||
compiled_model_pytorch = core.compile_model(ov_model_pytorch, device_name="CPU")
|
||||
|
||||
ov.save_model(ov_model_pytorch, "model/exported_pytorch_model.xml")
|
||||
|
||||
Getting Information about a Model
|
||||
---------------------------------
|
||||
|
||||
|
||||
|
||||
The OpenVINO Model instance stores information about the model.
|
||||
Information about the inputs and outputs of the model are in
|
||||
``model.inputs`` and ``model.outputs``. These are also properties of the
|
||||
@@ -415,13 +480,15 @@ Information about the inputs and outputs of the model are in
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.bin')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.bin')
|
||||
|
||||
|
||||
|
||||
Model Inputs
|
||||
~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Information about all input layers is stored in the ``inputs``
|
||||
dictionary.
|
||||
|
||||
@@ -495,6 +562,8 @@ point) precision.
|
||||
Model Outputs
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import openvino as ov
|
||||
@@ -559,32 +628,41 @@ classes (``C``). The output is returned as 32-bit floating point.
|
||||
Doing Inference on a Model
|
||||
--------------------------
|
||||
|
||||
|
||||
|
||||
**NOTE** this notebook demonstrates only the basic synchronous
|
||||
inference API. For an async inference example, please refer to `Async
|
||||
API notebook <115-async-api-with-output.html>`__
|
||||
|
||||
The diagram below shows a typical inference pipeline with OpenVINO
|
||||
|
||||
.. figure:: https://docs.openvino.ai/2023.0/_images/IMPLEMENT_PIPELINE_with_API_C.svg
|
||||
.. figure:: https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/a91bc582-165b-41a2-ab08-12c812059936
|
||||
:alt: image.png
|
||||
|
||||
image.png
|
||||
|
||||
Creating OpenVINO Core and model compilation is covered in the previous
|
||||
steps. The next step is preparing an inference request. To do inference
|
||||
on a model, first create an inference request by calling the
|
||||
``create_infer_request()`` method of ``CompiledModel``,
|
||||
``compiled_model`` that was loaded with ``compile_model()``. Then, call
|
||||
the ``infer()`` method of ``InferRequest``. It expects one argument:
|
||||
``inputs``. This is a dictionary that maps input layer names to input
|
||||
data or list of input data in ``np.ndarray`` format, where the position
|
||||
of the input tensor corresponds to input index. If a model has a single
|
||||
input, wrapping to a dictionary or list can be omitted.
|
||||
steps. The next step is preparing inputs. You can provide inputs in one
|
||||
of the supported format: dictionary with name of inputs as keys and
|
||||
``np.arrays`` that represent input tensors as values, list or tuple of
|
||||
``np.arrays`` represented input tensors (their order should match with
|
||||
model inputs order). If a model has a single input, wrapping to a
|
||||
dictionary or list can be omitted. To do inference on a model, pass
|
||||
prepared inputs into compiled model object obtained using
|
||||
``core.compile_model``. The inference result represented as dictionary,
|
||||
where keys are model outputs and ``np.arrays`` represented their
|
||||
produced data as values.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Install opencv package for image handling
|
||||
!pip install -q opencv-python
|
||||
%pip install -q opencv-python
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
**Load the network**
|
||||
|
||||
@@ -608,7 +686,7 @@ input, wrapping to a dictionary or list can be omitted.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.bin')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.bin')
|
||||
|
||||
|
||||
|
||||
@@ -756,9 +834,13 @@ notebook <001-hello-world-with-output.html>`__.
|
||||
Reshaping and Resizing
|
||||
----------------------
|
||||
|
||||
|
||||
|
||||
Change Image Size
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Instead of reshaping the image to fit the model, it is also possible to
|
||||
reshape the model to fit the image. Be aware that not all models support
|
||||
reshaping, and models that do, may not support all input shapes. The
|
||||
@@ -793,7 +875,7 @@ input shape.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/segmentation.bin')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/segmentation.bin')
|
||||
|
||||
|
||||
|
||||
@@ -847,6 +929,8 @@ dimensions. After reshaping, compile the network once again.
|
||||
Change Batch Size
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Use the ``.reshape()`` method to set the batch size, by increasing the
|
||||
first element of ``new_shape``. For example, to set a batch size of two,
|
||||
set ``new_shape = (2,3,544,544)`` in the cell above.
|
||||
@@ -907,6 +991,8 @@ input image through the network to see the result:
|
||||
Caching a Model
|
||||
---------------
|
||||
|
||||
|
||||
|
||||
For some devices, like GPU, loading a model can take some time. Model
|
||||
Caching solves this issue by caching the model in a cache directory. If
|
||||
``core.compile_model(model=net, device_name=device_name, config=config_dict)``
|
||||
@@ -944,7 +1030,7 @@ the cache.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.bin')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/002-openvino-api/model/classification.bin')
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -44,8 +44,7 @@ documentation <https://pytorch.org/vision/main/models/lraspp.html>`__
|
||||
|
||||
- `ONNX Model Conversion <#onnx-model-conversion>`__
|
||||
|
||||
- `Convert PyTorch model to
|
||||
ONNX <#convert-pytorch-model-to-onnx>`__
|
||||
- `Convert PyTorch model to ONNX <#convert-pytorch-model-to-onnx>`__
|
||||
- `Convert ONNX Model to OpenVINO IR
|
||||
Format <#convert-onnx-model-to-openvino-ir-format>`__
|
||||
|
||||
@@ -78,11 +77,15 @@ documentation <https://pytorch.org/vision/main/models/lraspp.html>`__
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
Preparation
|
||||
-----------------------------------------------------
|
||||
Preparation
|
||||
-----------
|
||||
|
||||
|
||||
|
||||
Imports
|
||||
~~~~~~~
|
||||
|
||||
|
||||
Imports
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -105,8 +108,10 @@ Imports
|
||||
|
||||
from notebook_utils import segmentation_map_to_image, viz_result_image, SegmentationMap, Label, download_file
|
||||
|
||||
Settings
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Settings
|
||||
~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Set a name for the model, then define width and height of the image that
|
||||
will be used by the network during inference. According to the input
|
||||
@@ -127,14 +132,14 @@ transforms function, the model is pre-trained on images with a height of
|
||||
onnx_path.parent.mkdir()
|
||||
ir_path = onnx_path.with_suffix(".xml")
|
||||
|
||||
Load Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Load Model
|
||||
~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Generally, PyTorch models represent an instance of ``torch.nn.Module``
|
||||
class, initialized by a state dictionary with model weights. Typical
|
||||
steps for getting a pre-trained model:
|
||||
|
||||
1. Create instance of model class
|
||||
steps for getting a pre-trained model: 1. Create instance of model class
|
||||
2. Load checkpoint state dict, which contains pre-trained model weights
|
||||
3. Turn model to evaluation for switching some operations to inference
|
||||
mode
|
||||
@@ -180,11 +185,15 @@ have not downloaded the model before.
|
||||
Loaded PyTorch LRASPP MobileNetV3 model
|
||||
|
||||
|
||||
ONNX Model Conversion
|
||||
---------------------------------------------------------------
|
||||
ONNX Model Conversion
|
||||
---------------------
|
||||
|
||||
|
||||
|
||||
Convert PyTorch model to ONNX
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Convert PyTorch model to ONNX
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
OpenVINO supports PyTorch models that are exported in ONNX format. We
|
||||
will use the ``torch.onnx.export`` function to obtain the ONNX model,
|
||||
@@ -223,8 +232,10 @@ line of the output will read:
|
||||
ONNX model exported to model/lraspp_mobilenet_v3_large.onnx.
|
||||
|
||||
|
||||
Convert ONNX Model to OpenVINO IR Format
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Convert ONNX Model to OpenVINO IR Format
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
To convert the ONNX model to OpenVINO IR with ``FP16`` precision, use
|
||||
model conversion API. The models are saved inside the current directory.
|
||||
@@ -246,14 +257,18 @@ For more information on how to convert models, see this
|
||||
Exporting ONNX model to IR... This may take a few minutes.
|
||||
|
||||
|
||||
Show Results
|
||||
------------------------------------------------------
|
||||
Show Results
|
||||
------------
|
||||
|
||||
|
||||
|
||||
Confirm that the segmentation results look as expected by comparing
|
||||
model predictions on the ONNX, OpenVINO IR and PyTorch models.
|
||||
|
||||
Load and Preprocess an Input Image
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Load and Preprocess an Input Image
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Images need to be normalized before propagating through the network.
|
||||
|
||||
@@ -296,8 +311,10 @@ Images need to be normalized before propagating through the network.
|
||||
data/coco.jpg: 0%| | 0.00/202k [00:00<?, ?B/s]
|
||||
|
||||
|
||||
Load the OpenVINO IR Network and Run Inference on the ONNX model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Load the OpenVINO IR Network and Run Inference on the ONNX model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
OpenVINO Runtime can load ONNX models directly. First, load the ONNX
|
||||
model, do inference and show the results. Then, load the model that was
|
||||
@@ -305,8 +322,10 @@ converted to OpenVINO Intermediate Representation (OpenVINO IR) with
|
||||
OpenVINO Converter and do inference on that model, and show the results
|
||||
on an image.
|
||||
|
||||
1. ONNX Model in OpenVINO Runtime
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1. ONNX Model in OpenVINO Runtime
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -316,8 +335,10 @@ on an image.
|
||||
# Read model to OpenVINO Runtime
|
||||
model_onnx = core.read_model(model=onnx_path)
|
||||
|
||||
Select inference device
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Select inference device
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -398,11 +419,15 @@ be applied to each label for more convenient visualization.
|
||||
|
||||
|
||||
|
||||
2. OpenVINO IR Model in OpenVINO Runtime
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
2. OpenVINO IR Model in OpenVINO Runtime
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
Select inference device
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
Select inference device
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -448,8 +473,10 @@ select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
|
||||
|
||||
PyTorch Comparison
|
||||
------------------------------------------------------------
|
||||
PyTorch Comparison
|
||||
------------------
|
||||
|
||||
|
||||
|
||||
Do inference on the PyTorch model to verify that the output visually
|
||||
looks the same as the output on the ONNX/OpenVINO IR models.
|
||||
@@ -474,8 +501,10 @@ looks the same as the output on the ONNX/OpenVINO IR models.
|
||||
|
||||
|
||||
|
||||
Performance Comparison
|
||||
----------------------------------------------------------------
|
||||
Performance Comparison
|
||||
----------------------
|
||||
|
||||
|
||||
|
||||
Measure the time it takes to do inference on twenty images. This gives
|
||||
an indication of performance. For more accurate benchmarking, use the
|
||||
@@ -547,9 +576,9 @@ performance.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PyTorch model on CPU: 0.044 seconds per image, FPS: 22.94
|
||||
ONNX model in OpenVINO Runtime/CPU: 0.020 seconds per image, FPS: 49.24
|
||||
OpenVINO IR model in OpenVINO Runtime/CPU: 0.032 seconds per image, FPS: 30.92
|
||||
PyTorch model on CPU: 0.039 seconds per image, FPS: 25.93
|
||||
ONNX model in OpenVINO Runtime/CPU: 0.018 seconds per image, FPS: 56.39
|
||||
OpenVINO IR model in OpenVINO Runtime/CPU: 0.018 seconds per image, FPS: 54.58
|
||||
|
||||
|
||||
**Show Device Information**
|
||||
@@ -567,8 +596,10 @@ performance.
|
||||
CPU: Intel(R) Core(TM) i9-10920X CPU @ 3.50GHz
|
||||
|
||||
|
||||
References
|
||||
----------------------------------------------------
|
||||
References
|
||||
----------
|
||||
|
||||
|
||||
|
||||
- `Torchvision <https://pytorch.org/vision/stable/index.html>`__
|
||||
- `Pytorch ONNX
|
||||
|
||||
@@ -1,796 +0,0 @@
|
||||
Convert a PyTorch Model to OpenVINO™ IR
|
||||
=======================================
|
||||
|
||||
This tutorial demonstrates step-by-step instructions on how to do
|
||||
inference on a PyTorch classification model using OpenVINO Runtime.
|
||||
Starting from OpenVINO 2023.0 release, OpenVINO supports direct PyTorch
|
||||
model conversion without an intermediate step to convert them into ONNX
|
||||
format. In order, if you try to use the lower OpenVINO version or prefer
|
||||
to use ONNX, please check this
|
||||
`tutorial <102-pytorch-to-openvino-with-output.html>`__.
|
||||
|
||||
In this tutorial, we will use the
|
||||
`RegNetY_800MF <https://arxiv.org/abs/2003.13678>`__ model from
|
||||
`torchvision <https://pytorch.org/vision/stable/index.html>`__ to
|
||||
demonstrate how to convert PyTorch models to OpenVINO Intermediate
|
||||
Representation.
|
||||
|
||||
The RegNet model was proposed in `Designing Network Design
|
||||
Spaces <https://arxiv.org/abs/2003.13678>`__ by Ilija Radosavovic, Raj
|
||||
Prateek Kosaraju, Ross Girshick, Kaiming He, Piotr Dollár. The authors
|
||||
design search spaces to perform Neural Architecture Search (NAS). They
|
||||
first start from a high dimensional search space and iteratively reduce
|
||||
the search space by empirically applying constraints based on the
|
||||
best-performing models sampled by the current search space. Instead of
|
||||
focusing on designing individual network instances, authors design
|
||||
network design spaces that parametrize populations of networks. The
|
||||
overall process is analogous to the classic manual design of networks
|
||||
but elevated to the design space level. The RegNet design space provides
|
||||
simple and fast networks that work well across a wide range of flop
|
||||
regimes.
|
||||
|
||||
**Table of contents:**
|
||||
|
||||
|
||||
- `Prerequisites <#prerequisites>`__
|
||||
- `Load PyTorch Model <#load-pytorch-model>`__
|
||||
|
||||
- `Prepare Input Data <#prepare-input-data>`__
|
||||
- `Run PyTorch Model
|
||||
Inference <#run-pytorch-model-inference>`__
|
||||
- `Benchmark PyTorch Model
|
||||
Inference <#benchmark-pytorch-model-inference>`__
|
||||
|
||||
- `Convert PyTorch Model to OpenVINO Intermediate
|
||||
Representation <#convert-pytorch-model-to-openvino-intermediate-representation>`__
|
||||
|
||||
- `Select inference device <#select-inference-device>`__
|
||||
- `Run OpenVINO Model
|
||||
Inference <#run-openvino-model-inference>`__
|
||||
- `Benchmark OpenVINO Model
|
||||
Inference <#benchmark-openvino-model-inference>`__
|
||||
|
||||
- `Convert PyTorch Model with Static Input
|
||||
Shape <#convert-pytorch-model-with-static-input-shape>`__
|
||||
|
||||
- `Select inference device <#select-inference-device>`__
|
||||
- `Run OpenVINO Model Inference with Static Input
|
||||
Shape <#run-openvino-model-inference-with-static-input-shape>`__
|
||||
- `Benchmark OpenVINO Model Inference with Static Input
|
||||
Shape <#benchmark-openvino-model-inference-with-static-input-shape>`__
|
||||
|
||||
- `Convert TorchScript Model to OpenVINO Intermediate
|
||||
Representation <#convert-torchscript-model-to-openvino-intermediate-representation>`__
|
||||
|
||||
- `Scripted Model <#scripted-model>`__
|
||||
- `Benchmark Scripted Model
|
||||
Inference <#benchmark-scripted-model-inference>`__
|
||||
- `Convert PyTorch Scripted Model to OpenVINO Intermediate
|
||||
Representation <#convert-pytorch-scripted-model-to-openvino-intermediate-representation>`__
|
||||
- `Benchmark OpenVINO Model Inference Converted From Scripted
|
||||
Model <#benchmark-openvino-model-inference-converted-from-scripted-model>`__
|
||||
- `Traced Model <#traced-model>`__
|
||||
- `Benchmark Traced Model
|
||||
Inference <#benchmark-traced-model-inference>`__
|
||||
- `Convert PyTorch Traced Model to OpenVINO Intermediate
|
||||
Representation <#convert-pytorch-traced-model-to-openvino-intermediate-representation>`__
|
||||
- `Benchmark OpenVINO Model Inference Converted From Traced
|
||||
Model <#benchmark-openvino-model-inference-converted-from-traced-model>`__
|
||||
|
||||
Prerequisites
|
||||
-------------------------------------------------------
|
||||
|
||||
Install notebook dependencies
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%pip install -q "openvino>=2023.1.0" scipy
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
Download input data and label map
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import requests
|
||||
from pathlib import Path
|
||||
from PIL import Image
|
||||
|
||||
MODEL_DIR = Path("model")
|
||||
DATA_DIR = Path("data")
|
||||
|
||||
MODEL_DIR.mkdir(exist_ok=True)
|
||||
DATA_DIR.mkdir(exist_ok=True)
|
||||
MODEL_NAME = "regnet_y_800mf"
|
||||
|
||||
image = Image.open(requests.get("https://farm9.staticflickr.com/8225/8511402100_fea15da1c5_z.jpg", stream=True).raw)
|
||||
|
||||
labels_file = DATA_DIR / "imagenet_2012.txt"
|
||||
|
||||
if not labels_file.exists():
|
||||
resp = requests.get("https://raw.githubusercontent.com/openvinotoolkit/open_model_zoo/master/data/dataset_classes/imagenet_2012.txt")
|
||||
with labels_file.open("wb") as f:
|
||||
f.write(resp.content)
|
||||
|
||||
imagenet_classes = labels_file.open("r").read().splitlines()
|
||||
|
||||
Load PyTorch Model
|
||||
------------------------------------------------------------
|
||||
|
||||
Generally, PyTorch models represent an instance of the
|
||||
``torch.nn.Module`` class, initialized by a state dictionary with model
|
||||
weights. Typical steps for getting a pre-trained model:
|
||||
|
||||
1. Create an instance of a model class
|
||||
2. Load checkpoint state dict, which contains pre-trained model weights
|
||||
3. Turn the model to evaluation for switching some operations to
|
||||
inference mode
|
||||
|
||||
The ``torchvision`` module provides a ready-to-use set of functions for
|
||||
model class initialization. We will use
|
||||
``torchvision.models.regnet_y_800mf``. You can directly pass pre-trained
|
||||
model weights to the model initialization function using the weights
|
||||
enum ``RegNet_Y_800MF_Weights.DEFAULT``.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import torchvision
|
||||
|
||||
# get default weights using available weights Enum for model
|
||||
weights = torchvision.models.RegNet_Y_800MF_Weights.DEFAULT
|
||||
|
||||
# create model topology and load weights
|
||||
model = torchvision.models.regnet_y_800mf(weights=weights)
|
||||
|
||||
# switch model to inference mode
|
||||
model.eval();
|
||||
|
||||
Prepare Input Data
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The code below demonstrates how to preprocess input data using a
|
||||
model-specific transforms module from ``torchvision``. After
|
||||
transformation, we should concatenate images into batched tensor, in our
|
||||
case, we will run the model with batch 1, so we just unsqueeze input on
|
||||
the first dimension.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import torch
|
||||
|
||||
# Initialize the Weight Transforms
|
||||
preprocess = weights.transforms()
|
||||
|
||||
# Apply it to the input image
|
||||
img_transformed = preprocess(image)
|
||||
|
||||
# Add batch dimension to image tensor
|
||||
input_tensor = img_transformed.unsqueeze(0)
|
||||
|
||||
Run PyTorch Model Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The model returns a vector of probabilities in raw logits format,
|
||||
softmax can be applied to get normalized values in the [0, 1] range. For
|
||||
a demonstration that the output of the original model and OpenVINO
|
||||
converted is the same, we defined a common postprocessing function which
|
||||
can be reused later.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import numpy as np
|
||||
from scipy.special import softmax
|
||||
|
||||
# Perform model inference on input tensor
|
||||
result = model(input_tensor)
|
||||
|
||||
# Postprocessing function for getting results in the same way for both PyTorch model inference and OpenVINO
|
||||
def postprocess_result(output_tensor:np.ndarray, top_k:int = 5):
|
||||
"""
|
||||
Posprocess model results. This function applied sofrmax on output tensor and returns specified top_k number of labels with highest probability
|
||||
Parameters:
|
||||
output_tensor (np.ndarray): model output tensor with probabilities
|
||||
top_k (int, *optional*, default 5): number of labels with highest probability for return
|
||||
Returns:
|
||||
topk_labels: label ids for selected top_k scores
|
||||
topk_scores: selected top_k highest scores predicted by model
|
||||
"""
|
||||
softmaxed_scores = softmax(output_tensor, -1)[0]
|
||||
topk_labels = np.argsort(softmaxed_scores)[-top_k:][::-1]
|
||||
topk_scores = softmaxed_scores[topk_labels]
|
||||
return topk_labels, topk_scores
|
||||
|
||||
# Postprocess results
|
||||
top_labels, top_scores = postprocess_result(result.detach().numpy())
|
||||
|
||||
# Show results
|
||||
display(image)
|
||||
for idx, (label, score) in enumerate(zip(top_labels, top_scores)):
|
||||
_, predicted_label = imagenet_classes[label].split(" ", 1)
|
||||
print(f"{idx + 1}: {predicted_label} - {score * 100 :.2f}%")
|
||||
|
||||
|
||||
|
||||
.. image:: 102-pytorch-to-openvino-with-output_files/102-pytorch-to-openvino-with-output_11_0.png
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
1: tiger cat - 25.91%
|
||||
2: Egyptian cat - 10.26%
|
||||
3: computer keyboard, keypad - 9.22%
|
||||
4: tabby, tabby cat - 9.09%
|
||||
5: hamper - 2.35%
|
||||
|
||||
|
||||
Benchmark PyTorch Model Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%%timeit
|
||||
|
||||
# Run model inference
|
||||
model(input_tensor)
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
17.5 ms ± 9.66 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
|
||||
|
||||
|
||||
Convert PyTorch Model to OpenVINO Intermediate Representation
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
|
||||
Starting from the 2023.0 release OpenVINO supports direct PyTorch models
|
||||
conversion to OpenVINO Intermediate Representation (IR) format. OpenVINO
|
||||
model conversion API should be used for these purposes. More details
|
||||
regarding PyTorch model conversion can be found in OpenVINO
|
||||
`documentation <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_PyTorch.html>`__
|
||||
|
||||
**Note**: Please, take into account that direct support PyTorch
|
||||
models conversion is an experimental feature. Model coverage will be
|
||||
increased in the next releases. For cases, when PyTorch model
|
||||
conversion failed, you still can try to export the model to ONNX
|
||||
format. Please refer to this
|
||||
`tutorial <102-pytorch-to-openvino-with-output.html>`__
|
||||
which explains how to convert PyTorch model to ONNX, then to OpenVINO
|
||||
|
||||
The ``convert_model`` function accepts the PyTorch model object and
|
||||
returns the ``openvino.Model`` instance ready to load on a device using
|
||||
``core.compile_model`` or save on disk for next usage using
|
||||
``ov.save_model``. Optionally, we can provide additional parameters,
|
||||
such as:
|
||||
|
||||
- ``compress_to_fp16`` - flag to perform model weights compression into
|
||||
FP16 data format. It may reduce the required space for model storage
|
||||
on disk and give speedup for inference devices, where FP16
|
||||
calculation is supported.
|
||||
- ``example_input`` - input data sample which can be used for model
|
||||
tracing.
|
||||
- ``input_shape`` - the shape of input tensor for conversion
|
||||
|
||||
and any other advanced options supported by model conversion Python API.
|
||||
More details can be found on this
|
||||
`page <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html>`__
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import openvino as ov
|
||||
|
||||
# Create OpenVINO Core object instance
|
||||
core = ov.Core()
|
||||
|
||||
# Convert model to openvino.runtime.Model object
|
||||
ov_model = ov.convert_model(model)
|
||||
|
||||
# Save openvino.runtime.Model object on disk
|
||||
ov.save_model(ov_model, MODEL_DIR / f"{MODEL_NAME}_dynamic.xml")
|
||||
|
||||
ov_model
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<Model: 'Model30'
|
||||
inputs[
|
||||
<ConstOutput: names[x] shape[?,3,?,?] type: f32>
|
||||
]
|
||||
outputs[
|
||||
<ConstOutput: names[x.21] shape[?,1000] type: f32>
|
||||
]>
|
||||
|
||||
|
||||
|
||||
Select inference device
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import ipywidgets as widgets
|
||||
|
||||
device = widgets.Dropdown(
|
||||
options=core.available_devices + ["AUTO"],
|
||||
value='AUTO',
|
||||
description='Device:',
|
||||
disabled=False,
|
||||
)
|
||||
|
||||
device
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Dropdown(description='Device:', index=1, options=('CPU', 'AUTO'), value='AUTO')
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Load OpenVINO model on device
|
||||
compiled_model = core.compile_model(ov_model, device.value)
|
||||
compiled_model
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<CompiledModel:
|
||||
inputs[
|
||||
<ConstOutput: names[x] shape[?,3,?,?] type: f32>
|
||||
]
|
||||
outputs[
|
||||
<ConstOutput: names[x.21] shape[?,1000] type: f32>
|
||||
]>
|
||||
|
||||
|
||||
|
||||
Run OpenVINO Model Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Run model inference
|
||||
result = compiled_model(input_tensor)[0]
|
||||
|
||||
# Posptorcess results
|
||||
top_labels, top_scores = postprocess_result(result)
|
||||
|
||||
# Show results
|
||||
display(image)
|
||||
for idx, (label, score) in enumerate(zip(top_labels, top_scores)):
|
||||
_, predicted_label = imagenet_classes[label].split(" ", 1)
|
||||
print(f"{idx + 1}: {predicted_label} - {score * 100 :.2f}%")
|
||||
|
||||
|
||||
|
||||
.. image:: 102-pytorch-to-openvino-with-output_files/102-pytorch-to-openvino-with-output_20_0.png
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
1: tiger cat - 25.91%
|
||||
2: Egyptian cat - 10.26%
|
||||
3: computer keyboard, keypad - 9.22%
|
||||
4: tabby, tabby cat - 9.09%
|
||||
5: hamper - 2.35%
|
||||
|
||||
|
||||
Benchmark OpenVINO Model Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%%timeit
|
||||
|
||||
compiled_model(input_tensor)
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
3.21 ms ± 12 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
|
||||
|
||||
|
||||
Convert PyTorch Model with Static Input Shape
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
The default conversion path preserves dynamic input shapes, in order if
|
||||
you want to convert the model with static shapes, you can explicitly
|
||||
specify it during conversion using the ``input_shape`` parameter or
|
||||
reshape the model into the desired shape after conversion. For the model
|
||||
reshaping example please check the following
|
||||
`tutorial <002-openvino-api-with-output.html>`__.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Convert model to openvino.runtime.Model object
|
||||
ov_model = ov.convert_model(model, input=[[1,3,224,224]])
|
||||
# Save openvino.runtime.Model object on disk
|
||||
ov.save_model(ov_model, MODEL_DIR / f"{MODEL_NAME}_static.xml")
|
||||
ov_model
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<Model: 'Model68'
|
||||
inputs[
|
||||
<ConstOutput: names[x] shape[1,3,224,224] type: f32>
|
||||
]
|
||||
outputs[
|
||||
<ConstOutput: names[x.21] shape[1,1000] type: f32>
|
||||
]>
|
||||
|
||||
|
||||
|
||||
Select inference device
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
device
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Dropdown(description='Device:', index=1, options=('CPU', 'AUTO'), value='AUTO')
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Load OpenVINO model on device
|
||||
compiled_model = core.compile_model(ov_model, device.value)
|
||||
compiled_model
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<CompiledModel:
|
||||
inputs[
|
||||
<ConstOutput: names[x] shape[1,3,224,224] type: f32>
|
||||
]
|
||||
outputs[
|
||||
<ConstOutput: names[x.21] shape[1,1000] type: f32>
|
||||
]>
|
||||
|
||||
|
||||
|
||||
Now, we can see that input of our converted model is tensor of shape [1,
|
||||
3, 224, 224] instead of [?, 3, ?, ?] reported by previously converted
|
||||
model.
|
||||
|
||||
Run OpenVINO Model Inference with Static Input Shape
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Run model inference
|
||||
result = compiled_model(input_tensor)[0]
|
||||
|
||||
# Posptorcess results
|
||||
top_labels, top_scores = postprocess_result(result)
|
||||
|
||||
# Show results
|
||||
display(image)
|
||||
for idx, (label, score) in enumerate(zip(top_labels, top_scores)):
|
||||
_, predicted_label = imagenet_classes[label].split(" ", 1)
|
||||
print(f"{idx + 1}: {predicted_label} - {score * 100 :.2f}%")
|
||||
|
||||
|
||||
|
||||
.. image:: 102-pytorch-to-openvino-with-output_files/102-pytorch-to-openvino-with-output_31_0.png
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
1: tiger cat - 25.91%
|
||||
2: Egyptian cat - 10.26%
|
||||
3: computer keyboard, keypad - 9.22%
|
||||
4: tabby, tabby cat - 9.09%
|
||||
5: hamper - 2.35%
|
||||
|
||||
|
||||
Benchmark OpenVINO Model Inference with Static Input Shape
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%%timeit
|
||||
|
||||
compiled_model(input_tensor)
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2.79 ms ± 12 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
|
||||
|
||||
|
||||
Convert TorchScript Model to OpenVINO Intermediate Representation
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
TorchScript is a way to create serializable and optimizable models from
|
||||
PyTorch code. Any TorchScript program can be saved from a Python process
|
||||
and loaded in a process where there is no Python dependency. More
|
||||
details about TorchScript can be found in `PyTorch
|
||||
documentation <https://pytorch.org/docs/stable/jit.html>`__.
|
||||
|
||||
There are 2 possible ways to convert the PyTorch model to TorchScript:
|
||||
|
||||
- ``torch.jit.script`` - Scripting a function or ``nn.Module`` will
|
||||
inspect the source code, compile it as TorchScript code using the
|
||||
TorchScript compiler, and return a ``ScriptModule`` or
|
||||
``ScriptFunction``.
|
||||
- ``torch.jit.trace`` - Trace a function and return an executable or
|
||||
``ScriptFunction`` that will be optimized using just-in-time
|
||||
compilation.
|
||||
|
||||
Let’s consider both approaches and their conversion into OpenVINO IR.
|
||||
|
||||
Scripted Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``torch.jit.script`` inspects model source code and compiles it to
|
||||
``ScriptModule``. After compilation model can be used for inference or
|
||||
saved on disk using the ``torch.jit.save`` function and after that
|
||||
restored with ``torch.jit.load`` in any other environment without the
|
||||
original PyTorch model code definitions.
|
||||
|
||||
TorchScript itself is a subset of the Python language, so not all
|
||||
features in Python work, but TorchScript provides enough functionality
|
||||
to compute on tensors and do control-dependent operations. For a
|
||||
complete guide, see the `TorchScript Language
|
||||
Reference <https://pytorch.org/docs/stable/jit_language_reference.html#language-reference>`__.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Get model path
|
||||
scripted_model_path = MODEL_DIR / f"{MODEL_NAME}_scripted.pth"
|
||||
|
||||
# Compile and save model if it has not been compiled before or load compiled model
|
||||
if not scripted_model_path.exists():
|
||||
scripted_model = torch.jit.script(model)
|
||||
torch.jit.save(scripted_model, scripted_model_path)
|
||||
else:
|
||||
scripted_model = torch.jit.load(scripted_model_path)
|
||||
|
||||
# Run scripted model inference
|
||||
result = scripted_model(input_tensor)
|
||||
|
||||
# Postprocess results
|
||||
top_labels, top_scores = postprocess_result(result.detach().numpy())
|
||||
|
||||
# Show results
|
||||
display(image)
|
||||
for idx, (label, score) in enumerate(zip(top_labels, top_scores)):
|
||||
_, predicted_label = imagenet_classes[label].split(" ", 1)
|
||||
print(f"{idx + 1}: {predicted_label} - {score * 100 :.2f}%")
|
||||
|
||||
|
||||
|
||||
.. image:: 102-pytorch-to-openvino-with-output_files/102-pytorch-to-openvino-with-output_35_0.png
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
1: tiger cat - 25.91%
|
||||
2: Egyptian cat - 10.26%
|
||||
3: computer keyboard, keypad - 9.22%
|
||||
4: tabby, tabby cat - 9.09%
|
||||
5: hamper - 2.35%
|
||||
|
||||
|
||||
Benchmark Scripted Model Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%%timeit
|
||||
|
||||
scripted_model(input_tensor)
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
12.9 ms ± 9.28 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
|
||||
|
||||
|
||||
Convert PyTorch Scripted Model to OpenVINO Intermediate Representation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The conversion step for the scripted model to OpenVINO IR is similar to
|
||||
the original PyTorch model.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Convert model to openvino.runtime.Model object
|
||||
ov_model = ov.convert_model(scripted_model)
|
||||
|
||||
# Load OpenVINO model on device
|
||||
compiled_model = core.compile_model(ov_model, device.value)
|
||||
|
||||
# Run OpenVINO model inference
|
||||
result = compiled_model(input_tensor, device.value)[0]
|
||||
|
||||
# Postprocess results
|
||||
top_labels, top_scores = postprocess_result(result)
|
||||
|
||||
# Show results
|
||||
display(image)
|
||||
for idx, (label, score) in enumerate(zip(top_labels, top_scores)):
|
||||
_, predicted_label = imagenet_classes[label].split(" ", 1)
|
||||
print(f"{idx + 1}: {predicted_label} - {score * 100 :.2f}%")
|
||||
|
||||
|
||||
|
||||
.. image:: 102-pytorch-to-openvino-with-output_files/102-pytorch-to-openvino-with-output_39_0.png
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
1: tiger cat - 25.91%
|
||||
2: Egyptian cat - 10.26%
|
||||
3: computer keyboard, keypad - 9.22%
|
||||
4: tabby, tabby cat - 9.09%
|
||||
5: hamper - 2.35%
|
||||
|
||||
|
||||
Benchmark OpenVINO Model Inference Converted From Scripted Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%%timeit
|
||||
|
||||
compiled_model(input_tensor)
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
3.21 ms ± 17.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
|
||||
|
||||
|
||||
Traced Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Using ``torch.jit.trace``, you can turn an existing module or Python
|
||||
function into a TorchScript ``ScriptFunction`` or ``ScriptModule``. You
|
||||
must provide example inputs, and model will be executed, recording the
|
||||
operations performed on all the tensors.
|
||||
|
||||
- The resulting recording of a standalone function produces
|
||||
``ScriptFunction``.
|
||||
|
||||
- The resulting recording of ``nn.Module.forward`` or ``nn.Module``
|
||||
produces ``ScriptModule``.
|
||||
|
||||
In the same way like scripted model, traced model can be used for
|
||||
inference or saved on disk using ``torch.jit.save`` function and after
|
||||
that restored with ``torch.jit.load`` in any other environment without
|
||||
original PyTorch model code definitions.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Get model path
|
||||
traced_model_path = MODEL_DIR / f"{MODEL_NAME}_traced.pth"
|
||||
|
||||
# Trace and save model if it has not been traced before or load traced model
|
||||
if not traced_model_path.exists():
|
||||
traced_model = torch.jit.trace(model, example_inputs=input_tensor)
|
||||
torch.jit.save(traced_model, traced_model_path)
|
||||
else:
|
||||
traced_model = torch.jit.load(traced_model_path)
|
||||
|
||||
# Run traced model inference
|
||||
result = traced_model(input_tensor)
|
||||
|
||||
# Postprocess results
|
||||
top_labels, top_scores = postprocess_result(result.detach().numpy())
|
||||
|
||||
# Show results
|
||||
display(image)
|
||||
for idx, (label, score) in enumerate(zip(top_labels, top_scores)):
|
||||
_, predicted_label = imagenet_classes[label].split(" ", 1)
|
||||
print(f"{idx + 1}: {predicted_label} - {score * 100 :.2f}%")
|
||||
|
||||
|
||||
|
||||
.. image:: 102-pytorch-to-openvino-with-output_files/102-pytorch-to-openvino-with-output_43_0.png
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
1: tiger cat - 25.91%
|
||||
2: Egyptian cat - 10.26%
|
||||
3: computer keyboard, keypad - 9.22%
|
||||
4: tabby, tabby cat - 9.09%
|
||||
5: hamper - 2.35%
|
||||
|
||||
|
||||
Benchmark Traced Model Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%%timeit
|
||||
|
||||
traced_model(input_tensor)
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
13.4 ms ± 22.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
|
||||
|
||||
|
||||
Convert PyTorch Traced Model to OpenVINO Intermediate Representation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The conversion step for a traced model to OpenVINO IR is similar to the
|
||||
original PyTorch model.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# Convert model to openvino.runtime.Model object
|
||||
ov_model = ov.convert_model(traced_model)
|
||||
|
||||
# Load OpenVINO model on device
|
||||
compiled_model = core.compile_model(ov_model, device.value)
|
||||
|
||||
# Run OpenVINO model inference
|
||||
result = compiled_model(input_tensor)[0]
|
||||
|
||||
# Postprocess results
|
||||
top_labels, top_scores = postprocess_result(result)
|
||||
|
||||
# Show results
|
||||
display(image)
|
||||
for idx, (label, score) in enumerate(zip(top_labels, top_scores)):
|
||||
_, predicted_label = imagenet_classes[label].split(" ", 1)
|
||||
print(f"{idx + 1}: {predicted_label} - {score * 100 :.2f}%")
|
||||
|
||||
|
||||
|
||||
.. image:: 102-pytorch-to-openvino-with-output_files/102-pytorch-to-openvino-with-output_47_0.png
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
1: tiger cat - 25.91%
|
||||
2: Egyptian cat - 10.26%
|
||||
3: computer keyboard, keypad - 9.22%
|
||||
4: tabby, tabby cat - 9.09%
|
||||
5: hamper - 2.35%
|
||||
|
||||
|
||||
Benchmark OpenVINO Model Inference Converted From Traced Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%%timeit
|
||||
|
||||
compiled_model(input_tensor)[0]
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2.82 ms ± 8.37 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/102-pytorch-to-openvino-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/102-pytorch-to-openvino-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/102-pytorch-to-openvino-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="102-pytorch-to-openvino-with-output_11_0.jpg">102-pytorch-to-openvino-with-output_11_0.jpg</a> 31-Oct-2023 00:35 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_11_0.png">102-pytorch-to-openvino-with-output_11_0.png</a> 31-Oct-2023 00:35 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_20_0.jpg">102-pytorch-to-openvino-with-output_20_0.jpg</a> 31-Oct-2023 00:35 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_20_0.png">102-pytorch-to-openvino-with-output_20_0.png</a> 31-Oct-2023 00:35 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_31_0.jpg">102-pytorch-to-openvino-with-output_31_0.jpg</a> 31-Oct-2023 00:35 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_31_0.png">102-pytorch-to-openvino-with-output_31_0.png</a> 31-Oct-2023 00:35 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_35_0.jpg">102-pytorch-to-openvino-with-output_35_0.jpg</a> 31-Oct-2023 00:35 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_35_0.png">102-pytorch-to-openvino-with-output_35_0.png</a> 31-Oct-2023 00:35 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_39_0.jpg">102-pytorch-to-openvino-with-output_39_0.jpg</a> 31-Oct-2023 00:35 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_39_0.png">102-pytorch-to-openvino-with-output_39_0.png</a> 31-Oct-2023 00:35 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_43_0.jpg">102-pytorch-to-openvino-with-output_43_0.jpg</a> 31-Oct-2023 00:35 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_43_0.png">102-pytorch-to-openvino-with-output_43_0.png</a> 31-Oct-2023 00:35 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_47_0.jpg">102-pytorch-to-openvino-with-output_47_0.jpg</a> 31-Oct-2023 00:35 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_47_0.png">102-pytorch-to-openvino-with-output_47_0.png</a> 31-Oct-2023 00:35 542516
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/102-pytorch-to-openvino-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="102-pytorch-to-openvino-with-output_11_0.jpg">102-pytorch-to-openvino-with-output_11_0.jpg</a> 07-Dec-2023 00:49 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_11_0.png">102-pytorch-to-openvino-with-output_11_0.png</a> 07-Dec-2023 00:49 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_20_0.jpg">102-pytorch-to-openvino-with-output_20_0.jpg</a> 07-Dec-2023 00:49 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_20_0.png">102-pytorch-to-openvino-with-output_20_0.png</a> 07-Dec-2023 00:49 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_31_0.jpg">102-pytorch-to-openvino-with-output_31_0.jpg</a> 07-Dec-2023 00:49 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_31_0.png">102-pytorch-to-openvino-with-output_31_0.png</a> 07-Dec-2023 00:49 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_35_0.jpg">102-pytorch-to-openvino-with-output_35_0.jpg</a> 07-Dec-2023 00:49 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_35_0.png">102-pytorch-to-openvino-with-output_35_0.png</a> 07-Dec-2023 00:49 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_39_0.jpg">102-pytorch-to-openvino-with-output_39_0.jpg</a> 07-Dec-2023 00:49 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_39_0.png">102-pytorch-to-openvino-with-output_39_0.png</a> 07-Dec-2023 00:49 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_43_0.jpg">102-pytorch-to-openvino-with-output_43_0.jpg</a> 07-Dec-2023 00:49 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_43_0.png">102-pytorch-to-openvino-with-output_43_0.png</a> 07-Dec-2023 00:49 542516
|
||||
<a href="102-pytorch-to-openvino-with-output_47_0.jpg">102-pytorch-to-openvino-with-output_47_0.jpg</a> 07-Dec-2023 00:49 54874
|
||||
<a href="102-pytorch-to-openvino-with-output_47_0.png">102-pytorch-to-openvino-with-output_47_0.png</a> 07-Dec-2023 00:49 542516
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -33,42 +33,35 @@ Source of the
|
||||
- `Select inference device <#select-inference-device>`__
|
||||
- `References <#references>`__
|
||||
|
||||
Preparation
|
||||
-----------------------------------------------------
|
||||
|
||||
Imports
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info.minor > 7:
|
||||
%pip install -q "paddlepaddle>=2.5.1"
|
||||
else:
|
||||
%pip install -q "paddlepaddle==2.4.2"
|
||||
Preparation
|
||||
-----------
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
Imports
|
||||
~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
!pip install -q paddleclas --no-deps
|
||||
!pip install -q "prettytable" "ujson" "visualdl>=2.2.0" "faiss-cpu>=1.7.1"
|
||||
%pip install -q "paddlepaddle>=2.5.1"
|
||||
%pip install -q paddleclas --no-deps
|
||||
%pip install -q "prettytable" "ujson" "visualdl>=2.2.0" "faiss-cpu>=1.7.1"
|
||||
# Install openvino package
|
||||
!pip install -q "openvino>=2023.1.0"
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
|
||||
paddleclas 2.5.1 requires easydict, which is not installed.
|
||||
paddleclas 2.5.1 requires faiss-cpu==1.7.1.post2, but you have faiss-cpu 1.7.4 which is incompatible.
|
||||
paddleclas 2.5.1 requires gast==0.3.3, but you have gast 0.4.0 which is incompatible.
|
||||
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -81,11 +74,11 @@ Imports
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
--2023-10-30 22:31:22-- http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb
|
||||
--2023-12-06 22:32:58-- http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb
|
||||
Resolving proxy-mu.intel.com (proxy-mu.intel.com)... 10.217.247.236
|
||||
Connecting to proxy-mu.intel.com (proxy-mu.intel.com)|10.217.247.236|:911... connected.
|
||||
Proxy request sent, awaiting response... 404 Not Found
|
||||
2023-10-30 22:31:22 ERROR 404: Not Found.
|
||||
2023-12-06 22:32:59 ERROR 404: Not Found.
|
||||
|
||||
dpkg: error: cannot access archive 'libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb': No such file or directory
|
||||
|
||||
@@ -114,12 +107,14 @@ Imports
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-10-30 22:31:24 INFO: Loading faiss with AVX2 support.
|
||||
2023-10-30 22:31:24 INFO: Successfully loaded faiss with AVX2 support.
|
||||
2023-12-06 22:33:00 INFO: Loading faiss with AVX2 support.
|
||||
2023-12-06 22:33:00 INFO: Successfully loaded faiss with AVX2 support.
|
||||
|
||||
|
||||
Settings
|
||||
~~~~~~~~
|
||||
|
||||
|
||||
Settings
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Set ``IMAGE_FILENAME`` to the filename of an image to use. Set
|
||||
``MODEL_NAME`` to the PaddlePaddle model to download from PaddleHub.
|
||||
@@ -175,8 +170,10 @@ PaddleHub. This may take a while.
|
||||
Model Extracted to "./model".
|
||||
|
||||
|
||||
Show Inference on PaddlePaddle Model
|
||||
------------------------------------------------------------------------------
|
||||
Show Inference on PaddlePaddle Model
|
||||
------------------------------------
|
||||
|
||||
|
||||
|
||||
In the next cell, we load the model, load and display an image, do
|
||||
inference on that image, and then show the top three prediction results.
|
||||
@@ -195,7 +192,7 @@ inference on that image, and then show the top three prediction results.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
[2023/10/30 22:31:43] ppcls WARNING: The current running environment does not support the use of GPU. CPU has been used instead.
|
||||
[2023/12/06 22:33:21] ppcls WARNING: The current running environment does not support the use of GPU. CPU has been used instead.
|
||||
Labrador retriever, 0.75138
|
||||
German short-haired pointer, 0.02373
|
||||
Great Dane, 0.01848
|
||||
@@ -204,7 +201,7 @@ inference on that image, and then show the top three prediction results.
|
||||
|
||||
|
||||
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_9_1.png
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_8_1.png
|
||||
|
||||
|
||||
``classifier.predict()`` takes an image file name, reads the image,
|
||||
@@ -259,26 +256,26 @@ clipping values.
|
||||
plt.imshow(np.transpose(processed_image, (1, 2, 0)))
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-12-06 22:33:22 WARNING: Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Processed image shape: (3, 224, 224)
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-10-30 22:31:44 WARNING: Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<matplotlib.image.AxesImage at 0x7f66f82966d0>
|
||||
<matplotlib.image.AxesImage at 0x7efc106a1910>
|
||||
|
||||
|
||||
|
||||
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_16_3.png
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_15_3.png
|
||||
|
||||
|
||||
To decode the labels predicted by the model to names of classes, we need
|
||||
@@ -297,8 +294,10 @@ OpenVINO model.
|
||||
partition = line.split("\n")[0].partition(" ")
|
||||
class_id_map[int(partition[0])] = str(partition[-1])
|
||||
|
||||
Convert the Model to OpenVINO IR Format
|
||||
---------------------------------------------------------------------------------
|
||||
Convert the Model to OpenVINO IR Format
|
||||
---------------------------------------
|
||||
|
||||
|
||||
|
||||
Call the OpenVINO Model Conversion API to convert the PaddlePaddle model
|
||||
to OpenVINO IR, with FP32 precision. ``ov.convert_model`` function
|
||||
@@ -318,8 +317,10 @@ for more information about the Model Conversion API.
|
||||
else:
|
||||
print(f"{model_xml} already exists.")
|
||||
|
||||
Select inference device
|
||||
-----------------------------------------------------------------
|
||||
Select inference device
|
||||
-----------------------
|
||||
|
||||
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -346,8 +347,10 @@ select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
|
||||
|
||||
Show Inference on OpenVINO Model
|
||||
--------------------------------------------------------------------------
|
||||
Show Inference on OpenVINO Model
|
||||
--------------------------------
|
||||
|
||||
|
||||
|
||||
Load the IR model, get model information, load the image, do inference,
|
||||
convert the inference to a meaningful result, and show the output. See
|
||||
@@ -391,11 +394,13 @@ information.
|
||||
|
||||
|
||||
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_24_1.png
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_23_1.png
|
||||
|
||||
|
||||
Timing and Comparison
|
||||
---------------------
|
||||
|
||||
|
||||
Timing and Comparison
|
||||
---------------------------------------------------------------
|
||||
|
||||
Measure the time it takes to do inference on fifty images and compare
|
||||
the result. The timing information gives an indication of performance.
|
||||
@@ -448,7 +453,7 @@ Note that many optimizations are possible to improve the performance.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PaddlePaddle model on CPU: 0.0071 seconds per image, FPS: 141.73
|
||||
PaddlePaddle model on CPU: 0.0070 seconds per image, FPS: 142.41
|
||||
|
||||
PaddlePaddle result:
|
||||
Labrador retriever, 0.75138
|
||||
@@ -459,11 +464,13 @@ Note that many optimizations are possible to improve the performance.
|
||||
|
||||
|
||||
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_28_1.png
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_27_1.png
|
||||
|
||||
|
||||
Select inference device
|
||||
-----------------------
|
||||
|
||||
|
||||
Select inference device
|
||||
-----------------------------------------------------------------
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -510,7 +517,7 @@ select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO IR model in OpenVINO Runtime (AUTO): 0.0030 seconds per image, FPS: 328.24
|
||||
OpenVINO IR model in OpenVINO Runtime (AUTO): 0.0028 seconds per image, FPS: 352.29
|
||||
|
||||
OpenVINO result:
|
||||
Labrador retriever, 0.74909
|
||||
@@ -521,11 +528,13 @@ select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
|
||||
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_31_1.png
|
||||
.. image:: 103-paddle-to-openvino-classification-with-output_files/103-paddle-to-openvino-classification-with-output_30_1.png
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
|
||||
References
|
||||
----------------------------------------------------
|
||||
|
||||
- `PaddleClas <https://github.com/PaddlePaddle/PaddleClas>`__
|
||||
- `OpenVINO PaddlePaddle
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:37fe65815997e6f67c6a635a98caf7ad3d5066aee57709f650fe8ef4c8bdfe11
|
||||
size 120883
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:306bb006db6e8ef4b71e12f1007cf62a782408867b1c5e2af981d0dcde7d50e7
|
||||
size 120883
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:22866fa0a0a063c7772d4a884812ca79fb0737c1eb2281bc825ee18eded729c5
|
||||
size 224886
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:aaa7ff0a118fe7ac95479e0467f34f793d1013d972c5c850c610e39f6983ee3c
|
||||
size 224886
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:22866fa0a0a063c7772d4a884812ca79fb0737c1eb2281bc825ee18eded729c5
|
||||
size 224886
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:aaa7ff0a118fe7ac95479e0467f34f793d1013d972c5c850c610e39f6983ee3c
|
||||
size 224886
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:22866fa0a0a063c7772d4a884812ca79fb0737c1eb2281bc825ee18eded729c5
|
||||
size 224886
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:aaa7ff0a118fe7ac95479e0467f34f793d1013d972c5c850c610e39f6983ee3c
|
||||
size 224886
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:22866fa0a0a063c7772d4a884812ca79fb0737c1eb2281bc825ee18eded729c5
|
||||
size 224886
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:aaa7ff0a118fe7ac95479e0467f34f793d1013d972c5c850c610e39f6983ee3c
|
||||
size 224886
|
||||
@@ -1,11 +1,11 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/103-paddle-to-openvino-classification-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/103-paddle-to-openvino-classification-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/103-paddle-to-openvino-classification-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="103-paddle-to-openvino-classification-with-output_16_3.png">103-paddle-to-openvino-classification-with-outp..></a> 31-Oct-2023 00:35 120883
|
||||
<a href="103-paddle-to-openvino-classification-with-output_24_1.png">103-paddle-to-openvino-classification-with-outp..></a> 31-Oct-2023 00:35 224886
|
||||
<a href="103-paddle-to-openvino-classification-with-output_28_1.png">103-paddle-to-openvino-classification-with-outp..></a> 31-Oct-2023 00:35 224886
|
||||
<a href="103-paddle-to-openvino-classification-with-output_31_1.png">103-paddle-to-openvino-classification-with-outp..></a> 31-Oct-2023 00:35 224886
|
||||
<a href="103-paddle-to-openvino-classification-with-output_9_1.png">103-paddle-to-openvino-classification-with-outp..></a> 31-Oct-2023 00:35 224886
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/103-paddle-to-openvino-classification-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="103-paddle-to-openvino-classification-with-output_15_3.png">103-paddle-to-openvino-classification-with-outp..></a> 07-Dec-2023 00:49 120883
|
||||
<a href="103-paddle-to-openvino-classification-with-output_23_1.png">103-paddle-to-openvino-classification-with-outp..></a> 07-Dec-2023 00:49 224886
|
||||
<a href="103-paddle-to-openvino-classification-with-output_27_1.png">103-paddle-to-openvino-classification-with-outp..></a> 07-Dec-2023 00:49 224886
|
||||
<a href="103-paddle-to-openvino-classification-with-output_30_1.png">103-paddle-to-openvino-classification-with-outp..></a> 07-Dec-2023 00:49 224886
|
||||
<a href="103-paddle-to-openvino-classification-with-output_8_1.png">103-paddle-to-openvino-classification-with-outp..></a> 07-Dec-2023 00:49 224886
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -31,8 +31,7 @@ and datasets. It consists of the following steps:
|
||||
- `Prepare the Dataset <#prepare-the-dataset>`__
|
||||
- `Optimize model using NNCF Post-training Quantization
|
||||
API <#optimize-model-using-nncf-post-training-quantization-api>`__
|
||||
- `Load and Test OpenVINO
|
||||
Model <#load-and-test-openvino-model>`__
|
||||
- `Load and Test OpenVINO Model <#load-and-test-openvino-model>`__
|
||||
|
||||
- `Select inference device <#select-inference-device>`__
|
||||
|
||||
@@ -44,7 +43,7 @@ and datasets. It consists of the following steps:
|
||||
.. code:: ipython3
|
||||
|
||||
%pip install -q "nncf>=2.5.0"
|
||||
%pip install -q "transformers" datasets evaluate
|
||||
%pip install -q "transformers" datasets evaluate --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
%pip install -q "openvino>=2023.1.0"
|
||||
|
||||
|
||||
@@ -55,8 +54,10 @@ and datasets. It consists of the following steps:
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
Imports
|
||||
-------------------------------------------------
|
||||
Imports
|
||||
-------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -87,10 +88,10 @@ Imports
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-10-30 22:33:08.247649: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-10-30 22:33:08.281400: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
2023-12-06 22:34:55.977192: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-12-06 22:34:56.010680: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
|
||||
2023-10-30 22:33:08.912908: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
2023-12-06 22:34:56.639162: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -98,8 +99,10 @@ Imports
|
||||
INFO:nncf:NNCF initialized successfully. Supported frameworks detected: torch, tensorflow, onnx, openvino
|
||||
|
||||
|
||||
Settings
|
||||
--------------------------------------------------
|
||||
Settings
|
||||
--------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -113,8 +116,10 @@ Settings
|
||||
os.makedirs(DATA_DIR, exist_ok=True)
|
||||
os.makedirs(MODEL_DIR, exist_ok=True)
|
||||
|
||||
Prepare the Model
|
||||
-----------------------------------------------------------
|
||||
Prepare the Model
|
||||
-----------------
|
||||
|
||||
|
||||
|
||||
Perform the following:
|
||||
|
||||
@@ -180,22 +185,13 @@ PyTorch model formats are supported:
|
||||
.. parsed-literal::
|
||||
|
||||
[ WARNING ] Please fix your imports. Module %s has been moved to %s. The old module will be deleted in version %s.
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
WARNING:nncf:NNCF provides best results with torch==2.0.1, while current torch version is 2.1.0+cpu. If you encounter issues, consider switching to torch==2.0.1
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/torch/jit/annotations.py:386: UserWarning: TorchScript will treat type annotations of Tensor dtype-specific subtypes as if they are normal Tensors. dtype constraints are not enforced in compilation either.
|
||||
warnings.warn(
|
||||
|
||||
|
||||
Prepare the Dataset
|
||||
-------------------------------------------------------------
|
||||
Prepare the Dataset
|
||||
-------------------
|
||||
|
||||
|
||||
|
||||
We download the `General Language Understanding Evaluation
|
||||
(GLUE) <https://gluebenchmark.com/>`__ dataset for the MRPC task from
|
||||
@@ -219,15 +215,10 @@ tokenizer from HuggingFace.
|
||||
|
||||
data_source = create_data_source()
|
||||
|
||||
Optimize model using NNCF Post-training Quantization API
|
||||
--------------------------------------------------------
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Map: 0%| | 0/408 [00:00<?, ? examples/s]
|
||||
|
||||
|
||||
Optimize model using NNCF Post-training Quantization API
|
||||
--------------------------------------------------------------------------------------------------
|
||||
|
||||
`NNCF <https://github.com/openvinotoolkit/nncf>`__ provides a suite of
|
||||
advanced algorithms for Neural Networks inference optimization in
|
||||
@@ -261,21 +252,93 @@ The optimization process contains the following steps:
|
||||
model_type=ModelType.TRANSFORMER)
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Statistics collection: 100%|██████████| 300/300 [00:07<00:00, 39.50it/s]
|
||||
Applying Smooth Quant: 100%|██████████| 50/50 [00:00<00:00, 51.91it/s]
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
INFO:nncf:36 ignored nodes was found by name in the NNCFGraph
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Statistics collection: 100%|██████████| 300/300 [00:25<00:00, 11.96it/s]
|
||||
Applying Fast Bias correction: 100%|██████████| 74/74 [00:25<00:00, 2.93it/s]
|
||||
INFO:nncf:36 ignored nodes were found by name in the NNCFGraph
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -283,8 +346,10 @@ The optimization process contains the following steps:
|
||||
compressed_model_xml = Path(MODEL_DIR) / "quantized_bert_mrpc.xml"
|
||||
ov.save_model(quantized_model, compressed_model_xml)
|
||||
|
||||
Load and Test OpenVINO Model
|
||||
----------------------------------------------------------------------
|
||||
Load and Test OpenVINO Model
|
||||
----------------------------
|
||||
|
||||
|
||||
|
||||
To load and test converted model, perform the following:
|
||||
|
||||
@@ -293,8 +358,10 @@ To load and test converted model, perform the following:
|
||||
- Run the inference.
|
||||
- Get the answer from the model output.
|
||||
|
||||
Select inference device
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Select inference device
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -352,8 +419,10 @@ changing ``sample_idx`` to another value (from 0 to 407).
|
||||
The same meaning: yes
|
||||
|
||||
|
||||
Compare F1-score of FP32 and INT8 models
|
||||
----------------------------------------------------------------------------------
|
||||
Compare F1-score of FP32 and INT8 models
|
||||
----------------------------------------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -393,11 +462,13 @@ Compare F1-score of FP32 and INT8 models
|
||||
Checking the accuracy of the original model:
|
||||
F1 score: 0.9019
|
||||
Checking the accuracy of the quantized model:
|
||||
F1 score: 0.8985
|
||||
F1 score: 0.8969
|
||||
|
||||
|
||||
Compare Performance of the Original, Converted and Quantized Models
|
||||
-------------------------------------------------------------------
|
||||
|
||||
|
||||
Compare Performance of the Original, Converted and Quantized Models
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Compare the original PyTorch model with OpenVINO converted and quantized
|
||||
models (``FP32``, ``INT8``) to see the difference in performance. It is
|
||||
@@ -454,9 +525,9 @@ Frames Per Second (FPS) for images.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PyTorch model on CPU: 0.073 seconds per sentence, SPS: 13.72
|
||||
IR FP32 model in OpenVINO Runtime/AUTO: 0.022 seconds per sentence, SPS: 46.40
|
||||
OpenVINO IR INT8 model in OpenVINO Runtime/AUTO: 0.010 seconds per sentence, SPS: 98.65
|
||||
PyTorch model on CPU: 0.073 seconds per sentence, SPS: 13.77
|
||||
IR FP32 model in OpenVINO Runtime/AUTO: 0.021 seconds per sentence, SPS: 48.61
|
||||
OpenVINO IR INT8 model in OpenVINO Runtime/AUTO: 0.009 seconds per sentence, SPS: 109.06
|
||||
|
||||
|
||||
Finally, measure the inference performance of OpenVINO ``FP32`` and
|
||||
@@ -486,20 +557,21 @@ in OpenVINO.
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ WARNING ] Default duration 120 seconds is used for unknown device device.value
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ ERROR ] Exception from src/inference/src/core.cpp:84:
|
||||
Exception from src/inference/src/dev/core_impl.cpp:565:
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ ERROR ] Exception from src/inference/src/core.cpp:244:
|
||||
Exception from src/inference/src/dev/core_impl.cpp:559:
|
||||
Device with "device" name is not registered in the OpenVINO Runtime
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/main.py", line 102, in main
|
||||
benchmark.print_version_info()
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/benchmark.py", line 48, in print_version_info
|
||||
for device, version in self.core.get_versions(self.device).items():
|
||||
RuntimeError: Exception from src/inference/src/core.cpp:84:
|
||||
Exception from src/inference/src/dev/core_impl.cpp:565:
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/main.py", line 165, in main
|
||||
supported_properties = benchmark.core.get_property(device, properties.supported_properties())
|
||||
RuntimeError: Exception from src/inference/src/core.cpp:244:
|
||||
Exception from src/inference/src/dev/core_impl.cpp:559:
|
||||
Device with "device" name is not registered in the OpenVINO Runtime
|
||||
|
||||
|
||||
@@ -518,20 +590,21 @@ in OpenVINO.
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ WARNING ] Default duration 120 seconds is used for unknown device device.value
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ ERROR ] Exception from src/inference/src/core.cpp:84:
|
||||
Exception from src/inference/src/dev/core_impl.cpp:565:
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ ERROR ] Exception from src/inference/src/core.cpp:244:
|
||||
Exception from src/inference/src/dev/core_impl.cpp:559:
|
||||
Device with "device" name is not registered in the OpenVINO Runtime
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/main.py", line 102, in main
|
||||
benchmark.print_version_info()
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/benchmark.py", line 48, in print_version_info
|
||||
for device, version in self.core.get_versions(self.device).items():
|
||||
RuntimeError: Exception from src/inference/src/core.cpp:84:
|
||||
Exception from src/inference/src/dev/core_impl.cpp:565:
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/main.py", line 165, in main
|
||||
supported_properties = benchmark.core.get_property(device, properties.supported_properties())
|
||||
RuntimeError: Exception from src/inference/src/core.cpp:244:
|
||||
Exception from src/inference/src/dev/core_impl.cpp:559:
|
||||
Device with "device" name is not registered in the OpenVINO Runtime
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@ steps:
|
||||
Representation <#convert-model-to-openvino-intermediate-representation>`__
|
||||
- `Prepare inference data <#prepare-inference-data>`__
|
||||
|
||||
- `Check model inference
|
||||
result <#check-model-inference-result>`__
|
||||
- `Check model inference result <#check-model-inference-result>`__
|
||||
- `Validate model accuracy on
|
||||
dataset <#validate-model-accuracy-on-dataset>`__
|
||||
- `Quantization <#quantization>`__
|
||||
@@ -42,8 +41,10 @@ steps:
|
||||
- `Compare Accuracy of the Original and Quantized
|
||||
Models <#compare-accuracy-of-the-original-and-quantized-models>`__
|
||||
|
||||
Download and prepare model
|
||||
--------------------------------------------------------------------
|
||||
Download and prepare model
|
||||
--------------------------
|
||||
|
||||
|
||||
|
||||
data2vec is a framework for self-supervised representation learning for
|
||||
images, speech, and text as described in `data2vec: A General Framework
|
||||
@@ -61,8 +62,10 @@ In our case, we will use ``data2vec-audio-base-960h`` model, which was
|
||||
finetuned on 960 hours of audio from LibriSpeech Automatic Speech
|
||||
Recognition corpus and distributed as part of HuggingFace transformers.
|
||||
|
||||
Obtain Pytorch model representation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Obtain Pytorch model representation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
For instantiating PyTorch model class, we should use
|
||||
``Data2VecAudioForCTC.from_pretrained`` method with providing model ID
|
||||
@@ -77,8 +80,8 @@ model specific pre- and post-processing steps.
|
||||
.. code:: ipython3
|
||||
|
||||
%pip install -q "openvino>=2023.1.0" "nncf>=2.5.0"
|
||||
%pip install -q datasets "torchmetrics>=0.11.0"
|
||||
%pip install -q soundfile librosa transformers
|
||||
%pip install -q datasets "torchmetrics>=0.11.0" --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
%pip install -q soundfile librosa transformers --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -96,8 +99,10 @@ model specific pre- and post-processing steps.
|
||||
2023-09-12 19:27:58.411557: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
|
||||
|
||||
Convert model to OpenVINO Intermediate Representation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Convert model to OpenVINO Intermediate Representation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -133,8 +138,10 @@ Convert model to OpenVINO Intermediate Representation
|
||||
Read IR model from model/data2vec-audo-base.xml
|
||||
|
||||
|
||||
Prepare inference data
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Prepare inference data
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
For demonstration purposes, we will use short dummy version of
|
||||
LibriSpeech dataset - ``patrickvonplaten/librispeech_asr_dummy`` to
|
||||
@@ -169,8 +176,10 @@ dataset.
|
||||
Loading cached processed dataset at /home/ea/.cache/huggingface/datasets/patrickvonplaten___librispeech_asr_dummy/clean/2.1.0/f2c70a4d03ab4410954901bde48c54b85ca1b7f9bf7d616e7e2a72b5ee6ddbfc/cache-5282243604a7a526.arrow
|
||||
|
||||
|
||||
Check model inference result
|
||||
----------------------------------------------------------------------
|
||||
Check model inference result
|
||||
----------------------------
|
||||
|
||||
|
||||
|
||||
The code below is used for running model inference on a single sample
|
||||
from the dataset. It contains the following steps:
|
||||
@@ -242,8 +251,10 @@ For reference, see the same function provided for OpenVINO model.
|
||||
|
||||
|
||||
|
||||
Validate model accuracy on dataset
|
||||
----------------------------------------------------------------------------
|
||||
Validate model accuracy on dataset
|
||||
----------------------------------
|
||||
|
||||
|
||||
|
||||
For model accuracy evaluation, `Word Error
|
||||
Rate <https://en.wikipedia.org/wiki/Word_error_rate>`__ metric can be
|
||||
@@ -302,8 +313,10 @@ library.
|
||||
[OpenVino] Word Error Rate: 0.0383
|
||||
|
||||
|
||||
Quantization
|
||||
------------------------------------------------------
|
||||
Quantization
|
||||
------------
|
||||
|
||||
|
||||
|
||||
`NNCF <https://github.com/openvinotoolkit/nncf>`__ provides a suite of
|
||||
advanced algorithms for Neural Networks inference optimization in
|
||||
@@ -565,8 +578,10 @@ saved using ``ov.save_model`` function.
|
||||
quantized_model_path = Path(f"{MODEL_NAME}_openvino_model/{MODEL_NAME}_quantized.xml")
|
||||
ov.save_model(quantized_model, quantized_model_path)
|
||||
|
||||
Check INT8 model inference result
|
||||
---------------------------------------------------------------------------
|
||||
Check INT8 model inference result
|
||||
---------------------------------
|
||||
|
||||
|
||||
|
||||
``INT8`` model is the same in usage like the original one. We need to
|
||||
read it, using the ``core.read_model`` method and load on the device,
|
||||
@@ -604,8 +619,8 @@ using ``core.compile_model``. After that, we can reuse the same
|
||||
|
||||
|
||||
|
||||
Compare Performance of the Original and Quantized Models
|
||||
--------------------------------------------------------------------------------------------------
|
||||
Compare Performance of the Original and Quantized Models
|
||||
--------------------------------------------------------
|
||||
|
||||
`Benchmark
|
||||
Tool <https://docs.openvino.ai/latest/openvino_inference_engine_tools_benchmark_tool_README.html>`__
|
||||
@@ -771,8 +786,10 @@ is used to measure the inference performance of the ``FP16`` and
|
||||
[ INFO ] Throughput: 66.40 FPS
|
||||
|
||||
|
||||
Compare Accuracy of the Original and Quantized Models
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Compare Accuracy of the Original and Quantized Models
|
||||
-----------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Finally, calculate WER metric for the ``INT8`` model representation and
|
||||
compare it with the ``FP16`` result.
|
||||
|
||||
@@ -27,8 +27,8 @@ The quantization and pre-post-processing API are not included here as
|
||||
they change the precision (quantization) or processing graph
|
||||
(prepostprocessor). You can find examples of how to apply them to
|
||||
optimize performance on OpenVINO IR files in
|
||||
`111-detection-quantization <111-detection-quantization-with-output.html>`__ and
|
||||
`118-optimize-preprocessing <118-optimize-preprocessing-with-output.html>`__.
|
||||
`111-detection-quantization <../111-detection-quantization>`__ and
|
||||
`118-optimize-preprocessing <../118-optimize-preprocessing>`__.
|
||||
|
||||
|image0|
|
||||
|
||||
@@ -44,11 +44,12 @@ optimize performance on OpenVINO IR files in
|
||||
result in different performance.
|
||||
|
||||
A similar notebook focused on the throughput mode is available
|
||||
`here <109-throughput-tricks-with-output.html>`__.
|
||||
`here <109-throughput-tricks.ipynb>`__.
|
||||
|
||||
**Table of contents:**
|
||||
|
||||
|
||||
- `Prerequisites <#prerequisites>`__
|
||||
- `Data <#data>`__
|
||||
- `Model <#model>`__
|
||||
- `Hardware <#hardware>`__
|
||||
@@ -70,14 +71,16 @@ A similar notebook focused on the throughput mode is available
|
||||
- `Performance comparison <#performance-comparison>`__
|
||||
- `Conclusions <#conclusions>`__
|
||||
|
||||
.. |image0| image:: https://user-images.githubusercontent.com/4547501/229120774-01f4f972-424d-4280-8395-220dd432985a.png
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
.. |image0| image:: https://user-images.githubusercontent.com/4547501/229120774-01f4f972-424d-4280-8395-220dd432985a.png
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%pip install -q "openvino>=2023.1.0" seaborn "ultralytics<=8.0.178" onnx
|
||||
%pip install -q "openvino>=2023.1.0" seaborn "ultralytics<=8.0.178" onnx --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -100,8 +103,10 @@ Prerequisites
|
||||
)
|
||||
import notebook_utils as utils
|
||||
|
||||
Data
|
||||
----------------------------------------------
|
||||
Data
|
||||
----
|
||||
|
||||
|
||||
|
||||
We will use the same image of the dog sitting on a bicycle for all
|
||||
experiments below. The image is resized and preprocessed to fulfill the
|
||||
@@ -129,19 +134,21 @@ requirements of this particular object detection model.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_4_0.jpg
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_5_0.jpg
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<DisplayHandle display_id=29bc2ebf99dd5b1672fd79f927d2a7b4>
|
||||
<DisplayHandle display_id=e5b567bdbd103853038ec2c801bd914a>
|
||||
|
||||
|
||||
|
||||
Model
|
||||
-----------------------------------------------
|
||||
Model
|
||||
-----
|
||||
|
||||
|
||||
|
||||
We decided to go with
|
||||
`YOLOv5n <https://github.com/ultralytics/yolov5>`__, one of the
|
||||
@@ -181,15 +188,17 @@ PyTorch Hub and small enough to see the difference in performance.
|
||||
.. parsed-literal::
|
||||
|
||||
Downloading https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5n.pt to model/yolov5n.pt...
|
||||
100%|██████████| 3.87M/3.87M [00:01<00:00, 3.48MB/s]
|
||||
100%|██████████| 3.87M/3.87M [00:02<00:00, 1.50MB/s]
|
||||
|
||||
Fusing layers...
|
||||
YOLOv5n summary: 213 layers, 1867405 parameters, 0 gradients
|
||||
Adding AutoShape...
|
||||
|
||||
|
||||
Hardware
|
||||
--------------------------------------------------
|
||||
Hardware
|
||||
--------
|
||||
|
||||
|
||||
|
||||
The code below lists the available hardware we will use in the
|
||||
benchmarking process.
|
||||
@@ -215,8 +224,10 @@ benchmarking process.
|
||||
CPU: Intel(R) Core(TM) i9-10920X CPU @ 3.50GHz
|
||||
|
||||
|
||||
Helper functions
|
||||
----------------------------------------------------------
|
||||
Helper functions
|
||||
----------------
|
||||
|
||||
|
||||
|
||||
We’re defining a benchmark model function to use for all optimized
|
||||
models below. It runs inference 1000 times, averages the latency time,
|
||||
@@ -350,15 +361,19 @@ the image.
|
||||
|
||||
utils.show_array(output_img)
|
||||
|
||||
Optimizations
|
||||
-------------------------------------------------------
|
||||
Optimizations
|
||||
-------------
|
||||
|
||||
|
||||
|
||||
Below, we present the performance tricks for faster inference in the
|
||||
latency mode. We release resources after every benchmarking to be sure
|
||||
the same amount of resource is available for every experiment.
|
||||
|
||||
PyTorch model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
PyTorch model
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
First, we’re benchmarking the original PyTorch model without any
|
||||
optimizations applied. We will treat it as our baseline.
|
||||
@@ -374,17 +389,19 @@ optimizations applied. We will treat it as our baseline.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_14_0.jpg
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_15_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PyTorch model on CPU. First inference time: 0.0219 seconds
|
||||
PyTorch model on CPU: 0.0199 seconds per image (50.21 FPS)
|
||||
PyTorch model on CPU. First inference time: 0.0252 seconds
|
||||
PyTorch model on CPU: 0.0214 seconds per image (46.73 FPS)
|
||||
|
||||
|
||||
ONNX model
|
||||
~~~~~~~~~~
|
||||
|
||||
|
||||
ONNX model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The first optimization is exporting the PyTorch model to ONNX and
|
||||
running it in OpenVINO. It’s possible, thanks to the ONNX frontend. It
|
||||
@@ -423,17 +440,19 @@ Representation (IR) to leverage the OpenVINO Runtime.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_17_0.jpg
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_18_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
ONNX model on CPU. First inference time: 0.0172 seconds
|
||||
ONNX model on CPU: 0.0133 seconds per image (75.13 FPS)
|
||||
ONNX model on CPU. First inference time: 0.0186 seconds
|
||||
ONNX model on CPU: 0.0124 seconds per image (80.72 FPS)
|
||||
|
||||
|
||||
OpenVINO IR model
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
OpenVINO IR model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Let’s convert the ONNX model to OpenVINO Intermediate Representation
|
||||
(IR) FP16 and run it. Reducing the precision is one of the well-known
|
||||
@@ -459,17 +478,19 @@ accuracy drop. That’s why we skip that step in this notebook.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_19_0.jpg
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_20_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model on CPU. First inference time: 0.0166 seconds
|
||||
OpenVINO model on CPU: 0.0133 seconds per image (75.29 FPS)
|
||||
OpenVINO model on CPU. First inference time: 0.0148 seconds
|
||||
OpenVINO model on CPU: 0.0123 seconds per image (81.38 FPS)
|
||||
|
||||
|
||||
OpenVINO IR model on GPU
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
OpenVINO IR model on GPU
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Usually, a GPU device is faster than a CPU, so let’s run the above model
|
||||
on the GPU. Please note you need to have an Intel GPU and `install
|
||||
@@ -492,8 +513,10 @@ execution.
|
||||
|
||||
del ov_gpu_model # release resources
|
||||
|
||||
OpenVINO IR model + more inference threads
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
OpenVINO IR model + more inference threads
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
There is a possibility to add a config for any device (CPU in this
|
||||
case). We will increase the number of threads to an equal number of our
|
||||
@@ -517,17 +540,19 @@ If it is the case, don’t use it.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_23_0.jpg
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_24_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model + more threads on CPU. First inference time: 0.0156 seconds
|
||||
OpenVINO model + more threads on CPU: 0.0134 seconds per image (74.72 FPS)
|
||||
OpenVINO model + more threads on CPU. First inference time: 0.0155 seconds
|
||||
OpenVINO model + more threads on CPU: 0.0124 seconds per image (80.47 FPS)
|
||||
|
||||
|
||||
OpenVINO IR model in latency mode
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
OpenVINO IR model in latency mode
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
OpenVINO offers a virtual device called
|
||||
`AUTO <https://docs.openvino.ai/2023.0/openvino_docs_OV_UG_supported_plugins_AUTO.html>`__,
|
||||
@@ -547,17 +572,19 @@ devices as well.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_25_0.jpg
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_26_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model on AUTO. First inference time: 0.0162 seconds
|
||||
OpenVINO model on AUTO: 0.0136 seconds per image (73.76 FPS)
|
||||
OpenVINO model on AUTO. First inference time: 0.0156 seconds
|
||||
OpenVINO model on AUTO: 0.0125 seconds per image (79.73 FPS)
|
||||
|
||||
|
||||
OpenVINO IR model in latency mode + shared memory
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
OpenVINO IR model in latency mode + shared memory
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
OpenVINO is a C++ toolkit with Python wrappers (API). The default
|
||||
behavior in the Python API is copying the input to the additional buffer
|
||||
@@ -581,27 +608,31 @@ performance!
|
||||
|
||||
|
||||
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_27_0.jpg
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_28_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model + shared memory on AUTO. First inference time: 0.0143 seconds
|
||||
OpenVINO model + shared memory on AUTO: 0.0054 seconds per image (186.06 FPS)
|
||||
OpenVINO model + shared memory on AUTO. First inference time: 0.0112 seconds
|
||||
OpenVINO model + shared memory on AUTO: 0.0054 seconds per image (185.55 FPS)
|
||||
|
||||
|
||||
Other tricks
|
||||
~~~~~~~~~~~~
|
||||
|
||||
|
||||
Other tricks
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
There are other tricks for performance improvement, such as quantization
|
||||
and pre-post-processing or dedicated to throughput mode. To get even
|
||||
more from your model, please visit
|
||||
`111-detection-quantization <111-detection-quantization-with-output.html>`__,
|
||||
`118-optimize-preprocessing <118-optimize-preprocessing-with-output.html>`__, and
|
||||
`109-throughput-tricks <109-throughput-tricks-with-output.html>`__.
|
||||
`111-detection-quantization <../111-detection-quantization>`__,
|
||||
`118-optimize-preprocessing <../118-optimize-preprocessing>`__, and
|
||||
`109-throughput-tricks <109-throughput-tricks.ipynb>`__.
|
||||
|
||||
Performance comparison
|
||||
----------------------
|
||||
|
||||
|
||||
Performance comparison
|
||||
----------------------------------------------------------------
|
||||
|
||||
The following graphical comparison is valid for the selected model and
|
||||
hardware simultaneously. If you cannot see any improvement between some
|
||||
@@ -634,11 +665,13 @@ steps, just skip them.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_30_0.png
|
||||
.. image:: 109-latency-tricks-with-output_files/109-latency-tricks-with-output_31_0.png
|
||||
|
||||
|
||||
Conclusions
|
||||
-----------
|
||||
|
||||
|
||||
Conclusions
|
||||
-----------------------------------------------------
|
||||
|
||||
We already showed the steps needed to improve the performance of an
|
||||
object detection model. Even if you experience much better performance
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ff39f8edc5bdcd106ae6c1d49b52edb7342a5a29490b03f3de375b0315155159
|
||||
size 57006
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:545f14f9a5a612fe9e498660b4640562ad87b9b29df063fa6b354df83c16eaa8
|
||||
size 57156
|
||||
@@ -1,14 +1,14 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/109-latency-tricks-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/109-latency-tricks-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/109-latency-tricks-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="109-latency-tricks-with-output_14_0.jpg">109-latency-tricks-with-output_14_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-latency-tricks-with-output_17_0.jpg">109-latency-tricks-with-output_17_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-latency-tricks-with-output_19_0.jpg">109-latency-tricks-with-output_19_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-latency-tricks-with-output_23_0.jpg">109-latency-tricks-with-output_23_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-latency-tricks-with-output_25_0.jpg">109-latency-tricks-with-output_25_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-latency-tricks-with-output_27_0.jpg">109-latency-tricks-with-output_27_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-latency-tricks-with-output_30_0.png">109-latency-tricks-with-output_30_0.png</a> 31-Oct-2023 00:35 57006
|
||||
<a href="109-latency-tricks-with-output_4_0.jpg">109-latency-tricks-with-output_4_0.jpg</a> 31-Oct-2023 00:35 155828
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/109-latency-tricks-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="109-latency-tricks-with-output_15_0.jpg">109-latency-tricks-with-output_15_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-latency-tricks-with-output_18_0.jpg">109-latency-tricks-with-output_18_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-latency-tricks-with-output_20_0.jpg">109-latency-tricks-with-output_20_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-latency-tricks-with-output_24_0.jpg">109-latency-tricks-with-output_24_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-latency-tricks-with-output_26_0.jpg">109-latency-tricks-with-output_26_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-latency-tricks-with-output_28_0.jpg">109-latency-tricks-with-output_28_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-latency-tricks-with-output_31_0.png">109-latency-tricks-with-output_31_0.png</a> 07-Dec-2023 00:49 57156
|
||||
<a href="109-latency-tricks-with-output_5_0.jpg">109-latency-tricks-with-output_5_0.jpg</a> 07-Dec-2023 00:49 155828
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -24,8 +24,8 @@ The quantization and pre-post-processing API are not included here as
|
||||
they change the precision (quantization) or processing graph
|
||||
(prepostprocessor). You can find examples of how to apply them to
|
||||
optimize performance on OpenVINO IR files in
|
||||
`111-detection-quantization <111-detection-quantization-with-output.html>`__ and
|
||||
`118-optimize-preprocessing <otebooks/118-optimize-preprocessing-with-output.html>`__.
|
||||
`111-detection-quantization <../111-detection-quantization>`__ and
|
||||
`118-optimize-preprocessing <../118-optimize-preprocessing>`__.
|
||||
|
||||
|image0|
|
||||
|
||||
@@ -41,11 +41,12 @@ optimize performance on OpenVINO IR files in
|
||||
result in different performance.
|
||||
|
||||
A similar notebook focused on the latency mode is available
|
||||
`here <109-latency-tricks-with-output.html>`__.
|
||||
`here <109-latency-tricks.ipynb>`__.
|
||||
|
||||
**Table of contents:**
|
||||
|
||||
|
||||
- `Prerequisites <#prerequisites>`__
|
||||
- `Data <#data>`__
|
||||
- `Model <#model>`__
|
||||
- `Hardware <#hardware>`__
|
||||
@@ -70,14 +71,16 @@ A similar notebook focused on the latency mode is available
|
||||
- `Performance comparison <#performance-comparison>`__
|
||||
- `Conclusions <#conclusions>`__
|
||||
|
||||
.. |image0| image:: https://github.com/openvinotoolkit/openvino_notebooks/assets/4547501/ac17148c-bee9-43aa-87fc-ead61ac75f1d
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
.. |image0| image:: https://github.com/openvinotoolkit/openvino_notebooks/assets/4547501/ac17148c-bee9-43aa-87fc-ead61ac75f1d
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%pip install -q "openvino>=2023.1.0" "ultralytics<=8.0.178" seaborn ultralytics onnx
|
||||
%pip install -q "openvino>=2023.1.0" "ultralytics<=8.0.178" seaborn onnx --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -99,8 +102,10 @@ Prerequisites
|
||||
)
|
||||
import notebook_utils as utils
|
||||
|
||||
Data
|
||||
----------------------------------------------
|
||||
Data
|
||||
----
|
||||
|
||||
|
||||
|
||||
We will use the same image of the dog sitting on a bicycle copied 1000
|
||||
times to simulate the video with 1000 frames (about 33s). The image is
|
||||
@@ -134,19 +139,21 @@ object detection model.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_4_0.jpg
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_5_0.jpg
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<DisplayHandle display_id=3e43afd5a99705453ed54799f0b6fc9b>
|
||||
<DisplayHandle display_id=ffb43bd5831f251ba3c21b52bdd4c3fc>
|
||||
|
||||
|
||||
|
||||
Model
|
||||
-----------------------------------------------
|
||||
Model
|
||||
-----
|
||||
|
||||
|
||||
|
||||
We decided to go with
|
||||
`YOLOv5n <https://github.com/ultralytics/yolov5>`__, one of the
|
||||
@@ -186,8 +193,10 @@ PyTorch Hub and small enough to see the difference in performance.
|
||||
requirements: /opt/home/k8sworker/.cache/torch/hub/requirements.txt not found, check failed.
|
||||
|
||||
|
||||
Hardware
|
||||
--------------------------------------------------
|
||||
Hardware
|
||||
--------
|
||||
|
||||
|
||||
|
||||
The code below lists the available hardware we will use in the
|
||||
benchmarking process.
|
||||
@@ -213,8 +222,10 @@ benchmarking process.
|
||||
CPU: Intel(R) Core(TM) i9-10920X CPU @ 3.50GHz
|
||||
|
||||
|
||||
Helper functions
|
||||
----------------------------------------------------------
|
||||
Helper functions
|
||||
----------------
|
||||
|
||||
|
||||
|
||||
We’re defining a benchmark model function to use for all optimizations
|
||||
below. It runs inference for 1000 frames and prints average frames per
|
||||
@@ -353,15 +364,19 @@ the image.
|
||||
|
||||
utils.show_array(output_img)
|
||||
|
||||
Optimizations
|
||||
-------------------------------------------------------
|
||||
Optimizations
|
||||
-------------
|
||||
|
||||
|
||||
|
||||
Below, we present the performance tricks for faster inference in the
|
||||
throughput mode. We release resources after every benchmarking to be
|
||||
sure the same amount of resource is available for every experiment.
|
||||
|
||||
PyTorch model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
PyTorch model
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
First, we’re benchmarking the original PyTorch model without any
|
||||
optimizations applied. We will treat it as our baseline.
|
||||
@@ -377,17 +392,19 @@ optimizations applied. We will treat it as our baseline.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_14_0.jpg
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_15_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PyTorch model on CPU. First inference time: 0.0292 seconds
|
||||
PyTorch model on CPU: 0.0210 seconds per image (47.67 FPS)
|
||||
PyTorch model on CPU. First inference time: 0.0220 seconds
|
||||
PyTorch model on CPU: 0.0208 seconds per image (48.18 FPS)
|
||||
|
||||
|
||||
OpenVINO IR model
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
OpenVINO IR model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The first optimization is exporting the PyTorch model to OpenVINO
|
||||
Intermediate Representation (IR) FP16 and running it. Reducing the
|
||||
@@ -422,17 +439,19 @@ step in this notebook.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_17_0.jpg
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_18_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model on CPU. First inference time: 0.0182 seconds
|
||||
OpenVINO model on CPU: 0.0073 seconds per image (136.13 FPS)
|
||||
OpenVINO model on CPU. First inference time: 0.0156 seconds
|
||||
OpenVINO model on CPU: 0.0071 seconds per image (141.19 FPS)
|
||||
|
||||
|
||||
OpenVINO IR model + bigger batch
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
OpenVINO IR model + bigger batch
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Batch processing often gives higher throughput as more inputs are
|
||||
processed at once. To use bigger batches (than 1), we must convert the
|
||||
@@ -478,17 +497,19 @@ hardware and model.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_20_0.jpg
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_21_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model + bigger batch on CPU. First inference time: 0.0502 seconds
|
||||
OpenVINO model + bigger batch on CPU: 0.0076 seconds per image (131.86 FPS)
|
||||
OpenVINO model + bigger batch on CPU. First inference time: 0.0481 seconds
|
||||
OpenVINO model + bigger batch on CPU: 0.0069 seconds per image (145.67 FPS)
|
||||
|
||||
|
||||
Asynchronous processing
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Asynchronous processing
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Asynchronous mode means that OpenVINO immediately returns from an
|
||||
inference call and doesn’t wait for the result. It requires more
|
||||
@@ -526,8 +547,10 @@ the pipeline.
|
||||
del infer_queue # release resources
|
||||
return fps
|
||||
|
||||
OpenVINO IR model in throughput mode
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
OpenVINO IR model in throughput mode
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
OpenVINO allows specifying a performance hint changing the internal
|
||||
configuration of the device. There are three different hints:
|
||||
@@ -548,17 +571,19 @@ feature, which sets the batch size to the optimal level.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_24_0.jpg
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_25_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model on CPU (THROUGHPUT). First inference time: 0.0274 seconds
|
||||
OpenVINO model on CPU (THROUGHPUT): 0.0040 seconds per image (249.34 FPS)
|
||||
OpenVINO model on CPU (THROUGHPUT). First inference time: 0.0254 seconds
|
||||
OpenVINO model on CPU (THROUGHPUT): 0.0040 seconds per image (250.82 FPS)
|
||||
|
||||
|
||||
OpenVINO IR model in throughput mode on GPU
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
OpenVINO IR model in throughput mode on GPU
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Usually, a GPU device provides more frames per second than a CPU, so
|
||||
let’s run the above model on the GPU. Please note you need to have an
|
||||
@@ -581,8 +606,10 @@ execution.
|
||||
|
||||
del ov_gpu_model # release resources
|
||||
|
||||
OpenVINO IR model in throughput mode on AUTO
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
OpenVINO IR model in throughput mode on AUTO
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
OpenVINO offers a virtual device called
|
||||
`AUTO <https://docs.openvino.ai/2023.0/openvino_docs_OV_UG_supported_plugins_AUTO.html>`__,
|
||||
@@ -599,17 +626,19 @@ performance hint.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_28_0.jpg
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_29_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model on AUTO (THROUGHPUT). First inference time: 0.0247 seconds
|
||||
OpenVINO model on AUTO (THROUGHPUT): 0.0040 seconds per image (248.93 FPS)
|
||||
OpenVINO model on AUTO (THROUGHPUT). First inference time: 0.0231 seconds
|
||||
OpenVINO model on AUTO (THROUGHPUT): 0.0040 seconds per image (251.86 FPS)
|
||||
|
||||
|
||||
OpenVINO IR model in cumulative throughput mode on AUTO
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
OpenVINO IR model in cumulative throughput mode on AUTO
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The AUTO device in throughput mode will select the best, but one
|
||||
physical device to bring the highest throughput. However, if we have
|
||||
@@ -625,29 +654,33 @@ activate all devices.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_30_0.jpg
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_31_0.jpg
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
OpenVINO model on AUTO (CUMULATIVE THROUGHPUT). First inference time: 0.0258 seconds
|
||||
OpenVINO model on AUTO (CUMULATIVE THROUGHPUT): 0.0040 seconds per image (250.04 FPS)
|
||||
OpenVINO model on AUTO (CUMULATIVE THROUGHPUT). First inference time: 0.0260 seconds
|
||||
OpenVINO model on AUTO (CUMULATIVE THROUGHPUT): 0.0040 seconds per image (251.22 FPS)
|
||||
|
||||
|
||||
Other tricks
|
||||
~~~~~~~~~~~~
|
||||
|
||||
|
||||
Other tricks
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
There are other tricks for performance improvement, such as advanced
|
||||
options, quantization and pre-post-processing or dedicated to latency
|
||||
mode. To get even more from your model, please visit `advanced
|
||||
throughput
|
||||
options <https://docs.openvino.ai/2023.0/openvino_docs_deployment_optimization_guide_tput_advanced.html>`__,
|
||||
`109-latency-tricks <109-latency-tricks-with-output.html>`__,
|
||||
`111-detection-quantization <111-detection-quantization-with-output.html>`__, and
|
||||
`118-optimize-preprocessing <118-optimize-preprocessing-with-output.html>`__.
|
||||
`109-latency-tricks <109-latency-tricks.ipynb>`__,
|
||||
`111-detection-quantization <../111-detection-quantization>`__, and
|
||||
`118-optimize-preprocessing <../118-optimize-preprocessing>`__.
|
||||
|
||||
Performance comparison
|
||||
----------------------
|
||||
|
||||
|
||||
Performance comparison
|
||||
----------------------------------------------------------------
|
||||
|
||||
The following graphical comparison is valid for the selected model and
|
||||
hardware simultaneously. If you cannot see any improvement between some
|
||||
@@ -679,11 +712,13 @@ steps, just skip them.
|
||||
|
||||
|
||||
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_33_0.png
|
||||
.. image:: 109-throughput-tricks-with-output_files/109-throughput-tricks-with-output_34_0.png
|
||||
|
||||
|
||||
Conclusions
|
||||
-----------
|
||||
|
||||
|
||||
Conclusions
|
||||
-----------------------------------------------------
|
||||
|
||||
We already showed the steps needed to improve the throughput of an
|
||||
object detection model. Even if you experience much better performance
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:10e27ed40dfd078777a2cd9513a00136b6327571b82ef0af6485b8ea5234dcfa
|
||||
size 62451
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b94c59d38427a1ec4994131e2bbefc03b0ebdf0fde6f20956a3775faa4e5f451
|
||||
size 62516
|
||||
@@ -1,14 +1,14 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/109-throughput-tricks-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/109-throughput-tricks-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/109-throughput-tricks-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="109-throughput-tricks-with-output_14_0.jpg">109-throughput-tricks-with-output_14_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-throughput-tricks-with-output_17_0.jpg">109-throughput-tricks-with-output_17_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-throughput-tricks-with-output_20_0.jpg">109-throughput-tricks-with-output_20_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-throughput-tricks-with-output_24_0.jpg">109-throughput-tricks-with-output_24_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-throughput-tricks-with-output_28_0.jpg">109-throughput-tricks-with-output_28_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-throughput-tricks-with-output_30_0.jpg">109-throughput-tricks-with-output_30_0.jpg</a> 31-Oct-2023 00:35 162715
|
||||
<a href="109-throughput-tricks-with-output_33_0.png">109-throughput-tricks-with-output_33_0.png</a> 31-Oct-2023 00:35 62451
|
||||
<a href="109-throughput-tricks-with-output_4_0.jpg">109-throughput-tricks-with-output_4_0.jpg</a> 31-Oct-2023 00:35 155828
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/109-throughput-tricks-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="109-throughput-tricks-with-output_15_0.jpg">109-throughput-tricks-with-output_15_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-throughput-tricks-with-output_18_0.jpg">109-throughput-tricks-with-output_18_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-throughput-tricks-with-output_21_0.jpg">109-throughput-tricks-with-output_21_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-throughput-tricks-with-output_25_0.jpg">109-throughput-tricks-with-output_25_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-throughput-tricks-with-output_29_0.jpg">109-throughput-tricks-with-output_29_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-throughput-tricks-with-output_31_0.jpg">109-throughput-tricks-with-output_31_0.jpg</a> 07-Dec-2023 00:49 162715
|
||||
<a href="109-throughput-tricks-with-output_34_0.png">109-throughput-tricks-with-output_34_0.png</a> 07-Dec-2023 00:49 62516
|
||||
<a href="109-throughput-tricks-with-output_5_0.jpg">109-throughput-tricks-with-output_5_0.jpg</a> 07-Dec-2023 00:49 155828
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -24,13 +24,13 @@ This third tutorial in the series shows how to:
|
||||
All notebooks in this series:
|
||||
|
||||
- `Data Preparation for 2D Segmentation of 3D Medical
|
||||
Data <data-preparation-ct-scan-with-output.html>`__
|
||||
Data <data-preparation-ct-scan.ipynb>`__
|
||||
- `Train a 2D-UNet Medical Imaging Model with PyTorch
|
||||
Lightning <pytorch-monai-training-with-output.html>`__
|
||||
Lightning <pytorch-monai-training.ipynb>`__
|
||||
- Convert and Quantize a Segmentation Model and Show Live Inference
|
||||
(this notebook)
|
||||
- `Live Inference and Benchmark CT-scan
|
||||
data <110-ct-scan-live-inference-with-output.html>`__
|
||||
data <110-ct-scan-live-inference.ipynb>`__
|
||||
|
||||
Instructions
|
||||
------------
|
||||
@@ -39,7 +39,7 @@ This notebook needs a trained UNet model. We provide a pre-trained
|
||||
model, trained for 20 epochs with the full
|
||||
`Kits-19 <https://github.com/neheller/kits19>`__ frames dataset, which
|
||||
has an F1 score on the validation set of 0.9. The training code is
|
||||
available in `this notebook <pytorch-monai-training-with-output.html>`__.
|
||||
available in `this notebook <pytorch-monai-training.ipynb>`__.
|
||||
|
||||
NNCF for PyTorch models requires a C++ compiler. On Windows, install
|
||||
`Microsoft Visual Studio
|
||||
@@ -66,8 +66,7 @@ purposes, use a representative dataset for quantizing the model.
|
||||
- `Metric <#metric>`__
|
||||
|
||||
- `Quantization <#quantization>`__
|
||||
- `Compare FP32 and INT8
|
||||
Model <#compare-fp-and-int-model>`__
|
||||
- `Compare FP32 and INT8 Model <#compare-fp-and-int-model>`__
|
||||
|
||||
- `Compare File Size <#compare-file-size>`__
|
||||
- `Compare Metrics for the original model and the quantized model to
|
||||
@@ -88,7 +87,7 @@ purposes, use a representative dataset for quantizing the model.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%pip install -q "openvino>=2023.1.0" "monai>=0.9.1,<1.0.0" "torchmetrics>=0.11.0"
|
||||
%pip install -q "openvino>=2023.1.0" "monai>=0.9.1,<1.0.0" "torchmetrics>=0.11.0" "nncf>=2.6.0" --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -96,8 +95,10 @@ purposes, use a representative dataset for quantizing the model.
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
Imports
|
||||
-------------------------------------------------
|
||||
Imports
|
||||
-------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -181,10 +182,10 @@ Imports
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-10-30 22:43:08.129843: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-10-30 22:43:08.164608: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
2023-12-06 22:47:51.629108: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-12-06 22:47:51.662883: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
|
||||
2023-10-30 22:43:08.732898: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
2023-12-06 22:47:52.221639: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -192,13 +193,15 @@ Imports
|
||||
INFO:nncf:NNCF initialized successfully. Supported frameworks detected: torch, tensorflow, onnx, openvino
|
||||
|
||||
|
||||
Settings
|
||||
--------------------------------------------------
|
||||
Settings
|
||||
--------
|
||||
|
||||
|
||||
|
||||
By default, this notebook will download one CT scan from the KITS19
|
||||
dataset that will be used for quantization. To use the full dataset, set
|
||||
``BASEDIR`` to the path of the dataset, as prepared according to the
|
||||
`Data Preparation <data-preparation-ct-scan-with-output.html>`__ notebook.
|
||||
`Data Preparation <data-preparation-ct-scan.ipynb>`__ notebook.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -208,8 +211,10 @@ dataset that will be used for quantization. To use the full dataset, set
|
||||
MODEL_DIR = Path("model")
|
||||
MODEL_DIR.mkdir(exist_ok=True)
|
||||
|
||||
Load PyTorch Model
|
||||
------------------------------------------------------------
|
||||
Load PyTorch Model
|
||||
------------------
|
||||
|
||||
|
||||
|
||||
Download the pre-trained model weights, load the PyTorch model and the
|
||||
``state_dict`` that was saved after training. The model used in this
|
||||
@@ -217,7 +222,7 @@ notebook is a
|
||||
`BasicUNet <https://docs.monai.io/en/stable/networks.html#basicunet>`__
|
||||
model from `MONAI <https://monai.io>`__. We provide a pre-trained
|
||||
checkpoint. To see how this model performs, check out the `training
|
||||
notebook <pytorch-monai-training-with-output.html>`__.
|
||||
notebook <pytorch-monai-training.ipynb>`__.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -254,8 +259,10 @@ notebook <pytorch-monai-training-with-output.html>`__.
|
||||
|
||||
|
||||
|
||||
Download CT-scan Data
|
||||
---------------------------------------------------------------
|
||||
Download CT-scan Data
|
||||
---------------------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -280,16 +287,20 @@ Download CT-scan Data
|
||||
Data for case_00117 exists
|
||||
|
||||
|
||||
Configuration
|
||||
-------------------------------------------------------
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
|
||||
|
||||
Dataset
|
||||
~~~~~~~
|
||||
|
||||
|
||||
Dataset
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``KitsDataset`` class in the next cell expects images and masks in
|
||||
the *``basedir``* directory, in a folder per patient. It is a simplified
|
||||
version of the Dataset class in the `training
|
||||
notebook <pytorch-monai-training-with-output.html>`__.
|
||||
notebook <pytorch-monai-training.ipynb>`__.
|
||||
|
||||
Images are loaded with MONAI’s
|
||||
`LoadImage <https://docs.monai.io/en/stable/transforms.html#loadimage>`__,
|
||||
@@ -381,8 +392,10 @@ kidney pixels to verify that the annotations look correct:
|
||||
.. image:: 110-ct-segmentation-quantize-nncf-with-output_files/110-ct-segmentation-quantize-nncf-with-output_15_1.png
|
||||
|
||||
|
||||
Metric
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Metric
|
||||
~~~~~~
|
||||
|
||||
|
||||
|
||||
Define a metric to determine the performance of the model.
|
||||
|
||||
@@ -416,8 +429,10 @@ library.
|
||||
metric.update(label.flatten(), prediction.flatten())
|
||||
return metric.compute()
|
||||
|
||||
Quantization
|
||||
------------------------------------------------------
|
||||
Quantization
|
||||
------------
|
||||
|
||||
|
||||
|
||||
Before quantizing the model, we compute the F1 score on the ``FP32``
|
||||
model, for comparison:
|
||||
@@ -454,7 +469,7 @@ this notebook.
|
||||
|
||||
[ WARNING ] Please fix your imports. Module %s has been moved to %s. The old module will be deleted in version %s.
|
||||
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/monai/networks/nets/basic_unet.py:179: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/monai/networks/nets/basic_unet.py:179: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
if x_e.shape[-i - 1] != x_0.shape[-i - 1]:
|
||||
|
||||
|
||||
@@ -497,6 +512,49 @@ steps:
|
||||
ignored_scope=nncf.IgnoredScope(patterns=[".*LeakyReLU.*"])
|
||||
)
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
Export the quantized model to ONNX and then convert it to OpenVINO IR
|
||||
model and save it.
|
||||
|
||||
@@ -512,11 +570,11 @@ model and save it.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/nncf/torch/quantization/layers.py:336: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/nncf/torch/quantization/layers.py:333: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
return self._level_low.item()
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/nncf/torch/quantization/layers.py:344: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/nncf/torch/quantization/layers.py:341: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
return self._level_high.item()
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/monai/networks/nets/basic_unet.py:179: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/monai/networks/nets/basic_unet.py:179: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
if x_e.shape[-i - 1] != x_0.shape[-i - 1]:
|
||||
|
||||
|
||||
@@ -527,11 +585,15 @@ than quantization. See the `NNCF
|
||||
documentation <https://github.com/openvinotoolkit/nncf/>`__ in the NNCF
|
||||
repository for more information.
|
||||
|
||||
Compare FP32 and INT8 Model
|
||||
---------------------------------------------------------------------
|
||||
Compare FP32 and INT8 Model
|
||||
---------------------------
|
||||
|
||||
|
||||
|
||||
Compare File Size
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Compare File Size
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -548,8 +610,10 @@ Compare File Size
|
||||
INT8 model size: 1940.55 KB
|
||||
|
||||
|
||||
Compare Metrics for the original model and the quantized model to be sure that there no degradation.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Compare Metrics for the original model and the quantized model to be sure that there no degradation.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -568,8 +632,10 @@ Compare Metrics for the original model and the quantized model to be sure that t
|
||||
INT8 F1: 0.999
|
||||
|
||||
|
||||
Compare Performance of the FP32 IR Model and Quantized Models
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Compare Performance of the FP32 IR Model and Quantized Models
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
To measure the inference performance of the ``FP32`` and ``INT8``
|
||||
models, we use `Benchmark
|
||||
@@ -606,18 +672,18 @@ be run in the notebook with ``! benchmark_app`` or
|
||||
[ INFO ] Parsing input parameters
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ INFO ] CPU
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ WARNING ] Performance hint was not explicitly specified in command line. Device(CPU) performance hint will be set to PerformanceMode.LATENCY.
|
||||
[Step 4/11] Reading model files
|
||||
[ INFO ] Loading model files
|
||||
[ INFO ] Read model took 34.85 ms
|
||||
[ INFO ] Read model took 26.10 ms
|
||||
[ INFO ] Original model I/O parameters:
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] x (node: x) : f32 / [...] / [?,?,?,?]
|
||||
@@ -631,7 +697,7 @@ be run in the notebook with ``! benchmark_app`` or
|
||||
[ INFO ] Model outputs:
|
||||
[ INFO ] ***NO_NAME*** (node: __module.final_conv/aten::_convolution/Add_425) : f32 / [...] / [?,1,16..,16..]
|
||||
[Step 7/11] Loading the model to the device
|
||||
[ INFO ] Compile model took 76.76 ms
|
||||
[ INFO ] Compile model took 80.42 ms
|
||||
[Step 8/11] Querying optimal runtime parameters
|
||||
[ INFO ] Model:
|
||||
[ INFO ] NETWORK_NAME: Model0
|
||||
@@ -653,9 +719,9 @@ be run in the notebook with ``! benchmark_app`` or
|
||||
[Step 9/11] Creating infer requests and preparing input tensors
|
||||
[ ERROR ] Input x is dynamic. Provide data shapes!
|
||||
Traceback (most recent call last):
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/main.py", line 485, in main
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/main.py", line 485, in main
|
||||
data_queue = get_input_data(paths_to_input, app_inputs_info)
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/utils/inputs_filling.py", line 123, in get_input_data
|
||||
File "/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/openvino/tools/benchmark/utils/inputs_filling.py", line 123, in get_input_data
|
||||
raise Exception(f"Input {info.name} is dynamic. Provide data shapes!")
|
||||
Exception: Input x is dynamic. Provide data shapes!
|
||||
|
||||
@@ -672,32 +738,32 @@ be run in the notebook with ``! benchmark_app`` or
|
||||
[ INFO ] Parsing input parameters
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ INFO ] CPU
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ WARNING ] Performance hint was not explicitly specified in command line. Device(CPU) performance hint will be set to PerformanceMode.LATENCY.
|
||||
[Step 4/11] Reading model files
|
||||
[ INFO ] Loading model files
|
||||
[ INFO ] Read model took 30.95 ms
|
||||
[ INFO ] Read model took 12.76 ms
|
||||
[ INFO ] Original model I/O parameters:
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] x.1 (node: x.1) : f32 / [...] / [1,1,512,512]
|
||||
[ INFO ] Model outputs:
|
||||
[ INFO ] 578 (node: 578) : f32 / [...] / [1,1,512,512]
|
||||
[ INFO ] 571 (node: 571) : f32 / [...] / [1,1,512,512]
|
||||
[Step 5/11] Resizing model to match image sizes and given batch
|
||||
[ INFO ] Model batch size: 1
|
||||
[Step 6/11] Configuring input of the model
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] x.1 (node: x.1) : f32 / [N,C,H,W] / [1,1,512,512]
|
||||
[ INFO ] Model outputs:
|
||||
[ INFO ] 578 (node: 578) : f32 / [...] / [1,1,512,512]
|
||||
[ INFO ] 571 (node: 571) : f32 / [...] / [1,1,512,512]
|
||||
[Step 7/11] Loading the model to the device
|
||||
[ INFO ] Compile model took 199.95 ms
|
||||
[ INFO ] Compile model took 188.00 ms
|
||||
[Step 8/11] Querying optimal runtime parameters
|
||||
[ INFO ] Model:
|
||||
[ INFO ] NETWORK_NAME: main_graph
|
||||
@@ -721,21 +787,23 @@ be run in the notebook with ``! benchmark_app`` or
|
||||
[ INFO ] Fill input 'x.1' with random values
|
||||
[Step 10/11] Measuring performance (Start inference synchronously, limits: 15000 ms duration)
|
||||
[ INFO ] Benchmarking in inference only mode (inputs filling are not included in measurement loop).
|
||||
[ INFO ] First inference took 33.43 ms
|
||||
[ INFO ] First inference took 30.70 ms
|
||||
[Step 11/11] Dumping statistics report
|
||||
[ INFO ] Execution Devices:['CPU']
|
||||
[ INFO ] Count: 954 iterations
|
||||
[ INFO ] Duration: 15006.26 ms
|
||||
[ INFO ] Count: 971 iterations
|
||||
[ INFO ] Duration: 15006.86 ms
|
||||
[ INFO ] Latency:
|
||||
[ INFO ] Median: 15.47 ms
|
||||
[ INFO ] Average: 15.52 ms
|
||||
[ INFO ] Min: 15.18 ms
|
||||
[ INFO ] Max: 19.34 ms
|
||||
[ INFO ] Throughput: 63.57 FPS
|
||||
[ INFO ] Median: 15.20 ms
|
||||
[ INFO ] Average: 15.24 ms
|
||||
[ INFO ] Min: 14.91 ms
|
||||
[ INFO ] Max: 16.90 ms
|
||||
[ INFO ] Throughput: 64.70 FPS
|
||||
|
||||
|
||||
Visually Compare Inference Results
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Visually Compare Inference Results
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Visualize the results of the model on four slices of the validation set.
|
||||
Compare the results of the ``FP32`` IR model with the results of the
|
||||
@@ -814,15 +882,17 @@ seed is displayed to enable reproducing specific runs of this cell.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Visualizing results with seed 1698702266
|
||||
Visualizing results with seed 1701899334
|
||||
|
||||
|
||||
|
||||
.. image:: 110-ct-segmentation-quantize-nncf-with-output_files/110-ct-segmentation-quantize-nncf-with-output_37_1.png
|
||||
|
||||
|
||||
Show Live Inference
|
||||
-------------------------------------------------------------
|
||||
Show Live Inference
|
||||
-------------------
|
||||
|
||||
|
||||
|
||||
To show live inference on the model in the notebook, we will use the
|
||||
asynchronous processing feature of OpenVINO.
|
||||
@@ -839,8 +909,10 @@ printed.
|
||||
**NOTE**: If you experience flickering on Firefox, consider using
|
||||
Chrome or Edge to run this notebook.
|
||||
|
||||
Load Model and List of Image Files
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Load Model and List of Image Files
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
We load the segmentation model to OpenVINO Runtime with
|
||||
``SegmentationModel``, based on the `Open Model
|
||||
@@ -866,8 +938,10 @@ overlay of the segmentation mask on the original image/frame.
|
||||
case_00117, 69 images
|
||||
|
||||
|
||||
Show Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Show Inference
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
In the next cell, we run the ``show_live_inference`` function, which
|
||||
loads the ``segmentation_model`` to the specified ``device`` (using
|
||||
@@ -891,24 +965,29 @@ performs inference, and displays the results on the frames loaded in
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Loaded model to CPU in 0.17 seconds.
|
||||
Total time for 68 frames: 3.43 seconds, fps:20.10
|
||||
Loaded model to CPU in 0.18 seconds.
|
||||
Total time for 68 frames: 2.73 seconds, fps:25.30
|
||||
|
||||
|
||||
References
|
||||
----------------------------------------------------
|
||||
References
|
||||
----------
|
||||
|
||||
**OpenVINO**
|
||||
|
||||
- `NNCF Repository <https://github.com/openvinotoolkit/nncf/>`__
|
||||
- `Neural Network Compression Framework for fast model
|
||||
inference <https://arxiv.org/abs/2002.08679>`__
|
||||
- `OpenVINO API Tutorial <002-openvino-api-with-output.html>`__
|
||||
- `OpenVINO PyPI (pip install openvino-dev) <https://pypi.org/project/openvino-dev/>`__
|
||||
|
||||
**Kits19 Data**
|
||||
**OpenVINO** - `NNCF
|
||||
Repository <https://github.com/openvinotoolkit/nncf/>`__ - `Neural
|
||||
Network Compression Framework for fast model
|
||||
inference <https://arxiv.org/abs/2002.08679>`__ - `OpenVINO API
|
||||
Tutorial <002-openvino-api-with-output.html>`__ - `OpenVINO
|
||||
PyPI (pip install
|
||||
openvino-dev) <https://pypi.org/project/openvino-dev/>`__
|
||||
|
||||
- `Kits19 Challenge Homepage <https://kits19.grand-challenge.org/>`__
|
||||
- `Kits19 GitHub Repository <https://github.com/neheller/kits19>`__
|
||||
- `The KiTS19 Challenge Data: 300 Kidney Tumor Cases with Clinical Context, CT Semantic Segmentations, and Surgical Outcomes <https://arxiv.org/abs/1904.00445>`__
|
||||
- `The state of the art in kidney and kidney tumor segmentation in contrast-enhanced CT imaging: Results of the KiTS19 challenge <https://www.sciencedirect.com/science/article/pii/S1361841520301857>`__
|
||||
**Kits19 Data** - `Kits19 Challenge
|
||||
Homepage <https://kits19.grand-challenge.org/>`__ - `Kits19 GitHub
|
||||
Repository <https://github.com/neheller/kits19>`__ - `The KiTS19
|
||||
Challenge Data: 300 Kidney Tumor Cases with Clinical Context, CT
|
||||
Semantic Segmentations, and Surgical
|
||||
Outcomes <https://arxiv.org/abs/1904.00445>`__ - `The state of the art
|
||||
in kidney and kidney tumor segmentation in contrast-enhanced CT imaging:
|
||||
Results of the KiTS19
|
||||
challenge <https://www.sciencedirect.com/science/article/pii/S1361841520301857>`__
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:eb2418bea000be01c041f45ac09c14c701e09a7b1ffbc551fbc9f7ce4c4fb6fd
|
||||
oid sha256:8d5031a8fde68c06c9d1585a57d549809af699f8411c9021d3571718ae037908
|
||||
size 158997
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6503457981c8d2d24c46d2879b1a499fb4143c566a5196b903b50b49c4094cc2
|
||||
size 378309
|
||||
oid sha256:04761a5918e007435a0a6d8e1e44df408ba32326558935ebb4c47c48aa1d41cc
|
||||
size 385394
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/110-ct-segmentation-quantize-nncf-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/110-ct-segmentation-quantize-nncf-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/110-ct-segmentation-quantize-nncf-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="110-ct-segmentation-quantize-nncf-with-output_15_1.png">110-ct-segmentation-quantize-nncf-with-output_1..></a> 31-Oct-2023 00:35 158997
|
||||
<a href="110-ct-segmentation-quantize-nncf-with-output_37_1.png">110-ct-segmentation-quantize-nncf-with-output_3..></a> 31-Oct-2023 00:35 378309
|
||||
<a href="110-ct-segmentation-quantize-nncf-with-output_42_0.jpg">110-ct-segmentation-quantize-nncf-with-output_4..></a> 31-Oct-2023 00:35 73812
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/110-ct-segmentation-quantize-nncf-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="110-ct-segmentation-quantize-nncf-with-output_15_1.png">110-ct-segmentation-quantize-nncf-with-output_1..></a> 07-Dec-2023 00:49 158997
|
||||
<a href="110-ct-segmentation-quantize-nncf-with-output_37_1.png">110-ct-segmentation-quantize-nncf-with-output_3..></a> 07-Dec-2023 00:49 385394
|
||||
<a href="110-ct-segmentation-quantize-nncf-with-output_42_0.jpg">110-ct-segmentation-quantize-nncf-with-output_4..></a> 07-Dec-2023 00:49 73812
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -31,8 +31,7 @@ quantization, not demanding the fine-tuning of the model.
|
||||
- `Settings <#settings>`__
|
||||
- `Download and Prepare Tiny ImageNet
|
||||
dataset <#download-and-prepare-tiny-imagenet-dataset>`__
|
||||
- `Helpers classes and
|
||||
functions <#helpers-classes-and-functions>`__
|
||||
- `Helpers classes and functions <#helpers-classes-and-functions>`__
|
||||
- `Validation function <#validation-function>`__
|
||||
- `Create and load original uncompressed
|
||||
model <#create-and-load-original-uncompressed-model>`__
|
||||
@@ -42,8 +41,7 @@ quantization, not demanding the fine-tuning of the model.
|
||||
- `Model quantization and
|
||||
benchmarking <#model-quantization-and-benchmarking>`__
|
||||
|
||||
- `I. Evaluate the loaded
|
||||
model <#i-evaluate-the-loaded-model>`__
|
||||
- `I. Evaluate the loaded model <#i-evaluate-the-loaded-model>`__
|
||||
- `II. Create and initialize
|
||||
quantization <#ii-create-and-initialize-quantization>`__
|
||||
- `III. Convert the models to OpenVINO Intermediate Representation
|
||||
@@ -52,8 +50,10 @@ quantization, not demanding the fine-tuning of the model.
|
||||
- `IV. Compare performance of INT8 model and FP32 model in
|
||||
OpenVINO <#iv-compare-performance-of-int-model-and-fp-model-in-openvino>`__
|
||||
|
||||
Preparations
|
||||
------------------------------------------------------
|
||||
Preparations
|
||||
------------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -105,8 +105,10 @@ Preparations
|
||||
os.environ["LIB"] = os.pathsep.join(b.library_dirs)
|
||||
print(f"Added {vs_dir} to PATH")
|
||||
|
||||
Imports
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Imports
|
||||
~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -133,8 +135,10 @@ Imports
|
||||
INFO:nncf:NNCF initialized successfully. Supported frameworks detected: torch, tensorflow, onnx, openvino
|
||||
|
||||
|
||||
Settings
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Settings
|
||||
~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -174,12 +178,14 @@ Settings
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/112-pytorch-post-training-quantization-nncf/model/resnet50_fp32.pth')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/112-pytorch-post-training-quantization-nncf/model/resnet50_fp32.pth')
|
||||
|
||||
|
||||
|
||||
Download and Prepare Tiny ImageNet dataset
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Download and Prepare Tiny ImageNet dataset
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
- 100k images of shape 3x64x64,
|
||||
- 200 different classes: snake, spider, cat, truck, grasshopper, gull,
|
||||
@@ -238,8 +244,10 @@ Download and Prepare Tiny ImageNet dataset
|
||||
Successfully downloaded and extracted dataset to: output
|
||||
|
||||
|
||||
Helpers classes and functions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Helpers classes and functions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
The code below will help to count accuracy and visualize validation
|
||||
process.
|
||||
@@ -304,8 +312,10 @@ process.
|
||||
|
||||
return res
|
||||
|
||||
Validation function
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Validation function
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -357,8 +367,10 @@ Validation function
|
||||
)
|
||||
return top1.avg
|
||||
|
||||
Create and load original uncompressed model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Create and load original uncompressed model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
ResNet-50 from the `torchivision
|
||||
repository <https://github.com/pytorch/vision>`__ is pre-trained on
|
||||
@@ -385,8 +397,10 @@ values.
|
||||
|
||||
model = create_model(MODEL_DIR / fp32_checkpoint_filename)
|
||||
|
||||
Create train and validation DataLoaders
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Create train and validation DataLoaders
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -435,15 +449,19 @@ Create train and validation DataLoaders
|
||||
|
||||
train_loader, val_loader = create_dataloaders()
|
||||
|
||||
Model quantization and benchmarking
|
||||
-----------------------------------------------------------------------------
|
||||
Model quantization and benchmarking
|
||||
-----------------------------------
|
||||
|
||||
|
||||
|
||||
With the validation pipeline, model files, and data-loading procedures
|
||||
for model calibration now prepared, it’s time to proceed with the actual
|
||||
post-training quantization using NNCF.
|
||||
|
||||
I. Evaluate the loaded model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
I. Evaluate the loaded model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -453,20 +471,22 @@ I. Evaluate the loaded model
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Test: [ 0/79] Time 0.260 (0.260) Acc@1 81.25 (81.25) Acc@5 92.19 (92.19)
|
||||
Test: [10/79] Time 0.232 (0.238) Acc@1 56.25 (66.97) Acc@5 86.72 (87.50)
|
||||
Test: [20/79] Time 0.233 (0.237) Acc@1 67.97 (64.29) Acc@5 85.16 (87.35)
|
||||
Test: [30/79] Time 0.233 (0.236) Acc@1 53.12 (62.37) Acc@5 77.34 (85.33)
|
||||
Test: [40/79] Time 0.236 (0.235) Acc@1 67.19 (60.86) Acc@5 90.62 (84.51)
|
||||
Test: [50/79] Time 0.232 (0.235) Acc@1 60.16 (60.80) Acc@5 88.28 (84.42)
|
||||
Test: [60/79] Time 0.230 (0.235) Acc@1 66.41 (60.46) Acc@5 86.72 (83.79)
|
||||
Test: [70/79] Time 0.244 (0.235) Acc@1 52.34 (60.21) Acc@5 80.47 (83.33)
|
||||
* Acc@1 60.740 Acc@5 83.960 Total time: 18.416
|
||||
Test: [ 0/79] Time 0.257 (0.257) Acc@1 81.25 (81.25) Acc@5 92.19 (92.19)
|
||||
Test: [10/79] Time 0.233 (0.231) Acc@1 56.25 (66.97) Acc@5 86.72 (87.50)
|
||||
Test: [20/79] Time 0.223 (0.231) Acc@1 67.97 (64.29) Acc@5 85.16 (87.35)
|
||||
Test: [30/79] Time 0.231 (0.231) Acc@1 53.12 (62.37) Acc@5 77.34 (85.33)
|
||||
Test: [40/79] Time 0.232 (0.234) Acc@1 67.19 (60.86) Acc@5 90.62 (84.51)
|
||||
Test: [50/79] Time 0.226 (0.233) Acc@1 60.16 (60.80) Acc@5 88.28 (84.42)
|
||||
Test: [60/79] Time 0.225 (0.233) Acc@1 66.41 (60.46) Acc@5 86.72 (83.79)
|
||||
Test: [70/79] Time 0.232 (0.234) Acc@1 52.34 (60.21) Acc@5 80.47 (83.33)
|
||||
* Acc@1 60.740 Acc@5 83.960 Total time: 18.296
|
||||
Test accuracy of FP32 model: 60.740
|
||||
|
||||
|
||||
II. Create and initialize quantization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
II. Create and initialize quantization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
NNCF enables post-training quantization by adding the quantization
|
||||
layers into the model graph and then using a subset of the training
|
||||
@@ -502,32 +522,59 @@ Guide <https://docs.openvino.ai/2023.0/basic_qauntization_flow.html#doxid-basic-
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-10-30 22:50:19.362657: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-10-30 22:50:19.393820: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
2023-12-06 22:54:25.232060: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-12-06 22:54:25.263296: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
|
||||
2023-10-30 22:50:19.903278: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
WARNING:nncf:NNCF provides best results with torch==2.0.1, while current torch version is 2.1.0+cpu. If you encounter issues, consider switching to torch==2.0.1
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-12-06 22:54:25.771528: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
INFO:nncf:Collecting tensor statistics |█████ | 1 / 3
|
||||
INFO:nncf:Collecting tensor statistics |██████████ | 2 / 3
|
||||
INFO:nncf:Collecting tensor statistics |████████████████| 3 / 3
|
||||
INFO:nncf:Compiling and loading torch extension: quantized_functions_cpu...
|
||||
INFO:nncf:Finished loading torch extension: quantized_functions_cpu
|
||||
INFO:nncf:BatchNorm statistics adaptation |█████ | 1 / 3
|
||||
INFO:nncf:BatchNorm statistics adaptation |██████████ | 2 / 3
|
||||
INFO:nncf:BatchNorm statistics adaptation |████████████████| 3 / 3
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
3. Evaluate the new model on the validation set after initialization of
|
||||
@@ -543,16 +590,16 @@ Guide <https://docs.openvino.ai/2023.0/basic_qauntization_flow.html#doxid-basic-
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Test: [ 0/79] Time 0.464 (0.464) Acc@1 80.47 (80.47) Acc@5 92.97 (92.97)
|
||||
Test: [10/79] Time 0.435 (0.443) Acc@1 57.03 (67.19) Acc@5 87.50 (87.93)
|
||||
Test: [20/79] Time 0.436 (0.439) Acc@1 67.97 (64.51) Acc@5 85.94 (87.83)
|
||||
Test: [30/79] Time 0.433 (0.437) Acc@1 53.91 (62.70) Acc@5 77.34 (85.74)
|
||||
Test: [40/79] Time 0.433 (0.436) Acc@1 68.75 (61.11) Acc@5 89.84 (84.64)
|
||||
Test: [50/79] Time 0.432 (0.435) Acc@1 60.94 (61.04) Acc@5 87.50 (84.50)
|
||||
Test: [60/79] Time 0.435 (0.435) Acc@1 64.06 (60.63) Acc@5 86.72 (83.90)
|
||||
Test: [70/79] Time 0.430 (0.435) Acc@1 54.69 (60.39) Acc@5 78.91 (83.44)
|
||||
* Acc@1 60.950 Acc@5 84.070 Total time: 34.031
|
||||
Accuracy of initialized INT8 model: 60.950
|
||||
Test: [ 0/79] Time 0.407 (0.407) Acc@1 82.03 (82.03) Acc@5 91.41 (91.41)
|
||||
Test: [10/79] Time 0.387 (0.389) Acc@1 54.69 (66.69) Acc@5 85.16 (87.43)
|
||||
Test: [20/79] Time 0.387 (0.387) Acc@1 67.97 (63.99) Acc@5 84.38 (87.17)
|
||||
Test: [30/79] Time 0.386 (0.386) Acc@1 53.12 (62.42) Acc@5 77.34 (84.93)
|
||||
Test: [40/79] Time 0.385 (0.385) Acc@1 66.41 (60.96) Acc@5 90.62 (84.24)
|
||||
Test: [50/79] Time 0.385 (0.386) Acc@1 58.59 (60.71) Acc@5 88.28 (84.18)
|
||||
Test: [60/79] Time 0.387 (0.386) Acc@1 65.62 (60.26) Acc@5 85.94 (83.62)
|
||||
Test: [70/79] Time 0.385 (0.386) Acc@1 53.12 (60.00) Acc@5 80.47 (83.16)
|
||||
* Acc@1 60.450 Acc@5 83.800 Total time: 30.199
|
||||
Accuracy of initialized INT8 model: 60.450
|
||||
|
||||
|
||||
It should be noted that the inference time for the quantized PyTorch
|
||||
@@ -561,8 +608,10 @@ added to the model by NNCF. However, the model’s performance will
|
||||
significantly improve when it is in the OpenVINO Intermediate
|
||||
Representation (IR) format.
|
||||
|
||||
III. Convert the models to OpenVINO Intermediate Representation (OpenVINO IR)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
III. Convert the models to OpenVINO Intermediate Representation (OpenVINO IR)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
To convert the Pytorch models to OpenVINO IR, use Model Conversion
|
||||
Python API. The models will be saved to the ‘OUTPUT’ directory for later
|
||||
@@ -599,16 +648,16 @@ For more information about model conversion, refer to this
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/nncf/torch/quantization/layers.py:336: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/nncf/torch/quantization/layers.py:333: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
return self._level_low.item()
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/nncf/torch/quantization/layers.py:344: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/nncf/torch/quantization/layers.py:341: TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
|
||||
return self._level_high.item()
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/torch/jit/_trace.py:1093: TracerWarning: Output nr 1. of the traced function does not match the corresponding output of the Python function. Detailed error:
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/torch/jit/_trace.py:1093: TracerWarning: Output nr 1. of the traced function does not match the corresponding output of the Python function. Detailed error:
|
||||
Tensor-likes are not close!
|
||||
|
||||
Mismatched elements: 24180 / 25600 (94.5%)
|
||||
Greatest absolute difference: 0.3703504800796509 at index (32, 149) (up to 1e-05 allowed)
|
||||
Greatest relative difference: 11.865051118017842 at index (64, 158) (up to 1e-05 allowed)
|
||||
Mismatched elements: 25580 / 25600 (99.9%)
|
||||
Greatest absolute difference: 0.45703113079071045 at index (99, 85) (up to 1e-05 allowed)
|
||||
Greatest relative difference: 134.48766541727224 at index (92, 158) (up to 1e-05 allowed)
|
||||
_check_trace(
|
||||
|
||||
|
||||
@@ -649,15 +698,15 @@ Evaluate the FP32 and INT8 models.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Test: [ 0/79] Time 0.196 (0.196) Acc@1 81.25 (81.25) Acc@5 92.19 (92.19)
|
||||
Test: [10/79] Time 0.142 (0.146) Acc@1 56.25 (66.97) Acc@5 86.72 (87.50)
|
||||
Test: [20/79] Time 0.138 (0.143) Acc@1 67.97 (64.29) Acc@5 85.16 (87.35)
|
||||
Test: [30/79] Time 0.141 (0.142) Acc@1 53.12 (62.37) Acc@5 77.34 (85.33)
|
||||
Test: [40/79] Time 0.139 (0.142) Acc@1 67.19 (60.86) Acc@5 90.62 (84.51)
|
||||
Test: [50/79] Time 0.141 (0.141) Acc@1 60.16 (60.80) Acc@5 88.28 (84.42)
|
||||
Test: [60/79] Time 0.141 (0.141) Acc@1 66.41 (60.46) Acc@5 86.72 (83.79)
|
||||
Test: [70/79] Time 0.140 (0.141) Acc@1 52.34 (60.21) Acc@5 80.47 (83.33)
|
||||
* Acc@1 60.740 Acc@5 83.960 Total time: 11.027
|
||||
Test: [ 0/79] Time 0.192 (0.192) Acc@1 81.25 (81.25) Acc@5 92.19 (92.19)
|
||||
Test: [10/79] Time 0.135 (0.142) Acc@1 56.25 (66.97) Acc@5 86.72 (87.50)
|
||||
Test: [20/79] Time 0.138 (0.140) Acc@1 67.97 (64.29) Acc@5 85.16 (87.35)
|
||||
Test: [30/79] Time 0.136 (0.139) Acc@1 53.12 (62.37) Acc@5 77.34 (85.33)
|
||||
Test: [40/79] Time 0.138 (0.139) Acc@1 67.19 (60.86) Acc@5 90.62 (84.51)
|
||||
Test: [50/79] Time 0.138 (0.138) Acc@1 60.16 (60.80) Acc@5 88.28 (84.42)
|
||||
Test: [60/79] Time 0.137 (0.138) Acc@1 66.41 (60.46) Acc@5 86.72 (83.79)
|
||||
Test: [70/79] Time 0.138 (0.138) Acc@1 52.34 (60.21) Acc@5 80.47 (83.33)
|
||||
* Acc@1 60.740 Acc@5 83.960 Total time: 10.797
|
||||
Accuracy of FP32 IR model: 60.740
|
||||
|
||||
|
||||
@@ -670,20 +719,22 @@ Evaluate the FP32 and INT8 models.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Test: [ 0/79] Time 0.196 (0.196) Acc@1 82.03 (82.03) Acc@5 92.97 (92.97)
|
||||
Test: [10/79] Time 0.082 (0.092) Acc@1 59.38 (67.76) Acc@5 85.16 (88.07)
|
||||
Test: [20/79] Time 0.080 (0.086) Acc@1 67.97 (64.73) Acc@5 85.16 (87.65)
|
||||
Test: [30/79] Time 0.078 (0.084) Acc@1 52.34 (62.83) Acc@5 76.56 (85.36)
|
||||
Test: [40/79] Time 0.079 (0.083) Acc@1 69.53 (61.41) Acc@5 89.84 (84.20)
|
||||
Test: [50/79] Time 0.077 (0.082) Acc@1 60.94 (61.29) Acc@5 87.50 (84.08)
|
||||
Test: [60/79] Time 0.078 (0.082) Acc@1 67.19 (60.86) Acc@5 87.50 (83.52)
|
||||
Test: [70/79] Time 0.079 (0.081) Acc@1 54.69 (60.59) Acc@5 79.69 (83.10)
|
||||
* Acc@1 61.170 Acc@5 83.720 Total time: 6.361
|
||||
Accuracy of INT8 IR model: 61.170
|
||||
Test: [ 0/79] Time 0.138 (0.138) Acc@1 81.25 (81.25) Acc@5 92.19 (92.19)
|
||||
Test: [10/79] Time 0.077 (0.082) Acc@1 53.91 (66.83) Acc@5 85.94 (87.36)
|
||||
Test: [20/79] Time 0.076 (0.079) Acc@1 67.19 (64.10) Acc@5 83.59 (87.02)
|
||||
Test: [30/79] Time 0.076 (0.078) Acc@1 53.12 (62.15) Acc@5 76.56 (84.95)
|
||||
Test: [40/79] Time 0.076 (0.078) Acc@1 67.19 (60.71) Acc@5 89.06 (84.22)
|
||||
Test: [50/79] Time 0.074 (0.077) Acc@1 58.59 (60.68) Acc@5 88.28 (84.19)
|
||||
Test: [60/79] Time 0.080 (0.077) Acc@1 65.62 (60.31) Acc@5 87.50 (83.70)
|
||||
Test: [70/79] Time 0.074 (0.077) Acc@1 53.12 (60.08) Acc@5 79.69 (83.23)
|
||||
* Acc@1 60.620 Acc@5 83.890 Total time: 6.027
|
||||
Accuracy of INT8 IR model: 60.620
|
||||
|
||||
|
||||
IV. Compare performance of INT8 model and FP32 model in OpenVINO
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
IV. Compare performance of INT8 model and FP32 model in OpenVINO
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Finally, measure the inference performance of the ``FP32`` and ``INT8``
|
||||
models, using `Benchmark
|
||||
@@ -742,13 +793,13 @@ throughput (frames per second) values.
|
||||
.. parsed-literal::
|
||||
|
||||
Benchmark FP32 model (OpenVINO IR)
|
||||
[ INFO ] Throughput: 38.82 FPS
|
||||
[ INFO ] Throughput: 39.12 FPS
|
||||
Benchmark INT8 model (OpenVINO IR)
|
||||
[ INFO ] Throughput: 155.52 FPS
|
||||
[ INFO ] Throughput: 155.73 FPS
|
||||
Benchmark FP32 model (OpenVINO IR) synchronously
|
||||
[ INFO ] Throughput: 39.97 FPS
|
||||
[ INFO ] Throughput: 40.37 FPS
|
||||
Benchmark INT8 model (OpenVINO IR) synchronously
|
||||
[ INFO ] Throughput: 137.50 FPS
|
||||
[ INFO ] Throughput: 137.36 FPS
|
||||
|
||||
|
||||
Show device Information for reference:
|
||||
|
||||
@@ -26,13 +26,11 @@ This tutorial consists of the following steps:
|
||||
- `Prepare Dataset <#prepare-dataset>`__
|
||||
- `Perform Quantization <#perform-quantization>`__
|
||||
|
||||
- `Create Dataset for
|
||||
Validation <#create-dataset-for-validation>`__
|
||||
- `Create Dataset for Validation <#create-dataset-for-validation>`__
|
||||
|
||||
- `Run nncf.quantize for Getting an Optimized
|
||||
Model <#run-nncfquantize-for-getting-an-optimized-model>`__
|
||||
- `Serialize an OpenVINO IR
|
||||
model <#serialize-an-openvino-ir-model>`__
|
||||
- `Serialize an OpenVINO IR model <#serialize-an-openvino-ir-model>`__
|
||||
- `Compare Accuracy of the Original and Quantized
|
||||
Models <#compare-accuracy-of-the-original-and-quantized-models>`__
|
||||
|
||||
@@ -66,8 +64,10 @@ This tutorial consists of the following steps:
|
||||
DATA_DIR.mkdir(exist_ok=True)
|
||||
MODEL_DIR.mkdir(exist_ok=True)
|
||||
|
||||
Prepare the Model
|
||||
-----------------------------------------------------------
|
||||
Prepare the Model
|
||||
-----------------
|
||||
|
||||
|
||||
|
||||
Model preparation stage has the following steps:
|
||||
|
||||
@@ -91,10 +91,10 @@ Model preparation stage has the following steps:
|
||||
Cloning into 'pytorch-cifar-models'...
|
||||
remote: Enumerating objects: 282, done.[K
|
||||
remote: Counting objects: 100% (281/281), done.[K
|
||||
remote: Compressing objects: 100% (95/95), done.[K
|
||||
remote: Total 282 (delta 136), reused 269 (delta 129), pack-reused 1[K
|
||||
Receiving objects: 100% (282/282), 9.22 MiB | 3.32 MiB/s, done.
|
||||
Resolving deltas: 100% (136/136), done.
|
||||
remote: Compressing objects: 100% (96/96), done.[K
|
||||
remote: Total 282 (delta 135), reused 269 (delta 128), pack-reused 1[K
|
||||
Receiving objects: 100% (282/282), 9.22 MiB | 3.72 MiB/s, done.
|
||||
Resolving deltas: 100% (135/135), done.
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -125,8 +125,10 @@ can be found on this
|
||||
|
||||
ov.save_model(ov_model, MODEL_DIR / "mobilenet_v2.xml")
|
||||
|
||||
Prepare Dataset
|
||||
---------------------------------------------------------
|
||||
Prepare Dataset
|
||||
---------------
|
||||
|
||||
|
||||
|
||||
We will use `CIFAR10 <https://www.cs.toronto.edu/~kriz/cifar.html>`__
|
||||
dataset from
|
||||
@@ -158,7 +160,7 @@ Preprocessing for model obtained from training
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
100%|██████████| 170498071/170498071 [01:12<00:00, 2348008.09it/s]
|
||||
100%|██████████| 170498071/170498071 [00:48<00:00, 3527631.36it/s]
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -166,8 +168,10 @@ Preprocessing for model obtained from training
|
||||
Extracting data/cifar-10-python.tar.gz to data
|
||||
|
||||
|
||||
Perform Quantization
|
||||
--------------------------------------------------------------
|
||||
Perform Quantization
|
||||
--------------------
|
||||
|
||||
|
||||
|
||||
`NNCF <https://github.com/openvinotoolkit/nncf>`__ provides a suite of
|
||||
advanced algorithms for Neural Networks inference optimization in
|
||||
@@ -180,8 +184,10 @@ MobileNetV2. The optimization process contains the following steps:
|
||||
3. Serialize an OpenVINO IR model, using the ``openvino.save_model``
|
||||
function.
|
||||
|
||||
Create Dataset for Validation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Create Dataset for Validation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
NNCF is compatible with ``torch.utils.data.DataLoader`` interface. For
|
||||
performing quantization it should be passed into ``nncf.Dataset`` object
|
||||
@@ -205,8 +211,10 @@ model during quantization, in our case, to pick input tensor from pair
|
||||
INFO:nncf:NNCF initialized successfully. Supported frameworks detected: torch, tensorflow, onnx, openvino
|
||||
|
||||
|
||||
Run nncf.quantize for Getting an Optimized Model
|
||||
------------------------------------------------------------------------------------------
|
||||
Run nncf.quantize for Getting an Optimized Model
|
||||
------------------------------------------------
|
||||
|
||||
|
||||
|
||||
``nncf.quantize`` function accepts model and prepared quantization
|
||||
dataset for performing basic quantization. Optionally, additional
|
||||
@@ -222,16 +230,58 @@ about supported parameters can be found on this
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-10-30 22:54:06.313060: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-10-30 22:54:06.344685: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
2023-12-06 23:00:00.245123: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-12-06 23:00:00.276123: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
|
||||
2023-10-30 22:54:06.959396: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
Statistics collection: 100%|██████████| 300/300 [00:09<00:00, 31.98it/s]
|
||||
Applying Fast Bias correction: 100%|██████████| 36/36 [00:01<00:00, 20.03it/s]
|
||||
2023-12-06 23:00:00.791927: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Output()
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"></pre>
|
||||
|
||||
|
||||
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
Serialize an OpenVINO IR model
|
||||
------------------------------
|
||||
|
||||
|
||||
Serialize an OpenVINO IR model
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Similar to ``ov.convert_model``, quantized model is ``ov.Model`` object
|
||||
which ready to be loaded into device and can be serialized on disk using
|
||||
@@ -241,8 +291,10 @@ which ready to be loaded into device and can be serialized on disk using
|
||||
|
||||
ov.save_model(quant_ov_model, MODEL_DIR / "quantized_mobilenet_v2.xml")
|
||||
|
||||
Compare Accuracy of the Original and Quantized Models
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Compare Accuracy of the Original and Quantized Models
|
||||
-----------------------------------------------------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -259,8 +311,10 @@ Compare Accuracy of the Original and Quantized Models
|
||||
total += 1
|
||||
return correct / total
|
||||
|
||||
Select inference device
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Select inference device
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -321,8 +375,10 @@ select device from dropdown list for running inference using OpenVINO
|
||||
Accuracy of the optimized model: 93.54%
|
||||
|
||||
|
||||
Compare Performance of the Original and Quantized Models
|
||||
--------------------------------------------------------------------------------------------------
|
||||
Compare Performance of the Original and Quantized Models
|
||||
--------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Finally, measure the inference performance of the ``FP32`` and ``INT8``
|
||||
models, using `Benchmark
|
||||
@@ -348,18 +404,18 @@ Tool <https://docs.openvino.ai/2023.0/openvino_inference_engine_tools_benchmark_
|
||||
[ INFO ] Parsing input parameters
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ INFO ] AUTO
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ WARNING ] Performance hint was not explicitly specified in command line. Device(AUTO) performance hint will be set to PerformanceMode.THROUGHPUT.
|
||||
[Step 4/11] Reading model files
|
||||
[ INFO ] Loading model files
|
||||
[ INFO ] Read model took 9.74 ms
|
||||
[ INFO ] Read model took 9.65 ms
|
||||
[ INFO ] Original model I/O parameters:
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] x (node: x) : f32 / [...] / [1,3,32,32]
|
||||
@@ -373,7 +429,7 @@ Tool <https://docs.openvino.ai/2023.0/openvino_inference_engine_tools_benchmark_
|
||||
[ INFO ] Model outputs:
|
||||
[ INFO ] x.17 (node: aten::linear/Add) : f32 / [...] / [1,10]
|
||||
[Step 7/11] Loading the model to the device
|
||||
[ INFO ] Compile model took 198.03 ms
|
||||
[ INFO ] Compile model took 176.84 ms
|
||||
[Step 8/11] Querying optimal runtime parameters
|
||||
[ INFO ] Model:
|
||||
[ INFO ] NETWORK_NAME: Model2
|
||||
@@ -405,17 +461,17 @@ Tool <https://docs.openvino.ai/2023.0/openvino_inference_engine_tools_benchmark_
|
||||
[ INFO ] Fill input 'x' with random values
|
||||
[Step 10/11] Measuring performance (Start inference asynchronously, 12 inference requests, limits: 15000 ms duration)
|
||||
[ INFO ] Benchmarking in inference only mode (inputs filling are not included in measurement loop).
|
||||
[ INFO ] First inference took 3.36 ms
|
||||
[ INFO ] First inference took 3.23 ms
|
||||
[Step 11/11] Dumping statistics report
|
||||
[ INFO ] Execution Devices:['CPU']
|
||||
[ INFO ] Count: 90276 iterations
|
||||
[ INFO ] Duration: 15002.97 ms
|
||||
[ INFO ] Count: 87924 iterations
|
||||
[ INFO ] Duration: 15003.28 ms
|
||||
[ INFO ] Latency:
|
||||
[ INFO ] Median: 1.76 ms
|
||||
[ INFO ] Average: 1.79 ms
|
||||
[ INFO ] Min: 1.06 ms
|
||||
[ INFO ] Max: 8.55 ms
|
||||
[ INFO ] Throughput: 6017.21 FPS
|
||||
[ INFO ] Median: 1.82 ms
|
||||
[ INFO ] Average: 1.84 ms
|
||||
[ INFO ] Min: 1.20 ms
|
||||
[ INFO ] Max: 8.90 ms
|
||||
[ INFO ] Throughput: 5860.32 FPS
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -430,18 +486,18 @@ Tool <https://docs.openvino.ai/2023.0/openvino_inference_engine_tools_benchmark_
|
||||
[ INFO ] Parsing input parameters
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ INFO ] AUTO
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ WARNING ] Performance hint was not explicitly specified in command line. Device(AUTO) performance hint will be set to PerformanceMode.THROUGHPUT.
|
||||
[Step 4/11] Reading model files
|
||||
[ INFO ] Loading model files
|
||||
[ INFO ] Read model took 20.48 ms
|
||||
[ INFO ] Read model took 18.89 ms
|
||||
[ INFO ] Original model I/O parameters:
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] x (node: x) : f32 / [...] / [1,3,32,32]
|
||||
@@ -455,7 +511,7 @@ Tool <https://docs.openvino.ai/2023.0/openvino_inference_engine_tools_benchmark_
|
||||
[ INFO ] Model outputs:
|
||||
[ INFO ] x.17 (node: aten::linear/Add) : f32 / [...] / [1,10]
|
||||
[Step 7/11] Loading the model to the device
|
||||
[ INFO ] Compile model took 316.40 ms
|
||||
[ INFO ] Compile model took 344.83 ms
|
||||
[Step 8/11] Querying optimal runtime parameters
|
||||
[ INFO ] Model:
|
||||
[ INFO ] NETWORK_NAME: Model2
|
||||
@@ -487,21 +543,23 @@ Tool <https://docs.openvino.ai/2023.0/openvino_inference_engine_tools_benchmark_
|
||||
[ INFO ] Fill input 'x' with random values
|
||||
[Step 10/11] Measuring performance (Start inference asynchronously, 12 inference requests, limits: 15000 ms duration)
|
||||
[ INFO ] Benchmarking in inference only mode (inputs filling are not included in measurement loop).
|
||||
[ INFO ] First inference took 1.86 ms
|
||||
[ INFO ] First inference took 2.03 ms
|
||||
[Step 11/11] Dumping statistics report
|
||||
[ INFO ] Execution Devices:['CPU']
|
||||
[ INFO ] Count: 165852 iterations
|
||||
[ INFO ] Duration: 15001.03 ms
|
||||
[ INFO ] Count: 163332 iterations
|
||||
[ INFO ] Duration: 15000.99 ms
|
||||
[ INFO ] Latency:
|
||||
[ INFO ] Median: 1.01 ms
|
||||
[ INFO ] Average: 1.04 ms
|
||||
[ INFO ] Min: 0.69 ms
|
||||
[ INFO ] Max: 6.71 ms
|
||||
[ INFO ] Throughput: 11056.04 FPS
|
||||
[ INFO ] Median: 1.02 ms
|
||||
[ INFO ] Average: 1.06 ms
|
||||
[ INFO ] Min: 0.71 ms
|
||||
[ INFO ] Max: 15.01 ms
|
||||
[ INFO ] Throughput: 10888.08 FPS
|
||||
|
||||
|
||||
Compare results on four pictures
|
||||
--------------------------------
|
||||
|
||||
|
||||
Compare results on four pictures
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b843161ca6e7220e4a7e33d700810df2dcc71bd501dec5ed138aa08a3bc6ebee
|
||||
oid sha256:16f09304ce7269cd0c468bb30705c6f414668fd03616e594e4b89c5734bbd6d4
|
||||
size 14855
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/113-image-classification-quantization-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/113-image-classification-quantization-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/113-image-classification-quantization-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="113-image-classification-quantization-with-output_30_2.png">113-image-classification-quantization-with-outp..></a> 31-Oct-2023 00:35 14855
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/113-image-classification-quantization-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="113-image-classification-quantization-with-output_30_2.png">113-image-classification-quantization-with-outp..></a> 07-Dec-2023 00:49 14855
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -13,6 +13,7 @@ requests) rather than wait for the current inference to complete first.
|
||||
|
||||
**Table of contents:**
|
||||
|
||||
|
||||
- `Imports <#imports>`__
|
||||
- `Prepare model and data
|
||||
processing <#prepare-model-and-data-processing>`__
|
||||
@@ -36,8 +37,7 @@ requests) rather than wait for the current inference to complete first.
|
||||
- `AsyncInferQueue <#asyncinferqueue>`__
|
||||
|
||||
- `Setting Callback <#setting-callback>`__
|
||||
- `Test the performance with
|
||||
AsyncInferQueue <#test-the-performance-with-asyncinferqueue>`__
|
||||
- `Test the performance with AsyncInferQueue <#test-the-performance-with-asyncinferqueue>`__
|
||||
|
||||
Imports
|
||||
-------
|
||||
@@ -46,8 +46,15 @@ Imports
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
# %pip install -q "openvino>=2023.1.0"
|
||||
# %pip install -q opencv-python matplotlib
|
||||
%pip install -q "openvino>=2023.1.0"
|
||||
%pip install -q opencv-python matplotlib
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -306,7 +313,7 @@ Test performance in Sync Mode
|
||||
.. parsed-literal::
|
||||
|
||||
Source ended
|
||||
average throuput in sync mode: 38.27 fps
|
||||
average throuput in sync mode: 40.67 fps
|
||||
|
||||
|
||||
Async Mode
|
||||
@@ -445,7 +452,7 @@ Test the performance in Async Mode
|
||||
.. parsed-literal::
|
||||
|
||||
Source ended
|
||||
average throuput in async mode: 72.15 fps
|
||||
average throuput in async mode: 74.75 fps
|
||||
|
||||
|
||||
Compare the performance
|
||||
@@ -588,5 +595,5 @@ Test the performance with ``AsyncInferQueue``
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
average throughput in async mode with async infer queue: 105.36 fps
|
||||
average throughput in async mode with async infer queue: 111.75 fps
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e4f523a824b6e628ef48fa654a0af2dedb2661f23bf18bc31d1e9cc37540fccd
|
||||
size 30440
|
||||
oid sha256:8b8c8b61f0bbb25c280a3e72cf2172fd29bf11668231cb3d2527c1b8a05307f2
|
||||
size 30406
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231114220808/dist/rst_files/115-async-api-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/115-async-api-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231114220808/dist/rst_files/115-async-api-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="115-async-api-with-output_15_0.png">115-async-api-with-output_15_0.png</a> 15-Nov-2023 00:43 4307
|
||||
<a href="115-async-api-with-output_19_0.png">115-async-api-with-output_19_0.png</a> 15-Nov-2023 00:43 4307
|
||||
<a href="115-async-api-with-output_21_0.png">115-async-api-with-output_21_0.png</a> 15-Nov-2023 00:43 30440
|
||||
<a href="115-async-api-with-output_27_0.png">115-async-api-with-output_27_0.png</a> 15-Nov-2023 00:43 4307
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/115-async-api-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="115-async-api-with-output_15_0.png">115-async-api-with-output_15_0.png</a> 07-Dec-2023 00:49 4307
|
||||
<a href="115-async-api-with-output_19_0.png">115-async-api-with-output_19_0.png</a> 07-Dec-2023 00:49 4307
|
||||
<a href="115-async-api-with-output_21_0.png">115-async-api-with-output_21_0.png</a> 07-Dec-2023 00:49 30406
|
||||
<a href="115-async-api-with-output_27_0.png">115-async-api-with-output_27_0.png</a> 07-Dec-2023 00:49 4307
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -37,13 +37,15 @@ consists of the following steps:
|
||||
performance <#benchmark-quantized-sparse-inference-performance>`__
|
||||
- `When this might be helpful <#when-this-might-be-helpful>`__
|
||||
|
||||
Prerequisites
|
||||
-------------------------------------------------------
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
%pip install -q "openvino>=2023.1.0"
|
||||
%pip install -q "git+https://github.com/huggingface/optimum-intel.git" datasets onnx onnxruntime
|
||||
%pip install -q "git+https://github.com/huggingface/optimum-intel.git" datasets onnx transformers>=4.33.0 --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -52,8 +54,10 @@ Prerequisites
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
Imports
|
||||
-------------------------------------------------
|
||||
Imports
|
||||
-------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -73,16 +77,16 @@ Imports
|
||||
.. parsed-literal::
|
||||
|
||||
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
|
||||
2023-10-30 22:57:12.569340: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-10-30 22:57:12.603049: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
2023-12-06 23:02:39.282111: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-12-06 23:02:39.316382: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
|
||||
2023-10-30 22:57:13.131994: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/transformers/deepspeed.py:23: FutureWarning: transformers.deepspeed module is deprecated and will be removed in a future version. Please import deepspeed modules directly from transformers.integrations
|
||||
warnings.warn(
|
||||
2023-12-06 23:02:40.030243: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
|
||||
|
||||
Download, quantize and sparsify the model, using Hugging Face Optimum API
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Download, quantize and sparsify the model, using Hugging Face Optimum API
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The first step is to download a quantized sparse transformers which has
|
||||
been translated to OpenVINO IR. Then, it will be put through a
|
||||
@@ -113,7 +117,7 @@ model card on Hugging Face.
|
||||
.. parsed-literal::
|
||||
|
||||
Compiling the model to CPU ...
|
||||
Set CACHE_DIR to /opt/home/k8sworker/.cache/huggingface/hub/models--OpenVINO--bert-base-uncased-sst2-int8-unstructured80/snapshots/dc44eb46300882463d50ee847e0f6485bad3cdad/model_cache
|
||||
Setting OpenVINO CACHE_DIR to /opt/home/k8sworker/.cache/huggingface/hub/models--OpenVINO--bert-base-uncased-sst2-int8-unstructured80/snapshots/dc44eb46300882463d50ee847e0f6485bad3cdad/model_cache
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -147,8 +151,10 @@ the IRs into a single folder.
|
||||
|
||||
|
||||
|
||||
Benchmark quantized dense inference performance
|
||||
-----------------------------------------------------------------------------------------
|
||||
Benchmark quantized dense inference performance
|
||||
-----------------------------------------------
|
||||
|
||||
|
||||
|
||||
Benchmark dense inference performance using parallel execution on four
|
||||
CPU cores to simulate a small instance in the cloud infrastructure.
|
||||
@@ -187,18 +193,18 @@ as an example. It is recommended to tune based on your applications.
|
||||
[ INFO ] Parsing input parameters
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ INFO ] CPU
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ WARNING ] Performance hint was not explicitly specified in command line. Device(CPU) performance hint will be set to PerformanceMode.THROUGHPUT.
|
||||
[Step 4/11] Reading model files
|
||||
[ INFO ] Loading model files
|
||||
[ INFO ] Read model took 77.13 ms
|
||||
[ INFO ] Read model took 60.26 ms
|
||||
[ INFO ] Original model I/O parameters:
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] input_ids (node: input_ids) : i64 / [...] / [?,?]
|
||||
@@ -209,7 +215,7 @@ as an example. It is recommended to tune based on your applications.
|
||||
[Step 5/11] Resizing model to match image sizes and given batch
|
||||
[ INFO ] Model batch size: 1
|
||||
[ INFO ] Reshaping model: 'input_ids': [1,64], 'attention_mask': [1,64], 'token_type_ids': [1,64]
|
||||
[ INFO ] Reshape model took 25.98 ms
|
||||
[ INFO ] Reshape model took 24.75 ms
|
||||
[Step 6/11] Configuring input of the model
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] input_ids (node: input_ids) : i64 / [...] / [1,64]
|
||||
@@ -218,7 +224,7 @@ as an example. It is recommended to tune based on your applications.
|
||||
[ INFO ] Model outputs:
|
||||
[ INFO ] logits (node: logits) : f32 / [...] / [1,2]
|
||||
[Step 7/11] Loading the model to the device
|
||||
[ INFO ] Compile model took 970.05 ms
|
||||
[ INFO ] Compile model took 1092.05 ms
|
||||
[Step 8/11] Querying optimal runtime parameters
|
||||
[ INFO ] Model:
|
||||
[ INFO ] NETWORK_NAME: torch_jit
|
||||
@@ -246,21 +252,23 @@ as an example. It is recommended to tune based on your applications.
|
||||
[ INFO ] Fill input 'token_type_ids' with random values
|
||||
[Step 10/11] Measuring performance (Start inference asynchronously, 4 inference requests, limits: 60000 ms duration)
|
||||
[ INFO ] Benchmarking in inference only mode (inputs filling are not included in measurement loop).
|
||||
[ INFO ] First inference took 28.50 ms
|
||||
[ INFO ] First inference took 27.56 ms
|
||||
[Step 11/11] Dumping statistics report
|
||||
[ INFO ] Execution Devices:['CPU']
|
||||
[ INFO ] Count: 9116 iterations
|
||||
[ INFO ] Duration: 60051.84 ms
|
||||
[ INFO ] Count: 8952 iterations
|
||||
[ INFO ] Duration: 60029.00 ms
|
||||
[ INFO ] Latency:
|
||||
[ INFO ] Median: 26.14 ms
|
||||
[ INFO ] Average: 26.19 ms
|
||||
[ INFO ] Min: 24.91 ms
|
||||
[ INFO ] Max: 41.99 ms
|
||||
[ INFO ] Throughput: 151.80 FPS
|
||||
[ INFO ] Median: 26.46 ms
|
||||
[ INFO ] Average: 26.52 ms
|
||||
[ INFO ] Min: 25.37 ms
|
||||
[ INFO ] Max: 40.49 ms
|
||||
[ INFO ] Throughput: 149.13 FPS
|
||||
|
||||
|
||||
Benchmark quantized sparse inference performance
|
||||
------------------------------------------------
|
||||
|
||||
|
||||
Benchmark quantized sparse inference performance
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
To enable sparse weight decompression feature, users can add it to
|
||||
runtime config like below. ``CPU_SPARSE_WEIGHTS_DECOMPRESSION_RATE``
|
||||
@@ -300,18 +308,18 @@ for which a layer will be enabled.
|
||||
[ INFO ] Parsing input parameters
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ INFO ] CPU
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ WARNING ] Performance hint was not explicitly specified in command line. Device(CPU) performance hint will be set to PerformanceMode.THROUGHPUT.
|
||||
[Step 4/11] Reading model files
|
||||
[ INFO ] Loading model files
|
||||
[ INFO ] Read model took 83.15 ms
|
||||
[ INFO ] Read model took 61.56 ms
|
||||
[ INFO ] Original model I/O parameters:
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] input_ids (node: input_ids) : i64 / [...] / [?,?]
|
||||
@@ -322,7 +330,7 @@ for which a layer will be enabled.
|
||||
[Step 5/11] Resizing model to match image sizes and given batch
|
||||
[ INFO ] Model batch size: 1
|
||||
[ INFO ] Reshaping model: 'input_ids': [1,64], 'attention_mask': [1,64], 'token_type_ids': [1,64]
|
||||
[ INFO ] Reshape model took 26.29 ms
|
||||
[ INFO ] Reshape model took 24.68 ms
|
||||
[Step 6/11] Configuring input of the model
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] input_ids (node: input_ids) : i64 / [...] / [1,64]
|
||||
@@ -331,7 +339,7 @@ for which a layer will be enabled.
|
||||
[ INFO ] Model outputs:
|
||||
[ INFO ] logits (node: logits) : f32 / [...] / [1,2]
|
||||
[Step 7/11] Loading the model to the device
|
||||
[ INFO ] Compile model took 903.83 ms
|
||||
[ INFO ] Compile model took 1029.24 ms
|
||||
[Step 8/11] Querying optimal runtime parameters
|
||||
[ INFO ] Model:
|
||||
[ INFO ] NETWORK_NAME: torch_jit
|
||||
@@ -359,21 +367,23 @@ for which a layer will be enabled.
|
||||
[ INFO ] Fill input 'token_type_ids' with random values
|
||||
[Step 10/11] Measuring performance (Start inference asynchronously, 4 inference requests, limits: 60000 ms duration)
|
||||
[ INFO ] Benchmarking in inference only mode (inputs filling are not included in measurement loop).
|
||||
[ INFO ] First inference took 29.52 ms
|
||||
[ INFO ] First inference took 29.95 ms
|
||||
[Step 11/11] Dumping statistics report
|
||||
[ INFO ] Execution Devices:['CPU']
|
||||
[ INFO ] Count: 9128 iterations
|
||||
[ INFO ] Duration: 60046.44 ms
|
||||
[ INFO ] Count: 8984 iterations
|
||||
[ INFO ] Duration: 60026.81 ms
|
||||
[ INFO ] Latency:
|
||||
[ INFO ] Median: 26.15 ms
|
||||
[ INFO ] Average: 26.18 ms
|
||||
[ INFO ] Min: 25.14 ms
|
||||
[ INFO ] Max: 42.73 ms
|
||||
[ INFO ] Throughput: 152.02 FPS
|
||||
[ INFO ] Median: 26.52 ms
|
||||
[ INFO ] Average: 26.59 ms
|
||||
[ INFO ] Min: 23.89 ms
|
||||
[ INFO ] Max: 40.95 ms
|
||||
[ INFO ] Throughput: 149.67 FPS
|
||||
|
||||
|
||||
When this might be helpful
|
||||
--------------------------
|
||||
|
||||
|
||||
When this might be helpful
|
||||
--------------------------------------------------------------------
|
||||
|
||||
This feature can improve inference performance for models with sparse
|
||||
weights in the scenarios when the model is deployed to handle multiple
|
||||
|
||||
@@ -27,18 +27,21 @@ and do inference with a sample image.
|
||||
Format <#convert-a-model-to-openvino-ir-format>`__
|
||||
- `Load model using OpenVINO TensorFlow Lite
|
||||
Frontend <#load-model-using-openvino-tensorflow-lite-frontend>`__
|
||||
- `Run OpenVINO model
|
||||
inference <#run-openvino-model-inference>`__
|
||||
- `Run OpenVINO model inference <#run-openvino-model-inference>`__
|
||||
|
||||
- `Select inference device <#select-inference-device>`__
|
||||
|
||||
- `Estimate Model Performance <#estimate-model-performance>`__
|
||||
|
||||
Preparation
|
||||
-----------------------------------------------------
|
||||
Preparation
|
||||
-----------
|
||||
|
||||
|
||||
|
||||
Install requirements
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Install requirements
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -59,8 +62,10 @@ Install requirements
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
Imports
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Imports
|
||||
~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -71,8 +76,10 @@ Imports
|
||||
|
||||
from notebook_utils import download_file, load_image
|
||||
|
||||
Download TFLite model
|
||||
---------------------------------------------------------------
|
||||
Download TFLite model
|
||||
---------------------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -80,7 +87,7 @@ Download TFLite model
|
||||
tflite_model_path = model_dir / "efficientnet_lite0_fp32_2.tflite"
|
||||
|
||||
ov_model_path = tflite_model_path.with_suffix(".xml")
|
||||
model_url = "https://tfhub.dev/tensorflow/lite-model/efficientnet/lite0/fp32/2?lite-format=tflite"
|
||||
model_url = "https://www.kaggle.com/models/tensorflow/efficientnet/frameworks/tfLite/variations/lite0-fp32/versions/2?lite-format=tflite"
|
||||
|
||||
download_file(model_url, tflite_model_path.name, model_dir)
|
||||
|
||||
@@ -95,12 +102,14 @@ Download TFLite model
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/119-tflite-to-openvino/model/efficientnet_lite0_fp32_2.tflite')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/119-tflite-to-openvino/model/efficientnet_lite0_fp32_2.tflite')
|
||||
|
||||
|
||||
|
||||
Convert a Model to OpenVINO IR Format
|
||||
-------------------------------------------------------------------------------
|
||||
Convert a Model to OpenVINO IR Format
|
||||
-------------------------------------
|
||||
|
||||
|
||||
|
||||
To convert the TFLite model to OpenVINO IR, model conversion Python API
|
||||
can be used. ``ov.convert_model`` function accepts the path to the
|
||||
@@ -127,13 +136,15 @@ For TensorFlow Lite models support, refer to this
|
||||
Model model/efficientnet_lite0_fp32_2.tflite successfully converted and saved to model/efficientnet_lite0_fp32_2.xml
|
||||
|
||||
|
||||
Load model using OpenVINO TensorFlow Lite Frontend
|
||||
--------------------------------------------------------------------------------------------
|
||||
Load model using OpenVINO TensorFlow Lite Frontend
|
||||
--------------------------------------------------
|
||||
|
||||
|
||||
|
||||
TensorFlow Lite models are supported via ``FrontEnd`` API. You may skip
|
||||
conversion to IR and read models directly by OpenVINO runtime API. For
|
||||
more examples supported formats reading via Frontend API, please look
|
||||
this `tutorial <002-openvino-api-with-output.html>`__.
|
||||
this `tutorial <../002-openvino-api>`__.
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -141,8 +152,10 @@ this `tutorial <002-openvino-api-with-output.html>`__.
|
||||
|
||||
ov_model = core.read_model(tflite_model_path)
|
||||
|
||||
Run OpenVINO model inference
|
||||
----------------------------------------------------------------------
|
||||
Run OpenVINO model inference
|
||||
----------------------------
|
||||
|
||||
|
||||
|
||||
We can find information about model input preprocessing in its
|
||||
`description <https://tfhub.dev/tensorflow/lite-model/efficientnet/lite0/fp32/2>`__
|
||||
@@ -156,8 +169,10 @@ on `TensorFlow Hub <https://tfhub.dev/>`__.
|
||||
resized_image = image.resize((224, 224))
|
||||
input_tensor = np.expand_dims((np.array(resized_image).astype(np.float32) - 127) / 128, 0)
|
||||
|
||||
Select inference device
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Select inference device
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -216,8 +231,8 @@ select device from dropdown list for running inference using OpenVINO
|
||||
Predicted label: n02109047 Great Dane with probability 0.715318
|
||||
|
||||
|
||||
Estimate Model Performance
|
||||
--------------------------------------------------------------------
|
||||
Estimate Model Performance
|
||||
--------------------------
|
||||
|
||||
`Benchmark
|
||||
Tool <https://docs.openvino.ai/latest/openvino_inference_engine_tools_benchmark_tool_README.html>`__
|
||||
@@ -247,18 +262,18 @@ GPU.
|
||||
[ INFO ] Parsing input parameters
|
||||
[Step 2/11] Loading OpenVINO Runtime
|
||||
[ INFO ] OpenVINO:
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ] Device info:
|
||||
[ INFO ] CPU
|
||||
[ INFO ] Build ................................. 2023.1.0-12185-9e6b00e51cd-releases/2023/1
|
||||
[ INFO ] Build ................................. 2023.2.0-13089-cfd42bd2cb0-HEAD
|
||||
[ INFO ]
|
||||
[ INFO ]
|
||||
[Step 3/11] Setting device configuration
|
||||
[ WARNING ] Performance hint was not explicitly specified in command line. Device(CPU) performance hint will be set to PerformanceMode.THROUGHPUT.
|
||||
[Step 4/11] Reading model files
|
||||
[ INFO ] Loading model files
|
||||
[ INFO ] Read model took 29.37 ms
|
||||
[ INFO ] Read model took 28.35 ms
|
||||
[ INFO ] Original model I/O parameters:
|
||||
[ INFO ] Model inputs:
|
||||
[ INFO ] images (node: images) : f32 / [...] / [1,224,224,3]
|
||||
@@ -272,7 +287,7 @@ GPU.
|
||||
[ INFO ] Model outputs:
|
||||
[ INFO ] Softmax (node: 63) : f32 / [...] / [1,1000]
|
||||
[Step 7/11] Loading the model to the device
|
||||
[ INFO ] Compile model took 133.03 ms
|
||||
[ INFO ] Compile model took 147.48 ms
|
||||
[Step 8/11] Querying optimal runtime parameters
|
||||
[ INFO ] Model:
|
||||
[ INFO ] NETWORK_NAME: TensorFlow_Lite_Frontend_IR
|
||||
@@ -296,15 +311,15 @@ GPU.
|
||||
[ INFO ] Fill input 'images' with random values
|
||||
[Step 10/11] Measuring performance (Start inference asynchronously, 6 inference requests, limits: 15000 ms duration)
|
||||
[ INFO ] Benchmarking in inference only mode (inputs filling are not included in measurement loop).
|
||||
[ INFO ] First inference took 7.30 ms
|
||||
[ INFO ] First inference took 7.23 ms
|
||||
[Step 11/11] Dumping statistics report
|
||||
[ INFO ] Execution Devices:['CPU']
|
||||
[ INFO ] Count: 17562 iterations
|
||||
[ INFO ] Duration: 15010.30 ms
|
||||
[ INFO ] Count: 17526 iterations
|
||||
[ INFO ] Duration: 15005.83 ms
|
||||
[ INFO ] Latency:
|
||||
[ INFO ] Median: 4.98 ms
|
||||
[ INFO ] Average: 4.99 ms
|
||||
[ INFO ] Min: 3.69 ms
|
||||
[ INFO ] Max: 15.16 ms
|
||||
[ INFO ] Throughput: 1170.00 FPS
|
||||
[ INFO ] Median: 5.00 ms
|
||||
[ INFO ] Average: 5.00 ms
|
||||
[ INFO ] Min: 2.72 ms
|
||||
[ INFO ] Max: 15.43 ms
|
||||
[ INFO ] Throughput: 1167.95 FPS
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/119-tflite-to-openvino-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/119-tflite-to-openvino-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/119-tflite-to-openvino-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="119-tflite-to-openvino-with-output_16_1.jpg">119-tflite-to-openvino-with-output_16_1.jpg</a> 31-Oct-2023 00:35 68170
|
||||
<a href="119-tflite-to-openvino-with-output_16_1.png">119-tflite-to-openvino-with-output_16_1.png</a> 31-Oct-2023 00:35 621006
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/119-tflite-to-openvino-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="119-tflite-to-openvino-with-output_16_1.jpg">119-tflite-to-openvino-with-output_16_1.jpg</a> 07-Dec-2023 00:49 68170
|
||||
<a href="119-tflite-to-openvino-with-output_16_1.png">119-tflite-to-openvino-with-output_16_1.png</a> 07-Dec-2023 00:49 621006
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -25,7 +25,6 @@ Runtime <https://docs.openvino.ai/nightly/openvino_docs_OV_UG_OV_Runtime_User_Gu
|
||||
and do inference with a sample image.
|
||||
|
||||
**Table of contents:**
|
||||
--
|
||||
|
||||
- `Prerequisites <#prerequisites>`__
|
||||
- `Imports <#imports>`__
|
||||
@@ -43,8 +42,10 @@ and do inference with a sample image.
|
||||
- `Async inference pipeline <#async-inference-pipeline>`__
|
||||
- `Integration preprocessing to model <#integration-preprocessing-to-model>`__
|
||||
|
||||
Prerequisites
|
||||
-------------------------------------------------------
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
|
||||
|
||||
Install required packages:
|
||||
|
||||
@@ -71,8 +72,10 @@ The notebook uses utility functions. The cell below will download the
|
||||
filename="notebook_utils.py",
|
||||
);
|
||||
|
||||
Imports
|
||||
-------------------------------------------------
|
||||
Imports
|
||||
-------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -90,8 +93,10 @@ Imports
|
||||
# OpenVINO modules
|
||||
import openvino as ov
|
||||
|
||||
Settings
|
||||
--------------------------------------------------
|
||||
Settings
|
||||
--------
|
||||
|
||||
|
||||
|
||||
Define model related variables and create corresponding directories:
|
||||
|
||||
@@ -113,12 +118,14 @@ Define model related variables and create corresponding directories:
|
||||
|
||||
openvino_ir_path = ir_model_dir / f"{model_name}.xml"
|
||||
|
||||
tf_model_url = "https://tfhub.dev/tensorflow/mask_rcnn/inception_resnet_v2_1024x1024/1?tf-hub-format=compressed"
|
||||
tf_model_url = "https://www.kaggle.com/models/tensorflow/mask-rcnn-inception-resnet-v2/frameworks/tensorFlow2/variations/1024x1024/versions/1?tf-hub-format=compressed"
|
||||
|
||||
tf_model_archive_filename = f"{model_name}.tar.gz"
|
||||
|
||||
Download Model from TensorFlow Hub
|
||||
----------------------------------------------------------------------------
|
||||
Download Model from TensorFlow Hub
|
||||
----------------------------------
|
||||
|
||||
|
||||
|
||||
Download archive with TensorFlow Instance Segmentation model
|
||||
(`mask_rcnn_inception_resnet_v2_1024x1024 <https://tfhub.dev/tensorflow/mask_rcnn/inception_resnet_v2_1024x1024/1>`__)
|
||||
@@ -149,8 +156,10 @@ archive:
|
||||
with tarfile.open(tf_model_dir / tf_model_archive_filename) as file:
|
||||
file.extractall(path=tf_model_dir)
|
||||
|
||||
Convert Model to OpenVINO IR
|
||||
----------------------------------------------------------------------
|
||||
Convert Model to OpenVINO IR
|
||||
----------------------------
|
||||
|
||||
|
||||
|
||||
OpenVINO Model Optimizer Python API can be used to convert the
|
||||
TensorFlow model to OpenVINO IR.
|
||||
@@ -175,11 +184,15 @@ when the model is run in the future.
|
||||
# Save converted OpenVINO IR model to the corresponding directory
|
||||
ov.save_model(ov_model, openvino_ir_path)
|
||||
|
||||
Test Inference on the Converted Model
|
||||
-------------------------------------------------------------------------------
|
||||
Test Inference on the Converted Model
|
||||
-------------------------------------
|
||||
|
||||
|
||||
|
||||
Select inference device
|
||||
-----------------------
|
||||
|
||||
|
||||
Select inference device
|
||||
-----------------------------------------------------------------
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -206,31 +219,35 @@ select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
|
||||
|
||||
Load the Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Load the Model
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
openvino_ir_model = core.read_model(openvino_ir_path)
|
||||
compiled_model = core.compile_model(model=openvino_ir_model, device_name=device.value)
|
||||
|
||||
Get Model Information
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Get Model Information
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Mask R-CNN with Inception ResNet V2 instance segmentation model has one
|
||||
input - a three-channel image of variable size. The input tensor shape
|
||||
is ``[1, height, width, 3]`` with values in ``[0, 255]``.
|
||||
|
||||
Model output dictionary contains a lot of tensors, we will use only 5 of
|
||||
them:
|
||||
|
||||
- ``num_detections``: A ``tf.int`` tensor with only one value, the number of detections ``[N]``.
|
||||
- ``detection_boxes``: A ``tf.float32`` tensor of shape ``[N, 4]`` containing bounding box coordinates in the following order: ``[ymin, xmin, ymax, xmax]``.
|
||||
- ``detection_classes``: A ``tf.int`` tensor of shape ``[N]`` containing detection class index from the label file.
|
||||
- ``detection_scores``: A ``tf.float32`` tensor of shape ``[N]`` containing detection scores.
|
||||
- ``detection_masks``: A ``[batch, max_detections, mask_height, mask_width]`` tensor.
|
||||
|
||||
Note that apixel-wise sigmoid score converter is applied to the detection masks.
|
||||
them: - ``num_detections``: A ``tf.int`` tensor with only one value, the
|
||||
number of detections ``[N]``. - ``detection_boxes``: A ``tf.float32``
|
||||
tensor of shape ``[N, 4]`` containing bounding box coordinates in the
|
||||
following order: ``[ymin, xmin, ymax, xmax]``. - ``detection_classes``:
|
||||
A ``tf.int`` tensor of shape ``[N]`` containing detection class index
|
||||
from the label file. - ``detection_scores``: A ``tf.float32`` tensor of
|
||||
shape ``[N]`` containing detection scores. - ``detection_masks``: A
|
||||
``[batch, max_detections, mask_height, mask_width]`` tensor. Note that a
|
||||
pixel-wise sigmoid score converter is applied to the detection masks.
|
||||
|
||||
For more information about model inputs, outputs and their formats, see
|
||||
the `model overview page on TensorFlow
|
||||
@@ -290,8 +307,10 @@ the first (and highest) detection score.
|
||||
<ConstOutput: names[proposal_boxes_normalized, final_anchors] shape[1,?,..8] type: f32>
|
||||
|
||||
|
||||
Get an Image for Test Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Get an Image for Test Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Load and save an image:
|
||||
|
||||
@@ -336,7 +355,7 @@ Read the image, resize and convert it to the input shape of the network:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<matplotlib.image.AxesImage at 0x7efe84247640>
|
||||
<matplotlib.image.AxesImage at 0x7f53cb91bca0>
|
||||
|
||||
|
||||
|
||||
@@ -344,8 +363,10 @@ Read the image, resize and convert it to the input shape of the network:
|
||||
.. image:: 120-tensorflow-instance-segmentation-to-openvino-with-output_files/120-tensorflow-instance-segmentation-to-openvino-with-output_25_1.png
|
||||
|
||||
|
||||
Perform Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Perform Inference
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -391,8 +412,10 @@ be extracted from the result. For further model result visualization
|
||||
image_detections_num: [100.]
|
||||
|
||||
|
||||
Inference Result Visualization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Inference Result Visualization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Define utility functions to visualize the inference results
|
||||
|
||||
@@ -631,24 +654,29 @@ original test image:
|
||||
.. image:: 120-tensorflow-instance-segmentation-to-openvino-with-output_files/120-tensorflow-instance-segmentation-to-openvino-with-output_39_0.png
|
||||
|
||||
|
||||
Next Steps
|
||||
----------------------------------------------------
|
||||
Next Steps
|
||||
----------
|
||||
|
||||
|
||||
|
||||
This section contains suggestions on how to additionally improve the
|
||||
performance of your application using OpenVINO.
|
||||
|
||||
Async inference pipeline
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Async inference pipeline
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The key advantage of the Async API is that when a device is busy with
|
||||
inference, the application can perform other tasks in parallel (for
|
||||
example, populating inputs or scheduling other requests) rather than
|
||||
wait for the current inference to complete first. To understand how to
|
||||
perform async inference using openvino, refer to the `Async API
|
||||
The key advantage of the Async
|
||||
API is that when a device is busy with inference, the application can
|
||||
perform other tasks in parallel (for example, populating inputs or
|
||||
scheduling other requests) rather than wait for the current inference to
|
||||
complete first. To understand how to perform async inference using
|
||||
openvino, refer to the `Async API
|
||||
tutorial <115-async-api-with-output.html>`__.
|
||||
|
||||
Integration preprocessing to model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Integration preprocessing to model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Preprocessing API enables making preprocessing a part of the model
|
||||
reducing application code and dependency on additional image processing
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:899a1126af7e881b5b8ad2182133a5334f3c98031a9d1b5d9285a76b44a162fc
|
||||
oid sha256:62971c6546b399ce0eecbdc81a5cb327c4bebdfa1a6db658e364870db606d761
|
||||
size 395346
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7d8537cac1002162c69c666fe659effaf3bb23d10d3da276349abe7af2469499
|
||||
size 394617
|
||||
oid sha256:1359365695e66164137690b56f261eae3364dff68f3e155a3e6b878ff17cea3f
|
||||
size 393190
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/120-tensorflow-instance-segmentation-to-openvino-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/120-tensorflow-instance-segmentation-to-openvino-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/120-tensorflow-instance-segmentation-to-openvino-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="120-tensorflow-instance-segmentation-to-openvino-with-output_25_1.png">120-tensorflow-instance-segmentation-to-openvin..></a> 31-Oct-2023 00:35 395346
|
||||
<a href="120-tensorflow-instance-segmentation-to-openvino-with-output_39_0.png">120-tensorflow-instance-segmentation-to-openvin..></a> 31-Oct-2023 00:35 394617
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/120-tensorflow-instance-segmentation-to-openvino-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="120-tensorflow-instance-segmentation-to-openvino-with-output_25_1.png">120-tensorflow-instance-segmentation-to-openvin..></a> 07-Dec-2023 00:49 395346
|
||||
<a href="120-tensorflow-instance-segmentation-to-openvino-with-output_39_0.png">120-tensorflow-instance-segmentation-to-openvin..></a> 07-Dec-2023 00:49 393190
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -31,8 +31,7 @@ and do inference with a sample image.
|
||||
- `Settings <#settings>`__
|
||||
- `Download Model from TensorFlow
|
||||
Hub <#download-model-from-tensorflow-hub>`__
|
||||
- `Convert Model to OpenVINO
|
||||
IR <#convert-model-to-openvino-ir>`__
|
||||
- `Convert Model to OpenVINO IR <#convert-model-to-openvino-ir>`__
|
||||
- `Test Inference on the Converted
|
||||
Model <#test-inference-on-the-converted-model>`__
|
||||
- `Select inference device <#select-inference-device>`__
|
||||
@@ -51,8 +50,10 @@ and do inference with a sample image.
|
||||
- `Integration preprocessing to
|
||||
model <#integration-preprocessing-to-model>`__
|
||||
|
||||
Prerequisites
|
||||
-------------------------------------------------------
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
|
||||
|
||||
Install required packages:
|
||||
|
||||
@@ -79,8 +80,10 @@ The notebook uses utility functions. The cell below will download the
|
||||
filename="notebook_utils.py",
|
||||
);
|
||||
|
||||
Imports
|
||||
-------------------------------------------------
|
||||
Imports
|
||||
-------
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -97,8 +100,10 @@ Imports
|
||||
# Notebook utils module
|
||||
from notebook_utils import download_file
|
||||
|
||||
Settings
|
||||
--------------------------------------------------
|
||||
Settings
|
||||
--------
|
||||
|
||||
|
||||
|
||||
Define model related variables and create corresponding directories:
|
||||
|
||||
@@ -120,12 +125,14 @@ Define model related variables and create corresponding directories:
|
||||
|
||||
openvino_ir_path = ir_model_dir / f"{model_name}.xml"
|
||||
|
||||
tf_model_url = "https://tfhub.dev/tensorflow/faster_rcnn/resnet50_v1_640x640/1?tf-hub-format=compressed"
|
||||
tf_model_url = "https://www.kaggle.com/models/tensorflow/faster-rcnn-resnet-v1/frameworks/tensorFlow2/variations/faster-rcnn-resnet50-v1-640x640/versions/1?tf-hub-format=compressed"
|
||||
|
||||
tf_model_archive_filename = f"{model_name}.tar.gz"
|
||||
|
||||
Download Model from TensorFlow Hub
|
||||
----------------------------------------------------------------------------
|
||||
Download Model from TensorFlow Hub
|
||||
----------------------------------
|
||||
|
||||
|
||||
|
||||
Download archive with TensorFlow Object Detection model
|
||||
(`faster_rcnn_resnet50_v1_640x640 <https://tfhub.dev/tensorflow/faster_rcnn/resnet50_v1_640x640/1>`__)
|
||||
@@ -150,7 +157,7 @@ from TensorFlow Hub:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/120-tensorflow-object-detection-to-openvino/model/tf/faster_rcnn_resnet50_v1_640x640.tar.gz')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/120-tensorflow-object-detection-to-openvino/model/tf/faster_rcnn_resnet50_v1_640x640.tar.gz')
|
||||
|
||||
|
||||
|
||||
@@ -163,8 +170,10 @@ Extract TensorFlow Object Detection model from the downloaded archive:
|
||||
with tarfile.open(tf_model_dir / tf_model_archive_filename) as file:
|
||||
file.extractall(path=tf_model_dir)
|
||||
|
||||
Convert Model to OpenVINO IR
|
||||
----------------------------------------------------------------------
|
||||
Convert Model to OpenVINO IR
|
||||
----------------------------
|
||||
|
||||
|
||||
|
||||
OpenVINO Model Converter Python API can be used to convert the
|
||||
TensorFlow model to OpenVINO IR.
|
||||
@@ -180,7 +189,7 @@ or saved on disk using the ``save_model`` function to reduce loading
|
||||
time when the model is run in the future.
|
||||
|
||||
See the `Model Converter Developer
|
||||
Guide <https://docs.openvino.ai/2023.2/openvino_docs_model_processing_introduction.html>`__
|
||||
Guide <https://docs.openvino.ai/2023.1/openvino_docs_model_processing_introduction.html>`__
|
||||
for more information about Model Converter and TensorFlow `models
|
||||
support <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow.html>`__.
|
||||
|
||||
@@ -191,11 +200,15 @@ support <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_conve
|
||||
# Save converted OpenVINO IR model to the corresponding directory
|
||||
ov.save_model(ov_model, openvino_ir_path)
|
||||
|
||||
Test Inference on the Converted Model
|
||||
-------------------------------------------------------------------------------
|
||||
Test Inference on the Converted Model
|
||||
-------------------------------------
|
||||
|
||||
|
||||
|
||||
Select inference device
|
||||
-----------------------
|
||||
|
||||
|
||||
Select inference device
|
||||
-----------------------------------------------------------------
|
||||
|
||||
select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
@@ -222,8 +235,10 @@ select device from dropdown list for running inference using OpenVINO
|
||||
|
||||
|
||||
|
||||
Load the Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Load the Model
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -231,8 +246,10 @@ Load the Model
|
||||
openvino_ir_model = core.read_model(openvino_ir_path)
|
||||
compiled_model = core.compile_model(model=openvino_ir_model, device_name=device.value)
|
||||
|
||||
Get Model Information
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Get Model Information
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Faster R-CNN with Resnet-50 V1 object detection model has one input - a
|
||||
three-channel image of variable size. The input tensor shape is
|
||||
@@ -299,8 +316,10 @@ for more information about model inputs, outputs and their formats.
|
||||
<ConstOutput: names[raw_detection_scores] shape[1,300,91] type: f32>
|
||||
|
||||
|
||||
Get an Image for Test Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Get an Image for Test Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Load and save an image:
|
||||
|
||||
@@ -324,7 +343,7 @@ Load and save an image:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/120-tensorflow-object-detection-to-openvino/data/coco_bike.jpg')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/120-tensorflow-object-detection-to-openvino/data/coco_bike.jpg')
|
||||
|
||||
|
||||
|
||||
@@ -352,7 +371,7 @@ Read the image, resize and convert it to the input shape of the network:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
<matplotlib.image.AxesImage at 0x7f968815d0a0>
|
||||
<matplotlib.image.AxesImage at 0x7f74d41406d0>
|
||||
|
||||
|
||||
|
||||
@@ -360,8 +379,10 @@ Read the image, resize and convert it to the input shape of the network:
|
||||
.. image:: 120-tensorflow-object-detection-to-openvino-with-output_files/120-tensorflow-object-detection-to-openvino-with-output_25_1.png
|
||||
|
||||
|
||||
Perform Inference
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Perform Inference
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
|
||||
@@ -471,8 +492,10 @@ outputs will be used.
|
||||
image_detections_num: [300.]
|
||||
|
||||
|
||||
Inference Result Visualization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Inference Result Visualization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Define utility functions to visualize the inference results
|
||||
|
||||
@@ -612,7 +635,7 @@ Zoo <https://github.com/openvinotoolkit/open_model_zoo/>`__:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/120-tensorflow-object-detection-to-openvino/data/coco_91cl.txt')
|
||||
PosixPath('/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/120-tensorflow-object-detection-to-openvino/data/coco_91cl.txt')
|
||||
|
||||
|
||||
|
||||
@@ -651,24 +674,29 @@ original test image:
|
||||
.. image:: 120-tensorflow-object-detection-to-openvino-with-output_files/120-tensorflow-object-detection-to-openvino-with-output_38_0.png
|
||||
|
||||
|
||||
Next Steps
|
||||
----------------------------------------------------
|
||||
Next Steps
|
||||
----------
|
||||
|
||||
|
||||
|
||||
This section contains suggestions on how to additionally improve the
|
||||
performance of your application using OpenVINO.
|
||||
|
||||
Async inference pipeline
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Async inference pipeline
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The key advantage of the Async API is that when a device is busy with
|
||||
inference, the application can perform other tasks in parallel (for
|
||||
example, populating inputs or scheduling other requests) rather than
|
||||
wait for the current inference to complete first. To understand how to
|
||||
perform async inference using openvino, refer to the `Async API
|
||||
The key advantage of the Async
|
||||
API is that when a device is busy with inference, the application can
|
||||
perform other tasks in parallel (for example, populating inputs or
|
||||
scheduling other requests) rather than wait for the current inference to
|
||||
complete first. To understand how to perform async inference using
|
||||
openvino, refer to the `Async API
|
||||
tutorial <115-async-api-with-output.html>`__.
|
||||
|
||||
Integration preprocessing to model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Integration preprocessing to model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Preprocessing API enables making preprocessing a part of the model
|
||||
reducing application code and dependency on additional image processing
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:899a1126af7e881b5b8ad2182133a5334f3c98031a9d1b5d9285a76b44a162fc
|
||||
oid sha256:62971c6546b399ce0eecbdc81a5cb327c4bebdfa1a6db658e364870db606d761
|
||||
size 395346
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:df9e84273cf7c5c19bf1c4ea8d6b61372f59b04228a95bacd2fac1b97dde6d4a
|
||||
size 392067
|
||||
oid sha256:ec79c39b72b7a139eca9f5b7081efec33a47fa8c55c9a459340774a045f2525b
|
||||
size 391797
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<html>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/120-tensorflow-object-detection-to-openvino-with-output_files/</title></head>
|
||||
<head><title>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/120-tensorflow-object-detection-to-openvino-with-output_files/</title></head>
|
||||
<body bgcolor="white">
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231030220807/dist/rst_files/120-tensorflow-object-detection-to-openvino-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="120-tensorflow-object-detection-to-openvino-with-output_25_1.png">120-tensorflow-object-detection-to-openvino-wit..></a> 31-Oct-2023 00:35 395346
|
||||
<a href="120-tensorflow-object-detection-to-openvino-with-output_38_0.png">120-tensorflow-object-detection-to-openvino-wit..></a> 31-Oct-2023 00:35 392067
|
||||
<h1>Index of /projects/ov-notebook/0.1.0-latest/20231206220809/dist/rst_files/120-tensorflow-object-detection-to-openvino-with-output_files/</h1><hr><pre><a href="../">../</a>
|
||||
<a href="120-tensorflow-object-detection-to-openvino-with-output_25_1.png">120-tensorflow-object-detection-to-openvino-wit..></a> 07-Dec-2023 00:49 395346
|
||||
<a href="120-tensorflow-object-detection-to-openvino-with-output_38_0.png">120-tensorflow-object-detection-to-openvino-wit..></a> 07-Dec-2023 00:49 391797
|
||||
</pre><hr></body>
|
||||
</html>
|
||||
|
||||
@@ -2,7 +2,10 @@ OpenVINO™ model conversion API
|
||||
==============================
|
||||
|
||||
This notebook shows how to convert a model from original framework
|
||||
format to OpenVINO Intermediate Representation (IR). Contents:
|
||||
format to OpenVINO Intermediate Representation (IR).
|
||||
|
||||
**Table of contents:**
|
||||
|
||||
|
||||
- `OpenVINO IR format <#openvino-ir-format>`__
|
||||
- `IR preparation with Python conversion API and Model Optimizer
|
||||
@@ -38,13 +41,15 @@ format to OpenVINO Intermediate Representation (IR). Contents:
|
||||
.. parsed-literal::
|
||||
|
||||
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
|
||||
tensorflow 2.13.1 requires protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3, but you have protobuf 3.20.2 which is incompatible.
|
||||
tensorflow 2.12.0 requires protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3, but you have protobuf 3.20.2 which is incompatible.
|
||||
Note: you may need to restart the kernel to use updated packages.
|
||||
|
||||
|
||||
OpenVINO IR format
|
||||
------------------
|
||||
|
||||
|
||||
|
||||
OpenVINO `Intermediate Representation
|
||||
(IR) <https://docs.openvino.ai/2023.0/openvino_ir.html>`__ is the
|
||||
proprietary model format of OpenVINO. It is produced after converting a
|
||||
@@ -58,6 +63,8 @@ an ``.xml`` file, containing information about network topology, and a
|
||||
IR preparation with Python conversion API and Model Optimizer command-line tool
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
There are two ways to convert a model from the original framework format
|
||||
to OpenVINO IR: Python conversion API and Model Optimizer command-line
|
||||
tool. You can choose one of them based on whichever is most convenient
|
||||
@@ -113,7 +120,7 @@ documentation.
|
||||
conversion into IR. The legacy Frontend is Python
|
||||
based and is available for TensorFlow*, ONNX*, MXNet*,
|
||||
Caffe*, and Kaldi* models.
|
||||
--input_model INPUT_MODEL, -w INPUT_MODEL, -m INPUT_MODEL
|
||||
--input_model INPUT_MODEL, -m INPUT_MODEL, -w INPUT_MODEL
|
||||
Tensorflow*: a file with a pre-trained model (binary
|
||||
or text .pb file after freezing). Caffe*: a model
|
||||
proto file with model weights.
|
||||
@@ -678,6 +685,8 @@ documentation.
|
||||
Fetching example models
|
||||
-----------------------
|
||||
|
||||
|
||||
|
||||
This notebook uses two models for conversion examples:
|
||||
|
||||
- `Distilbert <https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english>`__
|
||||
@@ -733,11 +742,11 @@ NLP model from Hugging Face and export it in ONNX format:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
2023-10-30 23:03:34.054449: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-10-30 23:03:34.088016: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
2023-12-06 23:09:08.345195: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
|
||||
2023-12-06 23:09:08.379671: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
|
||||
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
|
||||
2023-10-30 23:03:34.718197: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/transformers/models/distilbert/modeling_distilbert.py:223: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
|
||||
2023-12-06 23:09:09.007347: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
|
||||
/opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/.venv/lib/python3.8/site-packages/transformers/models/distilbert/modeling_distilbert.py:223: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
|
||||
mask, torch.tensor(torch.finfo(scores.dtype).min)
|
||||
|
||||
|
||||
@@ -976,6 +985,8 @@ Convert PyTorch model to ONNX format:
|
||||
Basic conversion
|
||||
----------------
|
||||
|
||||
|
||||
|
||||
To convert a model to OpenVINO IR, use the following command:
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1000,8 +1011,8 @@ To convert a model to OpenVINO IR, use the following command:
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1029,6 +1040,8 @@ To convert a model to OpenVINO IR, use the following command:
|
||||
Model conversion parameters
|
||||
---------------------------
|
||||
|
||||
|
||||
|
||||
Both Python conversion API and Model Optimizer command-line tool provide
|
||||
the following capabilities: \* overriding original input shapes for
|
||||
model conversion with ``input`` and ``input_shape`` parameters. `Setting
|
||||
@@ -1055,6 +1068,8 @@ mentioned above to override input shapes and cut the model.
|
||||
Setting Input Shapes
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Model conversion is supported for 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, it is recommended to
|
||||
@@ -1092,8 +1107,8 @@ guide <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_convert
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -1111,8 +1126,8 @@ guide <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_convert
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1162,8 +1177,8 @@ sequence length dimension for inputs:
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1207,8 +1222,8 @@ dimension:
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1226,6 +1241,8 @@ dimension:
|
||||
Cutting Off Parts of a Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
The following examples show when model cutting is useful or even
|
||||
required:
|
||||
|
||||
@@ -1273,8 +1290,8 @@ guide <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_convert
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -1292,8 +1309,8 @@ guide <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_convert
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/distilbert.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1314,6 +1331,8 @@ guide <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_prepare_model_convert
|
||||
Embedding Preprocessing Computation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
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 conversion
|
||||
@@ -1330,6 +1349,8 @@ article <https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_Additional_Optimiza
|
||||
Specifying Layout
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
Layout defines the meaning of dimensions in a 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
|
||||
@@ -1364,8 +1385,8 @@ Resnet50 model that was exported to the ONNX format:
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1379,6 +1400,8 @@ Resnet50 model that was exported to the ONNX format:
|
||||
Changing Model Layout
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
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.
|
||||
@@ -1408,8 +1431,8 @@ presented by input data. Use either ``layout`` or ``source_layout`` with
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -1427,8 +1450,8 @@ presented by input data. Use either ``layout`` or ``source_layout`` with
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1447,6 +1470,8 @@ presented by input data. Use either ``layout`` or ``source_layout`` with
|
||||
Specifying Mean and Scale Values
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
Model conversion API has the following parameters to specify the values:
|
||||
``mean_values``, ``scale_values``, ``scale``. Using these parameters,
|
||||
model conversion API embeds the corresponding preprocessing block for
|
||||
@@ -1477,8 +1502,8 @@ that the preprocessing takes negligible time for inference.
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -1496,8 +1521,8 @@ that the preprocessing takes negligible time for inference.
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1515,6 +1540,8 @@ that the preprocessing takes negligible time for inference.
|
||||
Reversing Input Channels
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
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
|
||||
@@ -1543,8 +1570,8 @@ the color channels before inference.
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1558,6 +1585,8 @@ the color channels before inference.
|
||||
Compressing a Model to FP16
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
Optionally all relevant floating-point weights can be compressed to FP16
|
||||
data type during the model conversion, creating a compressed FP16 model.
|
||||
This smaller model occupies about half of the original space in the file
|
||||
@@ -1586,8 +1615,8 @@ models, this decrease is negligible.
|
||||
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
|
||||
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
|
||||
[ SUCCESS ] Generated IR version 11 model.
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-534/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
[ SUCCESS ] XML file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.xml
|
||||
[ SUCCESS ] BIN file: /opt/home/k8sworker/ci-ai/cibuilds/ov-notebook/OVNotebookOps-561/.workspace/scm/ov-notebook/notebooks/121-convert-to-openvino/model/resnet.bin
|
||||
|
||||
|
||||
.. code:: ipython3
|
||||
@@ -1601,6 +1630,8 @@ models, this decrease is negligible.
|
||||
Convert Models Represented as Python Objects
|
||||
--------------------------------------------
|
||||
|
||||
|
||||
|
||||
Python conversion API can pass Python model objects, such as a Pytorch
|
||||
model or TensorFlow Keras model directly, without saving them into files
|
||||
and without leaving the training environment (Jupyter Notebook or
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user