gpt4 book ai didi

tensorflow - 使用 TFX 设计图像管道

转载 作者:行者123 更新时间:2023-12-05 06:26:46 26 4
gpt4 key购买 nike

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

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

最佳答案

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

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

但是可以使用 Tensorflow Ops 进行转换。例如,Image Augmentation 可以使用 tf.image 等来完成。

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

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

关于tensorflow - 使用 TFX 设计图像管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55738860/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com