[IE Sample Scripts] Change omz tool calls (#7717)

* Change omz tool calls in sample scripts (linux)

* Change omz tool calls in sample scripts (windows)

* Remove venv creation and /tools/model_optimizer/requirements.txt installation

* Remove `open_model_zoo/tools/downloader` from setupvars

* Remove `accuracy_checker` from setupvars

* Add error if omz tools are not installed

* Update scripts/demo/run_sample_benchmark_app.bat

Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>

* Add check for all omz tools

Co-authored-by: Zlobin Vladimir <vladimir.zlobin@intel.com>
This commit is contained in:
Dmitry Pigasin 2021-10-19 11:49:42 +03:00 committed by GitHub
parent feb7814a96
commit e3d5d4520f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 84 additions and 140 deletions

View File

@ -6,7 +6,6 @@ setlocal enabledelayedexpansion
set TARGET=CPU
set BUILD_FOLDER=%USERPROFILE%\Documents\Intel\OpenVINO
set VENV_DIR=%USERPROFILE%\Documents\Intel\OpenVINO\venv_openvino
:: command line arguments parsing
:input_arguments_loop
@ -52,6 +51,8 @@ set model_name=squeezenet1.1
set target_image_path=%ROOT_DIR%car.png
set omz_tool_error_message=It is required to download and convert a model. Check https://pypi.org/project/openvino-dev/ to install it. Then run the script again.
if exist "%ROOT_DIR%..\..\setupvars.bat" (
call "%ROOT_DIR%..\..\setupvars.bat"
) else (
@ -90,28 +91,26 @@ if not "%python_ver%"=="okay" (
goto error
)
:: install yaml python modules required for downloader.py
if exist "%VENV_DIR%" (
echo.
echo ###############^|^| Using the existing python virtual environment ^|^|###############
echo.
) else (
echo.
echo ###############^|^| Creating the python virtual environment ^|^|###############
echo.
python -m venv "%VENV_DIR%"
omz_info_dumper --print_all >NUL
if errorlevel 1 (
echo Error: omz_info_dumper was not found. %omz_tool_error_message%
goto error
)
call "%VENV_DIR%\Scripts\activate.bat"
python -m pip install -U pip
python -m pip install -r "%ROOT_DIR%..\open_model_zoo\tools\downloader\requirements.in"
omz_downloader --print_all >NUL
if errorlevel 1 (
echo Error: omz_downloader was not found. %omz_tool_error_message%
goto error
)
if ERRORLEVEL 1 GOTO errorHandling
set downloader_dir=%INTEL_OPENVINO_DIR%\extras\open_model_zoo\tools\downloader
omz_converter --print_all >NUL
if errorlevel 1 (
echo Error: omz_converter was not found. %omz_tool_error_message%
goto error
)
for /F "tokens=* usebackq" %%d in (
`python "%downloader_dir%\info_dumper.py" --name "%model_name%" ^|
`omz_info_dumper --name "%model_name%" ^|
python -c "import sys, json; print(json.load(sys.stdin)[0]['subdirectory'])"`
) do (
set model_dir=%%d
@ -119,9 +118,10 @@ for /F "tokens=* usebackq" %%d in (
set ir_dir=%irs_path%\%model_dir%\%target_precision%
echo.
echo Download public %model_name% model
echo python "%downloader_dir%\downloader.py" --name "%model_name%" --output_dir "%models_path%" --cache_dir "%models_cache%"
python "%downloader_dir%\downloader.py" --name "%model_name%" --output_dir "%models_path%" --cache_dir "%models_cache%"
echo omz_downloader --name "%model_name%" --output_dir "%models_path%" --cache_dir "%models_cache%"
omz_downloader --name "%model_name%" --output_dir "%models_path%" --cache_dir "%models_cache%"
echo %model_name% model downloading completed
CALL :delay 7
@ -134,23 +134,14 @@ if exist "%ir_dir%" (
GOTO buildSample
)
echo.
echo ###############^|^| Install Model Optimizer prerequisites ^|^|###############
echo.
CALL :delay 3
cd /d "%INTEL_OPENVINO_DIR%\tools\model_optimizer"
python -m pip install -r requirements.txt
if ERRORLEVEL 1 GOTO errorHandling
CALL :delay 7
echo.
echo ###############^|^| Run Model Optimizer ^|^|###############
echo.
CALL :delay 3
::set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
echo python "%downloader_dir%\converter.py" --mo "%INTEL_OPENVINO_DIR%\tools\model_optimizer\mo.py" --name "%model_name%" -d "%models_path%" -o "%irs_path%" --precisions "%TARGET_PRECISION%"
python "%downloader_dir%\converter.py" --mo "%INTEL_OPENVINO_DIR%\tools\model_optimizer\mo.py" --name "%model_name%" -d "%models_path%" -o "%irs_path%" --precisions "%TARGET_PRECISION%"
echo omz_converter --mo "%INTEL_OPENVINO_DIR%\tools\model_optimizer\mo.py" --name "%model_name%" -d "%models_path%" -o "%irs_path%" --precisions "%TARGET_PRECISION%"
omz_converter --mo "%INTEL_OPENVINO_DIR%\tools\model_optimizer\mo.py" --name "%model_name%" -d "%models_path%" -o "%irs_path%" --precisions "%TARGET_PRECISION%"
if ERRORLEVEL 1 GOTO errorHandling
CALL :delay 7

View File

@ -6,7 +6,6 @@
echo -ne "\e[0;33mWARNING: If you get an error when running the sample in the Docker container, you may need to install additional packages. To do this, run the container as root (-u 0) and run install_openvino_dependencies.sh script. If you get a package-independent error, try setting additional parameters using -sample-options.\e[0m\n"
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]-$0}" )" && pwd )"
VENV_DIR="$HOME/venv_openvino"
. "$ROOT_DIR/utils.sh"
@ -67,7 +66,8 @@ model_name="squeezenet1.1"
target_image_path="$ROOT_DIR/car.png"
run_again="Then run the script again\n\n"
run_again="Then run the script again.\n\n"
omz_tool_error_message="It is required to download and convert a model. Check https://pypi.org/project/openvino-dev/ to install it. ${run_again}"
if [ -e "$ROOT_DIR/../../setupvars.sh" ]; then
setupvars_path="$ROOT_DIR/../../setupvars.sh"
@ -111,51 +111,43 @@ if ! command -v $python_binary &>/dev/null; then
exit 1
fi
if [ -e "$VENV_DIR" ]; then
echo -ne "\n###############|| Using the existing python virtual environment ||###############\n\n"
else
echo -ne "\n###############|| Creating the python virtual environment ||###############\n\n"
"$python_binary" -m venv "$VENV_DIR"
if ! command -v omz_info_dumper &>/dev/null; then
echo -ne "\n\nomz_info_dumper was not found. ${omz_tool_error_message}"
exit 2
fi
. "$VENV_DIR/bin/activate"
python -m pip install -U pip
python -m pip install -r "$INTEL_OPENVINO_DIR/extras/open_model_zoo/tools/downloader/requirements.in"
if ! command -v omz_downloader &>/dev/null; then
echo -ne "\n\nomz_downloader was not found. ${omz_tool_error_message}"
exit 3
fi
if ! command -v omz_converter &>/dev/null; then
echo -ne "\n\nomz_converter was not found. ${omz_tool_error_message}"
exit 4
fi
# Step 1. Download the Caffe model and the prototxt of the model
echo -ne "\n###############|| Downloading the Caffe model and the prototxt ||###############\n\n"
downloader_dir="${INTEL_OPENVINO_DIR}/extras/open_model_zoo/tools/downloader"
model_dir=$(python "$downloader_dir/info_dumper.py" --name "$model_name" |
model_dir=$(omz_info_dumper --name "$model_name" |
python -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])')
downloader_path="$downloader_dir/downloader.py"
print_and_run python "$downloader_path" --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}"
print_and_run omz_downloader --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}"
ir_dir="${irs_path}/${model_dir}/${target_precision}"
if [ ! -e "$ir_dir" ]; then
# Step 2. Configure Model Optimizer
echo -ne "\n###############|| Install Model Optimizer dependencies ||###############\n\n"
cd "${INTEL_OPENVINO_DIR}/tools/model_optimizer"
python -m pip install -r requirements.txt
cd "$PWD"
# Step 3. Convert a model with Model Optimizer
# Step 2. Convert a model with Model Optimizer
echo -ne "\n###############|| Convert a model with Model Optimizer ||###############\n\n"
mo_path="${INTEL_OPENVINO_DIR}/tools/model_optimizer/mo.py"
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
print_and_run python "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
print_and_run omz_converter --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
else
echo -ne "\n\nTarget folder ${ir_dir} already exists. Skipping IR generation with Model Optimizer."
echo -ne "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}"
fi
# Step 4. Build samples
# Step 3. Build samples
echo -ne "\n###############|| Build Inference Engine samples ||###############\n\n"
OS_PATH=$(uname -m)
@ -179,7 +171,7 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path"
make $NUM_THREADS benchmark_app
# Step 5. Run samples
# Step 4. Run samples
echo -ne "\n###############|| Run Inference Engine benchmark app ||###############\n\n"
cd "$binaries_dir"

View File

@ -6,7 +6,6 @@ setlocal enabledelayedexpansion
set TARGET=CPU
set BUILD_FOLDER=%USERPROFILE%\Documents\Intel\OpenVINO
set VENV_DIR=%USERPROFILE%\Documents\Intel\OpenVINO\venv_openvino
:: command line arguments parsing
:input_arguments_loop
@ -48,6 +47,8 @@ set model_name=squeezenet1.1
set target_image_path=%ROOT_DIR%car.png
set omz_tool_error_message=It is required to download and convert a model. Check https://pypi.org/project/openvino-dev/ to install it. Then run the script again.
if exist "%ROOT_DIR%..\..\setupvars.bat" (
call "%ROOT_DIR%..\..\setupvars.bat"
) else (
@ -86,28 +87,26 @@ if not "%python_ver%"=="okay" (
goto error
)
:: install yaml python modules required for downloader.py
if exist "%VENV_DIR%" (
echo.
echo ###############^|^| Using the existing python virtual environment ^|^|###############
echo.
) else (
echo.
echo ###############^|^| Creating the python virtual environment ^|^|###############
echo.
python -m venv "%VENV_DIR%"
omz_info_dumper --print_all >NUL
if errorlevel 1 (
echo Error: omz_info_dumper was not found. %omz_tool_error_message%
goto error
)
call "%VENV_DIR%\Scripts\activate.bat"
python -m pip install -U pip
python -m pip install -r "%ROOT_DIR%..\open_model_zoo\tools\downloader\requirements.in"
omz_downloader --print_all >NUL
if errorlevel 1 (
echo Error: omz_downloader was not found. %omz_tool_error_message%
goto error
)
if ERRORLEVEL 1 GOTO errorHandling
set downloader_dir=%INTEL_OPENVINO_DIR%\extras\open_model_zoo\tools\downloader
omz_converter --print_all >NUL
if errorlevel 1 (
echo Error: omz_converter was not found. %omz_tool_error_message%
goto error
)
for /F "tokens=* usebackq" %%d in (
`python "%downloader_dir%\info_dumper.py" --name "%model_name%" ^|
`omz_info_dumper --name "%model_name%" ^|
python -c "import sys, json; print(json.load(sys.stdin)[0]['subdirectory'])"`
) do (
set model_dir=%%d
@ -115,9 +114,10 @@ for /F "tokens=* usebackq" %%d in (
set ir_dir=%irs_path%\%model_dir%\%target_precision%
echo.
echo Download public %model_name% model
echo python "%downloader_dir%\downloader.py" --name "%model_name%" --output_dir "%models_path%" --cache_dir "%models_cache%"
python "%downloader_dir%\downloader.py" --name "%model_name%" --output_dir "%models_path%" --cache_dir "%models_cache%"
echo omz_downloader --name "%model_name%" --output_dir "%models_path%" --cache_dir "%models_cache%"
omz_downloader --name "%model_name%" --output_dir "%models_path%" --cache_dir "%models_cache%"
echo %model_name% model downloading completed
CALL :delay 7
@ -130,23 +130,14 @@ if exist "%ir_dir%" (
GOTO buildSample
)
echo.
echo ###############^|^| Install Model Optimizer prerequisites ^|^|###############
echo.
CALL :delay 3
cd /d "%INTEL_OPENVINO_DIR%\tools\model_optimizer"
python -m pip install -r requirements.txt
if ERRORLEVEL 1 GOTO errorHandling
CALL :delay 7
echo.
echo ###############^|^| Run Model Optimizer ^|^|###############
echo.
CALL :delay 3
::set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
echo python "%downloader_dir%\converter.py" --mo "%INTEL_OPENVINO_DIR%\tools\model_optimizer\mo.py" --name "%model_name%" -d "%models_path%" -o "%irs_path%" --precisions "%TARGET_PRECISION%"
python "%downloader_dir%\converter.py" --mo "%INTEL_OPENVINO_DIR%\tools\model_optimizer\mo.py" --name "%model_name%" -d "%models_path%" -o "%irs_path%" --precisions "%TARGET_PRECISION%"
echo omz_converter --mo "%INTEL_OPENVINO_DIR%\tools\model_optimizer\mo.py" --name "%model_name%" -d "%models_path%" -o "%irs_path%" --precisions "%TARGET_PRECISION%"
omz_converter --mo "%INTEL_OPENVINO_DIR%\tools\model_optimizer\mo.py" --name "%model_name%" -d "%models_path%" -o "%irs_path%" --precisions "%TARGET_PRECISION%"
if ERRORLEVEL 1 GOTO errorHandling
CALL :delay 7

View File

@ -6,7 +6,6 @@
echo -ne "\e[0;33mWARNING: If you get an error when running the sample in the Docker container, you may need to install additional packages. To do this, run the container as root (-u 0) and run install_openvino_dependencies.sh script. If you get a package-independent error, try setting additional parameters using -sample-options.\e[0m\n"
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]-$0}" )" && pwd )"
VENV_DIR="$HOME/venv_openvino"
. "$ROOT_DIR/utils.sh"
@ -63,7 +62,8 @@ model_name="squeezenet1.1"
target_image_path="$ROOT_DIR/car.png"
run_again="Then run the script again\n\n"
run_again="Then run the script again.\n\n"
omz_tool_error_message="It is required to download and convert a model. Check https://pypi.org/project/openvino-dev/ to install it. ${run_again}"
if [ -e "$ROOT_DIR/../../setupvars.sh" ]; then
setupvars_path="$ROOT_DIR/../../setupvars.sh"
@ -107,51 +107,43 @@ if ! command -v $python_binary &>/dev/null; then
exit 1
fi
if [ -e "$VENV_DIR" ]; then
echo -ne "\n###############|| Using the existing python virtual environment ||###############\n\n"
else
echo -ne "\n###############|| Creating the python virtual environment ||###############\n\n"
"$python_binary" -m venv "$VENV_DIR"
if ! command -v omz_info_dumper &>/dev/null; then
echo -ne "\n\nomz_info_dumper was not found. ${omz_tool_error_message}"
exit 2
fi
. "$VENV_DIR/bin/activate"
python -m pip install -U pip
python -m pip install -r "$INTEL_OPENVINO_DIR/extras/open_model_zoo/tools/downloader/requirements.in"
if ! command -v omz_downloader &>/dev/null; then
echo -ne "\n\nomz_downloader was not found. ${omz_tool_error_message}"
exit 3
fi
if ! command -v omz_converter &>/dev/null; then
echo -ne "\n\nomz_converter was not found. ${omz_tool_error_message}"
exit 4
fi
# Step 1. Download the Caffe model and the prototxt of the model
echo -ne "\n###############|| Downloading the Caffe model and the prototxt ||###############\n\n"
downloader_dir="${INTEL_OPENVINO_DIR}/extras/open_model_zoo/tools/downloader"
model_dir=$(python "$downloader_dir/info_dumper.py" --name "$model_name" |
model_dir=$(omz_info_dumper --name "$model_name" |
python -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])')
downloader_path="$downloader_dir/downloader.py"
print_and_run python "$downloader_path" --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}"
print_and_run omz_downloader --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}"
ir_dir="${irs_path}/${model_dir}/${target_precision}"
if [ ! -e "$ir_dir" ]; then
# Step 2. Configure Model Optimizer
echo -ne "\n###############|| Install Model Optimizer dependencies ||###############\n\n"
cd "${INTEL_OPENVINO_DIR}/tools/model_optimizer"
python -m pip install -r requirements.txt
cd "$PWD"
# Step 3. Convert a model with Model Optimizer
# Step 2. Convert a model with Model Optimizer
echo -ne "\n###############|| Convert a model with Model Optimizer ||###############\n\n"
mo_path="${INTEL_OPENVINO_DIR}/tools/model_optimizer/mo.py"
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
print_and_run python "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
print_and_run omz_converter --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
else
echo -ne "\n\nTarget folder ${ir_dir} already exists. Skipping IR generation with Model Optimizer."
echo -ne "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}"
fi
# Step 4. Build samples
# Step 3. Build samples
echo -ne "\n###############|| Build Inference Engine samples ||###############\n\n"
OS_PATH=$(uname -m)
@ -175,7 +167,7 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path"
make $NUM_THREADS classification_sample_async
# Step 5. Run samples
# Step 4. Run sample
echo -ne "\n###############|| Run Inference Engine classification sample ||###############\n\n"
cd "$binaries_dir"

