|
Snapdragon Neural Processing Engine SDK
Reference Guide
|
The tutorials require additional resources which are not included in the default SNPE SDK package. These assets need to be downloaded before running the tutorials.
In this tutorial, AlexNet Caffe model files (prototxt and caffemodel), and sample image files are prepared for the Caffe tutorial. The script requires a directory path to the AlexNet assets. The script can also optionally download the AlexNet assets.
The AlexNet assets are listed below:
deploy.prototxt - https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_alexnet/deploy.prototxt bvlc_alexnet.caffemodel - http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel caffe_ilsvrc12.tar.gz - http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz
Note that the assets are large and can take some time to download.
Running "python3 $SNPE_ROOT/models/alexnet/scripts/setup_alexnet.py -h" will show the usage description.
usage: $SNPE_ROOT/models/alexnet/scripts/setup_alexnet.py [-h] -a ASSETS_DIR [-d]
Prepares the AlexNet assets for tutorial examples.
required arguments:
-a ASSETS_DIR, --assets_dir ASSETS_DIR
directory containing the AlexNet assets
optional arguments:
-d, --download Download AlexNet assets to AlexNet assets directoryDownload the model and prepare the assets
The assets directory contains the network model assets. If the assets have been previously downloaded set the ASSETS_DIR to this directory otherwise select a target directory to store the assets as they are downloaded. If the assets are already downloaded to a directory (e.g. ~/tmpdir) then issue the following command.
Issue this command to download the assets first. The downloaded files with be written to the specified assets directory (e.g. ~/tmpdir)
After the script is complete the prepared AlexNet assets are copied to the $SNPE_ROOT/models/alexnet directory, along with sample raw images, and converted SNPE DLC files.
In this tutorial, the Inception v3 TensorFlow model file, and sample image files are prepared for the TensorFlow classification tutorial. The script requires a directory path to the Inception v3 assets (zip file). The script can also optionally download the Inception v3 archive.
The Inception v3 assets are listed below:
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
Note that the assets are large and can take some time to download.
Running "python3 $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py -h" will show the usage description.
usage: $SNPE_ROOT/models/inception_v3/scripts/setup_inceptionv3.py [-h] -a ASSETS_DIR [-d] [-r RUNTIME] [-u]
Prepares the inception_v3 assets for tutorial examples.
required arguments:
-a ASSETS_DIR, --assets_dir ASSETS_DIR
directory containing the inception_v3 assets
optional arguments:
-d, --download Download inception_v3 assets to inception_v3 example
directory
-r RUNTIME, --runtime RUNTIME
Choose a runtime to set up tutorial for. Choices: cpu,
gpu, dsp, aip, all. 'all' option is only supported
with --udo flag
-u, --udo Generate and compile a user-defined operation package
to be used with inception_v3. Softmax is simulated as
a UDO for this script.
Download the model and prepare the assets
The assets directory is intended to contain the network model assets. If the assets have been previously downloaded set the ASSETS_DIR to this directory otherwise select a target directory to store the assets as they are downloaded, along with the option [–download] to actually download the model files.
Choice of target runtime
Depending on the chosen runtime the script may perform additional steps of optimization specific to a hardware target. Users can choose to generate the final DLC to run on one of CPU, GPU, DSP or the HTA targets at runtime.
The argument 'runtime' is optional and defaults to 'cpu' when not explicitly specified.
Here are some sample commands to use in different circumstances:
Let us use ~/tmpdir as our assets directory for these examples.
1. Run the script to download model and set up to run on CPU:
2. Run the script to download model and set up to run on DSP:
2. Run the script on an model already downloaded to ~/tmpdir to set up to run on HTA:
After the script is complete the prepared Inception v3 assets are copied to the $SNPE_ROOT/models/inception_v3 directory, along with sample raw images, and converted SNPE DLC files with additional optimizations as applicable.
Note: for information on running Inception v3 with UDO and the use of the /–udo visit UDO Tutorial