Hello Reshape SSD C++ Sample

This sample demonstrates how to do synchronous inference of object detection models using input reshape feature. Models with only one input and output are supported.

The following C++ API is used in the application:

Feature

API

Description

Node operations

ov::Node::get_type_info , ngraph::op::DetectionOutput::get_type_info_static , ov::Output::get_any_name , ov::Output::get_shape

Get a node info

Model Operations

ov::Model::get_ops , ov::Model::reshape

Get model nodes, reshape input

Tensor Operations

ov::Tensor::data

Get a tensor data

Preprocessing

ov::preprocess::PreProcessSteps::convert_element_type , ov::preprocess::PreProcessSteps::convert_layout

Model input preprocessing

Basic OpenVINO™ Runtime API is covered by Hello Classification C++ sample.

Options

Values

Validated Models

person-detection-retail-0013

Model Format

OpenVINO™ toolkit Intermediate Representation (*.xml + *.bin), ONNX (*.onnx)

Supported devices

All

Other language realization

Python

How It Works

Upon the start-up the sample application reads command line parameters, loads specified network and image to the Inference Engine plugin. Then, the sample creates an synchronous inference request object. When inference is done, the application creates output image and output data to the standard output stream.

You can see the explicit description of each sample step at Integration Steps section of “Integrate OpenVINO™ Runtime with Your Application” guide.

Building

To build the sample, please use instructions available at Build the Sample Applications section in OpenVINO™ Toolkit Samples guide.

Running

hello_reshape_ssd <path_to_model> <path_to_image> <device>

To run the sample, you need specify a model and image:

  • you can use public or Intel’s pre-trained models from the Open Model Zoo. The models can be downloaded using the Model Downloader.

  • you can use images from the media files collection available at https://storage.openvinotoolkit.org/data/test_data.

NOTES :

  • By default, OpenVINO™ Toolkit Samples and Demos expect input with BGR channels order. If you trained your model to work with RGB order, you need to manually rearrange the default channels order in the sample or demo application or reconvert your model using the Model Optimizer tool with --reverse_input_channels argument specified. For more information about the argument, refer to When to Reverse Input Channels section of Embedding Preprocessing Computation.

  • Before running the sample with a trained model, make sure the model is converted to the intermediate representation (IR) format (*.xml + *.bin) using the Model Optimizer tool.

  • The sample accepts models in ONNX format (*.onnx) that do not require preprocessing.

Example

  1. Install openvino-dev python package if you don’t have it to use Open Model Zoo Tools:

python -m pip install openvino-dev[caffe,onnx,tensorflow2,pytorch,mxnet]
  1. Download a pre-trained model using:

omz_downloader --name person-detection-retail-0013
  1. person-detection-retail-0013 does not need to be converted, because it is already in necessary format, so you can skip this step. If you want to use another model that is not in the IR or ONNX format, you can convert it using the model converter script:

omz_converter --name <model_name>
  1. Perform inference of person_detection.bmp using person-detection-retail-0013 model on a GPU, for example:

hello_reshape_ssd person-detection-retail-0013.xml person_detection.bmp GPU

Sample Output

The application renders an image with detected objects enclosed in rectangles. It outputs the list of classes of the detected objects along with the respective confidence values and the coordinates of the rectangles to the standard output stream.

[ INFO ] OpenVINO Runtime version ......... <version>
[ INFO ] Build ........... <build>
[ INFO ]
[ INFO ] Loading model files: \models\person-detection-retail-0013.xml
[ INFO ] model name: ResMobNet_v4 (LReLU) with single SSD head
[ INFO ]     inputs
[ INFO ]         input name: data
[ INFO ]         input type: f32
[ INFO ]         input shape: {1, 3, 320, 544}
[ INFO ]     outputs
[ INFO ]         output name: detection_out
[ INFO ]         output type: f32
[ INFO ]         output shape: {1, 1, 200, 7}
Reshape network to the image size = [960x1699]
[ INFO ] model name: ResMobNet_v4 (LReLU) with single SSD head
[ INFO ]     inputs
[ INFO ]         input name: data
[ INFO ]         input type: f32
[ INFO ]         input shape: {1, 3, 960, 1699}
[ INFO ]     outputs
[ INFO ]         output name: detection_out
[ INFO ]         output type: f32
[ INFO ]         output shape: {1, 1, 200, 7}
[0,1] element, prob = 0.716309,    (852,187)-(983,520)
The resulting image was saved in the file: hello_reshape_ssd_output.bmp

This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool

See Also