简体   繁体   English

Tensorflow对象检测API索引超出范围

[英]Tensorflow Object Detection API Index out of Bounds

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 在运行Android TF Detect Demo并使用经过重新训练的3类ssd_mobilenet_v1_coco模型后,我的TF Detect Demo崩溃,给出了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; 12-26 17:53:13.931 22429-25212 / org.tensorflow.demo E / AndroidRuntime:致命例外:推理过程: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) index = 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)

which comes from 来自

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));
}

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. 标签文件中的字符串,似乎该应用程序遵循第一个ID为1的pbtxt格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM