无法使用自定义tf馈送Evaluator。

时间:2019-07-03 05:17:51

标签: python tensorflow tfx

我已经训练了图像的模型和数据集。现在,我正在尝试运行TFX的评估程序组件:

    model_analyzer = Evaluator(
        model_exports=channel.as_channel([types.TfxType(
            type_name='path/to/evalSavedModel']),
        examples=channel.as_channel([types.TfxType(examples)])
    )

其中的示例是:

def create_examples():
    cwd = '/path/to/dataset/with/two/classes'
    keys = ['0', '1']
    values = [0, 1]
    classes = dict(zip(keys, values))
    examples = []
    for name, label in classes.items():
        class_path = os.path.join(cwd, name)
        for img_name in os.listdir(class_path):
            img_path = os.path.join(class_path, img_name)
            img = Image.open(img_path)
            img_raw = img.tobytes()
            example = tf.train.Example(features=tf.train.Features(feature={
                "img_raw": tf.train.Feature(bytes_list=tf.train.BytesList(value=[img_raw])),
                "label": tf.train.Feature(int64_list=tf.train.Int64List(value=[label]))}))
            examples.append(example)

    return examples

但是我收到以下错误:

TypeError: [features {
  feature {
    key: "img_raw"
    value {
      bytes_list {
        value: "\234z^\233 has type list, but expected one of: bytes, unicode

我在这个问题上花了很多时间。请帮忙!

谢谢!

0 个答案:

没有答案