我有一个Android应用程序,例如我对我的冻结模型进行了初始化。 似乎操作系统存在问题。我得到了这个例外:
java.lang.RuntimeException: Unable to start activity ComponentInfo{myapp/myapp.MainActivity}:
org.tensorflow.TensorFlowException: Op type not registered 'NonMaxSuppressionV3' in binary running on localhost. Make sure the Op and Kernel are registered in the binary running in this process.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:890)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:780)
Caused by: org.tensorflow.TensorFlowException: Op type not registered 'NonMaxSuppressionV3' in binary running on localhost. Make sure the Op and Kernel are registered in the binary running in this process.
at org.tensorflow.Graph.importGraphDef(Native Method)
at org.tensorflow.Graph.importGraphDef(Graph.java:130)
at org.tensorflow.Graph.importGraphDef(Graph.java:114)
at org.tensorflow.contrib.android.TensorFlowInferenceInterface.loadGraph(TensorFlowInferenceInterface.java:559)
at org.tensorflow.contrib.android.TensorFlowInferenceInterface.<init>(TensorFlowInferenceInterface.java:105)
at myapp.ActivityInference.<init>(ActivityInference.java:22)
at myapp.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6692)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:890)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:780)
我检查了tensorflow / core / kernels /中的BUILD文件,并定义了内核库:
tf_kernel_library( name = "non_max_suppression_op", prefix = "non_max_suppression_op", deps = IMAGE_DEPS, )
我是新手,所以我真的不知道如何解决它。 我正在研究预先训练好的冷冻模型。
这是我的Android代码:
package myapp;
import android.content.Context;
import android.content.res.AssetManager;
import org.tensorflow.contrib.android.TensorFlowInferenceInterface;
public class ActivityInference {
private static ActivityInference activityInferenceInstance;
private TensorFlowInferenceInterface inferenceInterface;
private static AssetManager assetManager;
private static final String MODEL_FILE = "file:///android_asset/frozen_inference_graph.pb";
private static final String INPUT_NODE = "input";
public ActivityInference(final Context context) {
this.assetManager = context.getAssets();
inferenceInterface = new TensorFlowInferenceInterface(assetManager, MODEL_FILE);
}
public static ActivityInference getInstance(final Context context){
if (activityInferenceInstance == null)
{
activityInferenceInstance = new ActivityInference(context);
}
return activityInferenceInstance;
}
}
以及Android的主要活动:
package myapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private ActivityInference activityInference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView textView = (TextView) findViewById(R.id.textView);
activityInference = new ActivityInference(getApplicationContext());
}
}
我真的没有看到任何方法可以修复它,我想之后会有另外一个例外。 提前感谢任何人寻求解决方案。