具体报错如下:
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