Hello NV12 Input Classification Sample — OpenVINO™ documentation (original) (raw)

This sample demonstrates how to execute an inference of image classification models with images in NV12 color format using Synchronous Inference Request API. Before using the sample, refer to the following requirements:

How It Works#

At startup, the sample application reads command line parameters, loads the specified model and an image in the NV12 color format to an OpenVINO™ Runtime plugin. Then, the sample creates an synchronous inference request object. When inference is done, the application outputs data to the standard output stream. You can place labels in .labels file near the model to get pretty output.

You can see the explicit description of each sample step atIntegration Stepssection of “Integrate OpenVINO™ Runtime with Your Application” guide.

Running#

C++

hello_nv12_input_classification

C

hello_nv12_input_classification_c

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

The sample accepts an uncompressed image in the NV12 color format. To run the sample, you need to convert your BGR/RGB image to NV12. To do this, you can use one of the widely available tools such as FFmpeg or GStreamer. Using FFmpeg and the following command, you can convert an ordinary image to an uncompressed NV12 image:

ffmpeg -i cat.jpg -pix_fmt nv12 cat.yuv

Note

Example#

  1. Download a pre-trained model.
  2. You can convert it by using:
  3. Perform inference of an NV12 image, using a model on a CPU, for example:
    C++
    hello_nv12_input_classification ./models/alexnet.xml ./images/cat.yuv 300x300 CPU
    C
    hello_nv12_input_classification_c ./models/alexnet.xml ./images/cat.yuv 300x300 CPU

Sample Output#

C++

The application outputs top-10 inference results.

[ INFO ] OpenVINO Runtime version ......... [ INFO ] Build ........... [ INFO ] [ INFO ] Loading model files: \models\alexnet.xml [ INFO ] model name: AlexNet [ INFO ] inputs [ INFO ] input name: data [ INFO ] input type: f32 [ INFO ] input shape: {1, 3, 227, 227} [ INFO ] outputs [ INFO ] output name: prob [ INFO ] output type: f32 [ INFO ] output shape: {1, 1000}

Top 10 results:

Image \images\car.yuv

classid probability


656 0.6668988 654 0.1125269 581 0.0679280 874 0.0340229 436 0.0257744 817 0.0169367 675 0.0110199 511 0.0106134 569 0.0083373 717 0.0061734

C

The application outputs top-10 inference results.

Top 10 results:

Image ./cat.yuv

classid probability


435 0.091733 876 0.081725 999 0.069305 587 0.043726 666 0.038957 419 0.032892 285 0.030309 700 0.029941 696 0.021628 855 0.020339

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

Additional Resources#