最近在看21个TensorFlow项目一书中,由于我环境是Python3.5,项目中环境应该是Python2。运行第三章data_prepare文件夹下data_convert.py将图片转换为tfrecord格式时出现

TypeError: 'range' object does not support item assignment

此处错误是因为Python3 range返回的不是list,修改:tfrecord.py第340行将

shuffled_index = range(len(filenames))

修改为

shuffled_index = list(range(len(filenames)))

再次运行data_convert.py时出现下列错误:

UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illega

TypeError:tf.train.Feature TypeError: 'RGB' has type str, but expected one of: bytes

TypeError: 'water' has type str, but expected one of: bytes

查找了相关资料错误原因可见https://blog.csdn.net/qq_29921623/article/details/80047339

需要修改下列地方:

tfrecord.py第160行改为  with open(filename, 'rb') as f:

tfrecord.py第94和96行修改为  colorspace = b'RGB'     image_format = b'JPEG'

tfrecord.py第104行修改为  'image/class/text': _bytes_feature(str.encode(text)),

tfrecord.py第106行修改为   'image/filename':_bytes_feature(os.path.basename(str.encode(filename))),

再次运行data_convert.py  (python data_convert.py -t pic/ --train-shards 2 --validation-shards 2 --num-threads 2 --dataset-name satellite)

21个TensorFlow项目转换tfrecord:TypeError: 'RGB' has type str, but expected one of: bytes(法二)相关推荐

  1. TypeError: 'RGB' has type str, but expected one of: bytes(法1)

    在使用Python3+(本人Python3.5)執行21個專案玩轉深度學習第三個專案的時候.在執行資料轉換操作 python data_convert.py -t pic/ \--train-shar ...

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

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

  3. tensorflow编码错误:TypeError: unsupported operand type(s) for *: ‘float‘ and ‘NoneType‘

    tensorflow 编码出现错误:TypeError: unsupported operand type(s) for *: 'float' and 'NoneType' 原码如下: import ...

  4. TypeError: Object of type set is not JSON serializable

    今天运行flask项目突然报TypeError: Object of type set is not JSON serializable错误,上网搜了一下 该对象是set形式,json序列不支持,回到 ...

  5. 深度学习(五十六)tensorflow项目构建流程

    tensorflow项目构建流程 博客:http://blog.csdn.net/hjimce 微博:黄锦池-hjimce   qq:1393852684 一.构建路线 个人感觉对于任何一个深度学习库 ...

  6. 把Eclipse项目转换成Maven项目

    把Maven项目转换成Eclipse项目只要使用Maven的Eclipse插件就能做到 mvn eclipse:eclipse 其实Maven的Eclipse插件也有把Eclipse项目转换成Mave ...

  7. TensorFlow 2.0 - TFRecord存储数据集、@tf.function图执行模式、tf.TensorArray、tf.config分配GPU

    文章目录 1. TFRecord 格式存储 2. tf.function 高性能 3. tf.TensorArray 支持计算图特性 4. tf.config 分配GPU 学习于:简单粗暴 Tenso ...

  8. Vue项目 报错TypeError [ERR INVALID ARG TYPE]: The “path“ argument must be of type string

    # Vue项目 报错TypeError [ERR INVALID ARG TYPE]: The "path" argument must be of type string 卡了半 ...

  9. 将已有项目转为se项目_如何将 Java 项目转换成 Maven 项目

    本文内容 Java 项目 Maven 项目 Java 项目转换成 Maven 项目 本文主要介绍如何将 Java 项目转换成 Maven 项目.首先要明确的是,用 Maven 管理 Java 项目的确 ...

最新文章

  1. 收藏 | 28个R语言绘图的实用程序包!
  2. 为什么要选择Apache Pulsar(一)
  3. Optimize Slow VBA Code
  4. IllegalArgumentException:@Body parameters cannot be used with form or multi-part encoding
  5. SqlBulkCopy只支持SQL Server? EF Core实现支持多数据库类型的Bulk Copy
  6. pip安装mysql模块_使用pip安装mysql模块for python
  7. 七步从AngularJS菜鸟到专家(7):Routing
  8. e-mobile帐号状态存在异常_Java 常见异常种类
  9. 【Elasticsearch】需要监控的 10 大 Elasticsearch 指标
  10. ubuntu下使用锐捷校园网
  11. ffmpeg 处理字幕
  12. JAVA-DDD项目结构
  13. 高中数学关于计算机的知识,高中数学必修三-算法概念基础知识解读
  14. 富途证券 8.14
  15. js获取上一个页面url
  16. 屏幕色彩(一)-已知混色光色点求配色比
  17. js将页面转成PDF文档
  18. 素描原理在PS鼠绘实物中的应用
  19. 模运算性质-mod (ACM学习笔记)
  20. 如何用蓝牙实现无线定位(三)--本地定位显示

热门文章

  1. windows查看linux文件工具,「实用工具」介绍几款Windows系统与Linux服务器传递文件的工具...
  2. oracle 如何添加数据文件,在Oracle数据库里插入excel文件数据的步骤
  3. drools 将添加switch支持
  4. centos8对外开发指定接口
  5. linux resin 自动启动不了,linux下开机启动nginx+resin
  6. java xml annotation_Annotation与XML配置ID生成策略
  7. GDAL中的SURF算法
  8. SURF算法学习心得
  9. Java基础知识框图总结
  10. Unity游戏开发——Excel数据读取到游戏中