Hi, I am trying to use YOLO with SNPE. How i have to preprocessing image before launch the execute method?
Preprocessing image for SNPE and Tiny YOLO
Posted: Wed, 2018-10-31 04:42
Hi, I am trying to use YOLO with SNPE. How i have to preprocessing image before launch the execute method?
Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.
Steps to build SNPE neural network and get the output FloatTensor:
1. Create an asset folder in Android/app directory and keep the model file(.dlc) in the asset folder.
// assetFileName is the file name of .dlc
InputStream assetInputStream = application.getAssets().open(assetFileName); // Create and build the neural network
NeuralNetwork network = new SNPE.NeuralNetworkBuilder(application)
.setDebugEnabled(false)
//outputLayerNames can be got while converted model to DLC format
.setOutputLayers(outputLayerNames)
.setModel(assetInputStream, assetInputStream.available())
.setPerformanceProfile(NeuralNetwork.PerformanceProfile.DEFAULT)
.setRuntimeOrder(selectedRuntime) // Runtime.DSP, Runtime.GPU_FLOAT16, Runtime.GPU, Runtime.CPU
.setCpuFallbackEnabled(needsCpuFallback)
.build();
// Close input
assetInputStream.close();
2. Create an Input Tensor
3. Propagate Input Tensors Through the Network
4. Process the Neural Network Output
Please follow the link below and find sections mentioned in steps 2,3 and 4 for preparing input Tensors and processing output tensors https://developer.qualcomm.com/docs/snpe/android_tutorial.html
with above setup i am only able to achieve 4-5fps on GPU for the yolov4 tiny model. I have tried many variations of the NeuralNetworkBuilder like below:
val builder: SNPE.NeuralNetworkBuilder = SNPE.NeuralNetworkBuilder(Cerebro.app)
This same model runs at 25fps on other non-qc platforms.
please help!