Update demo .sh scripts (#6078)

* Remove sudo package installation from demo scripts

* Change the build_dir path (benchmark_app.sh, squeezenet_download_convert_run)

* Remove redundant pip_binary

* Revert 'inference_engine_samples_build' as the build folder for .bat

* Add check for python 3.8

* Update help messages

* Use `model-optimizer/requirements.txt` instead of `install_prerequisites.sh`

* Add `--user` for python package installation (demo_security_barrier_camera.sh)

* Add python venv creation

* Create venv in $HOME instead of $ROOT_DIR

* Make the step messages look the same as in the .bat scripts

* Make the same changes to demo_benchmark_app.sh as in other .sh scripts

* Remove a mention of FPGA from a help message

* Set venv folder to `venv_openvino`
This commit is contained in:
Dmitry Pigasin 2021-07-05 12:47:11 +03:00 committed by GitHub
parent 8a31e8aafb
commit 860896c4bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 115 additions and 195 deletions

View File

@ -3,14 +3,21 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
echo -ne "\e[0;33mWARNING: If you get an error when running the demo 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"
usage() {
echo "Benchmark demo using public SqueezeNet topology"
echo "-d name specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified"
echo "-help print help message"
echo
echo "Options:"
echo " -help Print help message"
echo " -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified"
echo " -sample-options OPTIONS Specify command line arguments for the sample"
echo
exit 1
}
@ -50,7 +57,7 @@ fi
target_precision="FP16"
printf "target_precision = %s\n" ${target_precision}
echo -ne "target_precision = ${target_precision}\n"
models_path="$HOME/openvino_models/models"
models_cache="$HOME/openvino_models/cache"
@ -61,13 +68,11 @@ model_name="squeezenet1.1"
target_image_path="$ROOT_DIR/car.png"
run_again="Then run the script again\n\n"
dashes="\n\n###################################################\n\n"
if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then
setupvars_path="$ROOT_DIR/../../bin/setupvars.sh"
else
printf "Error: setupvars.sh is not found\n"
echo -ne "Error: setupvars.sh is not found\n"
fi
if ! . "$setupvars_path" ; then
@ -75,14 +80,6 @@ if ! . "$setupvars_path" ; then
exit 1
fi
# Step 1. Download the Caffe model and the prototxt of the model
echo -ne "${dashes}"
printf "\n\nDownloading the Caffe model and the prototxt"
cur_path=$PWD
printf "\nInstalling dependencies\n"
if [[ -f /etc/centos-release ]]; then
DISTRO="centos"
elif [[ -f /etc/lsb-release ]]; then
@ -90,55 +87,27 @@ elif [[ -f /etc/lsb-release ]]; then
fi
if [[ $DISTRO == "centos" ]]; then
sudo -E yum install -y centos-release-scl epel-release
sudo -E yum install -y gcc gcc-c++ make glibc-static glibc-devel libstdc++-static libstdc++-devel libstdc++ libgcc \
glibc-static.i686 glibc-devel.i686 libstdc++-static.i686 libstdc++.i686 libgcc.i686 cmake
sudo -E rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm || true
sudo -E yum install -y epel-release
sudo -E yum install -y cmake ffmpeg gstreamer1 gstreamer1-plugins-base libusbx-devel
# check installed Python version
if command -v python3.5 >/dev/null 2>&1; then
python_binary=python3.5
pip_binary=pip3.5
fi
if command -v python3.6 >/dev/null 2>&1; then
python_binary=python3.6
pip_binary=pip3.6
fi
if [ -z "$python_binary" ]; then
sudo -E yum install -y rh-python36 || true
. scl_source enable rh-python36
python_binary=python3.6
pip_binary=pip3.6
fi
elif [[ $DISTRO == "ubuntu" ]]; then
sudo -E apt update
print_and_run sudo -E apt -y install build-essential python3-pip virtualenv cmake libcairo2-dev libpango1.0-dev libglib2.0-dev libgtk2.0-dev libswscale-dev libavcodec-dev libavformat-dev libgstreamer1.0-0 gstreamer1.0-plugins-base
python_binary=python3
pip_binary=pip3
system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2)
if [ "$system_ver" = "16.04" ]; then
sudo -E apt-get install -y libpng12-dev
else
sudo -E apt-get install -y libpng-dev
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# check installed Python version
if command -v python3.7 >/dev/null 2>&1; then
if command -v python3.8 >/dev/null 2>&1; then
python_binary=python3.8
elif command -v python3.7 >/dev/null 2>&1; then
python_binary=python3.7
pip_binary=pip3.7
elif command -v python3.6 >/dev/null 2>&1; then
python_binary=python3.6
pip_binary=pip3.6
elif command -v python3.5 >/dev/null 2>&1; then
python_binary=python3.5
pip_binary=pip3.5
else
python_binary=python3
pip_binary=pip3
fi
fi
@ -147,47 +116,52 @@ if ! command -v $python_binary &>/dev/null; then
exit 1
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
$pip_binary install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
if [ -e "$VENV_DIR" ]; then
echo -ne "\n###############|| Using the existing python virtual environment ||###############\n\n"
else
sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
echo -ne "\n###############|| Creating the python virtual environment ||###############\n\n"
"$python_binary" -m venv "$VENV_DIR"
fi
. "$VENV_DIR/bin/activate"
python -m pip install -U pip
python -m pip install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
# 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}/deployment_tools/open_model_zoo/tools/downloader"
model_dir=$("$python_binary" "$downloader_dir/info_dumper.py" --name "$model_name" |
"$python_binary" -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])')
model_dir=$(python "$downloader_dir/info_dumper.py" --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_binary" "$downloader_path" --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}"
print_and_run python "$downloader_path" --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 "${dashes}"
printf "Install Model Optimizer dependencies\n\n"
cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites"
. ./install_prerequisites.sh caffe
cd "$cur_path"
echo -ne "\n###############|| Install Model Optimizer dependencies ||###############\n\n"
cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer"
python -m pip install -r requirements.txt
cd "$PWD"
# Step 3. Convert a model with Model Optimizer
echo -ne "${dashes}"
printf "Convert a model with Model Optimizer\n\n"
echo -ne "\n###############|| Convert a model with Model Optimizer ||###############\n\n"
mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py"
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
print_and_run python "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
else
printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}"
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
echo -ne "${dashes}"
printf "Build Inference Engine samples\n\n"
echo -ne "\n###############|| Build Inference Engine samples ||###############\n\n"
OS_PATH=$(uname -m)
NUM_THREADS="-j2"
@ -198,7 +172,7 @@ if [ "$OS_PATH" == "x86_64" ]; then
fi
samples_path="${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/samples/cpp"
build_dir="$HOME/inference_engine_samples_build"
build_dir="$HOME/inference_engine_cpp_samples_build"
binaries_dir="${build_dir}/${OS_PATH}/Release"
if [ -e "$build_dir/CMakeCache.txt" ]; then
@ -211,8 +185,7 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path"
make $NUM_THREADS benchmark_app
# Step 5. Run samples
echo -ne "${dashes}"
printf "Run Inference Engine benchmark app\n\n"
echo -ne "\n###############|| Run Inference Engine benchmark app ||###############\n\n"
cd "$binaries_dir"
@ -220,6 +193,4 @@ cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/"
print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc "${sampleoptions[@]}"
echo -ne "${dashes}"
printf "Inference Engine benchmark app completed successfully.\n\n"
echo -ne "\n###############|| Inference Engine benchmark app completed successfully ||###############\n\n"

