PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
44.34k stars 7.83k forks source link

RE模型训练出错,谁能帮忙分析一下原因 #13193

Closed shiwenliang closed 4 months ago

shiwenliang commented 4 months ago

问题描述 / Problem Description

Traceback (most recent call last): File "tools/train.py", line 208, in main(config, device, logger, vdl_writer) File "tools/train.py", line 180, in main program.train(config, train_dataloader, valid_dataloader, device, model, File "D:\tools\anaconda3\envs\ocr26\Lib\site-packages\PaddleOCR\tools\program.py", line 299, in train preds = model(batch) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\layers.py", line 930, in call return self._dygraph_call_func(*inputs, kwargs) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\layers.py", line 915, in _dygraph_call_func outputs = self.forward(*inputs, *kwargs) File "D:\tools\anaconda3\envs\ocr26\Lib\site-packages\PaddleOCR\ppocr\modeling\architectures\base_model.py", line 86, in forward x = self.backbone(x) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\layers.py", line 930, in call return self._dygraph_call_func(inputs, kwargs) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\layers.py", line 915, in _dygraph_call_func outputs = self.forward(*inputs, kwargs) File "D:\tools\anaconda3\envs\ocr26\Lib\site-packages\PaddleOCR\ppocr\modeling\backbones\vqa_layoutlm.py", line 227, in forward x = self.model( File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\layers.py", line 930, in call return self._dygraph_call_func(*inputs, *kwargs) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\layers.py", line 915, in _dygraph_call_func outputs = self.forward(inputs, kwargs) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddlenlp\transformers\layoutxlm\modeling.py", line 1492, in forward loss, pred_relations = self.extractor(sequence_output, entities, File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\layers.py", line 930, in call return self._dygraph_call_func(*inputs, *kwargs) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\layers.py", line 915, in _dygraph_call_func outputs = self.forward(inputs, **kwargs) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddlenlp\transformers\layoutxlm\modeling.py", line 1368, in forward relations, entities = self.build_relation(relations, entities) File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddlenlp\transformers\layoutxlm\modeling.py", line 1318, in build_relation if len(entities[b]["start"]) <= 2: File "D:\tools\anaconda3\envs\ocr26\lib\site-packages\paddle\fluid\dygraph\varbase_patch_methods.py", line 739, in getitem return self._getitem_index_not_tensor(item) ValueError: (InvalidArgument) Currently, Tensor.indices() only allows indexing by Integers, Slices, Ellipsis, None, tuples of these types and list of Bool and Integers, but received str in 1th slice item (at C:\home\workspace\Paddle_release\paddle/fluid/pybind/slice_utils.h:279)

运行环境 / Runtime Environment

python tools/train.py -c configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml

shiwenliang commented 4 months ago

PaddleOCR: 尝试了2.4、2.5、2.6

crackso commented 4 months ago

感觉数据的原因可能性较大。你提供的信息太少了,让大家无法判断。

shiwenliang commented 4 months ago

我提供一个训练的json样式,大家觉得还有缺少的可以告知我: ocr/0030.jpg [{"transcription": "姓名", "points": [[47, 57], [87, 57], [87, 79], [47, 79]], "id": 1, "label": "question", "linking": [[1, 2]]}, {"transcription": "XXX ", "points": [[91, 56], [141, 56], [141, 79], [91, 79]], "id": 2, "label": "answer", "linking": [[1, 2]]}, {"transcription": "性别", "points": [[47, 83], [86, 83], [86, 111], [47, 111]], "id": 3, "label": "question", "linking": [[3, 4]]}, {"transcription": "机器人", "points": [[90, 84], [145, 84], [145, 111], [90, 111]], "id": 4, "label": "answer", "linking": [[3, 4]]}, {"transcription": "出生", "points": [[47, 116], [87, 116], [87, 144], [47, 144]], "id": 5, "label": "question", "linking": [[5, 6]]}, {"transcription": "1999年5月11日", "points": [[90, 116], [239, 116], [239, 140], [90, 140]], "id": 6, "label": "answer", "linking": [[5, 6]]}, {"transcription": "住址", "points": [[46, 156], [87, 156], [87, 178], [46, 178]], "id": 7, "label": "question", "linking": [[7, 8]]}, {"transcription": "河北省XXXXXXXXXXXX号XXXX数据集", "points": [[91, 153], [278, 153], [278, 192], [91, 192]], "id": 8, "label": "answer", "linking": [[7, 8]]}, {"transcription": "XXXXX号码", "points": [[39, 235], [144, 235], [144, 262], [39, 262]], "id": 9, "label": "question", "linking": [[9, 10]]}, {"transcription": "871411866236473893", "points": [[146, 235], [310, 235], [310, 263], [146, 263]], "id": 10, "label": "answer", "linking": [[9, 10]]}]

shiwenliang commented 4 months ago

其实这就是一个身份证kie训练的案例,Ser训练没问题,RE训练出现了问题

shiwenliang commented 4 months ago

再提供一个附件是re_vi_layoutxlm_xfund_zh.yml re_vi_layoutxlm_xfund_zh.zip

shiwenliang commented 4 months ago

大家帮忙看看,这个问题卡主挺久了

GreatV commented 4 months ago

https://github.com/PaddlePaddle/PaddleOCR/blob/main/doc/doc_ch/kie.md#21-%E5%90%AF%E5%8A%A8%E8%AE%AD%E7%BB%83 按照文档可以跑通了,用提供的数据集。

shiwenliang commented 4 months ago

我就是参考官方例子跑的,RE训练就挂了,但是我训练数据集用的不是xfund,难道只能用xfund,不知道我本地开发环境是windows有没有关系?

shiwenliang commented 4 months ago

我看了标注和配置文件和官方也没啥差异,唯一的差别就是我本地是windows,官方肯定是linux跑的

jingsongliujing commented 4 months ago

paddle框架安装建议按照这里的配置选,paddle框架版本你有没有换过:https://www.paddlepaddle.org.cn/

shiwenliang commented 4 months ago

paddle框架安装建议按照这里的配置选,paddle框架版本你有没有换过:https://www.paddlepaddle.org.cn/

不知道paddleocr对于paddle版本是不是有什么要求,我的paddleocr用2.6的时候paddle用2.3。换了会不会跑不起来,对于python的版本是不是也有升级要求

crackso commented 4 months ago

目前看py38、py39都可以很好的运行。你中途有换过py的版本吗?