Java 我能';t在Android Studio上使用TensorFlow创建实例
Java 我能';t在Android Studio上使用TensorFlow创建实例,java,android,android-studio,tensorflow,Java,Android,Android Studio,Tensorflow,我想在Android Studio上使用TensorFlow图形。 首先,我可以导入org.tensorflow.contrib.android.tensorflowEnferenceInterface。但我无法举例说明。 这里是MainActivity.java。 package com.example.maguro.mnist_beginner; import android.support.v7.app.AppCompatActivity; import android.os.Bundl
我想在Android Studio上使用TensorFlow图形。
首先,我可以导入org.tensorflow.contrib.android.tensorflowEnferenceInterface。但我无法举例说明。
这里是MainActivity.java。
package com.example.maguro.mnist_beginner;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import org.tensorflow.contrib.android.TensorFlowInferenceInterface;
public class MainActivity extends AppCompatActivity {
static{
System.loadLibrary("tensorflow_inference");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TensorFlowInferenceInterface inferenceInterface = new TensorFlowInferenceInterface();
}
}
错误点是最后一个描述。TensorFlowInferenceInterface inferenceInterface = new TensorFlowInferenceInterface();
错误为“无法解析构造函数”TensorFlow推论接口();“虽然我参考了2个主页,但我收到了此错误。
我编辑了两个文件。“settings.gradle”和“app/build.gradle”
这是格雷德尔
include ':app',':TensorFlow-Android-Inference'
findProject(":TensorFlow-Android-Inference").projectDir = new File("/home/maguro/tensorflow/tensorflow/contrib/android/cmake")
下面是app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.maguro.mnist_beginner"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets{
main{
jniLibs.srcDirs = ['libs']
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
debugCompile project(path:':TensorFlow-Android-Inference',configuration:'debug')
releaseCompile project(path:':TensorFlow-Android-Inference',configuration:'release')
}
------我的环境------操作系统:Ubuntu 14.04 LTS
Tensorflow:用于python3.6的GPU的Anaconda
安卓工作室:2.3.3
CUDA工具包:8.0
cuDNN:6.0
我不能很好地使用英语。
如果我说了一些粗鲁的话,我很抱歉。
请帮我一把。正如错误消息所示,
TensorFlowEnferenceInterface
没有不带参数的构造函数
从中,我看到三个构造函数:
TensorFlow推论接口(AssetManager AssetManager,字符串模型)
TensorFlow推论接口(InputStream是)
TensorFlow推论接口(图g)
希望有帮助。你的项目中有libtensorflow_推理吗?是的,我制作了包含app/src/main/assets/libtensorflow_推理的目录。抱歉,我错过了前面的评论。我制作了包含app/libs/libandroid_tensorflow_推理的目录。java.jar和app/libs/arm64-v8a/libtensorflow_推理的目录。谢谢!!但现在,我不知道了“没有实验电脑。明天,我会试试。在我添加3个构造函数后,Android Studio没有告诉我错误!谢谢你教我!!:)对不起。在我解决问题后,我该怎么做?(例如,单击复选标记,评估你)。对不起,请告诉我。”。