View File

@ -3,14 +3,21 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
echo -ne "\e[0;33mWARNING: If you get an error when running the demo 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"
usage() {
echo "Security barrier camera demo that showcases three models coming with the product"
echo "-d name specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified"
echo "-help print help message"
echo
echo "Options:"
echo " -help Print help message"
echo " -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified"
echo " -sample-options OPTIONS Specify command line arguments for the sample"
echo
exit 1
}
@ -44,11 +51,19 @@ esac
shift
done
target_image_path="$ROOT_DIR/car_1.bmp"
run_again="Then run the script again\n\n"
dashes="\n\n###################################################\n\n"
if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then
setupvars_path="$ROOT_DIR/../../bin/setupvars.sh"
else
echo -ne "Error: setupvars.sh is not found\n"
fi
if ! . "$setupvars_path" ; then
echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}"
exit 1
fi
if [[ -f /etc/centos-release ]]; then
DISTRO="centos"
@ -59,55 +74,27 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
fi
if [[ $DISTRO == "centos" ]]; then
sudo -E yum install -y centos-release-scl epel-release
sudo -E yum install -y gcc gcc-c++ make glibc-static glibc-devel libstdc++-static libstdc++-devel libstdc++ libgcc \
glibc-static.i686 glibc-devel.i686 libstdc++-static.i686 libstdc++.i686 libgcc.i686 cmake
sudo -E rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm || true
sudo -E yum install -y epel-release
sudo -E yum install -y cmake ffmpeg gstreamer1 gstreamer1-plugins-base libusbx-devel
# check installed Python version
if command -v python3.5 >/dev/null 2>&1; then
python_binary=python3.5
pip_binary=pip3.5
fi
if command -v python3.6 >/dev/null 2>&1; then
python_binary=python3.6
pip_binary=pip3.6
fi
if [ -z "$python_binary" ]; then
sudo -E yum install -y rh-python36 || true
. scl_source enable rh-python36
python_binary=python3.6
pip_binary=pip3.6
fi
elif [[ $DISTRO == "ubuntu" ]]; then
sudo -E apt update
print_and_run sudo -E apt -y install build-essential python3-pip virtualenv cmake libcairo2-dev libpango1.0-dev libglib2.0-dev libgtk2.0-dev libswscale-dev libavcodec-dev libavformat-dev libgstreamer1.0-0 gstreamer1.0-plugins-base
python_binary=python3
pip_binary=pip3
system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2)
if [ "$system_ver" = "16.04" ]; then
sudo -E apt-get install -y libpng12-dev
else
sudo -E apt-get install -y libpng-dev
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# check installed Python version
if command -v python3.7 >/dev/null 2>&1; then
if command -v python3.8 >/dev/null 2>&1; then
python_binary=python3.8
elif command -v python3.7 >/dev/null 2>&1; then
python_binary=python3.7
pip_binary=pip3.7
elif command -v python3.6 >/dev/null 2>&1; then
python_binary=python3.6
pip_binary=pip3.6
elif command -v python3.5 >/dev/null 2>&1; then
python_binary=python3.5
pip_binary=pip3.5
else
python_binary=python3
pip_binary=pip3
fi
fi
@ -116,30 +103,23 @@ if ! command -v $python_binary &>/dev/null; then
exit 1
fi
if [[ $DISTRO == "macos" ]]; then
"$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
if [ -e "$VENV_DIR" ]; then
echo -ne "\n###############|| Using the existing python virtual environment ||###############\n\n"
else
sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
echo -ne "\n###############|| Creating the python virtual environment ||###############\n\n"
"$python_binary" -m venv "$VENV_DIR"
fi
if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then
setupvars_path="$ROOT_DIR/../../bin/setupvars.sh"
else
printf "Error: setupvars.sh is not found\n"
fi
if ! . "$setupvars_path" ; then
echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}"
exit 1
fi
. "$VENV_DIR/bin/activate"
python -m pip install -U pip
python -m pip install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
# Step 1. Downloading Intel models
echo -ne "${dashes}"
printf "Downloading Intel models\n\n"
echo -ne "\n###############|| Downloading Intel models ||###############\n\n"
target_precision="FP16"
printf "target_precision = %s\n" "${target_precision}"
echo -ne "target_precision = ${target_precision}\n"
downloader_dir="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/tools/downloader"
@ -150,19 +130,18 @@ models_cache="$HOME/openvino_models/cache"
declare -a model_args
while read -r model_opt model_name; do
model_subdir=$("$python_binary" "$downloader_dir/info_dumper.py" --name "$model_name" |
"$python_binary" -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])')
model_subdir=$(python "$downloader_dir/info_dumper.py" --name "$model_name" |
python -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])')
model_path="$models_path/$model_subdir/$target_precision/$model_name"
print_and_run "$python_binary" "$downloader_path" --name "$model_name" --output_dir "$models_path" --cache_dir "$models_cache"
print_and_run python "$downloader_path" --name "$model_name" --output_dir "$models_path" --cache_dir "$models_cache"
model_args+=("$model_opt" "${model_path}.xml")
done < "$ROOT_DIR/demo_security_barrier_camera.conf"
# Step 2. Build samples
echo -ne "${dashes}"
printf "Build Inference Engine demos\n\n"
echo -ne "\n###############|| Build Inference Engine demos ||###############\n\n"
demos_path="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/demos"
@ -189,13 +168,11 @@ cmake -DCMAKE_BUILD_TYPE=Release "$demos_path"
make $NUM_THREADS security_barrier_camera_demo
# Step 3. Run samples
echo -ne "${dashes}"
printf "Run Inference Engine security_barrier_camera demo\n\n"
echo -ne "\n###############|| Run Inference Engine security_barrier_camera demo ||###############\n\n"
binaries_dir="${build_dir}/${OS_PATH}/Release"
cd "$binaries_dir"
print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" "${sampleoptions[@]}"
echo -ne "${dashes}"
printf "Demo completed successfully.\n\n"
echo -ne "\n###############|| Demo completed successfully ||###############\n\n"

