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

在使用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
D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino: In function 'void onDataReceived()': D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino:31:16: error: 'class SPIClass' has no member named 'available' D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino:14:22: error: lvalue required as unary '&' operand D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino:40:47: note: in expansion of macro 'START_MARKER' D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino:15:20: error: lvalue required as unary '&' operand D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino:85:47: note: in expansion of macro 'END_MARKER' D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino:15:20: error: lvalue required as unary '&' operand D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino:95:43: note: in expansion of macro 'END_MARKER' D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino: In function 'void setup()': D:\小车例程\9DOFDemo\9DOF_Demo\9DOF_Demo.ino:111:9: error: 'class SPIClass' has no member named 'onData' exit status 1 Compilation error: 'class SPIClass' has no member named 'available' arduino出现以上错误 Traceback (most recent call last): File "C:\Users\hdhfg\PyCharmMiscProject\main.py", line 223, in <module> reconstructor = ImageReconstructor(port='COM3', baudrate=115200) File "C:\Users\hdhfg\PyCharmMiscProject\main.py", line 14, in __init__ self.serial_port = serial.Serial(port, baudrate, timeout=1) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hdhfg\PyCharmMiscProject\.venv\Lib\site-packages\serial\serialwin32.py", line 33, in __init__ super(Serial, self).__init__(*args, **kwargs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "C:\Users\hdhfg\PyCharmMiscProject\.venv\Lib\site-packages\serial\serialutil.py", line 244, in __init__ self.open() ~~~~~~~~~^^ File "C:\Users\hdhfg\PyCharmMiscProject\.venv\Lib\site-packages\serial\serialwin32.py", line 64, in open raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError())) serial.serialutil.SerialException: could not open port 'COM3': PermissionError(13, '拒绝访问。', None, 5) python出现以上错误 TypeError:can't convert int' object to str implicitly openmv出现以上错误 修改代码
06-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值