为多个对象创建 TFrecord 文件
creating TFrecord file for multiple objects
我正在学习来自 GitHub (https://github.com/datitran/raccoon_dataset) to detect animals using google object detection API. For this, I need to generate tfrecord file which is already generated here on line number 29 to 34 (https://github.com/datitran/raccoon_dataset/blob/master/generate_tfrecord.py) 的浣熊检测教程。
但他只完成了第 29 到 34 行中一种动物(浣熊)的代码。我有多种动物,如浣熊、螳螂、寄居蟹等,如何为多种动物修改此 tfrecord 文件。我发现的一种方法是对 generatetfrecord 文件中的第 29 行到第 34 行进行如下更改
def class_text_to_int(row_label):
if row_label == 'raccoon':
return 1
if row_label == 'prayingmantis':
return 2
else:
None
这种方法是否适合在同一个文件中包含多个 if,或者我需要生成多个 tfrecord 文件来训练多个对象
def class_text_to_int(row_label):
if row_label == 'raccoon':
return 1
elif row_label == 'prayingmantis':
return 2
else:
None
在 generatetfrecord 中进行上述更改是同时训练多个自定义图像的正确方法。此外,在对象 detection.pbtxt 文件中,进行以下更改:
item{
id:1
name:'racoon'
}
item{
id:2
name: 'prayingmantis'
}
并从第一步重新训练模型。
我正在学习来自 GitHub (https://github.com/datitran/raccoon_dataset) to detect animals using google object detection API. For this, I need to generate tfrecord file which is already generated here on line number 29 to 34 (https://github.com/datitran/raccoon_dataset/blob/master/generate_tfrecord.py) 的浣熊检测教程。
但他只完成了第 29 到 34 行中一种动物(浣熊)的代码。我有多种动物,如浣熊、螳螂、寄居蟹等,如何为多种动物修改此 tfrecord 文件。我发现的一种方法是对 generatetfrecord 文件中的第 29 行到第 34 行进行如下更改
def class_text_to_int(row_label):
if row_label == 'raccoon':
return 1
if row_label == 'prayingmantis':
return 2
else:
None
这种方法是否适合在同一个文件中包含多个 if,或者我需要生成多个 tfrecord 文件来训练多个对象
def class_text_to_int(row_label):
if row_label == 'raccoon':
return 1
elif row_label == 'prayingmantis':
return 2
else:
None
在 generatetfrecord 中进行上述更改是同时训练多个自定义图像的正确方法。此外,在对象 detection.pbtxt 文件中,进行以下更改:
item{
id:1
name:'racoon'
}
item{
id:2
name: 'prayingmantis'
}
并从第一步重新训练模型。