* initial setup and rename "how to" to "setup" * move API to main nav * move api to main nav * add get starated, rework nav order * rename to install move mds out of install section * update api nav and home page * add install docs and python qs updates * python get started work * remove c and obj c for now * move java, python, and obj-c docs under api folder * move java api html to iframe (ugh) * remove api docs w/o details, move api text getstar * remove api docs wo detail updates get started * remvoe iframes * move eco system to main nav * fix api buttons * added more examples moved intro to ORT * fix links * fix get started titles * fix get started titles * fix more links * fix more links * more link fixes * fix nav remove inferencing and training subnav * fix top nav remove inference and training nav * fix title * fix tutorials nav hierarchy * fix python api button * add tenorflow keras example * fix quickstart toc * add imports fix spacing * fix links * update nav and python get started page * move ort training example, add coming soon for iot * update C# get started * fix spacing on quantization * Add some js get started content * fix formatting * fix typo * removed onnx-pytorch and onnx-tf * updated pip install torch and added links iot page * added pytorch tutorial heirarchy * updated web to docs soon added release blog link * add web link
3.2 KiB
| nav_exclude |
|---|
| true |
Image classification with Squeezenet in CPP using OpenVINO Execution Provider:
{: .no_toc }
-
The image classification uses a Squeezenet Deep Learning ONNX Model from the ONNX Model Zoo.
-
The sample involves presenting an image to the ONNX Runtime (RT), which uses the OpenVINO Execution Provider for ONNX RT to run inference on various Intel hardware devices like Intel CPU, GPU, VPU and more. The sample uses OpenCV for image processing and ONNX Runtime OpenVINO EP for inference. After the sample image is inferred, the terminal will output the predicted label classes in order of their confidence.
The source code for this sample is available here.
How to build
Prerequisites
-
Use opencv (use the same opencv package that comes builtin with Intel® Distribution of OpenVINO toolkit)
-
Use any sample image as input to the sample.
-
Download the latest Squeezenet model from the ONNX Model Zoo. This example was adapted from ONNX Model Zoo.Download the latest version of the Squeezenet model from here.
Install ONNX Runtime for OpenVINO Execution Provider
Build steps
Reference Documentation
If you build it by yourself, you must append the "--build_shared_lib" flag to your build command.
./build.sh --config Release --use_openvino CPU_FP32 --build_shared_lib
Build the sample C++ Application
-
Navigate to the directory /onnxruntime/build/Linux/Release/
-
Now copy all the files required to run this sample at this same location (/onnxruntime/build/Linux/Release/)
-
compile the sample
g++ -o run_squeezenet squeezenet_cpp_app.cpp -I ../../../include/onnxruntime/core/session/ -I /opt/intel/openvino_2021.4.582/opencv/include/ -I /opt/intel/openvino_2021.4.582/opencv/lib/ -L ./ -lonnxruntime_providers_openvino -lonnxruntime_providers_shared -lonnxruntime -L /opt/intel/openvino_2021.4.582/opencv/lib/ -lopencv_imgcodecs -lopencv_dnn -lopencv_core -lopencv_imgproc
Note: This build command is using the opencv location from OpenVINO 2021.4 Release Installation. You can use any version of OpenVINO and change the location path accordingly.
-
Run the sample
To Run
(using Intel OpenVINO-EP)
./run_squeezenet --use_openvino <path_to_onnx_model> <path_to_sample_image> <path_to_labels_file>
Example:
./run_squeezenet --use_openvino squeezenet1.1-7.onnx demo.jpeg synset.txt (using Intel OpenVINO-EP)
(using Default CPU)
./run_squeezenet --use_cpu <path_to_onnx_model> <path_to_sample_image> <path_to_labels_file>
Example:
./run_squeezenet --use_cpu squeezenet1.1-7.onnx demo.jpeg synset.txt (using Default CPU)