嗨,我正试图让 TFX 管道像练习一样运行。我用来从磁盘ImportExampleGen
加载。TFRecords
每一个都Example
包含TFRecord
一个字节串、高度、宽度、深度、转向和油门标签形式的 jpg。
我正在尝试使用StatisticsGen
,但收到此警告;
WARNING:root:Feature "image_raw" has bytes value "None" which cannot be decoded as a UTF-8 string.
并让我的 Colab Notebook 崩溃。据我所知,TFRecord 中的所有字节字符串图像都没有损坏。
我找不到有关StatisticsGen
和处理图像数据的具体示例。根据文档Tensorflow Data Validation 可以处理图像数据。
除了计算一组默认的数据统计,TFDV 还可以计算语义域(例如,图像、文本)的统计。要启用语义域统计信息的计算,请将 enable_semantic_domain_stats 设置为 True 的 tfdv.StatsOptions 对象传递给 tfdv.generate_statistics_from_tfrecord。
但我不确定这如何与StatisticsGen
.
这是实例化ImportExampleGen
然后的代码StatisticsGen
from tfx.utils.dsl_utils import tfrecord_input
from tfx.components.example_gen.import_example_gen.component import ImportExampleGen
from tfx.proto import example_gen_pb2
examples = tfrecord_input(_tf_record_dir)
# https://www.tensorflow.org/tfx/guide/examplegen#custom_inputoutput_split
# has a good explanation of splitting the data the 'output_config' param
# Input train split is _tf_record_dir/*'
# Output 2 splits: train:eval=8:2.
train_ratio = 8
eval_ratio = 10-train_ratio
output = example_gen_pb2.Output(
split_config=example_gen_pb2.SplitConfig(splits=[
example_gen_pb2.SplitConfig.Split(name='train',
hash_buckets=train_ratio),
example_gen_pb2.SplitConfig.Split(name='eval',
hash_buckets=eval_ratio)
]))
example_gen = ImportExampleGen(input=examples,
output_config=output)
context.run(example_gen)
statistics_gen = StatisticsGen(
examples=example_gen.outputs['examples'])
context.run(statistics_gen)
提前致谢。