ArmNN SDK ENV variable set:
...
cd $BASEDIR/ComputeLibrary/build/examples export LD_LIBRARY_PATH=$BASEDIR/ComputeLibrary/build:$LD_LIBRARY_PATH ./graph_mobilenet_v2
| |
grep "Caff"
| |
2. Running Arm NN tests
Note that input data, model configurations, and model weights are not distributed with Arm NN. The user must download them separately and make sure they are available on the device before running the tests. However, Arm NN tests don't come with an documentation. Input file names are hardcoded, so investigate the code to find out what input file names are expected.
Following sections provide details about how to prepare the input data and how to run Arm NN tests. All of them use well known neural network models, therefore, with only few exceptions, such pre-trained networks are available freely on the Internet. Input images, models, formats and their content was deduced using code analysis.
Arm NN test source code is in $BASEDIR/armnn/tests
Arm NN test binary code is in $BASEDIR/armnn/build/tests
General work-flow is first to prepare data on a host machine and then to deploy it on the board, where the actual Arm NN tests will be run. The following sections assume that neural network model files are stored in a folder called models and input image files are stored in a folder called data. Both of them are created inside a folder called ArmnnTests. Create this folder structure on the larger partition using the following commands:
mkdir ArmnnTests
cd ArmnnTests
mkdir data
mkdir models
export PATH=$BASEDIR/armnn/build/tests:$PATH
2.1 Caffe tests
Arm NN SDK provides the following set of tests for Caffe models:
pi@raspberrypi:~/armnn-pi/armnn/build/tests$ ls -l | 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
...
2.1.1 CaffeAlexNet-Armnn
- Use A linux host with py-caffe installed
Download the model files:
...
3. Run the test
CaffeAlexNet-Armnn --data-dir=data --model-dir=models
2.2.2 CaffeInception_BN-Armnn
- 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 - batchsize1.prototxt
change the batch size to 1
Original content
name: "Inception21k" | ||
layer { | ||
name: "data" | ||
type: "Input" | ||
top: "data" | ||
input_param { shape: { dim: |
...
10 dim: 3 dim: 224 dim: 224 } } |
...
Modified content:
name: "Inception21k" | ||
layer { | ||
name: "data" | ||
type: "Input" | ||
top: "data" | ||
input_param { shape: { dim: |
...
1 dim: 3 dim: 224 dim: 224 } } |
Run the following python script to transform the network
import caffe
net = caffe.Net('deploy.prototxt', 'Inception21k.caffemodel', caffe.TEST)
new_net = caffe.Net('Inception-BN-batchsize1.prototxt', 'Inception21k.caffemodel', caffe.TEST)
new_net.save(' Inception-BN-batchsize1.caffemodel')python3
Copy Inception-BN-batchsize1.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 the SP7021.
3. Run the test
CaffeInception_BN-Armnn --data-dir=data --model-dir=models
2.1.3 CaffeMnist-Armnn
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 1Original content:
1name: "LeNet"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim:
64 dim: 1 dim: 28 dim: 28 } }
Modified content:
64name: "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- Find a .jpg file containing a shark (great white shark). Rename it to shark.jpg and copy it to the data folder on SP7021.
- Download the two archives below and unpack them:
curl -L -o t10k-images-idx3-ubyte.gz http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
curl -L -o t10k-labels-idx1-ubyte.gz http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
gzip -d t10k-images-idx3-ubyte.gz
gzip -d t10k-labels-idx1-ubyte.gz
4. Rename two files to be t10k-images.idx3-ubyte and t10k-labels.idx1-ubyte and copy files to the data folder on the device.
mv t10k-images-idx3-ubyte t10k-images.idx3-ubyte
mv t10k-labels-idx1-ubyte t10k-labels.idx1-ubyte
cp t10k-images-idx3-ubyte ./data/
cp t10k-labels-idx1-ubyte ./data/
5. Run the test
CaffeMnist-Armnn --data-dir=data --model-dir=models
2.2 TensorFlow tests
Arm NN SDK provides the following set of tests for TensorFlow models:
pi@raspberrypi:~/armnn-pi/armnn/build/tests$ ls -l | grep "Tf"
-rwxr-xr-x 1 pi pi 725444 Sep 2 05:51 TfCifar10-Armnn
-rwxr-xr-x 1 pi pi 920116 Sep 2 05:58 TfInceptionV3-Armnn
-rwxr-xr-x 1 pi pi 729696 Sep 2 05:49 TfMnist-Armnn
-rwxr-xr-x 1 pi pi 920116 Sep 2 05:56 TfMobileNet-Armnn
-rwxr-xr-x 1 pi pi 914928 Sep 2 05:58 TfResNext-Armnn
2.2.1 TfInceptionV3-Armnn
1. Download the model files. Unzip and move file to action folder :
cd ~/ArmnnTests
curl -L -o inception_v3_2016_08_28_frozen.pb.tar.gz https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz
tar zxvf inception_v3_2016_08_28_frozen.pb.tar.gz
mv inception_v3_2016_08_28_frozen.pb ./models/
...
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
...