我正在研究this demo。输入数据如下:

模型的代码如下:
model = ClassificationModel(
"layoutlm",
"microsoft/layoutlm-base-uncased",
num_labels=2,
use_cuda=True,
cuda_device = 0
)
predictions, raw_outputs = model.predict(['test data abc'])但它返回以下错误:
File "/mnt/data/home/tvkhuong/Data/SOFT/anaconda3/envs/classify/lib/python3.7/site-packages/simpletransformers/classification/classification_model.py", line 1708, in load_and_cache_examples
example.label = self.args.labels_map[example.label]
AttributeError: 'list' object has no attribute 'label'如何正确定义模型输入以获得预测结果?
发布于 2021-11-26 08:46:00
LayoutLM模型通常用于需要考虑文本以及图像中的文本布局的情况。与简单的机器学习模型不同,model.predict()在这里不会得到想要的结果。
首先需要对训练数据集中每个图像的文本信息、标签信息和边界框信息等训练数据进行训练,以学习上述标签下的图像。在继续之前,您还需要一个与您的模型相关联的标记器。
有关详细信息,请参阅文档:https://huggingface.co/transformers/model_doc/layoutlm.html
https://stackoverflow.com/questions/69910822
复制相似问题