implementation 'org.tensorflow:tensorflow-lite:+'在我的build.gradle依赖项下推理时间不是那么好,所以现在我想在 Android 的 NDK 中使用 TFL。
所以我在 Android Studio 的 NDK 中构建了 Java 应用程序的精确副本,现在我试图在项目中包含 TFL 库。我按照TensorFlow-Lite 的 Android 指南在本地构建了 TFL 库(并获得了一个 AAR 文件),并将该库包含在我在 Android Studio 中的 NDK 项目中。
现在我试图在我的 C++ 文件中使用 TFL 库,尝试#include在代码中使用它,但我收到一条错误消息:(cannot find tensorflow或我尝试使用的任何其他名称,根据我在我的CMakeLists.txt文件)。 …
我正在尝试在 Android 上以 tflite 形式运行 TensorFlow 模型(用于操作图像),但我不断收到java.io.FileNotFoundException。
不必费心阅读所有 Java 代码 - 当尝试加载模型时,它甚至在开始之前就失败了:
// Initialize model
try{
MappedByteBuffer tfliteModel
= FileUtil.loadMappedFile(this,
"model.tflite");
tflite = new Interpreter(tfliteModel);
} catch (IOException e){
Log.e("tfliteException", "Error: couldn't load tflite model.", e);
}
Run Code Online (Sandbox Code Playgroud)
构建.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.tflite"
minSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// tf lite …Run Code Online (Sandbox Code Playgroud)