Forums - Preprocessing image for SNPE and Tiny YOLO

3 posts / 0 new
Last post
Preprocessing image for SNPE and Tiny YOLO
luca.padovan
Join Date: 28 Sep 18
Posts: 12
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?

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Tue, 2019-09-24 03:31

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

  • Up0
  • Down0
aniket.vartak1
Join Date: 30 Jan 24
Posts: 7
Posted: Thu, 2024-04-04 15:32

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)

                .setDebugEnabled(false)
//                .setRuntimeOrder(NeuralNetwork.Runtime.DSP, NeuralNetwork.Runtime.GPU, NeuralNetwork.Runtime.GPU_FLOAT16,  NeuralNetwork.Runtime.CPU)
                .setRuntimeOrder(NeuralNetwork.Runtime.GPU_FLOAT16)
                // CPU fall back is needed for our model to run on the DSP, some ops not supported
                .setCpuFallbackEnabled(true)
                // Determined by the layer names from snpe-dlc-info -i quant.dlc
//                .setOutputLayers("concat_29", "concat_30") // yolov4_quantized.dlc
                .setOutputLayers("concat_21", "concat_22") // fp32.dlc
                .setModel(File(modelPath))
                .setPerformanceProfile(NeuralNetwork.PerformanceProfile.HIGH_PERFORMANCE)
                .setExecutionPriorityHint(NeuralNetwork.ExecutionPriorityHint.HIGH)
                .setUnsignedPD(false)
                .setRuntimeCheckOption(NeuralNetwork.RuntimeCheckOption.BASIC_CHECK)

This same model runs at 25fps on other non-qc platforms.

 

please help!

  • Up0
  • Down0
or Register

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.