从Uber Ludwig中的图像发布训练模型

时间:2019-07-10 13:58:14

标签: python python-3.x ludwig

执行我的训练python脚本时,返回以下内容。

Traceback (most recent call last):
  File "train.py", line 14, in <module>
    train_stats = model.train(data_csv="./dataset.csv")
  File "/home/user/.local/lib/python3.7/site-packages/ludwig/api.py", line 441, in train
    debug=debug,
  File "/home/user/.local/lib/python3.7/site-packages/ludwig/train.py", line 252, in full_train
    random_seed=random_seed
  File "/home/user/.local/lib/python3.7/site-packages/ludwig/data/preprocessing.py", line 403, in preprocess_for_training
    random_seed
  File "/home/user/.local/lib/python3.7/site-packages/ludwig/data/preprocessing.py", line 525, in _preprocess_csv_for_training
    random_seed=random_seed
  File "/home/user/.local/lib/python3.7/site-packages/ludwig/data/preprocessing.py", line 62, in build_dataset
    **kwargs
  File "/home/user/.local/lib/python3.7/site-packages/ludwig/data/preprocessing.py", line 83, in build_dataset_df
    global_preprocessing_parameters
  File "/home/user/.local/lib/python3.7/site-packages/ludwig/data/preprocessing.py", line 116, in build_metadata
    feature['preprocessing']
  File "/home/user/.local/lib/python3.7/site-packages/ludwig/utils/misc.py", line 97, in merge_dict
    for k, v in merge_dct.items():
AttributeError: 'list' object has no attribute 'items'

我浏览了路德维希的文档,并为此感到困惑。

from ludwig.api import LudwigModel

model_definition = {
    "input_features":[
        {"name":"image_path", "type":"image", "preprocessing":[{"height": "128", "width": "128"}],"resize_method": "interpolate"}
    ],
    "output_features":[
        {"name":"plate","type":"text"}
    ]
}

model = LudwigModel(model_definition)

train_stats = model.train(data_csv="./dataset.csv")

我的CSV源格式如下。

image_path, plate
./crop_m1/I00000.png, 9B52145
./crop_h1/I00000.png, 9B52145
./crop_m1/I00001.png, 6B94558
./crop_h1/I00001.png, 6B94558
./crop_m1/I00002.png, 8B90164
./crop_h1/I00002.png, 8B90164
./crop_m1/I00003.png, 5B11181
./crop_h1/I00003.png, 5B11181
./crop_m1/I00004.png, 8B79697
./crop_h1/I00004.png, 8B79697
./crop_m1/I00005.png, 8B90164

路德维希的预期行为是训练模型而没有任何错误。

1 个答案:

答案 0 :(得分:0)

您的预处理应该是字典而不是列表: 你有:

"preprocessing":[{"height": "128", "width": "128"}]

应为:

"preprocessing":{"height": "128", "width": "128"}