Я пытаюсь сгенерировать tfrecords так же, как был сгенерирован FSNS? - PullRequest
0 голосов
/ 27 ноября 2018

при запуске этого скрипта:

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: ни один не имеет тип нетип, и выходные данные ожидаются как int

иФайл dic.txt содержит введите описание изображения здесь

Итак, у кого-нибудь есть идеи, как решить эту проблему?Любое предложение очень ценится и спасибо всем заранее

...