Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

export BASEDIR=~/armnn-pi

export PATH=$BASEDIR/boost.build/bin:$PATH

export PATH=$BASEDIR/protobuf-host/bin:$PATH

export LD_LIBRARY_PATH=$BASEDIR/protobuf-host/lib:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH=$BASEDIR/armnn/build:$LD_LIBRARY_PATH

export ARMNN_INCLUDE=$BASEDIR/armnn/include

...

Arm NN SDK provides a set of tests which can also be considered as demos showing what Arm NN does and how to use it. They load neural network models of various formats (Caffe, TensorFlow, TensorFlow Lite, ONNX), run the inference on a specified input data and output the inference result.

ArmNN SDK can be built on SP7021 with RPIOS.

Please see the attach file to see the detail process.

View file
nameArmNN SDK compile on SP7021.pptx
height250

1. Arm Compute Library

It is in $BASEDIR/ComputeLibrary
It's library built is in $BASEDIR/ComputeLibrary/build

1.1 Running a DNN with random weights and inputs

Arm compute library comes with examples for most common DNN architectures like: AlexNet, MobileNet, ResNet, Inception v3, Inception v4, Squeezenet, etc.
All available examples source code can be found in this example location: $BASEDIR/ComputeLibrary/example .example 
All available examples can be found in this example build location: $BASEDIR/ComputeLibrary/build/example
Each model architecture can be tested with graph_[dnn_model] application. For example, to run the MobileNet v2 DNN model with random weights, run the example application without any argument:

cd $BASEDIR/ComputeLibrary/build/examples

export LD_LIBRARY_PATH=$BASEDIR/ComputeLibrary/build:$LD_LIBRARY_PATH

./graph_mobilenet_v2

The application will create the DNN with random weights and run it with random inputs. If inference finishes, the "Test passed" message should be printed.

1.2 Running AlexNet using graph API
Download the archive file to the example location folder from this link:
cd $BASEDIR/ComputeLibrary/build/examples
curl -L -o computer_library_alexnet.zip

https://developer.arm.com/-/media/Arm%20Developer%20Community/Images/Tutorial%20Guide%20Diagrams%20and%20Screenshots/Machine%20Learning/Running%20AlexNet%20on%20Pi%20with%20Compute%20Library/compute_library_alexnet.zip?revision=c1a232fa-f328-451f-9bd6-250b83511e01_


Create a new sub-folder and unzip the file.
mkdir assets_alexnet
unzip compute_library_alexnet.zip -d assets_alexnet


Set environment variables for execution:
export LD_LIBRARY_PATH=$BASEDIR/ComputeLibrary/build/examples:$LD_LIBRARY_PATH
export PATH_ASSETS=$BASEDIR/ComputeLibrary/build/examples/assets_alexnet


Run the program.
./graph_alexnet --data=$PATH_ASSETS --image=$PATH_ASSETS/go_kart.ppm --labels=$PATH_ASSETS/labels.txt



grep "Caff"
-rwxr-xr-x 1 pi pi 915248 Sep 2 05:51 CaffeAlexNet-Armnn
-rwxr-xr-x 1 pi pi 725688 Sep 2 05:23 CaffeCifar10AcrossChannels-Armnn
-rwxr-xr-x 1 pi pi 915252 Sep 2 05:41 CaffeInception_BN-Armnn
-rwxr-xr-x 1 pi pi 729920 Sep 2 05:49 CaffeMnist-Armnn
-rwxr-xr-x 1 pi pi 915236 Sep 2 05:15 CaffeResNet-Armnn
-rwxr-xr-x 1 pi pi 915248 Sep 2 05:33 CaffeVGG-Armnn
-rwxr-xr-x 1 pi pi 920148 Sep 2 05:43 CaffeYolo-Armnn
Two important limitations might require preprocessing of the Caffe model file prior to running an Arm NN Caffe test.
First, Arm NN tests require batch size to be set to 1.
Second, Arm NN does not support all Caffe syntaxes, therefore some older neural network model files will require updates to the latest Caffe syntax.
For example, if a Caffe model has a batch size different from one or uses an older Caffe version defined by files model_name.prototxt and model_name.caffemodel, create a copy of the .prototxt file (new_model_name.prototxt), modify this file to use the new Caffe syntax and change the batch size to 1 and finally run the following python script:
import caffe
net = caffe.Net('model_name.prototxt', 'model_name.caffemodel', caffe.TEST)
new_net = caffe.Net('new_model_name.prototxt', 'model_name.caffemodel', caffe.TEST)
new_net.save('new_model_name.caffemodel')

      1. CaffeAlexNet-Armnn
  1. Use A linux host with py-caffe installed

    Download the model files:
    cd ~/ArmnnTests
    curl -L -o deploy.prototxt https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_alexnet/deploy.prototxt
    curl -L -o bvlc_alexnet.caffemodel http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel
    cp deploy.prototxt bvlc_alexnet_1.prototxt
    nano bvlc_alexnet_1.prototxt

