Skip to content

Commit 4dc9c03

Browse files
authored
Fix demo scripts (#6280)
* Fix unknown command line flag errors if -sample-options is used * Fix raw escape sequences output with dashes * Fix raw escape sequences output with run_again message * try change sampleoptions to array
1 parent 3b2da7d commit 4dc9c03

3 files changed

+36
-36
lines changed

scripts/demo/demo_benchmark_app.sh

+14-14
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ case $key in
3333
shift
3434
;;
3535
-sample-options)
36-
sampleoptions="$2 $3 $4 $5 $6"
37-
echo sample-options = "${sampleoptions}"
36+
sampleoptions=("${@:2}")
37+
echo sample-options = "${sampleoptions[*]}"
3838
shift
3939
;;
4040
*)
@@ -44,8 +44,8 @@ esac
4444
shift
4545
done
4646

47-
if ([ -z "$sampleoptions" ]); then
48-
sampleoptions="-niter 1000"
47+
if [ -z "${sampleoptions[*]}" ]; then
48+
sampleoptions=( -niter 1000 )
4949
fi
5050

5151
target_precision="FP16"
@@ -71,12 +71,12 @@ else
7171
fi
7272

7373
if ! . "$setupvars_path" ; then
74-
printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}"
74+
echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}"
7575
exit 1
7676
fi
7777

7878
# Step 1. Download the Caffe model and the prototxt of the model
79-
printf "%s" "${dashes}"
79+
echo -ne "${dashes}"
8080
printf "\n\nDownloading the Caffe model and the prototxt"
8181

8282
cur_path=$PWD
@@ -143,7 +143,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
143143
fi
144144

145145
if ! command -v $python_binary &>/dev/null; then
146-
printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}"
146+
echo -ne "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}"
147147
exit 1
148148
fi
149149

@@ -166,14 +166,14 @@ ir_dir="${irs_path}/${model_dir}/${target_precision}"
166166

167167
if [ ! -e "$ir_dir" ]; then
168168
# Step 2. Configure Model Optimizer
169-
printf "%s" "${dashes}"
169+
echo -ne "${dashes}"
170170
printf "Install Model Optimizer dependencies\n\n"
171171
cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites"
172172
. ./install_prerequisites.sh caffe
173173
cd "$cur_path"
174174

175175
# Step 3. Convert a model with Model Optimizer
176-
printf "%s" "${dashes}"
176+
echo -ne "${dashes}"
177177
printf "Convert a model with Model Optimizer\n\n"
178178

179179
mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py"
@@ -182,11 +182,11 @@ if [ ! -e "$ir_dir" ]; then
182182
print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
183183
else
184184
printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}"
185-
printf "If you want to convert a model again, remove the entire %s folder. %s" "${ir_dir}" "${run_again}"
185+
echo -ne "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}"
186186
fi
187187

188188
# Step 4. Build samples
189-
printf "%s" "${dashes}"
189+
echo -ne "${dashes}"
190190
printf "Build Inference Engine samples\n\n"
191191

192192
OS_PATH=$(uname -m)
@@ -211,15 +211,15 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path"
211211
make $NUM_THREADS benchmark_app
212212

213213
# Step 5. Run samples
214-
printf "%s" "${dashes}"
214+
echo -ne "${dashes}"
215215
printf "Run Inference Engine benchmark app\n\n"
216216

217217
cd "$binaries_dir"
218218

219219
cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/"
220220

221-
print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc "${sampleoptions}"
221+
print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc "${sampleoptions[@]}"
222222

223-
printf "%s" "${dashes}"
223+
echo -ne "${dashes}"
224224

225225
printf "Inference Engine benchmark app completed successfully.\n\n"

scripts/demo/demo_security_barrier_camera.sh

+10-10
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ case $key in
3333
shift
3434
;;
3535
-sample-options)
36-
sampleoptions="$2 $3 $4 $5 $6"
37-
echo sample-options = "${sampleoptions}"
36+
sampleoptions=("${@:2}")
37+
echo sample-options = "${sampleoptions[*]}"
3838
shift
3939
;;
4040
*)
@@ -112,7 +112,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
112112
fi
113113

114114
if ! command -v $python_binary &>/dev/null; then
115-
printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}"
115+
echo -ne "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}"
116116
exit 1
117117
fi
118118

@@ -128,12 +128,12 @@ else
128128
printf "Error: setupvars.sh is not found\n"
129129
fi
130130
if ! . "$setupvars_path" ; then
131-
printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}"
131+
echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}"
132132
exit 1
133133
fi
134134

135135
# Step 1. Downloading Intel models
136-
printf "%s" "${dashes}"
136+
echo -ne "${dashes}"
137137
printf "Downloading Intel models\n\n"
138138

