所以我试图将自己的数据集用于tf对象检测模块中包含的train.py。
我使用以下脚本
创建了我的TFRecord文件@DateTimeFormat
现在当我运行train.py时收到此错误消息
def create_tf_example(example):
#Frame,Label,xmin,xmax,ymin,ymax
#0 1 2 3 4 5
# TODO(user): Populate the following variables from your example.
height = 960 # Image height
width = 540 # Image width
filename = example[0] # Filename of the image. Empty if image is not from file
filename = filename
encoded_image_data = None # Encoded image bytes
with tf.gfile.GFile('GELABELT_BBox/SCHILD/BILDER_149/'+example[0],'rb') as fid:
encoded_image_data = fid.read()
image_format = b'jpg' # b'jpeg' or b'png'
# List of normalized left x coordinates in bounding box (1 per box)
xmins = [int(example[2])/width]
xmaxs = [int(example[3])/width] # List of normalized right x coordinates in bounding box
# (1 per box)
# List of normalized top y coordinates in bounding box (1 per box)
ymins = [int(example[4])/height]
ymaxs = [int(example[5])/height] # List of normalized bottom y coordinates in bounding box
# (1 per box)
classes_text = [example[1]] # List of string class name of bounding box (1 per box)
classes = [1] # List of integer class id of bounding box (1 per box)
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),
'image/source_id': dataset_util.bytes_feature(filename),
'image/encoded': dataset_util.bytes_feature(encoded_image_data),
'image/format': dataset_util.bytes_feature(image_format),
'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
'image/object/class/label': dataset_util.int64_list_feature(classes),
}))
return tf_example
在发布的代码中,我使用python 2.7运行它,我也尝试使用python 3.6运行并使用encode()和encode(' utf8')作为filename和类输入的字符串条目。
我没有对train.py进行任何更改