Welcome back to the OpenVINO channel.
Let's look at the most simple Python sample code for the Inference-engine
It is the same classification sample as in video 16, but this time using Python
You can find this sample under the The inference-engine samples/ python samples/
We tried to bring here the mini mal code you have to add to your application in order to do inference using the inference-engine
A typical inference flow by the inference-engine will look like that
First, we initialize the model, set all the parameters
you can see that in that done in the white boxes,
Then we read one frame, arrange it into the input blob or input tensor
Do inference, Take the results from the output blob, and process them.
This is done by the 3 bottom yellow boxes for each of the frames you want to infer
The first API command is to setup the plugin, this is created from the IEPlugin class,
this class is the main plugin interface and serves to initialize and configure the plugin.
The class constructor requires the device argument (CPU, GPU and so on..)
which sets the hardware target and the plugin directory paths
Then, we load the Intermediate Representation using the constructor of the class IENetwork.
This class contains the information about the network model read from IR
and allows you to manipulate with some model parameters such as layers affinity and output layers.
This class takes as input the xml and binary files from the IR.
"Net" holds the network information like the inputs and outputs
We can access the first elements using "next"
And we set the input and output blobs (or tensors) to point to the first elements in the iterators on the input and outputs.
We load the network object (IENetwork) to the plugin using the function load from the IEPlugin class.
It loads a network that was read from the IR to the plugin
and creates an executable network object.
You can create as many networks as you need and use them simultaneously
And now we are ready..
we start by extracting the input tensor shape, then we read the images using OpenCV,
we resize to the input tensor shape.
OpenCV format is HWC, while OpenVINO expects CHW
so we need to shuffle the channels.
Images are added to an array which will be given to the inference.
And here comes the inference
The function starts the synchronous inference
and fill the outputs array.
It takes as input a dictionary that maps numpy.array objects of proper shape with input data for the layer
Now we need to read the inference results..
For this, we access the data inside the Output blob/tensor.
The data format is very dependent on the application,
bounding boxes coordinate for object detection or like here a list of probabilities for classification,
In this example, we sort the probabilities by highest values and display the N top probabilities..
We saw the most simple inference-engine Python sample,
Use it to implement your inference..
There are many other samples, for detection, segmentation and more..
Look them up in future videos or in the supplied package..
Subscribe to our channel to get more videos like this one..
Thank you.