繁体   English   中英

使用 TFX 设计图像流水线

[英]Using TFX for designing image piplines

在阅读 TFX 的文档时,尤其是与数据预处理相关的部分,我认为管道设计更适合分类特征。

我想知道 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM