Snapdragon Neural Processing Engine (SNPE) and Tiny Yolo on Android App

1.2k Views Asked by At

for my final university exam I am trying to use SNPE with Tiny YOLO for real time object detection in an Android App. I succesfully converted model to DLC format, but i can't understand how to prepare input tensors and how to process output tensors. Can sameone help me? Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

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