139139

@@ -161,13 +161,13 @@ while read -r model_opt model_name; do
161161
done < "$ROOT_DIR/demo_security_barrier_camera.conf"
162162

163163
# Step 2. Build samples
164-
printf "%s" "${dashes}"
164+
echo -ne "${dashes}"
165165
printf "Build Inference Engine demos\n\n"
166166

167167
demos_path="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/demos"
168168

169169
if ! command -v cmake &>/dev/null; then
170-
printf "\n\nCMAKE is not installed. It is required to build Inference Engine demos. Please install it. %s" "${run_again}"
170+
echo -ne "\n\nCMAKE is not installed. It is required to build Inference Engine demos. Please install it. ${run_again}"
171171
exit 1
172172
fi
173173

@@ -189,13 +189,13 @@ cmake -DCMAKE_BUILD_TYPE=Release "$demos_path"
189189
make $NUM_THREADS security_barrier_camera_demo
190190

191191
# Step 3. Run samples
192-
printf "%s" "${dashes}"
192+
echo -ne "${dashes}"
193193
printf "Run Inference Engine security_barrier_camera demo\n\n"
194194

195195
binaries_dir="${build_dir}/${OS_PATH}/Release"
196196
cd "$binaries_dir"
197197

198-
print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" "${sampleoptions}"
198+
print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" "${sampleoptions[@]}"
199199

200-
printf "%s" "${dashes}"
200+
echo -ne "${dashes}"
201201
printf "Demo completed successfully.\n\n"

scripts/demo/demo_squeezenet_download_convert_run.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ case $key in
3333
shift
3434
;;
3535
-sample-options)
36-
sampleoptions="$2 $3 $4 $5 $6"
37-
echo sample-options = "${sampleoptions}"
36+
sampleoptions=("${@:2}")
37+
echo sample-options = "${sampleoptions[*]}"
3838
shift
3939
;;
4040
*)
@@ -67,12 +67,12 @@ else
6767
fi
6868

6969
if ! . "$setupvars_path" ; then
70-
printf "Unable to run ./setupvars.sh. Please check its presence. %s" "${run_again}"
70+
echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}"
7171
exit 1
7272
fi
7373

7474
# Step 1. Download the Caffe model and the prototxt of the model
75-
printf "%s" "${dashes}"
75+
echo -ne "${dashes}"
7676
printf "\n\nDownloading the Caffe model and the prototxt"
7777

7878
cur_path=$PWD
@@ -139,7 +139,7 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
139139
fi
140140

141141
if ! command -v $python_binary &>/dev/null; then
142-
printf "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. %s" "${run_again}"
142+
echo -ne "\n\nPython 3.5 (x64) or higher is not installed. It is required to run Model Optimizer, please install it. ${run_again}"
143143
exit 1
144144
fi
145145

@@ -162,14 +162,14 @@ ir_dir="${irs_path}/${model_dir}/${target_precision}"
162162

163163
if [ ! -e "$ir_dir" ]; then
164164
# Step 2. Configure Model Optimizer
165-
printf "%s" "${dashes}"
165+
echo -ne "${dashes}"
166166
printf "Install Model Optimizer dependencies\n\n"
167167
cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites"
168168
. ./install_prerequisites.sh caffe
169169
cd "$cur_path"
170170

171171
# Step 3. Convert a model with Model Optimizer
172-
printf "%s" "${dashes}"
172+
echo -ne "${dashes}"
173173
printf "Convert a model with Model Optimizer\n\n"
174174

175175
mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py"
@@ -178,11 +178,11 @@ if [ ! -e "$ir_dir" ]; then
178178
print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision"
179179
else
180180
printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}"
181-
printf "If you want to convert a model again, remove the entire %s folder. %s" "${ir_dir}" "${run_again}"
181+
echo -ne "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}"
182182
fi
183183

184184
# Step 4. Build samples
185-
printf "%s" "${dashes}"
185+
echo -ne "${dashes}"
186186
printf "Build Inference Engine samples\n\n"
187187

188188
OS_PATH=$(uname -m)
@@ -207,14 +207,14 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path"
207207
make $NUM_THREADS classification_sample_async
208208

209209
# Step 5. Run samples
210-
printf "%s" "${dashes}"
210+
echo -ne "${dashes}"
211211
printf "Run Inference Engine classification sample\n\n"
212212

213213
cd "$binaries_dir"
214214

215215
cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/"
216216

217-
print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" "${sampleoptions}"
217+
print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" "${sampleoptions[@]}"
218218

219-
printf "%s" "${dashes}"
219+
echo -ne "${dashes}"
220220
printf "Demo completed successfully.\n\n"

0 commit comments

Comments
 (0)