Tensorflow 对象检测 API 索引越界 [英] Tensorflow Object Detection API Index out of Bounds

查看:78
本文介绍了Tensorflow 对象检测 API 索引越界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行 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)

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

推荐答案

通过添加???"解决我的 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 索引越界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