在阅读TFX的文档时,特别是在与数据预处理相关的部分中,我认为管道设计更适合分类特征。
我想知道TFX是否也可以用于涉及图像的管道。
发布于 2019-05-10 20:30:35
是的,TFX也可以用于涉及图像的管道。
特别是,在与数据预处理相关的部分,据我所知,Tensorflow Transform中没有内置函数。
但是可以使用Tensorflow Ops进行转换。例如,可以使用tf.image来完成图像放大,等等。
图像转换的示例代码如下所示,使用Tensorflow转换,通过将每个像素的值除以255,将图像从彩色转换为灰度:
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 outputshttps://stackoverflow.com/questions/55738860
复制相似问题