运行该脚本时:
def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value=value))
for j in range(0,int(len(addrs_image))):
print('Train data: {}/{}'.format(j,int(len(addrs_image))))
sys.stdout.flush()
img = Image.open(addrs_image[j])
img = img.resize((600, 150), Image.ANTIALIAS)
np_data = np.array(img)
image_data = img.tobytes()
for text in open(addrs_label[j], encoding="utf-8"):
char_ids_padded, char_ids_unpadded = encode_utf8_string(
text=text,
dic=dict,
length=7,
null_char_id=26)
example = tf.train.Example(features=tf.train.Features(
feature={
'image/encoded': _bytes_feature(image_data),
'image/format': _bytes_feature(b"raw"),
'image/width':
_int64_feature([np_data.shape[1]]),
'image/orig_width':
_int64_feature([np_data.shape[1]]),
'image/class': _int64_feature(char_ids_padded),
'image/unpadded_class':
_int64_feature(char_ids_unpadded),
'image/text': _bytes_feature(bytes(text, 'utf-8')),
# 'height': _int64_feature([crop_data.shape[0]]),
}
))
我看到一条错误消息:
类型错误:'image/class': _int64_feature(char_ids_padded),
'image/unpadded_class': _int64_feature(char_ids_unpadded),
r:none类型为nonetype,输出预期为int
和dic.txt文件包含 enter image description here
那么,有人对如何解决这个问题有想法吗? 任何建议都非常感谢,谢谢大家