在使用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)相关推荐

  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 ...

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

    原文:http://blog.csdn.net/sparkexpert/article/details/70230072 python3环境下 tensorflow环境中经常遇到'*' has typ ...

  3. 读取文件:TypeError: an integer is required (got type str)

    读取文件的时候报错: Traceback (most recent call last): File "D:\Python35\test\csdn.py", line 46, in ...

  4. 踩坑中:TypeError: unsupported operand type(s) for /: 'str' and 'int'

    在网上查看了很多博客,首先从报错提示来讲TypeError: unsupported operand type(s) for /: 'str' and 'int',明确了是类型错误:不支持操作类型为整 ...

  5. Django问题:TypeError: unsupported operand type(s) for -: ‘str‘ and ‘float‘

    Django问题:TypeError: unsupported operand type(s) for -: 'str' and 'float Traceback (most recent call ...

  6. TypeError: Unrecognized value type: <class ‘str‘> ParserError: Unknown string format

    TypeError: Unrecognized value type: <class 'str'>  ParserError: Unknown string format 目录 TypeE ...

  7. apex安装报错:TypeError: unsupported operand type(s) for +: ‘NoneType‘ and ‘str‘

    参考解决方法:TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' · Issue #990 · NVIDIA/apex ...

  8. 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 ...

  9. 成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type

    成功解决raise TypeError('Unexpected feature_names type')TypeError: Unexpected feature_names type 目录 解决问题 ...

最新文章

  1. 深入理解SERDES接口
  2. Gentoo - X11 forwarding request failed on channel 0
  3. 「技美之路」图形 1.1 渲染流水线
  4. 《机器人学导论--Join J.Craig》第一章 绪论
  5. 通俗的解释交叉熵与相对熵
  6. linux 日志编程(总结)
  7. 蜗牛星际A单千兆群晖系统崩溃恢复记录
  8. python共享单车数据分析_利用python分析共享单车项目
  9. 那些你不愿说给领导的话
  10. C语言快速互转HEX(16进制)和原始字符串/数组
  11. 上海市新生婴儿户口登记(出生申报)
  12. HBase 面试题(一)
  13. HTML/CSS学习笔记(1)
  14. Unity-拓展篇-pr序列帧转透明视频
  15. iOS-Core Animation 核心动画高级编程/5-变换
  16. 电脑怎么直接给服务器传文件夹,教你电脑怎么传文件夹给qq好友
  17. C++ for循环效率优化
  18. 腾讯加入专利保护社区 OIN
  19. 毕业生求职必会算法 约瑟夫环问题
  20. 把Foxmail里的邮件导入到Office Outlook里

热门文章

  1. vim 编辑器 bash文件测试
  2. mysql 锁监视器_MySQL锁监视器
  3. HTTP缓存原理及相关知识(2)-CDN
  4. html 两个idv上下居中,Django搭建个人博客:回到顶部浮动按钮、矢量图标、页脚沉底和粘性侧边栏...
  5. appim自动化--点击指定控件的指定位置
  6. PHP32向右位移2位是多少,PHP的二进制位移操作
  7. SQLServer 2000 126错误的解决方法
  8. Win2008使用WEB方式更改工作组计算机用户帐户密码
  9. H3C中标苏州教育城域网改造项目
  10. 实战MHDD检测硬盘