...

    Download the model files:

    curl -L -o deploy.prototxt https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_alexnet/deploy.prototxt

    curl -L -o bvlc_alexnet.caffemodel http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel

    cp deploy.prototxt bvlc_alexnet_1.prototxt

    nano bvlc_alexnet_1.prototxt

change the batch size to 1

...

2.2.2 CaffeInception_BN-Armnn

  1. Use A linux host with py-caffe installed
    Download the model files:
    cd ~/ArmnnTests
    curl -L -o deploy.prototxt https://raw.githubusercontent.com/pertusa/InceptionBN-21K-for-Caffe/master/deploy.prototxt
    curl -L -o Inception21k.caffemodel http://www.dlsi.ua.es/~pertusa/deep/Inception21k.caffemodel
    cp deploy.prototxt Inception-BN-batchsize1.prototxt
    nano Inception-BN-batchsize1.prototxt

...

2.1.3 CaffeMnist-Armnn

  1. Use A linux host with py-caffe installed
    Download the model files:
    cd ~/ArmnnTests
    curl -L -o lenet.prototxt https://raw.githubusercontent.com/BVLC/caffe/master/examples/mnist/lenet.prototxt
    curl -L -o lenet_iter_9000_ori.caffemodel https://github.com/ARM-software/ML-examples/blob/master/armnn-mnist/model/lenet_iter_9000.caffemodel
    cp lenet.prototxt lenet_iter_9000.prototxt
    nano lenet_iter_9000.prototxt
    change the batch size to 1

    Original content:

    name: "LeNet"


    layer {



    name: "data"


      type: "Input"


      top: "data"


      input_param { shape: { dim: 64 dim: 1 dim: 28 dim: 28 } }

    Modified content:

    name: "LeNet"


    layer {



    name: "data"


      type: "Input"


      top: "data"


      input_param { shape: { dim: 1 dim: 1 dim: 28 dim: 28 } }


    Run the following python script to transform the network
        python3
            import caffe
            net = caffe.Net(lenet.prototxt', lenet_iter_9000_ori.caffemodel', caffe.TEST)
            new_net = caffe.Net(' lenet_iter_9000.prototxt', lenet_iter_9000_ori.caffemodel', caffe.TEST)
            new_net.save(' lenet_iter_9000.caffemodel')

    Copy lenet_iter_9000.caffemodel to ~/ArmnnTests/models in SP7021

  2. Find a .jpg file containing a shark (great white shark). Rename it to shark.jpg and copy it to the data folder on SP7021.
  3. Download the two archives below and unpack them:

...

TfInceptionV3-Armnn --data-dir=data --model-dir=models

This is not an execution error. This occurs because the TfInceptionV3-Armnn test expects a specific type of dog, cat and shark to be found so if a different type/breed of these animals is passed to the test, it returns a case failed.
The expected inputs for this test are:

ID

Label

File name

208

Golden Retriever

Dog.jpg

283

Tiger Cat

Cat.jpg

3

White Shark

shark.jpg

The complete list of supported objects can be found in https://github.com/ARM-software/armnn/blob/branches/armnn_18_11/tests/TfLiteMobilenetQuantized-Armnn/labels.txt

...

3. Python interface to Arm NN (PyArmNN)

cd ~/armnn-pi/armnn/python/pyarmnn/examples/
python3 tflite_mobilenetv1_quantized.py

...

Image Added
python3 onnx_mobilenetv2.py

Image Added

Anchor
_GoBack
_GoBack

...