assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP

具体报错如下:

INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, assertion failed: [Unable to decode bytes as JPEG, PNG, GIF, or BMP]
         [[Node: image_decode/cond_jpeg/cond_png/cond_gif/Assert_1/Assert = Assert[T=[DT_STRING], summarize=3, _device="/job:worker/replica:0/task:0/device:CPU:0"](image_decode/cond_jpeg/cond_png/cond_gif/is_bmp, image_decode/cond_jpeg/cond_png/cond_gif/Assert_1/Assert/data_0)]]

这个报错是在训练中报错,导致任务结束,初步猜测是数据集中图片有问题,解析到有问题的图片错误引起的。

我的图片解析代码如下:
result = Record()
value_tensor = filename_label_queue.dequeue()
record_defaults = [[''],[0]]
result.name, result.label = tf.decode_csv(value_tensor, record_defaults, field_delim=' ')
file_contents = tf.read_file(result.name)
# Convert from a string to a vector of uint8 that is recrod_bytes long
# record_bytes = tf.image.decode_jpeg(file_contents, channels=3, name='image_decode')
record_bytes = tf.image.decode_image(file_contents, channels=3, name='image_decode')
# record_bytes is in [height, width, depth] format 
result.uint8image = record_bytes

对于tf.image.decode_image,官方说明:https://www.tensorflow.org/versions/r1.8/api_docs/python/tf/image/decode_image

 

具体可参考:

https://github.com/tensorflow/models/issues/2518

https://github.com/tensorflow/tensorflow/issues/13044

 

 

 

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值