tensorflow制作tfrecords文件TypeError: '*' has type str, but expected one of: bytes问题的解决

我得程序中定位到的出错位置在这tf.train.Feature(bytes_list=tf.train.BytesList(value=[v]))

意思是v不能为字符串类型,但是查询了各种各样的制作tfrecords文件的时候发现这里就是字符串类型

解决:

从这个教程中看到了解决办法

https://www.grt1st.cn/posts/tensorflow-with-tfrecords/


tensorflow制作tfrecords文件TypeError: '*' has type str, but expected one of: bytes问题的解决_第1张图片

上面这种方法好像失败了:

在我的程序中是'image/filename': _bytes_feature(filename),   调用的,

所以  在调用之前我加了filename = filename.encode()  就可以了


另外一种解决办法
https://github.com/tensorflow/models/issues/726
it can be solved by changing:
'jpeg' to b'jpeg' ,
'png' to b'png
'cat' to b'cat'
in object_detection/data_decoders/tf_example_decoder_test.py
但是我尝试了在字符串前面各种加b均无法取得成功

你可能感兴趣的:(tensorflow制作tfrecords文件TypeError: '*' has type str, but expected one of: bytes问题的解决)