栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

tensorflow将csv文件转换为tfrecord文件时报错:TypeError: None has type NoneType, but expected one of: int, long

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

tensorflow将csv文件转换为tfrecord文件时报错:TypeError: None has type NoneType, but expected one of: int, long

按照网上的教程,在进行csv_to_tfrecord这一步的时候,会报错:TypeError: None has type NoneType, but expected one of: int, long,检查时发现,tfrecord文件的大小为0kb,其中一个原因是因为这个文件:“generate_tfrecord.py”文件忘记修改了。

这个文件中本来有多处是注释掉的,下面代码块中的两处汉语注释就是出现问题的原因之一。

flags = tf.app.flags
flags.DEFINE_string('csv_input', '', 'Path to the CSV input')
flags.DEFINE_string('output_path', '', 'Path to output TFRecord')
flags.DEFINE_string('label', '', 'Name of class label')
# if your image has more labels input them as
flags.DEFINE_string('label0', '', 'Name of class[0] label')//默认状态下,此下都是注释掉的
#flags.DEFINE_string('label1', '', 'Name of class[1] label')
# flags.DEFINE_string('label2', '', 'Name of class[2] label')
# flags.DEFINE_string('label3', '', 'Name of class[3] label')
# flags.DEFINE_string('label4', '', 'Name of class[4] label')
# flags.DEFINE_string('label5', '', 'Name of class[5] label')
# flags.DEFINE_string('label6', '', 'Name of class[6] label')
# and so on.
flags.DEFINE_string('img_path', '', 'Path to images')
FLAGS = flags.FLAGS


# TO-DO replace this with label map
# for multiple labels add more else if statements
def class_text_to_int(row_label):
    if row_label == FLAGS.label0://此处的label后的数字和上边的要对应上
        return 1

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/942265.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号