Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Tensorflow decoder for TIFF images?

I have noticed that Tensorflow provides standard procedures for decoding jpeg, png and gif images after reading files. For instance for png:

import tensorflow as tf
filename_queue = tf.train.string_input_producer(['/Image.png']) #  list of files to read
reader = tf.WholeFileReader()    
key, value = reader.read(filename_queue)
decoded_image = tf.image.decode_png(value) # use png or jpg decoder based on your files.

However, the tiff format decoder seems to be missing.

So what solutions exist for tiff files? Surely, I could convert my input images to png, but this doesn't seem to be a very smart solution.

like image 709
Dr_Zaszuś Avatar asked Feb 01 '17 17:02

Dr_Zaszuś


2 Answers

There's currently no decoder for TIFF images. Look in tensorflow/core/kernels and you see

decode_csv_op.cc
decode_gif_op.cc
decode_jpeg_op.cc
decode_png_op.cc
decode_raw_op.cc

No decode_tiff_op.cc. This could be a good target for community contribution.

like image 195
Yaroslav Bulatov Avatar answered Oct 16 '22 21:10

Yaroslav Bulatov


As of February 2019, some (limited & experimental) TIFF support has been added as part of the Tensorflow I/O library:

Added a very preliminary TIFF support. TIFF format is rather complex so compressions such as JPEG have not been supported yet, but could be added if needed.

The following methods are currently available:

tfio.experimental.image.decode_tiff

Decode a TIFF-encoded image to a uint8 tensor.

tfio.experimental.image.decode_tiff_info

Decode a TIFF-encoded image meta data.

An example usage from a Tensorflow tutorial:

import tensorflow as tf
import tensorflow.io as tfio
...
def parse_image(img_path: str) -> dict:
...
image = tf.io.read_file(img_path)
tfio.experimental.image.decode_tiff(image)
...
like image 23
desertnaut Avatar answered Oct 16 '22 22:10

desertnaut