【发布时间】:2019-04-18 03:48:23
【问题描述】:
在阅读 TFX 的文档时,尤其是与数据预处理相关的部分,我认为管道设计更适合分类特征。
我想知道 TFX 是否也可以用于涉及图像的管道。
【问题讨论】:
-
您到底希望该管道做什么,因为据我了解,与其他数据集不同,图像数据集将仅包含像素。
标签: tensorflow tfx
在阅读 TFX 的文档时,尤其是与数据预处理相关的部分,我认为管道设计更适合分类特征。
我想知道 TFX 是否也可以用于涉及图像的管道。
【问题讨论】:
标签: tensorflow tfx
是的,TFX 也可用于涉及图像的管道。
特别是在与数据预处理相关的部分,据我所知,Tensorflow Transform 中没有内置函数。
但是可以使用 Tensorflow Ops 进行转换。例如,图像增强可以使用 tf.image 等来完成。
图像转换的示例代码,即将图像从彩色转换为灰度,通过将每个像素的值除以 255,使用 Tensorflow 变换如下所示:
def preprocessing_fn(inputs):
"""Preprocess input columns into transformed columns."""
# Since we are modifying some features and leaving others unchanged, we
# start by setting `outputs` to a copy of `inputs.
outputs = inputs.copy()
# Convert the Image from Color to Grey Scale.
# NUMERIC_FEATURE_KEYS is the names of Columns of Values of Pixels
for key in NUMERIC_FEATURE_KEYS:
outputs[key] = tf.divide(outputs[key], 255)
outputs[LABEL_KEY] = outputs[LABEL_KEY]
return outputs
【讨论】:
outputs[LABEL_KEY] = outputs[LABEL_KEY]这行有什么用。那只是一个无操作,什么都不做,不是吗?