【发布时间】:2018-10-30 11:14:53
【问题描述】:
在我的期末大学考试中,我正在尝试将 SNPE 与 Tiny YOLO 一起用于 Android 应用程序中的实时对象检测。我成功地将模型转换为 DLC 格式,但我不明白如何准备输入张量以及如何处理输出张量。同一个人可以帮助我吗?谢谢。
【问题讨论】:
在我的期末大学考试中,我正在尝试将 SNPE 与 Tiny YOLO 一起用于 Android 应用程序中的实时对象检测。我成功地将模型转换为 DLC 格式,但我不明白如何准备输入张量以及如何处理输出张量。同一个人可以帮助我吗?谢谢。
【问题讨论】:
构建SNPE神经网络并得到输出FloatTensor的步骤:
在Android/app目录下创建asset文件夹,并将模型文件(.dlc)保存在asset文件夹中。
// 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 中提到的准备输入张量和处理输出张量的部分https://developer.qualcomm.com/docs/snpe/android_tutorial.html
【讨论】: