升级环境 python2 到 python3 ,在做TFRecord 时遇见两个问题
报 name 'file' is not defined
file函数改为open函数
TypeError: ' xxx.jpg' has type str, but expected one of: bytes
byte feature 函数 中 加一句
value = tf.compat.as_bytes(value)
即 后 可正常生成
def _bytes_feature(value):
value = tf.compat.as_bytes(value)
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
参考 https://blog.youkuaiyun.com/Lisa_Ren_123/article/details/80199256