'jpg' has type str, but expected one of: bytes

				版权声明:本文为博主原创文章,未经博主允许不得转载。					https://blog.csdn.net/sparkexpert/article/details/70230072				</div>
							<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-f57960eb32.css">
							            <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-f57960eb32.css">
					<div class="htmledit_views" id="content_views">

为了对flowers数据集进行训练,于是调用了tensorflow的slim模块中的download_and_convert_flowers.py文件进行处理,


但是下载完成之后,执行过程中碰到一个问题:'jpg' has type str, but expected one of: bytes


看来tensorflow默认的源码都是基于python2环境下的。


而python3环境下是需要额外加个字符的。因此针对这种问题,只能修改源码:


具体修改如下:即在'jpg'前面加一个字母:b,即代表以字节的方式来进行处理。



            example = dataset_utils.image_to_tfexample(
                image_data, b'jpg', height, width, class_id)
            tfrecord_writer.write(example.SerializeToString())


修改完,再次执行这个文档,果然顺利通过:

>> Converting image 348/350 shard 4
>> Converting image 349/350 shard 4
>> Converting image 350/350 shard 4


Finished converting the Flowers dataset!

				版权声明:本文为博主原创文章,未经博主允许不得转载。					https://blog.csdn.net/sparkexpert/article/details/70230072				</div>
							<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-f57960eb32.css">
							            <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-f57960eb32.css">
					<div class="htmledit_views" id="content_views">

猜你喜欢

转载自blog.csdn.net/wc996789331/article/details/89443943