Python 使用数据读取器在tensorflow中读取tiff文件的正确方法
我正在使用tensorflow读取一些tiff格式的地理空间图像数据。我想使用类似于:Python 使用数据读取器在tensorflow中读取tiff文件的正确方法,python,machine-learning,tensorflow,tiff,Python,Machine Learning,Tensorflow,Tiff,我正在使用tensorflow读取一些tiff格式的地理空间图像数据。我想使用类似于: images = tf.convert_to_tensor(image_list, dtype=tf.string) img_contents = tf.read_file(images) img = tf.image.decode_image(img_contents, channels=3) 我想我需要做的是自己写一个解码函数。但img_内容实际上是一个张量字符串,我不能直接使用
images = tf.convert_to_tensor(image_list, dtype=tf.string)
img_contents = tf.read_file(images)
img = tf.image.decode_image(img_contents, channels=3)
我想我需要做的是自己写一个解码函数。但img_内容实际上是一个张量字符串,我不能直接使用它来访问文件。有什么方法可以读取tiff图像吗?您可以用Python解析您的文件,并通过feed\u dict传递给TensorFlow training graph,遵循代码进行演示,但不可运行:
def read_tiff_file(file_path):
#### code that read tiff_file content
return image_content # return the image content with 18 * 18 * 3
image_pl = tf.placeholder([18, 18, 3], tf.float32) # suppose your image is 18*18 with 3 channels
## constructing tf.graph with image_pl
## ...
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(loss)
with tf.Session as sess:
for file_name in file_name_list:
image_content = read_tiff_file(file_name)
sess.run(train_step, feed_dict={image_pl:image_content})
只是想知道,我有没有办法继续使用带队列的dataReader?@qsmank没有tiff_解码,所以我建议你写op,否则就不可能了。