Snapdragon神经处理引擎(SNPE)和Tiny Yolo在Android App上

时间:2018-10-30 11:14:54

标签: android yolo snpe

对于我的期末大学考试,我正在尝试将SNPE与Tiny YOLO结合使用以在Android App中进行实时对象检测。我成功地将模型转换为DLC格式,但是我不明白如何准备输入张量以及如何处理输出张量。可以帮我吗?谢谢。

1 个答案:

答案 0 :(得分:0)

建立SNPE神经网络并获取FloatTensor输出的步骤:

  1. 在Android / app目录中创建资产文件夹,并将模型文件(.dlc)保留在资产文件夹中。

    // 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. 创建输入张量

  3. 通过网络传播输入张量
  4. 处理神经网络输出

请点击下面的链接,找到步骤2、3和4中提到的部分,以准备输入张量和处理输出张量https://developer.qualcomm.com/docs/snpe/android_tutorial.html