gpt4 book ai didi

tensorflow - tensorflow 对象检测训练中的标签文件

转载 作者:行者123 更新时间:2023-12-05 06:30:35 29 4
gpt4 key购买 nike

我想使用 tensorflow object detection API 创建我自己的 .tfrecord 文件,并将它们用于训练。该记录将是原始数据集的子集,因此模型将仅检测特定类别。我不明白也无法找到任何相关信息的是,在训练期间 id 是如何分配给 label_map.pbtxt 中的标签的

我在做什么...

第 1 步:在创建 tfrecord 文件期间分配 label_id,我在其中放置自己的 ID:

'image/object/class/label': dataset_util.int64_list_feature(category_ids)
'image/object/class/text': dataset_util.bytes_list_feature(category_names)

第 2 步:使用例如创建标签文件两类:

item { name: "apple"  id: 53  display_name: "apple" }
item { name: "broccoli" id: 56 display_name: "broccoli" }

第 3 步:训练模型

训练后,检测到一些对象,但带有N/A 标签当我将 id 设置为从 1 开始时,它会显示正确的标签

我的问题是:

  1. 为什么它没有正确映射到带有自定义 ID 的标签?
  2. 第二个 id 可以有除 2 之外的其他值吗?我确定我在 coco 数据集的标签文件中看到了跳过的 ID。
  3. 如果可能,如何将 id 设置为具有自定义值?

谢谢

最佳答案

我的标签 map 也有同样的问题。在谷歌搜索了一下之后,我在这里找到了你的问题,还有 TensorFlow 对象检测的摘录 repository :

Each dataset is required to have a label map associated with it. This label map defines a mapping from string class names to integer class Ids. The label map should be a StringIntLabelMap text protobuf. Sample label maps can be found in object_detection/data. Label maps should always start from id 1.

我还检查了 label_map_util.py 的源代码并找到了这条评论:

We only allow class into the list if its id-label_id_offset isbetween 0 (inclusive) and max_num_classes (exclusive).If there are several items mapping to the same id in the label map,we will only keep the first one in the categories list

因此在您的示例中,它只有两个类,有效 ID 为 1 和 2。任何更高的值都将被忽略。

关于tensorflow - tensorflow 对象检测训练中的标签文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52222980/

29 4 0