【问题标题】:Error indices[0] = 0 is not in [0, 0) while training an object-detection model with tensorflow使用 tensorflow 训练对象检测模型时,错误索引 [0] = 0 不在 [0, 0) 中
【发布时间】:2018-03-01 11:02:53
【问题描述】:

所以我目前正在尝试在 tensorflow 上训练一个自定义对象检测模型来识别 raspberrypi2 的图像。一切都已经在我的硬件上设置并运行,但由于我的 gpu 的限制,我选择了云。我已经上传了我的数据(训练和测试记录以及 csv 文件)和我的检查点模型。这就是我从日志中得到的:

tensorflow:Restoring parameters from /mobilenet/model.ckpt

tensorflow:Starting Session.

tensorflow:Saving checkpoint to path training/model.ckpt

tensorflow:Starting Queues.

tensorflow:Error reported to Coordinator: <class tensorflow.python.framework.errors_impl.InvalidArgumentError'>, indices[0] = 0 is not in [0, 0)

我还有一个名为 images 的文件夹,其中包含实际的 .jpg 文件,它也在云端,但由于某种原因,我必须在每个目录中指定一个前面的正斜杠 /,这可能是一个问题,就像我目前所做的那样不知道某些文件是否正在尝试导入这些图像,但由于缺少 / 找不到路径。 如果你们中的任何人碰巧分享解决方案,我将非常感激。

编辑:我通过在 tensorflow 中下载旧版本的模型文件夹来修复它,并且模型开始训练,因此请注意 tf 团队。

【问题讨论】:

  • 嗨,我和你有同样的问题。你具体下载的是哪个版本?非常感谢!
  • 嗨,我猜是这个download.tensorflow.org/models/object_detection/…,但这只是移动网络模型。那是大约 7 个月前的事了,但你总是可以查看当时的一些旧提交。希望对您有所帮助!
  • 一定有我遗漏的东西,但是你在哪里可以得到以前的模型?我正在寻找 ssd_inception_v2 但在模型动物园中,唯一可用的版本是导致 index[0] = 0 is not in [0, 0) 错误的版本。 (编辑:顺便谢谢)

标签: python tensorflow object-detection


【解决方案1】:

改变我创建 TF 记录的方式对我来说很有效。看看下面的代码 -

 example = tf.train.Example(
                            features= tf.train.Features(
                                feature={
                                    'image/height': dataset_util.int64_feature(height),
                                    'image/width': dataset_util.int64_feature(width),
                                    'image/filename': dataset_util.bytes_feature(filename_str.encode('utf-8')),
                                    'image/source_id': dataset_util.bytes_feature(filename_str.encode('utf-8')),
                                    'image/format': dataset_util.bytes_feature(image_format),
                                    'image/encoded': dataset_util.bytes_feature(image_data),
                                    'image/object/bbox/xmin': dataset_util.float_list_feature(xmin),
                                    'image/object/bbox/xmax': dataset_util.float_list_feature(xmax),
                                    'image/object/bbox/ymin': dataset_util.float_list_feature(ymin),
                                    'image/object/bbox/ymax': dataset_util.float_list_feature(ymax),
                                    'image/object/class/text': dataset_util.bytes_list_feature(labels_text),
                                    'image/object/class/label': dataset_util.int64_list_feature(labels),
                                }
                            )
                        )

确保 TF 记录具有与上面显示的相同的键。这是因为您使用的模型需要与上述类似的键。我希望这会有所帮助。

早些时候,我使用了以下方法,但没有成功-

example = tf.train.Example(
                            features= tf.train.Features(
                                feature={
                                    'image/height': dataset_util.int64_feature(shape[0]),
                                    'image/width': dataset_util.int64_feature(shape[1]),
                                    'image/channels': dataset_util.int64_feature(shape[2]),
                                    'image/shape': dataset_util.int64_list_feature(shape),
                                    'image/object/bbox/xmin': dataset_util.float_list_feature(xmin),
                                    'image/object/bbox/xmax': dataset_util.float_list_feature(xmax),
                                    'image/object/bbox/ymin': dataset_util.float_list_feature(ymin),
                                    'image/object/bbox/ymax': dataset_util.float_list_feature(ymax),
                                    'image/object/bbox/class/label': dataset_util.int64_list_feature(labels),
                                    'image/object/bbox/class/text': dataset_util.bytes_list_feature(labels_text),
                                    'image/object/bbox/difficult': dataset_util.int64_list_feature(difficult),
                                    'image/object/bbox/truncated': dataset_util.int64_list_feature(truncated),
                                    'image/format': dataset_util.bytes_feature(image_format),
                                    'image/encoded': dataset_util.bytes_feature(image_data),
                                    'image/filename': dataset_util.bytes_feature(filename_str.encode('utf-8')),
                                    'image/source_id': dataset_util.bytes_feature(filename_str.encode('utf-8'))
                                }
                            )
                        )

如您所见,我写的是 image/object/bbox/class/label 而不是 image/object/class/label。我希望这会有所帮助。

您可以查看以下链接 -https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/using_your_own_dataset.md

【讨论】:

    【解决方案2】:

    我在使用 centernet_mobilenetv2 模型时遇到了同样的问题,但我只是删除了 pipeline.config 文件中的 num_keypoints 参数,然后一切正常。我不知道该参数有什么问题,但没有它我能够进行训练。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-12
      • 1970-01-01
      • 2018-07-29
      • 1970-01-01
      相关资源
      最近更新 更多