[PaddlePaddle/PaddleOCR]训练ser任务报错

2024-05-13 611 views
7
SER单卡训练

python3 tools/train.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml

报错: TypeError: init() got an unexpected keyword argument 'num_classes'

回答

2

环境是ubuntu

0

Traceback (most recent call last): File "tools/train.py", line 227, in main(config, device, logger, vdl_writer) File "tools/train.py", line 135, in main model = build_model(config['Architecture']) File "/mnt/workspace/PaddleOCR/ppocr/modeling/architectures/init.py", line 30, in build_model arch = BaseModel(config) File "/mnt/workspace/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 55, in init self.backbone = build_backbone(config["Backbone"], model_type) File "/mnt/workspace/PaddleOCR/ppocr/modeling/backbones/init.py", line 80, in build_backbone module_class = eval(module_name)(*config) File "/mnt/workspace/PaddleOCR/ppocr/modeling/backbones/vqa_layoutlm.py", line 156, in init num_classes=num_classes) File "/mnt/workspace/PaddleOCR/ppocr/modeling/backbones/vqa_layoutlm.py", line 66, in init base_model, num_classes=kwargs["num_classes"], dropout=None) File "/usr/local/lib/python3.7/dist-packages/paddlenlp/transformers/utils.py", line 249, in impl init_func(self, args, **kwargs) TypeError: init() got an unexpected keyword argument 'num_classes'

8

我把配置文件的num_classes注释了的话,又会报错:yaml.composer.ComposerError: found undefined alias 'num_classes' in "configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml", line 40, column 16

6

I also meet the same problem. If I leave "checkpoints:" empty, this would be occur!

3
  1. class_list.txt:

    image
  2. yml文件:

    image
  3. 有一种说法,叫做 num_classes = 2n-1。也就是说,class_list.txt里面有3行,所以num_classes = 2 * 3 - 1 = 5

5

谢谢解答,我用的是开源的XFUND数据集的标签好像就是2*4-1=7,好像不是标签数目的报错

7

谢谢解答,我用的是开源的XFUND数据集的标签好像就是2*4-1=7,好像不是标签数目的报错 Seem the error occur in LayoutXLMForTokenClassification class, which is take 2 arguments but, in this code, 3 arguments are given. image image

3

I uninstalled paddlenlp==2.6.2 and install 2.5.2 and it work well, hope that this thing can helpful with you!

5

paddlenlp更新到2.6.0后出现的报错,ser和re出现了不同的问题,downgrade到2.5.2可以解决。

5

paddlenlp更新到2.6.0后出现的报错,ser和re出现了不同的问题,downgrade到2.5.2可以解决。

请问你的paddlepaddle-gpu版本是多少,是在aistudio平台上跑的吗

8

谢谢解答,我用的是开源的XFUND数据集的标签好像就是2*4-1=7,好像不是标签数目的报错

请问最后是怎么解决的,将paddlenpl降级到2.5.2吗