android - Tensorflow 对象检测 API 索引越界

标签 android tensorflow object-detection

运行 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/

相关文章:

使用稀疏张量计算梯度时,tensorflow给出nans

python-3.x - 如何使用opencv通过xmax xmin ymax ymin编写矩形(边界框)

c# - EMGU CV SURF图像匹配

android - CollapsingToolbarLayout 内的 ViewPager

android - 具有数组响应解析的 KSOAP2

javascript - Tensorflow JS - 将张量转换为 JSON,然后再转换回张量

image - 如何检测图像中的裂缝?

android - 浏览器图像显示不正确

android - TextView 不在用户输入时显示 EditText 字符串

python - 封装 TensorFlow 计算图的类中的类继承