您的位置:首页 > 编程语言 > Python开发

python3环境下 tensorflow环境中经常遇到'*' has type str, but expected one of: bytes问题的解决

2018-03-03 16:17 941 查看
原文:http://blog.csdn.net/sparkexpert/article/details/70230072

python3环境下 tensorflow环境中经常遇到'*' has type str, but expected one of: bytes问题的解决

为了对flowers数据集进行训练,于是调用了tensorflow的slim模块中的download_and_convert_flowers.py文件进行处理,
但是下载完成之后,执行过程中碰到一个问题:'jpg' has type str, but expected one of: bytes

看来tensorflow默认的源码都是基于python2环境下的。
而python3环境下是需要额外加个字符的。因此针对这种问题,只能修改源码:
具体修改如下:即在'jpg'前面加一个字母:b,即代表以字节的方式来进行处理。

            example = dataset_utils.image_to_tfexample(
                image_data, b'jpg', height, width, class_id)
            tfrecord_writer.write(example.SerializeToString())

修改完,再次执行这个文档,果然顺利通过:>> Converting image 348/350 shard 4
>> Converting image 349/350 shard 4
>> Converting image 350/350 shard 4
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