python3环境下 tensorflow环境中经常遇到'*' has type str, but expected one of: bytes问题的解决
2018-03-03 16:17
941 查看
原文:http://blog.csdn.net/sparkexpert/article/details/70230072
但是下载完成之后,执行过程中碰到一个问题:'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
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
相关文章推荐
- python3环境下 tensorflow环境中经常遇到'*' has type str, but expected one of: bytes问题的解决
- python遇到AttributeError: 'str' object has no attribute '_getAssertEqualityFunc'问题解决过程
- JAVA: 解决is expected to be of type but was actually of type com.sun.proxy.$Proxy的问题
- Python学习笔记:学习爬虫时遇到的问题TypeError: cannot use a string pattern on a bytes-like object 与解决办法
- Python之Headers value 1 must be of type str or bytes, not <class 'int'>错误的解决
- 解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题
- 关于Android开发导入已有项目遇到Project has no default.properties file! Edit the project properties to set one.问题的解决方法
- Linux搭建python环境中cx_Oracle模块安装遇到的问题与解决方法
- 解决yum升级的问题“There was a problem importing one of the Python modules”
- 解决问题The content of the adapter has changed but ListView did not receive a notification.
- 解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题
- 解决yum升级的问题“There was a problem importing one of the Python modules”
- Bean named '...' is expected to be of type [...] but was actually of type [com.sun.proxy.$Proxy7解决方法
- Python出现TypeError: file() argument 1 must be encoded string without NULL bytes, not str问题解决
- 解决BeanNotOfRequiredTypeException: Bean named 'XXX' must be of type XXX, but was actually of type XXX问题
- 解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- git pull时遇到git pull error :error: remote ref is at but expected问题的解决办法
- Mac下执行php遇到Allowed memory size of 134217728 bytes exhausted问题解决方法