首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用TFX设计图像管线

使用TFX设计图像管线
EN

Stack Overflow用户
提问于 2019-04-18 11:48:23
回答 1查看 661关注 0票数 2

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

我想知道TFX是否也可以用于涉及图像的管道。

EN

回答 1

Stack Overflow用户

发布于 2019-05-10 20:30:35

是的,TFX也可以用于涉及图像的管道。

特别是,在与数据预处理相关的部分,据我所知,Tensorflow Transform中没有内置函数。

但是可以使用Tensorflow Ops进行转换。例如,可以使用tf.image来完成图像放大,等等。

图像转换的示例代码如下所示,使用Tensorflow转换,通过将每个像素的值除以255,将图像从彩色转换为灰度:

代码语言:javascript
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55738860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档