运行 Android TF Detect 演示并使用我重新训练的 3 类 ssd_mobilenet_v1_coco 模型时,我的 TF 检测演示崩溃,并给出 IndexOutOfBoundException ,这是
12-26 17:53:13.931 22429-25212/org.tensorflow.demo E/AndroidRuntime: FATAL EXCEPTION: inference Process: org.tensorflow.demo, PID: 22429 java.lang.ArrayIndexOutOfBoundsException: length=3; index=3 at java.util.Vector.arrayIndexOutOfBoundsException(Vector.java:907) at java.util.Vector.elementAt(Vector.java:328) at java.util.Vector.get(Vector.java:442) at org.tensorflow.demo.TensorFlowObjectDetectionAPIModel.recognizeImage(TensorFlowObjectDetectionAPIModel.java:194) at org.tensorflow.demo.DetectorActivity$3.run(DetectorActivity.java:289) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.os.HandlerThread.run(HandlerThread.java:61)
来自
for (int i = 0; i <= outputScores.length; ++i) {
final RectF detection =
new RectF(
outputLocations[4 * i + 1] * inputSize,
outputLocations[4 * i] * inputSize,
outputLocations[4 * i + 3] * inputSize,
outputLocations[4 * i + 2] * inputSize);
pq.add(new Recognition("" + i, labels.get((int) outputClasses[i]), outputScores[i], detection));
}
最佳答案
通过添加“???”解决我的标签文件中的字符串,看来该应用程序遵循 pbtxt 格式,第一个 ID 为 1。
关于android - Tensorflow 对象检测 API 索引越界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47976743/