TypeError: 'RGB' has type str, but expected one of: bytes(法1)
在使用Python3+(本人Python3.5)執行21個專案玩轉深度學習第三個專案的時候。在執行資料轉換操作
python data_convert.py -t pic/ \--train-shards 2 \--validation-shards 2 \--num-threads 2 \--dataset-name satellite
出現了 ‘’TypeError: 'RGB' has type str, but expected one of: bytes‘’,原因是Python2+與Python3+使用格式不對。經以下修改成功執行資料轉換。
colorspace = 'RGB'.encode()
channels = 3
image_format = 'JPEG'.encode()
example = tf.train.Example(features=tf.train.Features(feature={
‘image/height’: _int64_feature(height),
‘image/width’: _int64_feature(width),
‘image/colorspace’: _bytes_feature(colorspace),
‘image/channels’: _int64_feature(channels),
‘image/class/label’: _int64_feature(label),
‘image/class/text’: _bytes_feature(text.encode()),
‘image/format’: _bytes_feature(image_format),
‘image/filename’: _bytes_feature(os.path.basename(filename.encode())),
‘image/encoded’: _bytes_feature(image_buffer)}))
return example
INFO:root:2018-11-27 17:45:23.217677 [thread 0]: Processed 1000 of 2400 images in thread batch.
INFO:root:2018-11-27 17:45:23.219677 [thread 1]: Processed 1000 of 2400 images in thread batch.
INFO:root:2018-11-27 17:45:24.021429 [thread 0]: Processed 2000 of 2400 images in thread batch.
INFO:root:2018-11-27 17:45:24.025384 [thread 1]: Processed 2000 of 2400 images in thread batch.
INFO:root:2018-11-27 17:45:24.336195 [thread 0]: Wrote 2400 images to pic/satellite_train_00000-of-00002.tfrecord
INFO:root:2018-11-27 17:45:24.336302 [thread 0]: Wrote 2400 images to 2400 shards.
INFO:root:2018-11-27 17:45:24.348348 [thread 1]: Wrote 2400 images to pic/satellite_train_00001-of-00002.tfrecord
INFO:root:2018-11-27 17:45:24.348439 [thread 1]: Wrote 2400 images to 2400 shards.
INFO:root:2018-11-27 17:45:24.407238: Finished writing all 4800 images in data set.
TypeError: 'RGB' has type str, but expected one of: bytes(法1)相关推荐
- 21个TensorFlow项目转换tfrecord:TypeError: 'RGB' has type str, but expected one of: bytes(法二)
最近在看21个TensorFlow项目一书中,由于我环境是Python3.5,项目中环境应该是Python2.运行第三章data_prepare文件夹下data_convert.py将图片转换为tfr ...
- python3环境下 tensorflow环境中经常遇到'*' has type str, but expected one of: bytes问题的解决
原文:http://blog.csdn.net/sparkexpert/article/details/70230072 python3环境下 tensorflow环境中经常遇到'*' has typ ...
- 读取文件:TypeError: an integer is required (got type str)
读取文件的时候报错: Traceback (most recent call last): File "D:\Python35\test\csdn.py", line 46, in ...
- 踩坑中:TypeError: unsupported operand type(s) for /: 'str' and 'int'
在网上查看了很多博客,首先从报错提示来讲TypeError: unsupported operand type(s) for /: 'str' and 'int',明确了是类型错误:不支持操作类型为整 ...
- Django问题:TypeError: unsupported operand type(s) for -: ‘str‘ and ‘float‘
Django问题:TypeError: unsupported operand type(s) for -: 'str' and 'float Traceback (most recent call ...
- TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format
TypeError: Unrecognized value type: <class 'str'> ParserError: Unknown string format 目录 TypeE ...
- apex安装报错:TypeError: unsupported operand type(s) for +: ‘NoneType‘ and ‘str‘
参考解决方法:TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' · Issue #990 · NVIDIA/apex ...
- Flask API TypeError: Object of type 'Response' is not JSON serializable
Flask API TypeError: Object of type 'Response' is not JSON serializable 错误代码: session['image'] = str ...
- 成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type
成功解决raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type 目录 解决问题 ...
最新文章
- 深入理解SERDES接口
- Gentoo - X11 forwarding request failed on channel 0
- 「技美之路」图形 1.1 渲染流水线
- 《机器人学导论--Join J.Craig》第一章 绪论
- 通俗的解释交叉熵与相对熵
- linux 日志编程(总结)
- 蜗牛星际A单千兆群晖系统崩溃恢复记录
- python共享单车数据分析_利用python分析共享单车项目
- 那些你不愿说给领导的话
- C语言快速互转HEX(16进制)和原始字符串/数组
- 上海市新生婴儿户口登记(出生申报)
- HBase 面试题(一)
- HTML/CSS学习笔记(1)
- Unity-拓展篇-pr序列帧转透明视频
- iOS-Core Animation 核心动画高级编程/5-变换
- 电脑怎么直接给服务器传文件夹,教你电脑怎么传文件夹给qq好友
- C++ for循环效率优化
- 腾讯加入专利保护社区 OIN
- 毕业生求职必会算法 约瑟夫环问题
- 把Foxmail里的邮件导入到Office Outlook里