R2Inference - NCSDK Examples

From RidgeRun Developer Wiki




Previous: Examples Index Next: Examples/TensorFlow




R2Inference provides several examples to highlight its usage with different architectures and frameworks. The models used for these examples can be downloaded from our Model Zoo.

Preparation

To test the NCSDK examples you will need a NCSDK C API compatible graph file. You can generate it from Caffe or TensorFlow model files with the mvNCCompile tool. For example, given a caffe model (googlenet.caffemodel) and a network description (deploy.prototxt):

mvNCCompile -w bvlc_googlenet.caffemodel -s 12 deploy.prototxt

This command will output the graph and output_expected.npy files. We will use the graph file for the examples and ignore the other one. This model can also be downloaded from our Model Zoo.

Inception v2

This example is located in r2inference/examples/r2i/ncsdk . To use this example run:

./googlenet -i [JPG input_image] -m [GoogLeNet Inception v2 Model]

For example, evaluating this image:

GoogLeNet example input

Should produce the following output:

./googlenet -i plane.jpg -m graph_googlenet
Loading Model: graph_googlenet...
Setting model to engine...
Loading image: plane.jpg...
Configuring frame...
Starting engine...
Predicting...
Highest probability is label 404 (0.823242)
Stopping engine...

According to the ImageNet labels, 404 corresponds to an 'airliner'.

TinyYOLO v2

This example is located in r2inference/examples/r2i/ncsdk . To use this example run:

./tinyyolo -i [JPG input_image] -m [TinyYOLO v2 Model]

For example, evaluating this image:

TinyYOLO example input

Should produce the following output:

./tinyyolo -i yolo.jpg -m graph_yolo     
Loading Model: graph_yolo...
Setting model to engine...
Loading image: yolo.jpg...
Configuring frame...
Starting engine...
Predicting...
Box:[class:'dog', x_center:205.714, y_center:372.857, width:199.956, height:293.533, prob:0.141857]
Box:[class:'bicycle', x_center:369.964, y_center:283.239, width:522.349, height:373.425, prob:0.454611]
Box:[class:'car', x_center:525.696, y_center:123.167, width:163.172, height:50.8492, prob:0.489166]
Stopping engine...

Drawing the boxes over the original image we get:

TinyYOLO result




Previous: Examples Index Next: Examples/TensorFlow