How to read bmp files in tensorflow?

2019-03-05 13:02发布

问题:

I'm trying to read BMP files in TensorFlow in the following way:

reader = tf.TextLineReader()
_, value = reader.read(filename_queue)
filename, label = tf.decode_csv(value, [[''], [0]])

im = tf.decode_raw(tf.read_file(filename), tf.uint8)

The error is the following:

E tensorflow/core/client/tensor_c_api.cc:485] Input to reshape is a tensor with 44200 values, but the requested shape has 750000
       [[Node: batch_processing/Reshape = Reshape[T=DT_UINT8, _device="/job:localhost/replica:0/task:0/cpu:0"](batch_processing/Slice, batch_processing/Reshape/shape)]]
E tensorflow/core/client/tensor_c_api.cc:485] Input to reshape is a tensor with 33871 values, but the requested shape has 750000
       [[Node: batch_processing/Reshape = Reshape[T=DT_UINT8, _device="/job:localhost/replica:0/task:0/cpu:0"](batch_processing/Slice, batch_processing/Reshape/shape)]] 
E tensorflow/core/client/tensor_c_api.cc:485] Input to reshape is a tensor with 47566 values, but the requested shape has 750000     
       [[Node: batch_processing/Reshape = Reshape[T=DT_UINT8, _device="/job:localhost/replica:0/task:0/cpu:0"](batch_processing/Slice, batch_processing/Reshape/shape)]]

Why does the output of tf.decode change? How can I solve the problem?

Any help would be appreciated.