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

2024-10-01 07:12:48 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我目前正在尝试在tensorflow上训练一个自定义的对象检测模型来识别raspberrype2的图像。一切都已经在我的硬件上设置和运行,但是由于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中的models文件夹的旧版本修复了这个问题,并且模型开始培训,所以请注意tf团队。在


Tags: 文件to数据对象模型图像文件夹model
1条回答
网友
1楼 · 发布于 2024-10-01 07:12:48

改变我创建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记录具有与上面所示相同的键。这是因为您使用的模型需要与上面类似的键。我希望这有帮助。在

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

^{pr2}$

正如您所看到的,我写的是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

相关问题 更多 >