Scripts to convert and run a TF model using Qualcomm SNPE tools
The tensorflow for poets repo is a good one to get scripts to create and validate a simple PB file and also get training data. This repo has tools that help run SNPE tools on the PB and data....
Assumes you have created a MobileNet_V1 model from scratch or retrained one using TF for poets walkthrough.
- Get the data Based on the TF for poets walkthough
curl http://download.tensorflow.org/example_images/flower_photos.tgz \
| tar xz -C tf_files
ls tf_files/flower_photos/ | grep -v LICENSE > labels.txt
- Sample the data
random_sample.py tf_files/flower_photos/ samples/
- convert images to raw format (with mean subtraction etc)
python ./toraw.py samples/
find samples/ -name *.raw > samples.txt
Requires you to have SNPE tools setup
- convert the model
snpe-tensorflow-to-dlc --graph flowers.pb -i input 1,224,224,3 --out_node MobilenetV1/Predictions/Reshape_1 --allow_unconsumed_nodes
- quantize the model
snpe-dlc-quantize --input_dlc flowers.dlc --output_dlc flowers_q.dlc --input_list samples.txt
- run inferencing
snpe-net-run --container flowers.dlc --input_list samples.txt --output_dir flower_output
- show results
python show_classifications.py -i samples.txt -o flower_output -l labels.txt -s MobilenetV1/Predicti
ons/Reshape_1\: