R2Inference/Examples/NCSDK: Difference between revisions

From RidgeRun Developer Wiki
(Created page with "<noinclude> {{R2Inference/Head|previous=Examples|next=Examples/TensorFlow|keywords=NCSDK examples, NCSDK Inception v2 model, TinyYOLO v2 model, Tensorflow model}} </noinclude>...")
 
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 2: Line 2:
{{R2Inference/Head|previous=Examples|next=Examples/TensorFlow|keywords=NCSDK examples, NCSDK Inception v2 model, TinyYOLO v2 model, Tensorflow model}}
{{R2Inference/Head|previous=Examples|next=Examples/TensorFlow|keywords=NCSDK examples, NCSDK Inception v2 model, TinyYOLO v2 model, Tensorflow model}}
</noinclude>
</noinclude>
<!-- If you want a custom title for the page, un-comment and edit this line:
{{DISPLAYTITLE:R2Inference - NCSDK Examples|noerror}}
{{DISPLAYTITLE:R2Inference - <descriptive page name>|noerror}}
-->


R2Inference provide several examples to highlight its usage with different architectures and frameworks. The models used for this examples can be downloaded from our [[R2Inference/Model Zoo|Model Zoo]].
__TOC__


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


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.
== 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):
For example, given a caffe model (googlenet.caffemodel) and a network description (deploy.prototxt):
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
Line 25: Line 25:
</syntaxhighlight>
</syntaxhighlight>


For example evaluating this image:
For example, evaluating this image:


[[File:Plane example input.jpg|1800px|center|thumb|GoogLeNet example input]]
[[File:Plane example input.jpg|1800px|center|thumb|GoogLeNet example input]]
Line 43: Line 43:
</syntaxhighlight>
</syntaxhighlight>


According to the [https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a ImageNet labels] 404 corresponds to an 'airliner'.
According to the [https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a ImageNet labels], 404 corresponds to an 'airliner'.


== TinyYOLO v2 ==
== TinyYOLO v2 ==
Line 53: Line 53:
</syntaxhighlight>
</syntaxhighlight>


For example evaluating this image:
For example, evaluating this image:


[[File:Yolo example input.jpg|1800px|center|thumb|TinyYOLO example input]]
[[File:Yolo example input.jpg|1800px|center|thumb|TinyYOLO example input]]
Line 76: Line 76:


[[File:Tinyyolo postprocess2.png|1800px|center|thumb|TinyYOLO result]]
[[File:Tinyyolo postprocess2.png|1800px|center|thumb|TinyYOLO result]]
= Tensorflow =


<noinclude>
<noinclude>
{{R2Inference/Foot|Examples|Examples/TensorFlow}}
{{R2Inference/Foot|Examples|Examples/TensorFlow}}
</noinclude>
</noinclude>

Latest revision as of 18:48, 28 August 2020




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