问题描述
我目前正在使用 Tensorflow 的 Dataset API 来加载和预处理图像以进行训练和测试.这是我用来执行此操作的代码的片段:
I'm currently using Tensorflow's Dataset API to load and preprocess images for training and testing. Here's a snipped of the code I'm using to do so:
image_string = tf.read_file(self._data_conf.image_dir + in_image)
label_string = tf.read_file(self._data_conf.label_dir + in_label)
image = tf.image.decode_png(image_string, channels=self._num_channels)
label = tf.image.decode_png(label_string, channels=self._num_channels)
问题是,Tensorflow 不支持 TIFF 容器.这里只支持 tf.image.decode_image、tf.image.decode_jpeg 和 tf.image.decode_png 函数.现在,我实现了一个类,它从 TIFF 容器中提取特定页面作为 Numpy 数组.有没有办法将此 API(静态图)与自定义图像加载器(例如类)一起使用?
The problem is, that Tensorflow doesn't support TIFF containers. Here, only the functions tf.image.decode_image, tf.image.decode_jpeg and tf.image.decode_png are supported. Now, I've implemented a class which extracts specific pages from a TIFF container as Numpy array. Is there a way to use this API (static graph) with a custom image loader, such as the class?
推荐答案
一个简单的方法是直接使用 python imageio
然后使用 tf.py_func
打包.
A simple way would be directly using the python imageio
and then use tf.py_func
to package it.
这篇关于Tensorflow:如何使用 Tensorflow 的 Dataset API 来使用 TIFF 图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!