python - 使用 tensorflow 训练对象检测模型时,错误索引[0] = 0 不在 [0, 0) 中

标签 python tensorflow object-detection

所以我目前正在尝试在 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团队。

最佳答案

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

 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

关于python - 使用 tensorflow 训练对象检测模型时,错误索引[0] = 0 不在 [0, 0) 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49048262/

相关文章:

python - 在不使用 pip 的情况下安装 python wheel 文件

python - 使用 py 3.6 Ubuntu 16.04 安装工具在 Anaconda 环境中安装 TensorFlow 1.2 GPU 时出错

python - 加载 Fashion_mnist 数据需要太多时间

Tensorflow 服务在基本路径下找不到可服务的 <MODEL> 版本

python - 在 pygtk 中处理双击和单击事件

Python paramiko 脚本,在 exec_command() 期间读取输出时出现问题

python - 如何让 for 循环在 while 循环的每次迭代中重新评估

python - 将图像编辑为 tensorflow 张量 python

python - 如何修复 TensorFlow 对象检测示例中 version.py 导致的错误

deep-learning - 是否可以在没有适当训练数据的情况下执行目标检测