gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 14:03:56 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com