View File

@ -3,14 +3,21 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
echo -ne "\e[0;33mWARNING: If you get an error when running the demo 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"
usage() {
echo "Classification demo using public SqueezeNet topology"
echo "-d name specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified"
echo "-help print help message"
echo
echo "Options:"
echo " -help Print help message"
echo " -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified"
echo " -sample-options OPTIONS Specify command line arguments for the sample"
echo
exit 1
}
@ -46,7 +53,7 @@ done
target_precision="FP16"
printf "target_precision = %s\n" "${target_precision}"
echo -ne "target_precision = ${target_precision}\n"
models_path="$HOME/openvino_models/models"
models_cache="$HOME/openvino_models/cache"
@ -57,13 +64,11 @@ model_name="squeezenet1.1"
target_image_path="$ROOT_DIR/car.png"
run_again="Then run the script again\n\n"
dashes="\n\n###################################################\n\n"
if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then
setupvars_path="$ROOT_DIR/../../bin/setupvars.sh"
else
printf "Error: setupvars.sh is not found\n"
echo -ne "Error: setupvars.sh is not found\n"
fi
if ! . "$setupvars_path" ; then
@ -71,14 +76,6 @@ if ! . "$setupvars_path" ; then
exit 1
fi
# Step 1. Download the Caffe model and the prototxt of the model
echo -ne "${dashes}"
printf "\n\nDownloading the Caffe model and the prototxt"
cur_path=$PWD
printf "\nInstalling dependencies\n"
if [[ -f /etc/centos-release ]]; then
DISTRO="centos"
elif [[ -f /etc/lsb-release ]]; then
@ -86,55 +83,27 @@ elif [[ -f /etc/lsb-release ]]; then
fi
if [[ $DISTRO == "centos" ]]; then
sudo -E yum install -y centos-release-scl epel-release
sudo -E yum install -y gcc gcc-c++ make glibc-static glibc-devel libstdc++-static libstdc++-devel libstdc++ libgcc \
glibc-static.i686 glibc-devel.i686 libstdc++-static.i686 libstdc++.i686 libgcc.i686 cmake
sudo -E rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm || true
sudo -E yum install -y epel-release
sudo -E yum install -y cmake ffmpeg gstreamer1 gstreamer1-plugins-base libusbx-devel
# check installed Python version
if command -v python3.5 >/dev/null 2>&1; then
python_binary=python3.5
pip_binary=pip3.5
fi
if command -v python3.6 >/dev/null 2>&1; then
python_binary=python3.6
pip_binary=pip3.6
fi
if [ -z "$python_binary" ]; then
sudo -E yum install -y rh-python36 || true
. scl_source enable rh-python36
python_binary=python3.6
pip_binary=pip3.6
fi
elif [[ $DISTRO == "ubuntu" ]]; then
sudo -E apt update
print_and_run sudo -E apt -y install build-essential python3-pip virtualenv cmake libcairo2-dev libpango1.0-dev libglib2.0-dev libgtk2.0-dev libswscale-dev libavcodec-dev libavformat-dev libgstreamer1.0-0 gstreamer1.0-plugins-base
python_binary=python3
pip_binary=pip3
system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2)
if [ "$system_ver" = "16.04" ]; then
sudo -E apt-get install -y libpng12-dev
else
sudo -E apt-get install -y libpng-dev
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# check installed Python version
if command -v python3.7 >/dev/null 2>&1; then
if command -v python3.8 >/dev/null 2>&1; then
python_binary=python3.8
elif command -v python3.7 >/dev/null 2>&1; then
python_binary=python3.7
pip_binary=pip3.7
elif command -v python3.6 >/dev/null 2>&1; then
python_binary=python3.6
pip_binary=pip3.6
elif command -v python3.5 >/dev/null 2>&1; then
python_binary=python3.5
pip_binary=pip3.5
else
python_binary=python3
pip_binary=pip3
fi
fi
@ -143,47 +112,52 @@ if ! command -v $python_binary &>/dev/null; then
exit 1
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
"$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
if [ -e "$VENV_DIR" ]; then
echo -ne "\n###############|| Using the existing python virtual environment ||###############\n\n"
else
sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
echo -ne "\n###############|| Creating the python virtual environment ||###############\n\n"
"$python_binary" -m venv "$VENV_DIR"
fi
. "$VENV_DIR/bin/activate"
python -m pip install -U pip
python -m pip install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in"
# 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}/deployment_tools/open_model_zoo/tools/downloader"
model_dir=$("$python_binary" "$downloader_dir/info_dumper.py" --name "$model_name" |
"$python_binary" -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])')
model_dir=$(python "$downloader_dir/info_dumper.py" --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_binary" "$downloader_path" --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}"
print_and_run python "$downloader_path" --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 "${dashes}"
printf "Install Model Optimizer dependencies\n\n"
cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites"
. ./install_prerequisites.sh caffe
cd "$cur_path"
echo -ne "\n###############|| Install Model Optimizer dependencies ||###############\n\n"
cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer"
python -m pip install -r requirements.txt
cd "$PWD"
# Step 3. Convert a model with Model Optimizer
echo -ne "${dashes}"
printf "Convert a model with Model Optimizer\n\n"
echo -ne "\n###############|| Convert a model with Model Optimizer ||###############\n\n"
mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py"
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
print_and_run python "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
else
printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}"
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
echo -ne "${dashes}"
printf "Build Inference Engine samples\n\n"
echo -ne "\n###############|| Build Inference Engine samples ||###############\n\n"
OS_PATH=$(uname -m)
NUM_THREADS="-j2"
@ -194,7 +168,7 @@ if [ "$OS_PATH" == "x86_64" ]; then
fi
samples_path="${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/samples/cpp"
build_dir="$HOME/inference_engine_samples_build"
build_dir="$HOME/inference_engine_cpp_samples_build"
binaries_dir="${build_dir}/${OS_PATH}/Release"
if [ -e "$build_dir/CMakeCache.txt" ]; then
@ -207,8 +181,7 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path"
make $NUM_THREADS classification_sample_async
# Step 5. Run samples
echo -ne "${dashes}"
printf "Run Inference Engine classification sample\n\n"
echo -ne "\n###############|| Run Inference Engine classification sample ||###############\n\n"
cd "$binaries_dir"
@ -216,5 +189,4 @@ cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/"
print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" "${sampleoptions[@]}"
echo -ne "${dashes}"
printf "Demo completed successfully.\n\n"
echo -ne "\n###############|| Demo completed successfully ||###############\n\n"