View File

@ -39,13 +39,6 @@ set PYTHONPATH=%INTEL_OPENVINO_DIR%\tools\model_optimizer;%PYTHONPATH%
set "PATH=%INTEL_OPENVINO_DIR%\tools\model_optimizer;%PATH%"
)
:: Model Downloader
if exist %INTEL_OPENVINO_DIR%\extras\open_model_zoo\tools\downloader (
set PYTHONPATH=%INTEL_OPENVINO_DIR%\extras\open_model_zoo\tools\downloader;%PYTHONPATH%
set "PATH=%INTEL_OPENVINO_DIR%\extras\open_model_zoo\tools\downloader;%PATH%"
)
:: OpenVINO runtime
set "InferenceEngine_DIR=%INTEL_OPENVINO_DIR%\runtime\cmake"
set "ngraph_DIR=%INTEL_OPENVINO_DIR%\runtime\cmake"
@ -117,10 +110,6 @@ if not "%bitness%"=="64" (
set PYTHONPATH=%INTEL_OPENVINO_DIR%\python\python%pyversion_major%.%pyversion_minor%;%INTEL_OPENVINO_DIR%\python\python3;%PYTHONPATH%
if exist %INTEL_OPENVINO_DIR%\tools\accuracy_checker (
set PYTHONPATH=%INTEL_OPENVINO_DIR%\tools\accuracy_checker;%PYTHONPATH%
)
if exist %INTEL_OPENVINO_DIR%\tools\post_training_optimization_toolkit (
set PYTHONPATH=%INTEL_OPENVINO_DIR%\tools\post_training_optimization_toolkit;%PYTHONPATH%
)

View File

@ -75,17 +75,6 @@ fi
export PATH="$INTEL_OPENVINO_DIR/tools/model_optimizer${PATH:+:$PATH}"
export PYTHONPATH="$INTEL_OPENVINO_DIR/tools/model_optimizer${PYTHONPATH:+:$PYTHONPATH}"
if [ -e "$INTEL_OPENVINO_DIR/extras/open_model_zoo/tools/downloader" ]; then
export PYTHONPATH="$INTEL_OPENVINO_DIR/extras/open_model_zoo/tools/downloader:$PYTHONPATH"
export PATH="$INTEL_OPENVINO_DIR/extras/open_model_zoo/tools/downloader:$PATH"
fi
if [ -e "$INTEL_OPENVINO_DIR/tools/accuracy_checker" ]; then
export PYTHONPATH="$INTEL_OPENVINO_DIR/tools/accuracy_checker:$PYTHONPATH"
fi
if [ -e "$INTEL_OPENVINO_DIR/tools/post_training_optimization_toolkit" ]; then
export PYTHONPATH="$INTEL_OPENVINO_DIR/tools/post_training_optimization_toolkit:$PYTHONPATH"
fi