问题描述
在运行 Android TF 检测演示并使用我重新训练的 3 类 ssd_mobilenet_v1_coco 模型后,我的 TF 检测演示崩溃并给出 IndexOutOfBoundException,即
Upon running the Android TF Detect Demo and using my retrained 3 class ssd_mobilenet_v1_coco model my TF detect Demo crashes giving an IndexOutOfBoundException which is
12-26 17:53:13.931 22429-25212/org.tensorflow.demo E/AndroidRuntime:致命异常:推理进程:org.tensorflow.demo,PID:22429java.lang.ArrayIndexOutOfBoundsException: length=3;指数=3在 java.util.Vector.arrayIndexOutOfBoundsException(Vector.java:907)在 java.util.Vector.elementAt(Vector.java:328)在 java.util.Vector.get(Vector.java:442)在 org.tensorflow.demo.TensorFlowObjectDetectionAPIModel.recognizeImage(TensorFlowObjectDetectionAPIModel.java:194)在 org.tensorflow.demo.DetectorActivity$3.run(DetectorActivity.java:289)在 android.os.Handler.handleCallback(Handler.java:739)在 android.os.Handler.dispatchMessage(Handler.java:95)在 android.os.Looper.loop(Looper.java:148)在 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));
}
推荐答案
通过添加???"解决我的 Label 文件中的字符串,看起来 App 遵循 pbtxt 格式,第一个 ID 为 1.
Solved by Adding a "???" string inside my Label file, it seems that the App follows the pbtxt format of having the first ID which is 1.
这篇关于Tensorflow 对象检测 API 索引越界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!